1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "mysqlc_driver.hxx"
20 #include "mysqlc_connection.hxx"
22 using namespace css::uno
;
23 using namespace css::lang
;
24 using namespace css::beans
;
25 using namespace css::sdbc
;
26 using namespace connectivity::mysqlc
;
28 #include <cppuhelper/supportsservice.hxx>
30 MysqlCDriver::MysqlCDriver(const Reference
<XMultiServiceFactory
>& _rxFactory
)
31 : ODriver_BASE(m_aMutex
)
32 , m_xFactory(_rxFactory
)
36 void MysqlCDriver::disposing()
38 ::osl::MutexGuard
aGuard(m_aMutex
);
40 // when driver will be destroyed so all our connections have to be destroyed as well
41 for (auto const& connection
: m_xConnections
)
43 Reference
<XComponent
> xComp(connection
.get(), UNO_QUERY
);
49 m_xConnections
.clear();
51 ODriver_BASE::disposing();
55 OUString
MysqlCDriver::getImplementationName_Static()
57 return "com.sun.star.comp.sdbc.mysqlc.MysqlCDriver";
60 Sequence
<OUString
> MysqlCDriver::getSupportedServiceNames_Static()
62 return { "com.sun.star.sdbc.Driver" };
65 OUString SAL_CALL
MysqlCDriver::getImplementationName() { return getImplementationName_Static(); }
67 sal_Bool SAL_CALL
MysqlCDriver::supportsService(const OUString
& _rServiceName
)
69 return cppu::supportsService(this, _rServiceName
);
72 Sequence
<OUString
> SAL_CALL
MysqlCDriver::getSupportedServiceNames()
74 return getSupportedServiceNames_Static();
77 Reference
<XConnection
> SAL_CALL
MysqlCDriver::connect(const OUString
& url
,
78 const Sequence
<PropertyValue
>& info
)
80 ::osl::MutexGuard
aGuard(m_aMutex
);
87 Reference
<XConnection
> xConn
;
88 // create a new connection with the given properties and append it to our vector
89 rtl::Reference
<OConnection
> pCon
= new OConnection(*this);
91 pCon
->construct(url
, info
);
92 m_xConnections
.push_back(WeakReferenceHelper(*pCon
));
96 sal_Bool SAL_CALL
MysqlCDriver::acceptsURL(const OUString
& url
)
98 return url
.startsWith("sdbc:mysqlc:") || url
.startsWith("sdbc:mysql:mysqlc:");
101 Sequence
<DriverPropertyInfo
> SAL_CALL
102 MysqlCDriver::getPropertyInfo(const OUString
& url
, const Sequence
<PropertyValue
>& /* info */)
106 return { { "Hostname", "Name of host", true, "localhost", {} },
107 { "Port", "Port", true, "3306", {} } };
110 return Sequence
<DriverPropertyInfo
>();
113 sal_Int32 SAL_CALL
MysqlCDriver::getMajorVersion() { return MARIADBC_VERSION_MAJOR
; }
115 sal_Int32 SAL_CALL
MysqlCDriver::getMinorVersion() { return MARIADBC_VERSION_MINOR
; }
117 namespace connectivity::mysqlc
119 Reference
<XInterface
> MysqlCDriver_CreateInstance(const Reference
<XMultiServiceFactory
>& _rxFactory
)
121 return (*(new MysqlCDriver(_rxFactory
)));
124 void checkDisposed(bool _bThrow
)
128 throw DisposedException();
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */