Update ooo320-m1
[ooovba.git] / dbaccess / source / ui / dlg / odbcconfig.hxx
blobe77af9937ed7f32bb097f3ad01bb8daa588ba542
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: odbcconfig.hxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DBAUI_ODBC_CONFIG_HXX_
32 #define _DBAUI_ODBC_CONFIG_HXX_
34 #include "commontypes.hxx"
36 #if defined(WIN) || defined(WNT) || defined (UNX) || defined (OS2)
37 #define HAVE_ODBC_SUPPORT
38 #endif
40 #if ( defined(WIN) || defined(WNT) || defined (OS2) ) && defined(HAVE_ODBC_SUPPORT)
41 #define HAVE_ODBC_ADMINISTRATION
42 #endif
44 #include <tools/link.hxx>
45 #include <osl/module.h>
47 #include <memory>
49 //.........................................................................
50 namespace dbaui
52 //.........................................................................
54 //=========================================================================
55 //= OOdbcLibWrapper
56 //=========================================================================
57 /** base for helper classes wrapping functionality from an ODBC library
59 class OOdbcLibWrapper
61 oslModule m_pOdbcLib; // the library handle
62 ::rtl::OUString m_sLibPath; // the path to the library
64 public:
65 #ifdef HAVE_ODBC_SUPPORT
66 sal_Bool isLoaded() const { return NULL != m_pOdbcLib; }
67 #else
68 sal_Bool isLoaded() const { return sal_False; }
69 #endif
70 ::rtl::OUString getLibraryName() const { return m_sLibPath; }
72 protected:
73 #ifndef HAVE_ODBC_SUPPORT
74 OOdbcLibWrapper() : m_pOdbcLib(NULL) { }
75 #else
76 OOdbcLibWrapper();
77 #endif
78 ~OOdbcLibWrapper();
80 oslGenericFunction loadSymbol(const sal_Char* _pFunctionName);
82 /// load the lib
83 sal_Bool load(const sal_Char* _pLibPath);
84 /// unload the lib
85 void unload();
88 //=========================================================================
89 //= OOdbcEnumeration
90 //=========================================================================
91 struct OdbcTypesImpl;
92 class OOdbcEnumeration : public OOdbcLibWrapper
94 #ifdef HAVE_ODBC_SUPPORT
95 // entry points for ODBC administration
96 oslGenericFunction m_pAllocHandle;
97 oslGenericFunction m_pFreeHandle;
98 oslGenericFunction m_pSetEnvAttr;
99 oslGenericFunction m_pDataSources;
101 #endif
102 OdbcTypesImpl* m_pImpl;
103 // needed because we can't have a member of type SQLHANDLE: this would require us to include the respective
104 // ODBC file, which would lead to a lot of conflicts with other includes
106 public:
107 OOdbcEnumeration();
108 ~OOdbcEnumeration();
110 void getDatasourceNames(StringBag& _rNames);
112 protected:
113 /// ensure that an ODBC environment is allocated
114 sal_Bool allocEnv();
115 /// free any allocated ODBC environment
116 void freeEnv();
119 //=========================================================================
120 //= OOdbcManagement
121 //=========================================================================
122 #ifdef HAVE_ODBC_ADMINISTRATION
123 class ProcessTerminationWait;
124 class OOdbcManagement
126 ::std::auto_ptr< ProcessTerminationWait > m_pProcessWait;
127 Link m_aAsyncFinishCallback;
129 public:
130 OOdbcManagement( const Link& _rAsyncFinishCallback );
131 ~OOdbcManagement();
133 bool manageDataSources_async();
134 bool isRunning() const;
136 #endif
138 //.........................................................................
139 } // namespace dbaui
140 //.........................................................................
142 #endif // _DBAUI_ODBC_CONFIG_HXX_