Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _DBAUI_ODBC_CONFIG_HXX_
21 : #define _DBAUI_ODBC_CONFIG_HXX_
22 :
23 : #include "commontypes.hxx"
24 :
25 : #if defined(WNT) || (defined (UNX) && !defined(ANDROID) && !defined(IOS))
26 : #define HAVE_ODBC_SUPPORT
27 : #endif
28 :
29 : #if defined(WNT) && defined(HAVE_ODBC_SUPPORT)
30 : #define HAVE_ODBC_ADMINISTRATION
31 : #endif
32 :
33 : #include <tools/link.hxx>
34 : #include <osl/module.h>
35 :
36 : #include <memory>
37 :
38 : //.........................................................................
39 : namespace dbaui
40 : {
41 : //.........................................................................
42 :
43 : //=========================================================================
44 : //= OOdbcLibWrapper
45 : //=========================================================================
46 : /** base for helper classes wrapping functionality from an ODBC library
47 : */
48 : class OOdbcLibWrapper
49 : {
50 : oslModule m_pOdbcLib; // the library handle
51 : ::rtl::OUString m_sLibPath; // the path to the library
52 :
53 : public:
54 : #ifdef HAVE_ODBC_SUPPORT
55 0 : sal_Bool isLoaded() const { return NULL != m_pOdbcLib; }
56 : #else
57 : sal_Bool isLoaded() const { return sal_False; }
58 : #endif
59 0 : ::rtl::OUString getLibraryName() const { return m_sLibPath; }
60 :
61 : protected:
62 : #ifndef HAVE_ODBC_SUPPORT
63 : OOdbcLibWrapper() : m_pOdbcLib(NULL) { }
64 : #else
65 : OOdbcLibWrapper();
66 : #endif
67 : ~OOdbcLibWrapper();
68 :
69 : oslGenericFunction loadSymbol(const sal_Char* _pFunctionName);
70 :
71 : /// load the lib
72 : sal_Bool load(const sal_Char* _pLibPath);
73 : /// unload the lib
74 : void unload();
75 : };
76 :
77 : //=========================================================================
78 : //= OOdbcEnumeration
79 : //=========================================================================
80 : struct OdbcTypesImpl;
81 : class OOdbcEnumeration : public OOdbcLibWrapper
82 : {
83 : #ifdef HAVE_ODBC_SUPPORT
84 : // entry points for ODBC administration
85 : oslGenericFunction m_pAllocHandle;
86 : oslGenericFunction m_pFreeHandle;
87 : oslGenericFunction m_pSetEnvAttr;
88 : oslGenericFunction m_pDataSources;
89 :
90 : #endif
91 : OdbcTypesImpl* m_pImpl;
92 : // needed because we can't have a member of type SQLHANDLE: this would require us to include the respective
93 : // ODBC file, which would lead to a lot of conflicts with other includes
94 :
95 : public:
96 : OOdbcEnumeration();
97 : ~OOdbcEnumeration();
98 :
99 : void getDatasourceNames(StringBag& _rNames);
100 :
101 : protected:
102 : /// ensure that an ODBC environment is allocated
103 : sal_Bool allocEnv();
104 : /// free any allocated ODBC environment
105 : void freeEnv();
106 : };
107 :
108 : //=========================================================================
109 : //= OOdbcManagement
110 : //=========================================================================
111 : #ifdef HAVE_ODBC_ADMINISTRATION
112 : class ProcessTerminationWait;
113 : class OOdbcManagement
114 : {
115 : ::std::auto_ptr< ProcessTerminationWait > m_pProcessWait;
116 : Link m_aAsyncFinishCallback;
117 :
118 : public:
119 : OOdbcManagement( const Link& _rAsyncFinishCallback );
120 : ~OOdbcManagement();
121 :
122 : bool manageDataSources_async();
123 : bool isRunning() const;
124 : };
125 : #endif
126 :
127 : //.........................................................................
128 : } // namespace dbaui
129 : //.........................................................................
130 :
131 : #endif // _DBAUI_ODBC_CONFIG_HXX_
132 :
133 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|