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