xref: /aoo41x/main/ucb/source/core/ucb.hxx (revision 6df1ea1f)
1*6df1ea1fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6df1ea1fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6df1ea1fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6df1ea1fSAndrew Rist  * distributed with this work for additional information
6*6df1ea1fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6df1ea1fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6df1ea1fSAndrew Rist  * "License"); you may not use this file except in compliance
9*6df1ea1fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*6df1ea1fSAndrew Rist  *
11*6df1ea1fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*6df1ea1fSAndrew Rist  *
13*6df1ea1fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6df1ea1fSAndrew Rist  * software distributed under the License is distributed on an
15*6df1ea1fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6df1ea1fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*6df1ea1fSAndrew Rist  * specific language governing permissions and limitations
18*6df1ea1fSAndrew Rist  * under the License.
19*6df1ea1fSAndrew Rist  *
20*6df1ea1fSAndrew Rist  *************************************************************/
21*6df1ea1fSAndrew Rist 
22*6df1ea1fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _UCB_HXX
25cdf0e10cSrcweir #define _UCB_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandProcessor.hpp>
28cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProvider.hpp>
29cdf0e10cSrcweir #include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
30cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProviderManager.hpp>
31cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
34cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
36cdf0e10cSrcweir #include <com/sun/star/util/XChangesListener.hpp>
37cdf0e10cSrcweir #include <com/sun/star/util/XChangesNotifier.hpp>
38cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
41cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
42cdf0e10cSrcweir #include <osl/mutex.hxx>
43cdf0e10cSrcweir #include <osl/interlck.h>
44cdf0e10cSrcweir #include <ucbhelper/macros.hxx>
45cdf0e10cSrcweir #include "providermap.hxx"
46cdf0e10cSrcweir #include <ucbhelper/registerucb.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <vector>
49cdf0e10cSrcweir //=========================================================================
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #define UCB_SERVICE_NAME "com.sun.star.ucb.UniversalContentBroker"
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //=========================================================================
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace cppu { class OInterfaceContainerHelper; }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace ucb {
58cdf0e10cSrcweir 	class XCommandInfo;
59cdf0e10cSrcweir 	struct GlobalTransferCommandArgument;
60cdf0e10cSrcweir } } } }
61cdf0e10cSrcweir 
62cdf0e10cSrcweir class UniversalContentBroker :
63cdf0e10cSrcweir 				public cppu::OWeakObject,
64cdf0e10cSrcweir 				public com::sun::star::lang::XTypeProvider,
65cdf0e10cSrcweir 				public com::sun::star::lang::XComponent,
66cdf0e10cSrcweir 				public com::sun::star::lang::XServiceInfo,
67cdf0e10cSrcweir 				public com::sun::star::lang::XInitialization,
68cdf0e10cSrcweir 				public com::sun::star::ucb::XContentProviderManager,
69cdf0e10cSrcweir 				public com::sun::star::ucb::XContentProvider,
70cdf0e10cSrcweir 				public com::sun::star::ucb::XContentIdentifierFactory,
71cdf0e10cSrcweir 				public com::sun::star::ucb::XCommandProcessor,
72cdf0e10cSrcweir 				public com::sun::star::util::XChangesListener
73cdf0e10cSrcweir {
74cdf0e10cSrcweir public:
75cdf0e10cSrcweir 	UniversalContentBroker( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
76cdf0e10cSrcweir 	virtual ~UniversalContentBroker();
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	// XInterface
79cdf0e10cSrcweir 	XINTERFACE_DECL()
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	// XTypeProvider
82cdf0e10cSrcweir 	XTYPEPROVIDER_DECL()
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     // XServiceInfo
85cdf0e10cSrcweir 	XSERVICEINFO_DECL()
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	// XComponent
88cdf0e10cSrcweir     virtual void SAL_CALL
89cdf0e10cSrcweir 	dispose()
90cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
91cdf0e10cSrcweir     virtual void SAL_CALL
92cdf0e10cSrcweir 	addEventListener( const com::sun::star::uno::Reference<
93cdf0e10cSrcweir 						com::sun::star::lang::XEventListener >& Listener )
94cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
95cdf0e10cSrcweir     virtual void SAL_CALL
96cdf0e10cSrcweir 	removeEventListener( const com::sun::star::uno::Reference<
97cdf0e10cSrcweir 							com::sun::star::lang::XEventListener >& Listener )
98cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	// XInitialization
101cdf0e10cSrcweir     virtual void SAL_CALL
102cdf0e10cSrcweir 	initialize( const com::sun::star::uno::Sequence<
103cdf0e10cSrcweir 						com::sun::star::uno::Any >& aArguments )
104cdf0e10cSrcweir 		throw( com::sun::star::uno::Exception,
105cdf0e10cSrcweir 			   com::sun::star::uno::RuntimeException );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	// XContentProviderManager
108cdf0e10cSrcweir     virtual com::sun::star::uno::Reference<
109cdf0e10cSrcweir 		com::sun::star::ucb::XContentProvider > SAL_CALL
110cdf0e10cSrcweir 	registerContentProvider( const com::sun::star::uno::Reference<
111cdf0e10cSrcweir 								com::sun::star::ucb::XContentProvider >&
112cdf0e10cSrcweir 									Provider,
113cdf0e10cSrcweir 							 const rtl::OUString& Scheme,
114cdf0e10cSrcweir 							 sal_Bool ReplaceExisting )
115cdf0e10cSrcweir 		throw( com::sun::star::ucb::DuplicateProviderException,
116cdf0e10cSrcweir 			   com::sun::star::uno::RuntimeException );
117cdf0e10cSrcweir     virtual void SAL_CALL
118cdf0e10cSrcweir 	deregisterContentProvider( const com::sun::star::uno::Reference<
119cdf0e10cSrcweir 									com::sun::star::ucb::XContentProvider >&
120cdf0e10cSrcweir 										Provider,
121cdf0e10cSrcweir 							   const rtl::OUString& Scheme )
122cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
123cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence<
124cdf0e10cSrcweir 		com::sun::star::ucb::ContentProviderInfo > SAL_CALL
125cdf0e10cSrcweir 	queryContentProviders()
126cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
127cdf0e10cSrcweir     virtual com::sun::star::uno::Reference<
128cdf0e10cSrcweir 		com::sun::star::ucb::XContentProvider >	SAL_CALL
129cdf0e10cSrcweir 	queryContentProvider( const rtl::OUString& Identifier )
130cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	// XContentProvider
133cdf0e10cSrcweir 	virtual com::sun::star::uno::Reference<
134cdf0e10cSrcweir 		com::sun::star::ucb::XContent > SAL_CALL
135cdf0e10cSrcweir 	queryContent( const com::sun::star::uno::Reference<
136cdf0e10cSrcweir 					com::sun::star::ucb::XContentIdentifier >& Identifier )
137cdf0e10cSrcweir 		throw( com::sun::star::ucb::IllegalIdentifierException,
138cdf0e10cSrcweir 			   com::sun::star::uno::RuntimeException );
139cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL
140cdf0e10cSrcweir 	compareContentIds( const com::sun::star::uno::Reference<
141cdf0e10cSrcweir 						com::sun::star::ucb::XContentIdentifier >& Id1,
142cdf0e10cSrcweir 					   const com::sun::star::uno::Reference<
143cdf0e10cSrcweir 					   	com::sun::star::ucb::XContentIdentifier >& Id2 )
144cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	// XContentIdentifierFactory
147cdf0e10cSrcweir     virtual com::sun::star::uno::Reference<
148cdf0e10cSrcweir 		com::sun::star::ucb::XContentIdentifier > SAL_CALL
149cdf0e10cSrcweir 	createContentIdentifier( const rtl::OUString& ContentId )
150cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	// XCommandProcessor
153cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL
154cdf0e10cSrcweir 	createCommandIdentifier()
155cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
156cdf0e10cSrcweir     virtual com::sun::star::uno::Any SAL_CALL
157cdf0e10cSrcweir 	execute( const com::sun::star::ucb::Command& aCommand,
158cdf0e10cSrcweir 	         sal_Int32 CommandId,
159cdf0e10cSrcweir 			 const com::sun::star::uno::Reference<
160cdf0e10cSrcweir 			 	com::sun::star::ucb::XCommandEnvironment >& Environment )
161cdf0e10cSrcweir 		throw( com::sun::star::uno::Exception,
162cdf0e10cSrcweir 			   com::sun::star::ucb::CommandAbortedException,
163cdf0e10cSrcweir 			   com::sun::star::uno::RuntimeException );
164cdf0e10cSrcweir     virtual void SAL_CALL
165cdf0e10cSrcweir 	abort( sal_Int32 CommandId )
166cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 	// XChangesListener
169cdf0e10cSrcweir     virtual void SAL_CALL changesOccurred( const com::sun::star::util::ChangesEvent& Event )
170cdf0e10cSrcweir 		throw( com::sun::star::uno::RuntimeException );
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	 // XEventListener ( base of XChangesLisetenr )
173cdf0e10cSrcweir     virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source )
174cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir private:
177cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >
178cdf0e10cSrcweir 	queryContentProvider( const rtl::OUString& Identifier,
179cdf0e10cSrcweir                           sal_Bool bResolved );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::ucb::XCommandInfo >
182cdf0e10cSrcweir 	getCommandInfo();
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 	void
185cdf0e10cSrcweir 	globalTransfer(
186cdf0e10cSrcweir 			const com::sun::star::ucb::GlobalTransferCommandArgument & rArg,
187cdf0e10cSrcweir 			const com::sun::star::uno::Reference<
188cdf0e10cSrcweir 			 	com::sun::star::ucb::XCommandEnvironment >& xEnv )
189cdf0e10cSrcweir 		throw( com::sun::star::uno::Exception );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 	bool configureUcb()
193cdf0e10cSrcweir 		throw ( com::sun::star::uno::RuntimeException);
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 	bool getContentProviderData(
196cdf0e10cSrcweir 			const rtl::OUString & rKey1,
197cdf0e10cSrcweir 			const rtl::OUString & rKey2,
198cdf0e10cSrcweir             ucbhelper::ContentProviderDataList & rListToFill);
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 	void prepareAndRegister( const ucbhelper::ContentProviderDataList& rData);
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 	com::sun::star::uno::Reference<
203cdf0e10cSrcweir 		com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	com::sun::star::uno::Reference<
206cdf0e10cSrcweir 		com::sun::star::util::XChangesNotifier > m_xNotifier;
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_aArguments;
209cdf0e10cSrcweir 	ProviderMap_Impl m_aProviders;
210cdf0e10cSrcweir 	osl::Mutex m_aMutex;
211cdf0e10cSrcweir 	cppu::OInterfaceContainerHelper* m_pDisposeEventListeners;
212cdf0e10cSrcweir 	oslInterlockedCount m_nInitCount; //@@@ see initialize() method
213cdf0e10cSrcweir 	sal_Int32 m_nCommandId;
214cdf0e10cSrcweir };
215cdf0e10cSrcweir 
216cdf0e10cSrcweir #endif /* !_UCB_HXX */
217