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_manager.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_MANAGER_H
32 #define INCLUDED_DP_MANAGER_H
34 #include "dp_manager.hrc"
36 #include "dp_interact.h"
37 #include "dp_activepackages.hxx"
38 #include "rtl/ref.hxx"
39 #include "cppuhelper/compbase1.hxx"
40 #include "cppuhelper/implbase2.hxx"
41 #include "ucbhelper/content.hxx"
42 #include "com/sun/star/deployment/XPackageRegistry.hpp"
43 #include "com/sun/star/deployment/XPackageManager.hpp"
47 namespace css
= ::com::sun::star
;
49 namespace dp_manager
{
51 typedef ::cppu::WeakComponentImplHelper1
<
52 css::deployment::XPackageManager
> t_pm_helper
;
54 //==============================================================================
55 class PackageManagerImpl
: private ::dp_misc::MutexHolder
, public t_pm_helper
57 css::uno::Reference
<css::uno::XComponentContext
> m_xComponentContext
;
58 ::rtl::OUString m_context
;
59 ::rtl::OUString m_registryCache
;
62 ::rtl::OUString m_activePackages
;
63 ::rtl::OUString m_activePackages_expanded
;
64 ::std::auto_ptr
< ActivePackages
> m_activePackagesDB
;
65 //This mutex is only used for synchronization in addPackage
66 ::osl::Mutex m_addMutex
;
67 css::uno::Reference
<css::ucb::XProgressHandler
> m_xLogFile
;
68 inline void logIntern( css::uno::Any
const & status
);
71 css::uno::Reference
<css::deployment::XPackageRegistry
> m_xRegistry
;
73 void initRegistryBackends();
74 void initActivationLayer(
75 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
76 ::rtl::OUString
detectMediaType(
77 ::ucbhelper::Content
const & ucbContent
, bool throw_exc
= true );
78 ::rtl::OUString
insertToActivationLayer(
79 ::rtl::OUString
const & mediaType
,
80 ::ucbhelper::Content
const & sourceContent
,
81 ::rtl::OUString
const & title
, ActivePackages::Data
* dbData
);
82 void insertToActivationLayerDB(
83 ::rtl::OUString
const & id
, ActivePackages::Data
const & dbData
);
85 void deletePackageFromCache(
86 css::uno::Reference
<css::deployment::XPackage
> const & xPackage
,
87 ::rtl::OUString
const & destFolder
);
90 css::uno::Reference
<css::deployment::XPackage
> const & package
,
91 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & origCmdEnv
,
92 css::uno::Reference
<css::ucb::XCommandEnvironment
> const &
96 css::uno::Reference
<css::deployment::XPackage
> const & package
,
97 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & cmdEnv
);
100 class CmdEnvWrapperImpl
101 : public ::cppu::WeakImplHelper2
< css::ucb::XCommandEnvironment
,
102 css::ucb::XProgressHandler
>
104 css::uno::Reference
<css::ucb::XProgressHandler
> m_xLogFile
;
105 css::uno::Reference
<css::ucb::XProgressHandler
> m_xUserProgress
;
106 css::uno::Reference
<css::task::XInteractionHandler
>
107 m_xUserInteractionHandler
;
110 virtual ~CmdEnvWrapperImpl();
112 css::uno::Reference
<css::ucb::XCommandEnvironment
>
114 css::uno::Reference
<css::ucb::XProgressHandler
> const & xLogFile
);
116 // XCommandEnvironment
117 virtual css::uno::Reference
<css::task::XInteractionHandler
> SAL_CALL
118 getInteractionHandler() throw (css::uno::RuntimeException
);
119 virtual css::uno::Reference
<css::ucb::XProgressHandler
> SAL_CALL
120 getProgressHandler() throw (css::uno::RuntimeException
);
123 virtual void SAL_CALL
push( css::uno::Any
const & Status
)
124 throw (css::uno::RuntimeException
);
125 virtual void SAL_CALL
update( css::uno::Any
const & Status
)
126 throw (css::uno::RuntimeException
);
127 virtual void SAL_CALL
pop() throw (css::uno::RuntimeException
);
132 virtual void SAL_CALL
disposing();
134 virtual ~PackageManagerImpl();
135 inline PackageManagerImpl(
136 css::uno::Reference
<css::uno::XComponentContext
>
137 const & xComponentContext
, ::rtl::OUString
const & context
)
138 : t_pm_helper( getMutex() ),
139 m_xComponentContext( xComponentContext
),
140 m_context( context
),
145 static css::uno::Reference
<css::deployment::XPackageManager
> create(
146 css::uno::Reference
<css::uno::XComponentContext
>
147 const & xComponentContext
, ::rtl::OUString
const & context
);
150 virtual void SAL_CALL
dispose() throw (css::uno::RuntimeException
);
151 virtual void SAL_CALL
addEventListener(
152 css::uno::Reference
<css::lang::XEventListener
> const & xListener
)
153 throw (css::uno::RuntimeException
);
154 virtual void SAL_CALL
removeEventListener(
155 css::uno::Reference
<css::lang::XEventListener
> const & xListener
)
156 throw (css::uno::RuntimeException
);
158 // XModifyBroadcaster
159 virtual void SAL_CALL
addModifyListener(
160 css::uno::Reference
<css::util::XModifyListener
> const & xListener
)
161 throw (css::uno::RuntimeException
);
162 virtual void SAL_CALL
removeModifyListener(
163 css::uno::Reference
<css::util::XModifyListener
> const & xListener
)
164 throw (css::uno::RuntimeException
);
167 virtual ::rtl::OUString SAL_CALL
getContext()
168 throw (css::uno::RuntimeException
);
169 virtual css::uno::Sequence
<
170 css::uno::Reference
<css::deployment::XPackageTypeInfo
> > SAL_CALL
171 getSupportedPackageTypes() throw (css::uno::RuntimeException
);
173 virtual css::uno::Reference
<css::task::XAbortChannel
> SAL_CALL
174 createAbortChannel() throw (css::uno::RuntimeException
);
176 virtual css::uno::Reference
<css::deployment::XPackage
> SAL_CALL
addPackage(
177 ::rtl::OUString
const & url
, ::rtl::OUString
const & mediaType
,
178 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
179 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
180 throw (css::deployment::DeploymentException
,
181 css::ucb::CommandFailedException
,
182 css::ucb::CommandAbortedException
,
183 css::lang::IllegalArgumentException
,
184 css::uno::RuntimeException
);
186 /* Unregisters the package but does not remove it from disk.
187 When the operation is canceled by the user, a CommandAbortedException
188 is thrown. Then the package is still fully functional.
193 ::rtl::OUString
const & id
, ::rtl::OUString
const & fileName
,
194 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
195 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
,
196 ActivePackages::Data
* out_oldData
);
198 virtual void SAL_CALL
removePackage(
199 ::rtl::OUString
const & id
, ::rtl::OUString
const & fileName
,
200 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
201 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
202 throw (css::deployment::DeploymentException
,
203 css::ucb::CommandFailedException
,
204 css::ucb::CommandAbortedException
,
205 css::lang::IllegalArgumentException
,
206 css::uno::RuntimeException
);
208 ::rtl::OUString
getDeployPath( ActivePackages::Data
const & data
);
209 css::uno::Reference
<css::deployment::XPackage
> SAL_CALL
getDeployedPackage_(
210 ::rtl::OUString
const & id
, ::rtl::OUString
const & fileName
,
211 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
212 css::uno::Reference
<css::deployment::XPackage
> getDeployedPackage_(
213 ::rtl::OUString
const & id
, ActivePackages::Data
const & data
,
214 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
,
215 bool ignoreAlienPlatforms
= false );
216 virtual css::uno::Reference
<css::deployment::XPackage
> SAL_CALL
218 ::rtl::OUString
const & id
, ::rtl::OUString
const & fileName
,
219 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
220 throw (css::deployment::DeploymentException
,
221 css::ucb::CommandFailedException
,
222 css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
224 css::uno::Sequence
< css::uno::Reference
<css::deployment::XPackage
> >
225 getDeployedPackages_(
226 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
227 virtual css::uno::Sequence
< css::uno::Reference
<css::deployment::XPackage
> >
228 SAL_CALL
getDeployedPackages(
229 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
230 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
231 throw (css::deployment::DeploymentException
,
232 css::ucb::CommandFailedException
,
233 css::ucb::CommandAbortedException
,
234 css::lang::IllegalArgumentException
,
235 css::uno::RuntimeException
);
237 virtual void SAL_CALL
reinstallDeployedPackages(
238 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
239 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
240 throw (css::deployment::DeploymentException
,
241 css::ucb::CommandFailedException
,
242 css::ucb::CommandAbortedException
,
243 css::lang::IllegalArgumentException
,
244 css::uno::RuntimeException
);
246 virtual ::sal_Bool SAL_CALL
isReadOnly( )
247 throw (::com::sun::star::uno::RuntimeException
);
250 //______________________________________________________________________________
251 inline void PackageManagerImpl::check()
253 ::osl::MutexGuard
guard( getMutex() );
254 if (rBHelper
.bInDispose
|| rBHelper
.bDisposed
)
255 throw css::lang::DisposedException(
256 OUSTR("PackageManager instance has already been disposed!"),
257 static_cast< ::cppu::OWeakObject
* >(this) );
260 //______________________________________________________________________________
261 inline void PackageManagerImpl::logIntern( css::uno::Any
const & status
)
264 m_xLogFile
->update( status
);