1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3*cdf0e10cSrcweir * 4*cdf0e10cSrcweir * Copyright 2008 by Sun Microsystems, Inc. 5*cdf0e10cSrcweir * 6*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 7*cdf0e10cSrcweir * 8*cdf0e10cSrcweir * $RCSfile: mysqlc_driver.hxx,v $ 9*cdf0e10cSrcweir * 10*cdf0e10cSrcweir * $Revision: 1.1.2.4 $ 11*cdf0e10cSrcweir * 12*cdf0e10cSrcweir * This file is part of OpenOffice.org. 13*cdf0e10cSrcweir * 14*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 15*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 16*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 17*cdf0e10cSrcweir * 18*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 19*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 20*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 22*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 23*cdf0e10cSrcweir * 24*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 25*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 26*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 27*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 28*cdf0e10cSrcweir ************************************************************************/ 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #ifndef MYSQLC_SDRIVER_HXX 31*cdf0e10cSrcweir #define MYSQLC_SDRIVER_HXX 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "mysqlc_connection.hxx" 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <com/sun/star/sdbc/XDriver.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 39*cdf0e10cSrcweir #include <preextstl.h> 40*cdf0e10cSrcweir #include <cppconn/driver.h> 41*cdf0e10cSrcweir #include <postextstl.h> 42*cdf0e10cSrcweir #include <osl/module.h> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir namespace connectivity 45*cdf0e10cSrcweir { 46*cdf0e10cSrcweir namespace mysqlc 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir using ::rtl::OUString; 49*cdf0e10cSrcweir using ::com::sun::star::sdbc::SQLException; 50*cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 51*cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 52*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 53*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 54*cdf0e10cSrcweir Reference< ::com::sun::star::uno::XInterface > SAL_CALL MysqlCDriver_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw(Exception); 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XDriver, 57*cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo > ODriver_BASE; 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir typedef void* (SAL_CALL * OMysqlCConnection_CreateInstanceFunction)(void* _pDriver); 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir class MysqlCDriver : public ODriver_BASE 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir protected: 64*cdf0e10cSrcweir Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; 65*cdf0e10cSrcweir ::osl::Mutex m_aMutex; // mutex is need to control member access 66*cdf0e10cSrcweir OWeakRefArray m_xConnections; // vector containing a list 67*cdf0e10cSrcweir // of all the Connection objects 68*cdf0e10cSrcweir // for this Driver 69*cdf0e10cSrcweir #ifndef SYSTEM_MYSQL_CPPCONN 70*cdf0e10cSrcweir oslModule m_hCppConnModule; 71*cdf0e10cSrcweir bool m_bAttemptedLoadCppConn; 72*cdf0e10cSrcweir #endif 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir sql::Driver * cppDriver; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir public: 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir MysqlCDriver(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir // OComponentHelper 81*cdf0e10cSrcweir void SAL_CALL disposing(void); 82*cdf0e10cSrcweir // XInterface 83*cdf0e10cSrcweir static OUString getImplementationName_Static() throw(RuntimeException); 84*cdf0e10cSrcweir static Sequence< OUString > getSupportedServiceNames_Static() throw(RuntimeException); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir // XServiceInfo 87*cdf0e10cSrcweir OUString SAL_CALL getImplementationName() throw(RuntimeException); 88*cdf0e10cSrcweir sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(RuntimeException); 89*cdf0e10cSrcweir Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir // XDriver 92*cdf0e10cSrcweir Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect(const OUString& url, const Sequence< ::com::sun::star::beans::PropertyValue >& info) 93*cdf0e10cSrcweir throw(SQLException, RuntimeException); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir sal_Bool SAL_CALL acceptsURL(const OUString& url) throw(SQLException, RuntimeException); 96*cdf0e10cSrcweir Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const OUString& url, const Sequence< ::com::sun::star::beans::PropertyValue >& info) 97*cdf0e10cSrcweir throw(SQLException, RuntimeException); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir sal_Int32 SAL_CALL getMajorVersion() throw(RuntimeException); 100*cdf0e10cSrcweir sal_Int32 SAL_CALL getMinorVersion() throw(RuntimeException); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir inline Reference< ::com::sun::star::lang::XMultiServiceFactory > getFactory() const { return m_xFactory; } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir rtl_TextEncoding getDefaultEncoding() { return RTL_TEXTENCODING_UTF8; } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir private: 107*cdf0e10cSrcweir void impl_initCppConn_lck_throw(); 108*cdf0e10cSrcweir }; 109*cdf0e10cSrcweir } /* mysqlc */ 110*cdf0e10cSrcweir } /* connectivity */ 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir #endif // MYSQLC_SDRIVER_HXX 113*cdf0e10cSrcweir /* 114*cdf0e10cSrcweir * Local variables: 115*cdf0e10cSrcweir * tab-width: 4 116*cdf0e10cSrcweir * c-basic-offset: 4 117*cdf0e10cSrcweir * End: 118*cdf0e10cSrcweir * vim600: noet sw=4 ts=4 fdm=marker 119*cdf0e10cSrcweir * vim<600: noet sw=4 ts=4 120*cdf0e10cSrcweir */ 121