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 _UCBHELPER_REGISTERUCB_HXX_
25 #define _UCBHELPER_REGISTERUCB_HXX_
26 
27 #include <com/sun/star/uno/RuntimeException.hpp>
28 #include <com/sun/star/uno/Reference.h>
29 #include <com/sun/star/ucb/XContentProvider.hpp>
30 #include <com/sun/star/ucb/XContentProviderManager.hpp>
31 #include <vector>
32 
33 #include "ucbhelper/ucbhelperdllapi.h"
34 
35 namespace com { namespace sun { namespace star {
36 	namespace lang { class XMultiServiceFactory; }
37 } } }
38 
39 namespace rtl { class OUString; }
40 
41 namespace ucbhelper {
42 
43 //============================================================================
44 /** Information about a registered content provider.
45  */
46 struct ContentProviderRegistrationInfo
47 {
48 	/** The registered content provider (or null if registration failed).
49 	 */
50 	com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >
51 	    m_xProvider;
52 
53 	/** The arguments the content provider was instantiated with.
54 	 */
55 	rtl::OUString m_aArguments;
56 
57 	/** The URL template the content provider is registered on.
58 	 */
59 	rtl::OUString m_aTemplate;
60 };
61 
62 typedef std::vector< ContentProviderRegistrationInfo >
63                                     ContentProviderRegistrationInfoList;
64 
65 //============================================================================
66 /** Information about a content provider, passed to
67     <method>configureUcb</method>.
68  */
69 struct ContentProviderData
70 {
71     /** The UNO service name to use to instanciate the content provider.
72 	 */
73 	rtl::OUString ServiceName;
74 
75     /** The URL template to use to instanciate the content provider.
76 	 */
77     rtl::OUString URLTemplate;
78 
79     /** The arguments to use to instanciate the content provider.
80 	 */
81     rtl::OUString Arguments;
82 
ContentProviderDataucbhelper::ContentProviderData83 	ContentProviderData() {};
ContentProviderDataucbhelper::ContentProviderData84 	ContentProviderData( const rtl::OUString & rService,
85 						 const rtl::OUString & rTemplate,
86 						 const rtl::OUString & rArgs )
87 	: ServiceName( rService ), URLTemplate( rTemplate ), Arguments( rArgs ) {}
88 };
89 
90 typedef std::vector< ContentProviderData > ContentProviderDataList;
91 //============================================================================
92 /** Register a content provider at a Universal Content Broker.
93 
94 	@param rManager  A content provider manager (normally, this would be a
95 	UCB).  May be null, which is only useful if the content provider is an
96 	<type>XParamterizedContentProvider</type>s.
97 
98 	@param rServiceFactory  A factory through which to obtain the required
99 	services.
100 
101 	@param rName  The service name of the content provider.
102 
103 	@param rArguments  Any arguments to instantiate the content provider with.
104 
105 	@param rTemplate  The URL template to register the content provider on.
106 
107 	@param pInfo  If not null, this output parameter is filled with
108 	information about the (atemptively) registered provider.
109  */
110 
111 UCBHELPER_DLLPUBLIC bool registerAtUcb(
112     com::sun::star::uno::Reference<
113 	        com::sun::star::ucb::XContentProviderManager > const &
114 	    rManager,
115 	com::sun::star::uno::Reference<
116 	        com::sun::star::lang::XMultiServiceFactory > const &
117 	    rServiceFactory,
118 	rtl::OUString const & rName,
119 	rtl::OUString const & rArguments,
120 	rtl::OUString const & rTemplate,
121 	ContentProviderRegistrationInfo * pInfo)
122 	throw (com::sun::star::uno::RuntimeException);
123 
124 }
125 #endif // _UCBHELPER_REGISTERUCB_HXX_
126