xref: /trunk/main/desktop/source/offacc/acceptor.hxx (revision 0a1e2f0e)
1*0a1e2f0eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*0a1e2f0eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*0a1e2f0eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*0a1e2f0eSAndrew Rist  * distributed with this work for additional information
6*0a1e2f0eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*0a1e2f0eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*0a1e2f0eSAndrew Rist  * "License"); you may not use this file except in compliance
9*0a1e2f0eSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*0a1e2f0eSAndrew Rist  *
11*0a1e2f0eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*0a1e2f0eSAndrew Rist  *
13*0a1e2f0eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*0a1e2f0eSAndrew Rist  * software distributed under the License is distributed on an
15*0a1e2f0eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0a1e2f0eSAndrew Rist  * KIND, either express or implied.  See the License for the
17*0a1e2f0eSAndrew Rist  * specific language governing permissions and limitations
18*0a1e2f0eSAndrew Rist  * under the License.
19*0a1e2f0eSAndrew Rist  *
20*0a1e2f0eSAndrew Rist  *************************************************************/
21*0a1e2f0eSAndrew Rist 
22*0a1e2f0eSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
25cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp>
26cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
27cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
28cdf0e10cSrcweir #include <com/sun/star/connection/XAcceptor.hpp>
29cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
30cdf0e10cSrcweir #include <com/sun/star/bridge/XInstanceProvider.hpp>
31cdf0e10cSrcweir #include <com/sun/star/bridge/XBridgeFactory.hpp>
32cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
33cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
34cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
35cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
36cdf0e10cSrcweir #include <rtl/logfile.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp>
39cdf0e10cSrcweir #include <comphelper/weakbag.hxx>
40cdf0e10cSrcweir #include <osl/mutex.hxx>
41cdf0e10cSrcweir #include <osl/conditn.hxx>
42cdf0e10cSrcweir #include <osl/thread.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 
45cdf0e10cSrcweir using namespace ::rtl;
46cdf0e10cSrcweir using namespace ::osl;
47cdf0e10cSrcweir using namespace ::com::sun::star::uno;
48cdf0e10cSrcweir using namespace ::com::sun::star::beans;
49cdf0e10cSrcweir using namespace ::com::sun::star::bridge;
50cdf0e10cSrcweir using namespace ::com::sun::star::lang;
51cdf0e10cSrcweir using namespace ::com::sun::star::connection;
52cdf0e10cSrcweir using namespace ::com::sun::star::container;
53cdf0e10cSrcweir using namespace ::com::sun::star::registry;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace desktop {
56cdf0e10cSrcweir 
57cdf0e10cSrcweir class  Acceptor
58cdf0e10cSrcweir 	: public ::cppu::WeakImplHelper2<XServiceInfo, XInitialization>
59cdf0e10cSrcweir {
60cdf0e10cSrcweir private:
61cdf0e10cSrcweir 	static const sal_Char *serviceName;
62cdf0e10cSrcweir 	static const sal_Char *implementationName;
63cdf0e10cSrcweir 	static const sal_Char *supportedServiceNames[];
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	static Mutex m_aMutex;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     oslThread m_thread;
68cdf0e10cSrcweir     comphelper::WeakBag< com::sun::star::bridge::XBridge > m_bridges;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	Condition m_cEnable;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	Reference< XMultiServiceFactory > m_rSMgr;
73cdf0e10cSrcweir 	Reference< XInterface >			  m_rContext;
74cdf0e10cSrcweir 	Reference< XAcceptor >            m_rAcceptor;
75cdf0e10cSrcweir 	Reference< XBridgeFactory >       m_rBridgeFactory;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	OUString m_aAcceptString;
78cdf0e10cSrcweir 	OUString m_aConnectString;
79cdf0e10cSrcweir 	OUString m_aProtocol;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	sal_Bool m_bInit;
82cdf0e10cSrcweir     bool m_bDying;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir public:
85cdf0e10cSrcweir 	Acceptor( const Reference< XMultiServiceFactory >& aFactory );
86cdf0e10cSrcweir     virtual ~Acceptor();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	void SAL_CALL run();
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	// XService info
91cdf0e10cSrcweir 	static  OUString                    impl_getImplementationName();
92cdf0e10cSrcweir     virtual OUString           SAL_CALL getImplementationName()
93cdf0e10cSrcweir 		throw (RuntimeException);
94cdf0e10cSrcweir 	static  Sequence<OUString>          impl_getSupportedServiceNames();
95cdf0e10cSrcweir 	virtual Sequence<OUString> SAL_CALL getSupportedServiceNames()
96cdf0e10cSrcweir 		throw (RuntimeException);
97cdf0e10cSrcweir 	virtual sal_Bool           SAL_CALL supportsService( const OUString& aName )
98cdf0e10cSrcweir 		throw (RuntimeException);
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	// XInitialize
101cdf0e10cSrcweir 	virtual void SAL_CALL initialize( const Sequence<Any>& aArguments )
102cdf0e10cSrcweir 		throw ( Exception );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	static  Reference<XInterface> impl_getInstance( const Reference< XMultiServiceFactory >& aFactory );
105cdf0e10cSrcweir };
106cdf0e10cSrcweir 
107cdf0e10cSrcweir class AccInstanceProvider : public ::cppu::WeakImplHelper1<XInstanceProvider>
108cdf0e10cSrcweir {
109cdf0e10cSrcweir private:
110cdf0e10cSrcweir 	Reference<XMultiServiceFactory> m_rSMgr;
111cdf0e10cSrcweir 	Reference<XConnection> m_rConnection;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir public:
114cdf0e10cSrcweir 	AccInstanceProvider(const Reference< XMultiServiceFactory >& aFactory,
115cdf0e10cSrcweir 		                const Reference< XConnection >& rConnection);
116cdf0e10cSrcweir 	virtual ~AccInstanceProvider();
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	// XInstanceProvider
119cdf0e10cSrcweir     virtual Reference<XInterface> SAL_CALL getInstance (const OUString& aName )
120cdf0e10cSrcweir         throw ( NoSuchElementException );
121cdf0e10cSrcweir };
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir } //namespace desktop
125cdf0e10cSrcweir 
126