xref: /aoo41x/main/desktop/source/offacc/acceptor.hxx (revision 0a1e2f0e)
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 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/uno/Exception.hpp>
26 #include <com/sun/star/uno/Reference.h>
27 #include <com/sun/star/lang/XComponent.hpp>
28 #include <com/sun/star/connection/XAcceptor.hpp>
29 #include <com/sun/star/lang/XInitialization.hpp>
30 #include <com/sun/star/bridge/XInstanceProvider.hpp>
31 #include <com/sun/star/bridge/XBridgeFactory.hpp>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <cppuhelper/implbase1.hxx>
34 #include <cppuhelper/implbase2.hxx>
35 #include <cppuhelper/interfacecontainer.h>
36 #include <rtl/logfile.hxx>
37 
38 #include <com/sun/star/registry/XRegistryKey.hpp>
39 #include <comphelper/weakbag.hxx>
40 #include <osl/mutex.hxx>
41 #include <osl/conditn.hxx>
42 #include <osl/thread.hxx>
43 
44 
45 using namespace ::rtl;
46 using namespace ::osl;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::beans;
49 using namespace ::com::sun::star::bridge;
50 using namespace ::com::sun::star::lang;
51 using namespace ::com::sun::star::connection;
52 using namespace ::com::sun::star::container;
53 using namespace ::com::sun::star::registry;
54 
55 namespace desktop {
56 
57 class  Acceptor
58 	: public ::cppu::WeakImplHelper2<XServiceInfo, XInitialization>
59 {
60 private:
61 	static const sal_Char *serviceName;
62 	static const sal_Char *implementationName;
63 	static const sal_Char *supportedServiceNames[];
64 
65 	static Mutex m_aMutex;
66 
67     oslThread m_thread;
68     comphelper::WeakBag< com::sun::star::bridge::XBridge > m_bridges;
69 
70 	Condition m_cEnable;
71 
72 	Reference< XMultiServiceFactory > m_rSMgr;
73 	Reference< XInterface >			  m_rContext;
74 	Reference< XAcceptor >            m_rAcceptor;
75 	Reference< XBridgeFactory >       m_rBridgeFactory;
76 
77 	OUString m_aAcceptString;
78 	OUString m_aConnectString;
79 	OUString m_aProtocol;
80 
81 	sal_Bool m_bInit;
82     bool m_bDying;
83 
84 public:
85 	Acceptor( const Reference< XMultiServiceFactory >& aFactory );
86     virtual ~Acceptor();
87 
88 	void SAL_CALL run();
89 
90 	// XService info
91 	static  OUString                    impl_getImplementationName();
92     virtual OUString           SAL_CALL getImplementationName()
93 		throw (RuntimeException);
94 	static  Sequence<OUString>          impl_getSupportedServiceNames();
95 	virtual Sequence<OUString> SAL_CALL getSupportedServiceNames()
96 		throw (RuntimeException);
97 	virtual sal_Bool           SAL_CALL supportsService( const OUString& aName )
98 		throw (RuntimeException);
99 
100 	// XInitialize
101 	virtual void SAL_CALL initialize( const Sequence<Any>& aArguments )
102 		throw ( Exception );
103 
104 	static  Reference<XInterface> impl_getInstance( const Reference< XMultiServiceFactory >& aFactory );
105 };
106 
107 class AccInstanceProvider : public ::cppu::WeakImplHelper1<XInstanceProvider>
108 {
109 private:
110 	Reference<XMultiServiceFactory> m_rSMgr;
111 	Reference<XConnection> m_rConnection;
112 
113 public:
114 	AccInstanceProvider(const Reference< XMultiServiceFactory >& aFactory,
115 		                const Reference< XConnection >& rConnection);
116 	virtual ~AccInstanceProvider();
117 
118 	// XInstanceProvider
119     virtual Reference<XInterface> SAL_CALL getInstance (const OUString& aName )
120         throw ( NoSuchElementException );
121 };
122 
123 
124 } //namespace desktop
125 
126