bump product version to 7.2.5.1
[LibreOffice.git] / connectivity / source / drivers / macab / MacabDriver.hxx
blobf75391dedb466dfdcfc937649580da6a27b65a6b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #pragma once
22 #include <com/sun/star/sdbc/XDriver.hpp>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <com/sun/star/frame/XTerminateListener.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include <cppuhelper/compbase.hxx>
28 #include <osl/module.h>
30 // the address book driver's version
31 #define MACAB_DRIVER_VERSION "0.1"
32 #define MACAB_DRIVER_VERSION_MAJOR 0
33 #define MACAB_DRIVER_VERSION_MINOR 1
35 namespace connectivity::macab
37 class MacabConnection;
38 class MacabDriver;
40 typedef void* (SAL_CALL * ConnectionFactoryFunction)( void* _pDriver );
42 typedef std::vector< css::uno::WeakReferenceHelper > OWeakRefArray;
45 // = MacabImplModule
47 class MacabImplModule
49 private:
50 /// Did we already attempt to load the module and to retrieve the symbols?
51 bool m_bAttemptedLoadModule;
52 oslModule m_hConnectorModule;
53 ConnectionFactoryFunction m_pConnectionFactoryFunc;
55 public:
56 MacabImplModule();
58 /** determines whether there is a mac OS present in the environment
60 bool isMacOSPresent();
62 /** initializes the implementation module.
64 @throws css::uno::RuntimeException
65 if the module could be loaded, but required symbols are missing
66 @throws css::sdbc::SQLException
67 if no Mac OS was found at all
69 void init();
71 /** shuts down the impl module
73 void shutdown();
75 /** creates a new connection
76 @precond
77 <member>init</member> has been called before
78 @throws css::uno::RuntimeException
79 if no connection object could be created (which is a severe error, normally impossible)
81 MacabConnection* createConnection( MacabDriver* _pDriver ) const;
83 private:
84 /** loads the implementation module and retrieves the needed symbols
86 Save against being called multiple times.
88 @return <TRUE/> if the module could be loaded successfully.
90 @throws css::uno::RuntimeException
91 if the module could be loaded, but required symbols are missing
93 bool impl_loadModule();
95 /** unloads the implementation module, and resets all function pointers to <NULL/>
96 @precond m_hConnectorModule is not <NULL/>
98 void impl_unloadModule();
102 // = MacabDriver
104 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XDriver,
105 css::lang::XServiceInfo,
106 css::frame::XTerminateListener > MacabDriver_BASE;
107 class MacabDriver : public MacabDriver_BASE
109 protected:
110 ::osl::Mutex m_aMutex; // mutex is need to control member access
111 OWeakRefArray m_xConnections; // vector containing a list of all the
112 // MacabConnection objects for this Driver
113 css::uno::Reference< css::uno::XComponentContext >
114 m_xContext; // the multi-service factory
115 MacabImplModule m_aImplModule;
117 public:
118 css::uno::Reference< css::uno::XComponentContext > const &
119 getComponentContext() const { return m_xContext; }
121 /** returns the path of our configuration settings
123 static OUString impl_getConfigurationSettingsPath();
125 explicit MacabDriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
126 protected:
128 // OComponentHelper
129 virtual void SAL_CALL disposing() override;
131 // XServiceInfo
132 virtual OUString SAL_CALL getImplementationName( ) override;
133 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
134 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
136 // XDriver
137 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
138 virtual sal_Bool SAL_CALL acceptsURL( const OUString& url ) override;
139 virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
140 virtual sal_Int32 SAL_CALL getMajorVersion() override;
141 virtual sal_Int32 SAL_CALL getMinorVersion() override;
143 // XTerminateListener
144 virtual void SAL_CALL queryTermination( const css::lang::EventObject& Event ) override;
145 virtual void SAL_CALL notifyTermination( const css::lang::EventObject& Event ) override;
147 // XEventListener
148 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
150 private:
151 /** shuts down the library which contains the real implementations
153 This method is safe against being called multiple times
155 @precond our mutex is locked
157 void impl_shutdownImplementationModule();
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */