1 /************************************************************************* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * Copyright 2008 by Sun Microsystems, Inc. 5 * 6 * OpenOffice.org - a multi-platform office productivity suite 7 * 8 * $RCSfile: mysqlc_driver.hxx,v $ 9 * 10 * $Revision: 1.1.2.4 $ 11 * 12 * This file is part of OpenOffice.org. 13 * 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. 17 * 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). 23 * 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. 28 ************************************************************************/ 29 30 #ifndef MYSQLC_SDRIVER_HXX 31 #define MYSQLC_SDRIVER_HXX 32 33 #include "mysqlc_connection.hxx" 34 35 #include <com/sun/star/sdbc/XDriver.hpp> 36 #include <com/sun/star/lang/XServiceInfo.hpp> 37 38 #include <cppuhelper/compbase2.hxx> 39 #include <preextstl.h> 40 #include <cppconn/driver.h> 41 #include <postextstl.h> 42 #include <osl/module.h> 43 44 namespace connectivity 45 { 46 namespace mysqlc 47 { 48 using ::rtl::OUString; 49 using ::com::sun::star::sdbc::SQLException; 50 using ::com::sun::star::uno::RuntimeException; 51 using ::com::sun::star::uno::Exception; 52 using ::com::sun::star::uno::Reference; 53 using ::com::sun::star::uno::Sequence; 54 Reference< ::com::sun::star::uno::XInterface > SAL_CALL MysqlCDriver_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw(Exception); 55 56 typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XDriver, 57 ::com::sun::star::lang::XServiceInfo > ODriver_BASE; 58 59 typedef void* (SAL_CALL * OMysqlCConnection_CreateInstanceFunction)(void* _pDriver); 60 61 class MysqlCDriver : public ODriver_BASE 62 { 63 protected: 64 Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; 65 ::osl::Mutex m_aMutex; // mutex is need to control member access 66 OWeakRefArray m_xConnections; // vector containing a list 67 // of all the Connection objects 68 // for this Driver 69 #ifndef SYSTEM_MYSQL_CPPCONN 70 oslModule m_hCppConnModule; 71 bool m_bAttemptedLoadCppConn; 72 #endif 73 74 sql::Driver * cppDriver; 75 76 public: 77 78 MysqlCDriver(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); 79 80 // OComponentHelper 81 void SAL_CALL disposing(void); 82 // XInterface 83 static OUString getImplementationName_Static() throw(RuntimeException); 84 static Sequence< OUString > getSupportedServiceNames_Static() throw(RuntimeException); 85 86 // XServiceInfo 87 OUString SAL_CALL getImplementationName() throw(RuntimeException); 88 sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(RuntimeException); 89 Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); 90 91 // XDriver 92 Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect(const OUString& url, const Sequence< ::com::sun::star::beans::PropertyValue >& info) 93 throw(SQLException, RuntimeException); 94 95 sal_Bool SAL_CALL acceptsURL(const OUString& url) throw(SQLException, RuntimeException); 96 Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString& url, const Sequence< ::com::sun::star::beans::PropertyValue >& info) 97 throw(SQLException, RuntimeException); 98 99 sal_Int32 SAL_CALL getMajorVersion() throw(RuntimeException); 100 sal_Int32 SAL_CALL getMinorVersion() throw(RuntimeException); 101 102 inline Reference< ::com::sun::star::lang::XMultiServiceFactory > getFactory() const { return m_xFactory; } 103 104 rtl_TextEncoding getDefaultEncoding() { return RTL_TEXTENCODING_UTF8; } 105 106 private: 107 void impl_initCppConn_lck_throw(); 108 }; 109 } /* mysqlc */ 110 } /* connectivity */ 111 112 #endif // MYSQLC_SDRIVER_HXX 113 /* 114 * Local variables: 115 * tab-width: 4 116 * c-basic-offset: 4 117 * End: 118 * vim600: noet sw=4 ts=4 fdm=marker 119 * vim<600: noet sw=4 ts=4 120 */ 121