1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _UCB_HXX 29*cdf0e10cSrcweir #define _UCB_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandProcessor.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProvider.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentIdentifierFactory.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProviderManager.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/util/XChangesListener.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/util/XChangesNotifier.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 45*cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 46*cdf0e10cSrcweir #include <osl/mutex.hxx> 47*cdf0e10cSrcweir #include <osl/interlck.h> 48*cdf0e10cSrcweir #include <ucbhelper/macros.hxx> 49*cdf0e10cSrcweir #include "providermap.hxx" 50*cdf0e10cSrcweir #include <ucbhelper/registerucb.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include <vector> 53*cdf0e10cSrcweir //========================================================================= 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #define UCB_SERVICE_NAME "com.sun.star.ucb.UniversalContentBroker" 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir //========================================================================= 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir namespace cppu { class OInterfaceContainerHelper; } 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace ucb { 62*cdf0e10cSrcweir class XCommandInfo; 63*cdf0e10cSrcweir struct GlobalTransferCommandArgument; 64*cdf0e10cSrcweir } } } } 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir class UniversalContentBroker : 67*cdf0e10cSrcweir public cppu::OWeakObject, 68*cdf0e10cSrcweir public com::sun::star::lang::XTypeProvider, 69*cdf0e10cSrcweir public com::sun::star::lang::XComponent, 70*cdf0e10cSrcweir public com::sun::star::lang::XServiceInfo, 71*cdf0e10cSrcweir public com::sun::star::lang::XInitialization, 72*cdf0e10cSrcweir public com::sun::star::ucb::XContentProviderManager, 73*cdf0e10cSrcweir public com::sun::star::ucb::XContentProvider, 74*cdf0e10cSrcweir public com::sun::star::ucb::XContentIdentifierFactory, 75*cdf0e10cSrcweir public com::sun::star::ucb::XCommandProcessor, 76*cdf0e10cSrcweir public com::sun::star::util::XChangesListener 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir public: 79*cdf0e10cSrcweir UniversalContentBroker( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rXSMgr ); 80*cdf0e10cSrcweir virtual ~UniversalContentBroker(); 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir // XInterface 83*cdf0e10cSrcweir XINTERFACE_DECL() 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir // XTypeProvider 86*cdf0e10cSrcweir XTYPEPROVIDER_DECL() 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir // XServiceInfo 89*cdf0e10cSrcweir XSERVICEINFO_DECL() 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir // XComponent 92*cdf0e10cSrcweir virtual void SAL_CALL 93*cdf0e10cSrcweir dispose() 94*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 95*cdf0e10cSrcweir virtual void SAL_CALL 96*cdf0e10cSrcweir addEventListener( const com::sun::star::uno::Reference< 97*cdf0e10cSrcweir com::sun::star::lang::XEventListener >& Listener ) 98*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 99*cdf0e10cSrcweir virtual void SAL_CALL 100*cdf0e10cSrcweir removeEventListener( const com::sun::star::uno::Reference< 101*cdf0e10cSrcweir com::sun::star::lang::XEventListener >& Listener ) 102*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir // XInitialization 105*cdf0e10cSrcweir virtual void SAL_CALL 106*cdf0e10cSrcweir initialize( const com::sun::star::uno::Sequence< 107*cdf0e10cSrcweir com::sun::star::uno::Any >& aArguments ) 108*cdf0e10cSrcweir throw( com::sun::star::uno::Exception, 109*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir // XContentProviderManager 112*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< 113*cdf0e10cSrcweir com::sun::star::ucb::XContentProvider > SAL_CALL 114*cdf0e10cSrcweir registerContentProvider( const com::sun::star::uno::Reference< 115*cdf0e10cSrcweir com::sun::star::ucb::XContentProvider >& 116*cdf0e10cSrcweir Provider, 117*cdf0e10cSrcweir const rtl::OUString& Scheme, 118*cdf0e10cSrcweir sal_Bool ReplaceExisting ) 119*cdf0e10cSrcweir throw( com::sun::star::ucb::DuplicateProviderException, 120*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 121*cdf0e10cSrcweir virtual void SAL_CALL 122*cdf0e10cSrcweir deregisterContentProvider( const com::sun::star::uno::Reference< 123*cdf0e10cSrcweir com::sun::star::ucb::XContentProvider >& 124*cdf0e10cSrcweir Provider, 125*cdf0e10cSrcweir const rtl::OUString& Scheme ) 126*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 127*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< 128*cdf0e10cSrcweir com::sun::star::ucb::ContentProviderInfo > SAL_CALL 129*cdf0e10cSrcweir queryContentProviders() 130*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 131*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< 132*cdf0e10cSrcweir com::sun::star::ucb::XContentProvider > SAL_CALL 133*cdf0e10cSrcweir queryContentProvider( const rtl::OUString& Identifier ) 134*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir // XContentProvider 137*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< 138*cdf0e10cSrcweir com::sun::star::ucb::XContent > SAL_CALL 139*cdf0e10cSrcweir queryContent( const com::sun::star::uno::Reference< 140*cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& Identifier ) 141*cdf0e10cSrcweir throw( com::sun::star::ucb::IllegalIdentifierException, 142*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 143*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 144*cdf0e10cSrcweir compareContentIds( const com::sun::star::uno::Reference< 145*cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& Id1, 146*cdf0e10cSrcweir const com::sun::star::uno::Reference< 147*cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& Id2 ) 148*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir // XContentIdentifierFactory 151*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< 152*cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier > SAL_CALL 153*cdf0e10cSrcweir createContentIdentifier( const rtl::OUString& ContentId ) 154*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir // XCommandProcessor 157*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 158*cdf0e10cSrcweir createCommandIdentifier() 159*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 160*cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL 161*cdf0e10cSrcweir execute( const com::sun::star::ucb::Command& aCommand, 162*cdf0e10cSrcweir sal_Int32 CommandId, 163*cdf0e10cSrcweir const com::sun::star::uno::Reference< 164*cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment >& Environment ) 165*cdf0e10cSrcweir throw( com::sun::star::uno::Exception, 166*cdf0e10cSrcweir com::sun::star::ucb::CommandAbortedException, 167*cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 168*cdf0e10cSrcweir virtual void SAL_CALL 169*cdf0e10cSrcweir abort( sal_Int32 CommandId ) 170*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir // XChangesListener 173*cdf0e10cSrcweir virtual void SAL_CALL changesOccurred( const com::sun::star::util::ChangesEvent& Event ) 174*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir // XEventListener ( base of XChangesLisetenr ) 177*cdf0e10cSrcweir virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) 178*cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir private: 181*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > 182*cdf0e10cSrcweir queryContentProvider( const rtl::OUString& Identifier, 183*cdf0e10cSrcweir sal_Bool bResolved ); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::ucb::XCommandInfo > 186*cdf0e10cSrcweir getCommandInfo(); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir void 189*cdf0e10cSrcweir globalTransfer( 190*cdf0e10cSrcweir const com::sun::star::ucb::GlobalTransferCommandArgument & rArg, 191*cdf0e10cSrcweir const com::sun::star::uno::Reference< 192*cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment >& xEnv ) 193*cdf0e10cSrcweir throw( com::sun::star::uno::Exception ); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir bool configureUcb() 197*cdf0e10cSrcweir throw ( com::sun::star::uno::RuntimeException); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir bool getContentProviderData( 200*cdf0e10cSrcweir const rtl::OUString & rKey1, 201*cdf0e10cSrcweir const rtl::OUString & rKey2, 202*cdf0e10cSrcweir ucbhelper::ContentProviderDataList & rListToFill); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir void prepareAndRegister( const ucbhelper::ContentProviderDataList& rData); 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir com::sun::star::uno::Reference< 207*cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory > m_xSMgr; 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir com::sun::star::uno::Reference< 210*cdf0e10cSrcweir com::sun::star::util::XChangesNotifier > m_xNotifier; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_aArguments; 213*cdf0e10cSrcweir ProviderMap_Impl m_aProviders; 214*cdf0e10cSrcweir osl::Mutex m_aMutex; 215*cdf0e10cSrcweir cppu::OInterfaceContainerHelper* m_pDisposeEventListeners; 216*cdf0e10cSrcweir oslInterlockedCount m_nInitCount; //@@@ see initialize() method 217*cdf0e10cSrcweir sal_Int32 m_nCommandId; 218*cdf0e10cSrcweir }; 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir #endif /* !_UCB_HXX */ 221