1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dp_backend.h,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #if ! defined INCLUDED_DP_REGISTRY_H
32 #define INCLUDED_DP_REGISTRY_H
35 #include "dp_resource.h"
36 #include "dp_interact.h"
37 #include "rtl/ref.hxx"
38 #include "cppuhelper/weakref.hxx"
39 #include "cppuhelper/implbase1.hxx"
40 #include "cppuhelper/compbase1.hxx"
41 #include "cppuhelper/compbase2.hxx"
42 #include "tools/inetmime.hxx"
43 #include "com/sun/star/lang/XEventListener.hpp"
44 #include "com/sun/star/deployment/XPackageRegistry.hpp"
45 #include "com/sun/star/deployment/XPackageManager.hpp"
48 #include "dp_registry.hrc"
55 namespace css
= ::com::sun::star
;
57 class PackageRegistryBackend
;
59 char const* const BACKEND_SERVICE_NAME
=
60 "com.sun.star.deployment.PackageRegistryBackend";
62 typedef ::cppu::WeakComponentImplHelper1
<
63 css::deployment::XPackage
> t_PackageBase
;
65 //==============================================================================
66 class Package
: protected ::dp_misc::MutexHolder
, public t_PackageBase
68 void processPackage_impl(
70 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
71 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
74 ::rtl::Reference
<PackageRegistryBackend
> m_myBackend
;
75 const ::rtl::OUString m_url
;
76 ::rtl::OUString m_name
;
77 ::rtl::OUString m_displayName
;
78 const css::uno::Reference
<css::deployment::XPackageTypeInfo
> m_xPackageType
;
82 virtual void SAL_CALL
disposing();
85 ::rtl::Reference
< ::dp_misc::AbortChannel
> const & abortChannel
);
87 // @@@ to be implemented by specific backend:
88 virtual css::beans::Optional
< css::beans::Ambiguous
<sal_Bool
> >
90 ::osl::ResettableMutexGuard
& guard
,
91 ::rtl::Reference
< ::dp_misc::AbortChannel
> const & abortChannel
,
92 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
94 virtual void processPackage_(
95 ::osl::ResettableMutexGuard
& guard
,
97 ::rtl::Reference
< ::dp_misc::AbortChannel
> const & abortChannel
,
98 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
102 Package( ::rtl::Reference
<PackageRegistryBackend
> const & myBackend
,
103 ::rtl::OUString
const & url
,
104 ::rtl::OUString
const & name
,
105 ::rtl::OUString
const & displayName
,
106 css::uno::Reference
<css::deployment::XPackageTypeInfo
> const &
112 public ::cppu::WeakImplHelper1
<css::deployment::XPackageTypeInfo
>
114 const ::rtl::OUString m_mediaType
;
115 const ::rtl::OUString m_fileFilter
;
116 const ::rtl::OUString m_shortDescr
;
117 const sal_uInt16 m_smallIcon
, m_smallIcon_HC
;
120 TypeInfo( ::rtl::OUString
const & mediaType
,
121 ::rtl::OUString
const & fileFilter
,
122 ::rtl::OUString
const & shortDescr
,
123 sal_uInt16 smallIcon
, sal_uInt16 smallIcon_HC
)
124 : m_mediaType(mediaType
), m_fileFilter(fileFilter
),
125 m_shortDescr(shortDescr
),
126 m_smallIcon(smallIcon
), m_smallIcon_HC(smallIcon_HC
)
129 virtual ::rtl::OUString SAL_CALL
getMediaType()
130 throw (css::uno::RuntimeException
);
131 virtual ::rtl::OUString SAL_CALL
getDescription()
132 throw (css::uno::RuntimeException
);
133 virtual ::rtl::OUString SAL_CALL
getShortDescription()
134 throw (css::uno::RuntimeException
);
135 virtual ::rtl::OUString SAL_CALL
getFileFilter()
136 throw (css::uno::RuntimeException
);
137 virtual css::uno::Any SAL_CALL
getIcon( sal_Bool highContrast
,
139 throw (css::uno::RuntimeException
);
143 virtual void SAL_CALL
dispose() throw (css::uno::RuntimeException
);
144 virtual void SAL_CALL
addEventListener(
145 css::uno::Reference
<css::lang::XEventListener
> const & xListener
)
146 throw (css::uno::RuntimeException
);
147 virtual void SAL_CALL
removeEventListener(
148 css::uno::Reference
<css::lang::XEventListener
> const & xListener
)
149 throw (css::uno::RuntimeException
);
151 // XModifyBroadcaster
152 virtual void SAL_CALL
addModifyListener(
153 css::uno::Reference
<css::util::XModifyListener
> const & xListener
)
154 throw (css::uno::RuntimeException
);
155 virtual void SAL_CALL
removeModifyListener(
156 css::uno::Reference
<css::util::XModifyListener
> const & xListener
)
157 throw (css::uno::RuntimeException
);
160 virtual css::uno::Reference
<css::task::XAbortChannel
> SAL_CALL
161 createAbortChannel() throw (css::uno::RuntimeException
);
162 virtual css::beans::Optional
< css::beans::Ambiguous
<sal_Bool
> >
163 SAL_CALL
isRegistered(
164 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
165 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
166 throw (css::deployment::DeploymentException
,
167 css::ucb::CommandFailedException
,
168 css::ucb::CommandAbortedException
,
169 css::uno::RuntimeException
);
171 virtual ::sal_Bool SAL_CALL
checkPrerequisites(
172 const css::uno::Reference
< css::task::XAbortChannel
>& xAbortChannel
,
173 const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xCmdEnv
,
174 sal_Bool bInstalled
, ::rtl::OUString
const & aContextName
)
175 throw (css::deployment::DeploymentException
,
176 css::ucb::CommandFailedException
,
177 css::ucb::CommandAbortedException
,
178 css::uno::RuntimeException
);
180 virtual ::sal_Bool SAL_CALL
checkDependencies(
181 const css::uno::Reference
< css::ucb::XCommandEnvironment
>& xCmdEnv
)
182 throw (css::deployment::DeploymentException
,
183 css::ucb::CommandFailedException
,
184 css::uno::RuntimeException
);
186 virtual void SAL_CALL
registerPackage(
187 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
188 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
189 throw (css::deployment::DeploymentException
,
190 css::ucb::CommandFailedException
,
191 css::ucb::CommandAbortedException
,
192 css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
193 virtual void SAL_CALL
revokePackage(
194 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
195 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
196 throw (css::deployment::DeploymentException
,
197 css::ucb::CommandFailedException
,
198 css::ucb::CommandAbortedException
,
199 css::lang::IllegalArgumentException
,
200 css::uno::RuntimeException
);
201 virtual sal_Bool SAL_CALL
isBundle()
202 throw (css::uno::RuntimeException
);
203 virtual css::uno::Sequence
< css::uno::Reference
<css::deployment::XPackage
> >
205 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
206 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
207 throw (css::deployment::DeploymentException
,
208 css::ucb::CommandFailedException
,
209 css::ucb::CommandAbortedException
,
210 css::lang::IllegalArgumentException
,
211 css::uno::RuntimeException
);
212 virtual ::rtl::OUString SAL_CALL
getName()
213 throw (css::uno::RuntimeException
);
214 virtual css::beans::Optional
< ::rtl::OUString
> SAL_CALL
getIdentifier()
215 throw (css::uno::RuntimeException
);
216 virtual ::rtl::OUString SAL_CALL
getVersion()
217 throw (css::uno::RuntimeException
);
218 virtual ::rtl::OUString SAL_CALL
getURL()
219 throw (css::uno::RuntimeException
);
220 virtual ::rtl::OUString SAL_CALL
getDisplayName()
221 throw (css::uno::RuntimeException
);
222 virtual ::rtl::OUString SAL_CALL
getDescription()
223 throw (css::uno::RuntimeException
);
224 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
225 getUpdateInformationURLs() throw (css::uno::RuntimeException
);
227 virtual css::beans::StringPair SAL_CALL
getPublisherInfo() throw (css::uno::RuntimeException
);
228 virtual css::uno::Reference
< css::graphic::XGraphic
> SAL_CALL
getIcon( sal_Bool bHighContrast
) throw (css::uno::RuntimeException
);
230 virtual css::uno::Reference
<css::deployment::XPackageTypeInfo
> SAL_CALL
231 getPackageType() throw (css::uno::RuntimeException
);
232 virtual void SAL_CALL
exportTo(
233 ::rtl::OUString
const & destFolderURL
,
234 ::rtl::OUString
const & newTitle
,
235 sal_Int32 nameClashAction
,
236 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
237 throw (css::ucb::CommandFailedException
,
238 css::ucb::CommandAbortedException
, css::uno::RuntimeException
);
241 typedef ::cppu::WeakComponentImplHelper2
<
242 css::lang::XEventListener
,
243 css::deployment::XPackageRegistry
> t_BackendBase
;
245 //==============================================================================
246 class PackageRegistryBackend
247 : protected ::dp_misc::MutexHolder
, public t_BackendBase
249 ::rtl::OUString m_cachePath
;
251 typedef ::std::hash_map
<
252 ::rtl::OUString
, css::uno::WeakReference
<css::deployment::XPackage
>,
253 ::rtl::OUStringHash
> t_string2weakref
;
254 t_string2weakref m_bound
;
257 css::uno::Reference
<css::uno::XComponentContext
> m_xComponentContext
;
259 ::rtl::OUString m_context
;
260 // currently only for library containers:
263 CONTEXT_USER
, CONTEXT_SHARED
,
268 struct StrCannotDetectMediaType
: public ::dp_misc::StaticResourceString
<
269 StrCannotDetectMediaType
, RID_STR_CANNOT_DETECT_MEDIA_TYPE
> {};
270 struct StrUnsupportedMediaType
: public ::dp_misc::StaticResourceString
<
271 StrUnsupportedMediaType
, RID_STR_UNSUPPORTED_MEDIA_TYPE
> {};
273 // @@@ to be implemented by specific backend:
274 virtual css::uno::Reference
<css::deployment::XPackage
> bindPackage_(
275 ::rtl::OUString
const & url
, ::rtl::OUString
const & mediaType
,
276 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
280 virtual void SAL_CALL
disposing();
282 virtual ~PackageRegistryBackend();
283 PackageRegistryBackend(
284 css::uno::Sequence
<css::uno::Any
> const & args
,
285 css::uno::Reference
<css::uno::XComponentContext
> const & xContext
);
288 struct StrRegisteringPackage
: public ::dp_misc::StaticResourceString
<
289 StrRegisteringPackage
, RID_STR_REGISTERING_PACKAGE
> {};
290 struct StrRevokingPackage
: public ::dp_misc::StaticResourceString
<
291 StrRevokingPackage
, RID_STR_REVOKING_PACKAGE
> {};
293 inline css::uno::Reference
<css::uno::XComponentContext
> const &
294 getComponentContext() const { return m_xComponentContext
; }
296 inline ::rtl::OUString
const & getCachePath() const { return m_cachePath
; }
297 inline bool transientMode() const { return m_cachePath
.getLength() == 0; }
300 virtual void SAL_CALL
disposing( css::lang::EventObject
const & evt
)
301 throw (css::uno::RuntimeException
);
304 virtual css::uno::Reference
<css::deployment::XPackage
> SAL_CALL
bindPackage(
305 ::rtl::OUString
const & url
, ::rtl::OUString
const & mediaType
,
306 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
307 throw (css::deployment::DeploymentException
,
308 css::ucb::CommandFailedException
,
309 css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
310 // virtual css::uno::Sequence<
311 // css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL
312 // getSupportedPackageTypes() throw (css::uno::RuntimeException);