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 #ifndef _UCB_HXX 25 #define _UCB_HXX 26 27 #include <com/sun/star/ucb/XCommandProcessor.hpp> 28 #include <com/sun/star/ucb/XContentProvider.hpp> 29 #include <com/sun/star/ucb/XContentIdentifierFactory.hpp> 30 #include <com/sun/star/ucb/XContentProviderManager.hpp> 31 #include <com/sun/star/lang/XServiceInfo.hpp> 32 #include <com/sun/star/lang/XComponent.hpp> 33 #include <com/sun/star/lang/XInitialization.hpp> 34 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 35 #include <com/sun/star/lang/XTypeProvider.hpp> 36 #include <com/sun/star/util/XChangesListener.hpp> 37 #include <com/sun/star/util/XChangesNotifier.hpp> 38 #include <com/sun/star/container/XContainer.hpp> 39 40 #include <rtl/ustrbuf.hxx> 41 #include <cppuhelper/weak.hxx> 42 #include <osl/mutex.hxx> 43 #include <osl/interlck.h> 44 #include <ucbhelper/macros.hxx> 45 #include "providermap.hxx" 46 #include <ucbhelper/registerucb.hxx> 47 48 #include <vector> 49 //========================================================================= 50 51 #define UCB_SERVICE_NAME "com.sun.star.ucb.UniversalContentBroker" 52 53 //========================================================================= 54 55 namespace cppu { class OInterfaceContainerHelper; } 56 57 namespace com { namespace sun { namespace star { namespace ucb { 58 class XCommandInfo; 59 struct GlobalTransferCommandArgument; 60 } } } } 61 62 class UniversalContentBroker : 63 public cppu::OWeakObject, 64 public com::sun::star::lang::XTypeProvider, 65 public com::sun::star::lang::XComponent, 66 public com::sun::star::lang::XServiceInfo, 67 public com::sun::star::lang::XInitialization, 68 public com::sun::star::ucb::XContentProviderManager, 69 public com::sun::star::ucb::XContentProvider, 70 public com::sun::star::ucb::XContentIdentifierFactory, 71 public com::sun::star::ucb::XCommandProcessor, 72 public com::sun::star::util::XChangesListener 73 { 74 public: 75 UniversalContentBroker( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rXSMgr ); 76 virtual ~UniversalContentBroker(); 77 78 // XInterface 79 XINTERFACE_DECL() 80 81 // XTypeProvider 82 XTYPEPROVIDER_DECL() 83 84 // XServiceInfo 85 XSERVICEINFO_DECL() 86 87 // XComponent 88 virtual void SAL_CALL 89 dispose(); 90 virtual void SAL_CALL 91 addEventListener( const com::sun::star::uno::Reference< 92 com::sun::star::lang::XEventListener >& Listener ); 93 virtual void SAL_CALL 94 removeEventListener( const com::sun::star::uno::Reference< 95 com::sun::star::lang::XEventListener >& Listener ); 96 97 // XInitialization 98 virtual void SAL_CALL 99 initialize( const com::sun::star::uno::Sequence< 100 com::sun::star::uno::Any >& aArguments ); 101 102 // XContentProviderManager 103 virtual com::sun::star::uno::Reference< 104 com::sun::star::ucb::XContentProvider > SAL_CALL 105 registerContentProvider( const com::sun::star::uno::Reference< 106 com::sun::star::ucb::XContentProvider >& 107 Provider, 108 const rtl::OUString& Scheme, 109 sal_Bool ReplaceExisting ); 110 virtual void SAL_CALL 111 deregisterContentProvider( const com::sun::star::uno::Reference< 112 com::sun::star::ucb::XContentProvider >& 113 Provider, 114 const rtl::OUString& Scheme ); 115 virtual com::sun::star::uno::Sequence< 116 com::sun::star::ucb::ContentProviderInfo > SAL_CALL 117 queryContentProviders(); 118 virtual com::sun::star::uno::Reference< 119 com::sun::star::ucb::XContentProvider > SAL_CALL 120 queryContentProvider( const rtl::OUString& Identifier ); 121 122 // XContentProvider 123 virtual com::sun::star::uno::Reference< 124 com::sun::star::ucb::XContent > SAL_CALL 125 queryContent( const com::sun::star::uno::Reference< 126 com::sun::star::ucb::XContentIdentifier >& Identifier ); 127 virtual sal_Int32 SAL_CALL 128 compareContentIds( const com::sun::star::uno::Reference< 129 com::sun::star::ucb::XContentIdentifier >& Id1, 130 const com::sun::star::uno::Reference< 131 com::sun::star::ucb::XContentIdentifier >& Id2 ); 132 133 // XContentIdentifierFactory 134 virtual com::sun::star::uno::Reference< 135 com::sun::star::ucb::XContentIdentifier > SAL_CALL 136 createContentIdentifier( const rtl::OUString& ContentId ); 137 138 // XCommandProcessor 139 virtual sal_Int32 SAL_CALL 140 createCommandIdentifier(); 141 virtual com::sun::star::uno::Any SAL_CALL 142 execute( const com::sun::star::ucb::Command& aCommand, 143 sal_Int32 CommandId, 144 const com::sun::star::uno::Reference< 145 com::sun::star::ucb::XCommandEnvironment >& Environment ); 146 virtual void SAL_CALL 147 abort( sal_Int32 CommandId ); 148 149 // XChangesListener 150 virtual void SAL_CALL changesOccurred( const com::sun::star::util::ChangesEvent& Event ); 151 152 // XEventListener ( base of XChangesLisetenr ) 153 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ); 154 155 private: 156 com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > 157 queryContentProvider( const rtl::OUString& Identifier, 158 sal_Bool bResolved ); 159 160 com::sun::star::uno::Reference< com::sun::star::ucb::XCommandInfo > 161 getCommandInfo(); 162 163 void 164 globalTransfer( 165 const com::sun::star::ucb::GlobalTransferCommandArgument & rArg, 166 const com::sun::star::uno::Reference< 167 com::sun::star::ucb::XCommandEnvironment >& xEnv ); 168 169 170 bool configureUcb(); 171 172 bool getContentProviderData( 173 const rtl::OUString & rKey1, 174 const rtl::OUString & rKey2, 175 ucbhelper::ContentProviderDataList & rListToFill); 176 177 void prepareAndRegister( const ucbhelper::ContentProviderDataList& rData); 178 179 com::sun::star::uno::Reference< 180 com::sun::star::lang::XMultiServiceFactory > m_xSMgr; 181 182 com::sun::star::uno::Reference< 183 com::sun::star::util::XChangesNotifier > m_xNotifier; 184 185 com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_aArguments; 186 ProviderMap_Impl m_aProviders; 187 osl::Mutex m_aMutex; 188 cppu::OInterfaceContainerHelper* m_pDisposeEventListeners; 189 oslInterlockedCount m_nInitCount; //@@@ see initialize() method 190 sal_Int32 m_nCommandId; 191 }; 192 193 #endif /* !_UCB_HXX */ 194