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 static Sequence<OUString> impl_getSupportedServiceNames(); 94 virtual Sequence<OUString> SAL_CALL getSupportedServiceNames(); 95 virtual sal_Bool SAL_CALL supportsService( const OUString& aName ); 96 97 // XInitialize 98 virtual void SAL_CALL initialize( const Sequence<Any>& aArguments ); 99 100 static Reference<XInterface> impl_getInstance( const Reference< XMultiServiceFactory >& aFactory ); 101 }; 102 103 class AccInstanceProvider : public ::cppu::WeakImplHelper1<XInstanceProvider> 104 { 105 private: 106 Reference<XMultiServiceFactory> m_rSMgr; 107 Reference<XConnection> m_rConnection; 108 109 public: 110 AccInstanceProvider(const Reference< XMultiServiceFactory >& aFactory, 111 const Reference< XConnection >& rConnection); 112 virtual ~AccInstanceProvider(); 113 114 // XInstanceProvider 115 virtual Reference<XInterface> SAL_CALL getInstance (const OUString& aName ); 116 }; 117 118 119 } //namespace desktop 120