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 .
21 #include "mysqlc_connection.hxx"
23 #include <com/sun/star/sdbc/XDriver.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <cppuhelper/compbase2.hxx>
28 #include <osl/module.h>
30 namespace connectivity::mysqlc
32 using css::sdbc::SQLException
;
33 using css::uno::Exception
;
34 using css::uno::Reference
;
35 using css::uno::RuntimeException
;
36 using css::uno::Sequence
;
38 Reference
<css::uno::XInterface
>
39 MysqlCDriver_CreateInstance(const Reference
<css::lang::XMultiServiceFactory
>& _rxFactory
);
41 typedef ::cppu::WeakComponentImplHelper2
<css::sdbc::XDriver
, css::lang::XServiceInfo
> ODriver_BASE
;
43 typedef void* (*OMysqlCConnection_CreateInstanceFunction
)(void* _pDriver
);
45 class MysqlCDriver
: public ODriver_BASE
48 Reference
<css::lang::XMultiServiceFactory
> m_xFactory
;
49 ::osl::Mutex m_aMutex
; // mutex is need to control member access
50 OWeakRefArray m_xConnections
; // vector containing a list
51 // of all the Connection objects
54 oslModule m_hCConnModule
;
55 bool m_bAttemptedLoadCConn
;
58 explicit MysqlCDriver(const Reference
<css::lang::XMultiServiceFactory
>& _rxFactory
);
61 void SAL_CALL
disposing() override
;
63 static OUString
getImplementationName_Static();
64 static Sequence
<OUString
> getSupportedServiceNames_Static();
67 OUString SAL_CALL
getImplementationName() override
;
68 sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
69 Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
72 Reference
<css::sdbc::XConnection
> SAL_CALL
73 connect(const OUString
& url
, const Sequence
<css::beans::PropertyValue
>& info
) override
;
75 sal_Bool SAL_CALL
acceptsURL(const OUString
& url
) override
;
76 Sequence
<css::sdbc::DriverPropertyInfo
> SAL_CALL
77 getPropertyInfo(const OUString
& url
, const Sequence
<css::beans::PropertyValue
>& info
) override
;
79 sal_Int32 SAL_CALL
getMajorVersion() override
;
80 sal_Int32 SAL_CALL
getMinorVersion() override
;
82 const Reference
<css::lang::XMultiServiceFactory
>& getFactory() const { return m_xFactory
; }
84 static rtl_TextEncoding
getDefaultEncoding() { return RTL_TEXTENCODING_UTF8
; }
87 } /* connectivity::mysqlc */
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */