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