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