xref: /trunk/main/desktop/source/deployment/manager/dp_manager.h (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #if ! defined INCLUDED_DP_MANAGER_H
29*cdf0e10cSrcweir #define INCLUDED_DP_MANAGER_H
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "dp_manager.hrc"
32*cdf0e10cSrcweir #include "dp_misc.h"
33*cdf0e10cSrcweir #include "dp_interact.h"
34*cdf0e10cSrcweir #include "dp_activepackages.hxx"
35*cdf0e10cSrcweir #include "rtl/ref.hxx"
36*cdf0e10cSrcweir #include "cppuhelper/compbase1.hxx"
37*cdf0e10cSrcweir #include "cppuhelper/implbase2.hxx"
38*cdf0e10cSrcweir #include "ucbhelper/content.hxx"
39*cdf0e10cSrcweir #include "com/sun/star/deployment/XPackageRegistry.hpp"
40*cdf0e10cSrcweir #include "com/sun/star/deployment/XPackageManager.hpp"
41*cdf0e10cSrcweir #include <memory>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir namespace css = ::com::sun::star;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir namespace dp_manager {
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1<
49*cdf0e10cSrcweir     css::deployment::XPackageManager > t_pm_helper;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir //==============================================================================
52*cdf0e10cSrcweir class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir     css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
55*cdf0e10cSrcweir     ::rtl::OUString m_context;
56*cdf0e10cSrcweir     ::rtl::OUString m_registrationData;
57*cdf0e10cSrcweir     ::rtl::OUString m_registrationData_expanded;
58*cdf0e10cSrcweir     ::rtl::OUString m_registryCache;
59*cdf0e10cSrcweir     bool m_readOnly;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir     ::rtl::OUString m_activePackages;
62*cdf0e10cSrcweir     ::rtl::OUString m_activePackages_expanded;
63*cdf0e10cSrcweir     ::std::auto_ptr< ActivePackages > m_activePackagesDB;
64*cdf0e10cSrcweir     //This mutex is only used for synchronization in addPackage
65*cdf0e10cSrcweir     ::osl::Mutex m_addMutex;
66*cdf0e10cSrcweir     css::uno::Reference<css::ucb::XProgressHandler> m_xLogFile;
67*cdf0e10cSrcweir     inline void logIntern( css::uno::Any const & status );
68*cdf0e10cSrcweir     void fireModified();
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     css::uno::Reference<css::deployment::XPackageRegistry> m_xRegistry;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir     void initRegistryBackends();
73*cdf0e10cSrcweir     void initActivationLayer(
74*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
75*cdf0e10cSrcweir     ::rtl::OUString detectMediaType(
76*cdf0e10cSrcweir         ::ucbhelper::Content const & ucbContent, bool throw_exc = true );
77*cdf0e10cSrcweir     ::rtl::OUString insertToActivationLayer(
78*cdf0e10cSrcweir         css::uno::Sequence<css::beans::NamedValue> const & properties,
79*cdf0e10cSrcweir         ::rtl::OUString const & mediaType,
80*cdf0e10cSrcweir         ::ucbhelper::Content const & sourceContent,
81*cdf0e10cSrcweir         ::rtl::OUString const & title, ActivePackages::Data * dbData );
82*cdf0e10cSrcweir     void insertToActivationLayerDB(
83*cdf0e10cSrcweir         ::rtl::OUString const & id, ActivePackages::Data const & dbData );
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     void deletePackageFromCache(
86*cdf0e10cSrcweir         css::uno::Reference<css::deployment::XPackage> const & xPackage,
87*cdf0e10cSrcweir         ::rtl::OUString const & destFolder );
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     bool isInstalled(
90*cdf0e10cSrcweir         css::uno::Reference<css::deployment::XPackage> const & package);
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     bool synchronizeRemovedExtensions(
93*cdf0e10cSrcweir         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
94*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     bool synchronizeAddedExtensions(
97*cdf0e10cSrcweir         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
98*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     class CmdEnvWrapperImpl
101*cdf0e10cSrcweir         : public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment,
102*cdf0e10cSrcweir                                           css::ucb::XProgressHandler >
103*cdf0e10cSrcweir     {
104*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XProgressHandler> m_xLogFile;
105*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XProgressHandler> m_xUserProgress;
106*cdf0e10cSrcweir         css::uno::Reference<css::task::XInteractionHandler>
107*cdf0e10cSrcweir         m_xUserInteractionHandler;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     public:
110*cdf0e10cSrcweir         virtual ~CmdEnvWrapperImpl();
111*cdf0e10cSrcweir         CmdEnvWrapperImpl(
112*cdf0e10cSrcweir             css::uno::Reference<css::ucb::XCommandEnvironment>
113*cdf0e10cSrcweir             const & xUserCmdEnv,
114*cdf0e10cSrcweir             css::uno::Reference<css::ucb::XProgressHandler> const & xLogFile );
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir         // XCommandEnvironment
117*cdf0e10cSrcweir         virtual css::uno::Reference<css::task::XInteractionHandler> SAL_CALL
118*cdf0e10cSrcweir         getInteractionHandler() throw (css::uno::RuntimeException);
119*cdf0e10cSrcweir         virtual css::uno::Reference<css::ucb::XProgressHandler> SAL_CALL
120*cdf0e10cSrcweir         getProgressHandler() throw (css::uno::RuntimeException);
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir         // XProgressHandler
123*cdf0e10cSrcweir         virtual void SAL_CALL push( css::uno::Any const & Status )
124*cdf0e10cSrcweir             throw (css::uno::RuntimeException);
125*cdf0e10cSrcweir         virtual void SAL_CALL update( css::uno::Any const & Status )
126*cdf0e10cSrcweir             throw (css::uno::RuntimeException);
127*cdf0e10cSrcweir         virtual void SAL_CALL pop() throw (css::uno::RuntimeException);
128*cdf0e10cSrcweir     };
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir protected:
131*cdf0e10cSrcweir     inline void check();
132*cdf0e10cSrcweir     virtual void SAL_CALL disposing();
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     virtual ~PackageManagerImpl();
135*cdf0e10cSrcweir     inline PackageManagerImpl(
136*cdf0e10cSrcweir         css::uno::Reference<css::uno::XComponentContext>
137*cdf0e10cSrcweir         const & xComponentContext, ::rtl::OUString const & context )
138*cdf0e10cSrcweir         : t_pm_helper( getMutex() ),
139*cdf0e10cSrcweir           m_xComponentContext( xComponentContext ),
140*cdf0e10cSrcweir           m_context( context ),
141*cdf0e10cSrcweir           m_readOnly( true )
142*cdf0e10cSrcweir         {}
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir public:
145*cdf0e10cSrcweir     static css::uno::Reference<css::deployment::XPackageManager> create(
146*cdf0e10cSrcweir         css::uno::Reference<css::uno::XComponentContext>
147*cdf0e10cSrcweir         const & xComponentContext, ::rtl::OUString const & context );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     // XComponent
150*cdf0e10cSrcweir     virtual void SAL_CALL dispose() throw (css::uno::RuntimeException);
151*cdf0e10cSrcweir     virtual void SAL_CALL addEventListener(
152*cdf0e10cSrcweir         css::uno::Reference<css::lang::XEventListener> const & xListener )
153*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
154*cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener(
155*cdf0e10cSrcweir         css::uno::Reference<css::lang::XEventListener> const & xListener )
156*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir     // XModifyBroadcaster
159*cdf0e10cSrcweir     virtual void SAL_CALL addModifyListener(
160*cdf0e10cSrcweir         css::uno::Reference<css::util::XModifyListener> const & xListener )
161*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
162*cdf0e10cSrcweir     virtual void SAL_CALL removeModifyListener(
163*cdf0e10cSrcweir         css::uno::Reference<css::util::XModifyListener> const & xListener )
164*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     // XPackageManager
167*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getContext()
168*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
169*cdf0e10cSrcweir     virtual css::uno::Sequence<
170*cdf0e10cSrcweir         css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL
171*cdf0e10cSrcweir     getSupportedPackageTypes() throw (css::uno::RuntimeException);
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     virtual css::uno::Reference<css::task::XAbortChannel> SAL_CALL
174*cdf0e10cSrcweir     createAbortChannel() throw (css::uno::RuntimeException);
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir     virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL addPackage(
177*cdf0e10cSrcweir         ::rtl::OUString const & url,
178*cdf0e10cSrcweir         css::uno::Sequence<css::beans::NamedValue> const & properties,
179*cdf0e10cSrcweir         ::rtl::OUString const & mediaType,
180*cdf0e10cSrcweir         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
181*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
182*cdf0e10cSrcweir         throw (css::deployment::DeploymentException,
183*cdf0e10cSrcweir                css::ucb::CommandFailedException,
184*cdf0e10cSrcweir                css::ucb::CommandAbortedException,
185*cdf0e10cSrcweir                css::lang::IllegalArgumentException,
186*cdf0e10cSrcweir                css::uno::RuntimeException);
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL importExtension(
189*cdf0e10cSrcweir         css::uno::Reference<css::deployment::XPackage> const & extension,
190*cdf0e10cSrcweir         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
191*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
192*cdf0e10cSrcweir         throw (css::deployment::DeploymentException,
193*cdf0e10cSrcweir             css::ucb::CommandFailedException,
194*cdf0e10cSrcweir             css::ucb::CommandAbortedException,
195*cdf0e10cSrcweir             css::lang::IllegalArgumentException,
196*cdf0e10cSrcweir             css::uno::RuntimeException);
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     virtual void SAL_CALL removePackage(
199*cdf0e10cSrcweir         ::rtl::OUString const & id, ::rtl::OUString const & fileName,
200*cdf0e10cSrcweir         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
201*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
202*cdf0e10cSrcweir         throw (css::deployment::DeploymentException,
203*cdf0e10cSrcweir                css::ucb::CommandFailedException,
204*cdf0e10cSrcweir                css::ucb::CommandAbortedException,
205*cdf0e10cSrcweir                css::lang::IllegalArgumentException,
206*cdf0e10cSrcweir                css::uno::RuntimeException);
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir     ::rtl::OUString getDeployPath( ActivePackages::Data const & data );
209*cdf0e10cSrcweir     css::uno::Reference<css::deployment::XPackage> SAL_CALL getDeployedPackage_(
210*cdf0e10cSrcweir         ::rtl::OUString const & id, ::rtl::OUString const & fileName,
211*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
212*cdf0e10cSrcweir     css::uno::Reference<css::deployment::XPackage> getDeployedPackage_(
213*cdf0e10cSrcweir         ::rtl::OUString const & id, ActivePackages::Data const & data,
214*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
215*cdf0e10cSrcweir         bool ignoreAlienPlatforms = false );
216*cdf0e10cSrcweir     virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL
217*cdf0e10cSrcweir     getDeployedPackage(
218*cdf0e10cSrcweir         ::rtl::OUString const & id, ::rtl::OUString const & fileName,
219*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
220*cdf0e10cSrcweir         throw (css::deployment::DeploymentException,
221*cdf0e10cSrcweir                css::ucb::CommandFailedException,
222*cdf0e10cSrcweir                css::lang::IllegalArgumentException, css::uno::RuntimeException);
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir     css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
225*cdf0e10cSrcweir     getDeployedPackages_(
226*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
227*cdf0e10cSrcweir     virtual css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
228*cdf0e10cSrcweir     SAL_CALL getDeployedPackages(
229*cdf0e10cSrcweir         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
230*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
231*cdf0e10cSrcweir         throw (css::deployment::DeploymentException,
232*cdf0e10cSrcweir                css::ucb::CommandFailedException,
233*cdf0e10cSrcweir                css::ucb::CommandAbortedException,
234*cdf0e10cSrcweir                css::lang::IllegalArgumentException,
235*cdf0e10cSrcweir                css::uno::RuntimeException);
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir     virtual void SAL_CALL reinstallDeployedPackages(
238*cdf0e10cSrcweir         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
239*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
240*cdf0e10cSrcweir         throw (css::deployment::DeploymentException,
241*cdf0e10cSrcweir                css::ucb::CommandFailedException,
242*cdf0e10cSrcweir                css::ucb::CommandAbortedException,
243*cdf0e10cSrcweir                css::lang::IllegalArgumentException,
244*cdf0e10cSrcweir                css::uno::RuntimeException);
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL isReadOnly(  )
247*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL synchronize(
250*cdf0e10cSrcweir         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
251*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
252*cdf0e10cSrcweir         throw (css::deployment::DeploymentException,
253*cdf0e10cSrcweir                css::ucb::CommandFailedException,
254*cdf0e10cSrcweir                css::ucb::CommandAbortedException,
255*cdf0e10cSrcweir                css::uno::RuntimeException);
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir     virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL
258*cdf0e10cSrcweir     getExtensionsWithUnacceptedLicenses(
259*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
260*cdf0e10cSrcweir         throw (css::deployment::DeploymentException,
261*cdf0e10cSrcweir                css::uno::RuntimeException);
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL checkPrerequisites(
264*cdf0e10cSrcweir         css::uno::Reference<css::deployment::XPackage> const & extension,
265*cdf0e10cSrcweir         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
266*cdf0e10cSrcweir         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
267*cdf0e10cSrcweir         throw (css::deployment::DeploymentException,
268*cdf0e10cSrcweir                css::ucb::CommandFailedException,
269*cdf0e10cSrcweir                css::ucb::CommandAbortedException,
270*cdf0e10cSrcweir                css::lang::IllegalArgumentException,
271*cdf0e10cSrcweir                css::uno::RuntimeException);
272*cdf0e10cSrcweir         };
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir //______________________________________________________________________________
275*cdf0e10cSrcweir inline void PackageManagerImpl::check()
276*cdf0e10cSrcweir {
277*cdf0e10cSrcweir     ::osl::MutexGuard guard( getMutex() );
278*cdf0e10cSrcweir     if (rBHelper.bInDispose || rBHelper.bDisposed)
279*cdf0e10cSrcweir         throw css::lang::DisposedException(
280*cdf0e10cSrcweir             OUSTR("PackageManager instance has already been disposed!"),
281*cdf0e10cSrcweir             static_cast< ::cppu::OWeakObject * >(this) );
282*cdf0e10cSrcweir }
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir //______________________________________________________________________________
285*cdf0e10cSrcweir inline void PackageManagerImpl::logIntern( css::uno::Any const & status )
286*cdf0e10cSrcweir {
287*cdf0e10cSrcweir     if (m_xLogFile.is())
288*cdf0e10cSrcweir         m_xLogFile->update( status );
289*cdf0e10cSrcweir }
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir #endif
294*cdf0e10cSrcweir 
295