xref: /trunk/main/ucb/source/core/ucb.hxx (revision 6df1ea1f)
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 		throw( com::sun::star::uno::RuntimeException );
91     virtual void SAL_CALL
92 	addEventListener( const com::sun::star::uno::Reference<
93 						com::sun::star::lang::XEventListener >& Listener )
94 		throw( com::sun::star::uno::RuntimeException );
95     virtual void SAL_CALL
96 	removeEventListener( const com::sun::star::uno::Reference<
97 							com::sun::star::lang::XEventListener >& Listener )
98 		throw( com::sun::star::uno::RuntimeException );
99 
100 	// XInitialization
101     virtual void SAL_CALL
102 	initialize( const com::sun::star::uno::Sequence<
103 						com::sun::star::uno::Any >& aArguments )
104 		throw( com::sun::star::uno::Exception,
105 			   com::sun::star::uno::RuntimeException );
106 
107 	// XContentProviderManager
108     virtual com::sun::star::uno::Reference<
109 		com::sun::star::ucb::XContentProvider > SAL_CALL
110 	registerContentProvider( const com::sun::star::uno::Reference<
111 								com::sun::star::ucb::XContentProvider >&
112 									Provider,
113 							 const rtl::OUString& Scheme,
114 							 sal_Bool ReplaceExisting )
115 		throw( com::sun::star::ucb::DuplicateProviderException,
116 			   com::sun::star::uno::RuntimeException );
117     virtual void SAL_CALL
118 	deregisterContentProvider( const com::sun::star::uno::Reference<
119 									com::sun::star::ucb::XContentProvider >&
120 										Provider,
121 							   const rtl::OUString& Scheme )
122 		throw( com::sun::star::uno::RuntimeException );
123     virtual com::sun::star::uno::Sequence<
124 		com::sun::star::ucb::ContentProviderInfo > SAL_CALL
125 	queryContentProviders()
126 		throw( com::sun::star::uno::RuntimeException );
127     virtual com::sun::star::uno::Reference<
128 		com::sun::star::ucb::XContentProvider >	SAL_CALL
129 	queryContentProvider( const rtl::OUString& Identifier )
130 		throw( com::sun::star::uno::RuntimeException );
131 
132 	// XContentProvider
133 	virtual com::sun::star::uno::Reference<
134 		com::sun::star::ucb::XContent > SAL_CALL
135 	queryContent( const com::sun::star::uno::Reference<
136 					com::sun::star::ucb::XContentIdentifier >& Identifier )
137 		throw( com::sun::star::ucb::IllegalIdentifierException,
138 			   com::sun::star::uno::RuntimeException );
139     virtual sal_Int32 SAL_CALL
140 	compareContentIds( const com::sun::star::uno::Reference<
141 						com::sun::star::ucb::XContentIdentifier >& Id1,
142 					   const com::sun::star::uno::Reference<
143 					   	com::sun::star::ucb::XContentIdentifier >& Id2 )
144 		throw( com::sun::star::uno::RuntimeException );
145 
146 	// XContentIdentifierFactory
147     virtual com::sun::star::uno::Reference<
148 		com::sun::star::ucb::XContentIdentifier > SAL_CALL
149 	createContentIdentifier( const rtl::OUString& ContentId )
150 		throw( com::sun::star::uno::RuntimeException );
151 
152 	// XCommandProcessor
153     virtual sal_Int32 SAL_CALL
154 	createCommandIdentifier()
155 		throw( com::sun::star::uno::RuntimeException );
156     virtual com::sun::star::uno::Any SAL_CALL
157 	execute( const com::sun::star::ucb::Command& aCommand,
158 	         sal_Int32 CommandId,
159 			 const com::sun::star::uno::Reference<
160 			 	com::sun::star::ucb::XCommandEnvironment >& Environment )
161 		throw( com::sun::star::uno::Exception,
162 			   com::sun::star::ucb::CommandAbortedException,
163 			   com::sun::star::uno::RuntimeException );
164     virtual void SAL_CALL
165 	abort( sal_Int32 CommandId )
166 		throw( com::sun::star::uno::RuntimeException );
167 
168 	// XChangesListener
169     virtual void SAL_CALL changesOccurred( const com::sun::star::util::ChangesEvent& Event )
170 		throw( com::sun::star::uno::RuntimeException );
171 
172 	 // XEventListener ( base of XChangesLisetenr )
173     virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source )
174         throw( com::sun::star::uno::RuntimeException );
175 
176 private:
177 	com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >
178 	queryContentProvider( const rtl::OUString& Identifier,
179                           sal_Bool bResolved );
180 
181     com::sun::star::uno::Reference< com::sun::star::ucb::XCommandInfo >
182 	getCommandInfo();
183 
184 	void
185 	globalTransfer(
186 			const com::sun::star::ucb::GlobalTransferCommandArgument & rArg,
187 			const com::sun::star::uno::Reference<
188 			 	com::sun::star::ucb::XCommandEnvironment >& xEnv )
189 		throw( com::sun::star::uno::Exception );
190 
191 
192 	bool configureUcb()
193 		throw ( com::sun::star::uno::RuntimeException);
194 
195 	bool getContentProviderData(
196 			const rtl::OUString & rKey1,
197 			const rtl::OUString & rKey2,
198             ucbhelper::ContentProviderDataList & rListToFill);
199 
200 	void prepareAndRegister( const ucbhelper::ContentProviderDataList& rData);
201 
202 	com::sun::star::uno::Reference<
203 		com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
204 
205 	com::sun::star::uno::Reference<
206 		com::sun::star::util::XChangesNotifier > m_xNotifier;
207 
208 	com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_aArguments;
209 	ProviderMap_Impl m_aProviders;
210 	osl::Mutex m_aMutex;
211 	cppu::OInterfaceContainerHelper* m_pDisposeEventListeners;
212 	oslInterlockedCount m_nInitCount; //@@@ see initialize() method
213 	sal_Int32 m_nCommandId;
214 };
215 
216 #endif /* !_UCB_HXX */
217