bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / mysqlc / mysqlc_driver.cxx
blob0f6c90922e5fa5bb57ef993d41fd3c6d38e81961
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
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"
21 #include "mysqlc_general.hxx"
23 using namespace css::uno;
24 using namespace css::lang;
25 using namespace css::beans;
26 using namespace css::sdbc;
27 using namespace connectivity::mysqlc;
29 #include <cppuhelper/supportsservice.hxx>
30 #include <stdio.h>
32 MysqlCDriver::MysqlCDriver(const Reference<XMultiServiceFactory>& _rxFactory)
33 : ODriver_BASE(m_aMutex)
34 , m_xFactory(_rxFactory)
38 void MysqlCDriver::disposing()
40 ::osl::MutexGuard aGuard(m_aMutex);
42 // when driver will be destroyed so all our connections have to be destroyed as well
43 for (auto const& connection : m_xConnections)
45 Reference<XComponent> xComp(connection.get(), UNO_QUERY);
46 if (xComp.is())
48 xComp->dispose();
51 m_xConnections.clear();
53 ODriver_BASE::disposing();
56 // static ServiceInfo
57 OUString MysqlCDriver::getImplementationName_Static()
59 return OUString("com.sun.star.comp.sdbc.mysqlc.MysqlCDriver");
62 Sequence<OUString> MysqlCDriver::getSupportedServiceNames_Static()
64 Sequence<OUString> aSNS(1);
65 aSNS[0] = "com.sun.star.sdbc.Driver";
66 return aSNS;
69 OUString SAL_CALL MysqlCDriver::getImplementationName() { return getImplementationName_Static(); }
71 sal_Bool SAL_CALL MysqlCDriver::supportsService(const OUString& _rServiceName)
73 return cppu::supportsService(this, _rServiceName);
76 Sequence<OUString> SAL_CALL MysqlCDriver::getSupportedServiceNames()
78 return getSupportedServiceNames_Static();
81 Reference<XConnection> SAL_CALL MysqlCDriver::connect(const OUString& url,
82 const Sequence<PropertyValue>& info)
84 ::osl::MutexGuard aGuard(m_aMutex);
86 if (!acceptsURL(url))
88 return nullptr;
91 Reference<XConnection> xConn;
92 // create a new connection with the given properties and append it to our vector
93 OConnection* pCon = new OConnection(*this);
94 xConn = pCon;
96 pCon->construct(url, info);
97 m_xConnections.push_back(WeakReferenceHelper(*pCon));
98 return xConn;
101 sal_Bool SAL_CALL MysqlCDriver::acceptsURL(const OUString& url)
103 return url.startsWith("sdbc:mysqlc:") || url.startsWith("sdbc:mysql:mysqlc:");
106 Sequence<DriverPropertyInfo> SAL_CALL
107 MysqlCDriver::getPropertyInfo(const OUString& url, const Sequence<PropertyValue>& /* info */)
109 if (acceptsURL(url))
111 ::std::vector<DriverPropertyInfo> aDriverInfo;
113 aDriverInfo.push_back(DriverPropertyInfo("Hostname", "Name of host", true, "localhost",
114 Sequence<OUString>()));
115 aDriverInfo.push_back(
116 DriverPropertyInfo("Port", "Port", true, "3306", Sequence<OUString>()));
117 return Sequence<DriverPropertyInfo>(aDriverInfo.data(), aDriverInfo.size());
120 return Sequence<DriverPropertyInfo>();
123 sal_Int32 SAL_CALL MysqlCDriver::getMajorVersion() { return MARIADBC_VERSION_MAJOR; }
125 sal_Int32 SAL_CALL MysqlCDriver::getMinorVersion() { return MARIADBC_VERSION_MINOR; }
127 namespace connectivity
129 namespace mysqlc
131 Reference<XInterface> MysqlCDriver_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
133 return (*(new MysqlCDriver(_rxFactory)));
136 void checkDisposed(bool _bThrow)
138 if (_bThrow)
140 throw DisposedException();
144 } /* mysqlc */
145 } /* connectivity */
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */