xref: /AOO41X/main/connectivity/inc/connectivity/ConnectionWrapper.hxx (revision caf5cd79edad04a48dcaf209068b3b89eae4622e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CONNECTIVITY_ZCONNECTIONWRAPPER_HXX_
25 #define _CONNECTIVITY_ZCONNECTIONWRAPPER_HXX_
26 
27 #include <cppuhelper/implbase2.hxx>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/beans/PropertyValue.hpp>
30 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include <com/sun/star/sdbc/XConnection.hpp>
32 #include <comphelper/broadcasthelper.hxx>
33 #include "connectivity/CommonTools.hxx"
34 #include "connectivity/dbtoolsdllapi.hxx"
35 
36 namespace connectivity
37 {
38 
39     //==========================================================================
40     //= OConnectionWrapper - wraps all methods to the real connection from the driver
41     //= but when disposed it doesn't dispose the real connection
42     //==========================================================================
43     typedef ::cppu::ImplHelper2<        ::com::sun::star::lang::XServiceInfo,
44                                         ::com::sun::star::lang::XUnoTunnel
45                                 > OConnection_BASE;
46 
47     class OOO_DLLPUBLIC_DBTOOLS OConnectionWrapper :     public OConnection_BASE
48     {
49     protected:
50         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xProxyConnection;
51         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
52         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider > m_xTypeProvider;
53         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > m_xUnoTunnel;
54         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo > m_xServiceInfo;
55 
56         virtual ~OConnectionWrapper();
57         void setDelegation(::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxProxyConnection,oslInterlockedCount& _rRefCount);
58         void setDelegation(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection
59             ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB
60             ,oslInterlockedCount& _rRefCount);
61         // must be called from derived classes
62         void disposing();
63     public:
64         OConnectionWrapper( );
65 
66         // XServiceInfo
67         DECLARE_SERVICE_INFO();
68         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
69         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw (::com::sun::star::uno::RuntimeException);
70 
71         // com::sun::star::lang::XUnoTunnel
72         virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
73         static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
74         /** method to create unique ids
75             @param  _rURL
76                 The URL.
77             @param  _rInfo
78                 The info property of the datasource. It will be resorted if needed.
79             @param  _pBuffer
80                 Here we store the digest. Must not NULL.
81             @param  _rUserName
82                 The user name.
83             @param  _rPassword
84                 The password.
85         */
86         static void createUniqueId( const ::rtl::OUString& _rURL
87                     ,::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo
88                     ,sal_uInt8* _pBuffer
89                     ,const ::rtl::OUString& _rUserName = ::rtl::OUString()
90                     ,const ::rtl::OUString& _rPassword = ::rtl::OUString());
91     };
92 }
93 #endif // _CONNECTIVITY_ZCONNECTIONWRAPPER_HXX_
94 
95