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 _CONNECTIVITY_ZCONNECTIONWRAPPER_HXX_
29 #define _CONNECTIVITY_ZCONNECTIONWRAPPER_HXX_
30 
31 #include <cppuhelper/implbase2.hxx>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/beans/PropertyValue.hpp>
34 #include <com/sun/star/lang/XUnoTunnel.hpp>
35 #include <com/sun/star/sdbc/XConnection.hpp>
36 #include <comphelper/broadcasthelper.hxx>
37 #include "connectivity/CommonTools.hxx"
38 #include "connectivity/dbtoolsdllapi.hxx"
39 
40 namespace connectivity
41 {
42 
43 	//==========================================================================
44 	//= OConnectionWrapper - wraps all methods to the real connection from the driver
45 	//= but when disposed it doesn't dispose the real connection
46 	//==========================================================================
47     typedef ::cppu::ImplHelper2<        ::com::sun::star::lang::XServiceInfo,
48 										::com::sun::star::lang::XUnoTunnel
49 								> OConnection_BASE;
50 
51 	class OOO_DLLPUBLIC_DBTOOLS OConnectionWrapper :	 public OConnection_BASE
52 	{
53 	protected:
54 		::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xProxyConnection;
55 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
56 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider > m_xTypeProvider;
57 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > m_xUnoTunnel;
58 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo > m_xServiceInfo;
59 
60 		virtual ~OConnectionWrapper();
61 		void setDelegation(::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxProxyConnection,oslInterlockedCount& _rRefCount);
62 		void setDelegation(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection
63 			,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB
64 			,oslInterlockedCount& _rRefCount);
65 		// must be called from derived classes
66 		void disposing();
67 	public:
68 		OConnectionWrapper( );
69 
70 		// XServiceInfo
71 		DECLARE_SERVICE_INFO();
72 		virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
73 		virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw (::com::sun::star::uno::RuntimeException);
74 
75 		// com::sun::star::lang::XUnoTunnel
76         virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
77         static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
78 		/** method to create unique ids
79 			@param	_rURL
80 				The URL.
81 			@param	_rInfo
82 				The info property of the datasource. It will be resorted if needed.
83 			@param	_pBuffer
84 				Here we store the digest. Must not NULL.
85 			@param	_rUserName
86 				The user name.
87 			@param	_rPassword
88 				The password.
89 		*/
90 		static void createUniqueId( const ::rtl::OUString& _rURL
91 					,::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo
92 					,sal_uInt8* _pBuffer
93 					,const ::rtl::OUString& _rUserName = ::rtl::OUString()
94 					,const ::rtl::OUString& _rPassword = ::rtl::OUString());
95 	};
96 }
97 #endif // _CONNECTIVITY_ZCONNECTIONWRAPPER_HXX_
98 
99