Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_MANAGER_DP_MANAGER_H
21 : #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_MANAGER_DP_MANAGER_H
22 :
23 : #include "dp_manager.hrc"
24 : #include "dp_misc.h"
25 : #include "dp_interact.h"
26 : #include "dp_activepackages.hxx"
27 : #include "rtl/ref.hxx"
28 : #include "cppuhelper/compbase1.hxx"
29 : #include "cppuhelper/implbase2.hxx"
30 : #include "ucbhelper/content.hxx"
31 : #include "com/sun/star/deployment/XPackageRegistry.hpp"
32 : #include "com/sun/star/deployment/XPackageManager.hpp"
33 : #include <memory>
34 :
35 :
36 : namespace dp_manager {
37 :
38 : typedef ::cppu::WeakComponentImplHelper1<
39 : css::deployment::XPackageManager > t_pm_helper;
40 :
41 :
42 : class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper
43 : {
44 : css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
45 : OUString m_context;
46 : OUString m_registrationData;
47 : OUString m_registrationData_expanded;
48 : OUString m_registryCache;
49 : bool m_readOnly;
50 :
51 : OUString m_activePackages;
52 : OUString m_activePackages_expanded;
53 : ::std::auto_ptr< ActivePackages > m_activePackagesDB;
54 : //This mutex is only used for synchronization in addPackage
55 : ::osl::Mutex m_addMutex;
56 : css::uno::Reference<css::ucb::XProgressHandler> m_xLogFile;
57 : inline void logIntern( css::uno::Any const & status );
58 : void fireModified();
59 :
60 : css::uno::Reference<css::deployment::XPackageRegistry> m_xRegistry;
61 :
62 : void initRegistryBackends();
63 : void initActivationLayer(
64 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
65 : OUString detectMediaType(
66 : ::ucbhelper::Content const & ucbContent, bool throw_exc = true );
67 : OUString insertToActivationLayer(
68 : css::uno::Sequence<css::beans::NamedValue> const & properties,
69 : OUString const & mediaType,
70 : ::ucbhelper::Content const & sourceContent,
71 : OUString const & title, ActivePackages::Data * dbData );
72 : void insertToActivationLayerDB(
73 : OUString const & id, ActivePackages::Data const & dbData );
74 :
75 : void deletePackageFromCache(
76 : css::uno::Reference<css::deployment::XPackage> const & xPackage,
77 : OUString const & destFolder );
78 :
79 : bool isInstalled(
80 : css::uno::Reference<css::deployment::XPackage> const & package);
81 :
82 : bool synchronizeRemovedExtensions(
83 : css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
84 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
85 :
86 : bool synchronizeAddedExtensions(
87 : css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
88 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
89 :
90 : class CmdEnvWrapperImpl
91 : : public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment,
92 : css::ucb::XProgressHandler >
93 : {
94 : css::uno::Reference<css::ucb::XProgressHandler> m_xLogFile;
95 : css::uno::Reference<css::ucb::XProgressHandler> m_xUserProgress;
96 : css::uno::Reference<css::task::XInteractionHandler>
97 : m_xUserInteractionHandler;
98 :
99 : public:
100 : virtual ~CmdEnvWrapperImpl();
101 : CmdEnvWrapperImpl(
102 : css::uno::Reference<css::ucb::XCommandEnvironment>
103 : const & xUserCmdEnv,
104 : css::uno::Reference<css::ucb::XProgressHandler> const & xLogFile );
105 :
106 : // XCommandEnvironment
107 : virtual css::uno::Reference<css::task::XInteractionHandler> SAL_CALL
108 : getInteractionHandler() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 : virtual css::uno::Reference<css::ucb::XProgressHandler> SAL_CALL
110 : getProgressHandler() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 :
112 : // XProgressHandler
113 : virtual void SAL_CALL push( css::uno::Any const & Status )
114 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 : virtual void SAL_CALL update( css::uno::Any const & Status )
116 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
117 : virtual void SAL_CALL pop() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 : };
119 :
120 : protected:
121 : inline void check();
122 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
123 :
124 : virtual ~PackageManagerImpl();
125 0 : inline PackageManagerImpl(
126 : css::uno::Reference<css::uno::XComponentContext>
127 : const & xComponentContext, OUString const & context )
128 0 : : t_pm_helper( getMutex() ),
129 : m_xComponentContext( xComponentContext ),
130 : m_context( context ),
131 0 : m_readOnly( true )
132 0 : {}
133 :
134 : public:
135 : static css::uno::Reference<css::deployment::XPackageManager> create(
136 : css::uno::Reference<css::uno::XComponentContext>
137 : const & xComponentContext, OUString const & context );
138 :
139 : // XComponent
140 : virtual void SAL_CALL dispose() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 : virtual void SAL_CALL addEventListener(
142 : css::uno::Reference<css::lang::XEventListener> const & xListener )
143 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 : virtual void SAL_CALL removeEventListener(
145 : css::uno::Reference<css::lang::XEventListener> const & xListener )
146 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 :
148 : // XModifyBroadcaster
149 : virtual void SAL_CALL addModifyListener(
150 : css::uno::Reference<css::util::XModifyListener> const & xListener )
151 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
152 : virtual void SAL_CALL removeModifyListener(
153 : css::uno::Reference<css::util::XModifyListener> const & xListener )
154 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 :
156 : // XPackageManager
157 : virtual OUString SAL_CALL getContext()
158 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 : virtual css::uno::Sequence<
160 : css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL
161 : getSupportedPackageTypes() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
162 :
163 : virtual css::uno::Reference<css::task::XAbortChannel> SAL_CALL
164 : createAbortChannel() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
165 :
166 : virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL addPackage(
167 : OUString const & url,
168 : css::uno::Sequence<css::beans::NamedValue> const & properties,
169 : OUString const & mediaType,
170 : css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
171 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
172 : throw (css::deployment::DeploymentException,
173 : css::ucb::CommandFailedException,
174 : css::ucb::CommandAbortedException,
175 : css::lang::IllegalArgumentException,
176 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 :
178 : virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL importExtension(
179 : css::uno::Reference<css::deployment::XPackage> const & extension,
180 : css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
181 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
182 : throw (css::deployment::DeploymentException,
183 : css::ucb::CommandFailedException,
184 : css::ucb::CommandAbortedException,
185 : css::lang::IllegalArgumentException,
186 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 :
188 : virtual void SAL_CALL removePackage(
189 : OUString const & id, OUString const & fileName,
190 : css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
191 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
192 : throw (css::deployment::DeploymentException,
193 : css::ucb::CommandFailedException,
194 : css::ucb::CommandAbortedException,
195 : css::lang::IllegalArgumentException,
196 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
197 :
198 : OUString getDeployPath( ActivePackages::Data const & data );
199 : css::uno::Reference<css::deployment::XPackage> SAL_CALL getDeployedPackage_(
200 : OUString const & id, OUString const & fileName,
201 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
202 : css::uno::Reference<css::deployment::XPackage> getDeployedPackage_(
203 : OUString const & id, ActivePackages::Data const & data,
204 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
205 : bool ignoreAlienPlatforms = false );
206 : virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL
207 : getDeployedPackage(
208 : OUString const & id, OUString const & fileName,
209 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
210 : throw (css::deployment::DeploymentException,
211 : css::ucb::CommandFailedException,
212 : css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
213 :
214 : css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
215 : getDeployedPackages_(
216 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
217 : virtual css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
218 : SAL_CALL getDeployedPackages(
219 : css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
220 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
221 : throw (css::deployment::DeploymentException,
222 : css::ucb::CommandFailedException,
223 : css::ucb::CommandAbortedException,
224 : css::lang::IllegalArgumentException,
225 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
226 :
227 : virtual void SAL_CALL reinstallDeployedPackages(
228 : sal_Bool force,
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, std::exception) SAL_OVERRIDE;
236 :
237 : virtual ::sal_Bool SAL_CALL isReadOnly( )
238 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
239 :
240 : virtual ::sal_Bool SAL_CALL synchronize(
241 : css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
242 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
243 : throw (css::deployment::DeploymentException,
244 : css::ucb::CommandFailedException,
245 : css::ucb::CommandAbortedException,
246 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
247 :
248 : virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL
249 : getExtensionsWithUnacceptedLicenses(
250 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
251 : throw (css::deployment::DeploymentException,
252 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
253 :
254 : virtual sal_Int32 SAL_CALL checkPrerequisites(
255 : css::uno::Reference<css::deployment::XPackage> const & extension,
256 : css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
257 : css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
258 : throw (css::deployment::DeploymentException,
259 : css::ucb::CommandFailedException,
260 : css::ucb::CommandAbortedException,
261 : css::lang::IllegalArgumentException,
262 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
263 : };
264 :
265 :
266 0 : inline void PackageManagerImpl::check()
267 : {
268 0 : ::osl::MutexGuard guard( getMutex() );
269 0 : if (rBHelper.bInDispose || rBHelper.bDisposed)
270 : throw css::lang::DisposedException(
271 : "PackageManager instance has already been disposed!",
272 0 : static_cast< ::cppu::OWeakObject * >(this) );
273 0 : }
274 :
275 :
276 0 : inline void PackageManagerImpl::logIntern( css::uno::Any const & status )
277 : {
278 0 : if (m_xLogFile.is())
279 0 : m_xLogFile->update( status );
280 0 : }
281 :
282 : }
283 :
284 : #endif
285 :
286 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|