1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DP_EXTENSIONMANAGER_H
21 #define INCLUDED_DP_EXTENSIONMANAGER_H
23 #include "dp_manager.hrc"
25 #include "dp_interact.h"
26 #include "dp_activepackages.hxx"
27 #include "rtl/ref.hxx"
28 #include "cppuhelper/compbase1.hxx"
29 #include "ucbhelper/content.hxx"
30 #include "com/sun/star/deployment/XPackageRegistry.hpp"
31 #include "com/sun/star/deployment/XPackageManager.hpp"
32 #include "osl/mutex.hxx"
34 #include <boost/unordered_map.hpp>
36 namespace dp_manager
{
38 typedef ::boost::unordered_map
<
40 ::std::vector
<css::uno::Reference
<css::deployment::XPackage
> >,
41 OUStringHash
> id2extensions
;
43 class ExtensionManager
: private ::dp_misc::MutexHolder
,
44 public ::cppu::WeakComponentImplHelper1
< css::deployment::XExtensionManager
>
47 ExtensionManager( css::uno::Reference
< css::uno::XComponentContext
>const& xContext
);
48 virtual ~ExtensionManager();
50 static css::uno::Sequence
< OUString
> getServiceNames();
51 static OUString
getImplName();
59 virtual void SAL_CALL
addModifyListener(
60 css::uno::Reference
<css::util::XModifyListener
> const & xListener
)
61 throw (css::uno::RuntimeException
);
62 virtual void SAL_CALL
removeModifyListener(
63 css::uno::Reference
<css::util::XModifyListener
> const & xListener
)
64 throw (css::uno::RuntimeException
);
67 virtual css::uno::Sequence
<
68 css::uno::Reference
<css::deployment::XPackageTypeInfo
> > SAL_CALL
69 getSupportedPackageTypes()
70 throw (css::uno::RuntimeException
);
72 virtual css::uno::Reference
<css::task::XAbortChannel
> SAL_CALL
73 createAbortChannel() throw (css::uno::RuntimeException
);
75 virtual css::uno::Reference
<css::deployment::XPackage
> SAL_CALL
addExtension(
77 css::uno::Sequence
<css::beans::NamedValue
> const & properties
,
78 OUString
const & repository
,
79 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
80 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
81 throw (css::deployment::DeploymentException
,
82 css::ucb::CommandFailedException
,
83 css::ucb::CommandAbortedException
,
84 css::lang::IllegalArgumentException
,
85 css::uno::RuntimeException
);
87 virtual void SAL_CALL
removeExtension(
88 OUString
const & identifier
,
89 OUString
const & filename
,
90 OUString
const & repository
,
91 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
92 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
93 throw (css::deployment::DeploymentException
,
94 css::ucb::CommandFailedException
,
95 css::ucb::CommandAbortedException
,
96 css::lang::IllegalArgumentException
,
97 css::uno::RuntimeException
);
99 virtual void SAL_CALL
enableExtension(
100 css::uno::Reference
<css::deployment::XPackage
> const & extension
,
101 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
102 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
103 throw (css::deployment::DeploymentException
,
104 css::ucb::CommandFailedException
,
105 css::ucb::CommandAbortedException
,
106 css::lang::IllegalArgumentException
,
107 css::uno::RuntimeException
);
109 virtual void SAL_CALL
disableExtension(
110 css::uno::Reference
<css::deployment::XPackage
> const & extension
,
111 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
112 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
113 throw (css::deployment::DeploymentException
,
114 css::ucb::CommandFailedException
,
115 css::ucb::CommandAbortedException
,
116 css::lang::IllegalArgumentException
,
117 css::uno::RuntimeException
);
119 virtual sal_Int32 SAL_CALL
checkPrerequisitesAndEnable(
120 css::uno::Reference
<css::deployment::XPackage
> const & extension
,
121 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
122 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
123 throw (css::deployment::DeploymentException
,
124 css::ucb::CommandFailedException
,
125 css::ucb::CommandAbortedException
,
126 css::lang::IllegalArgumentException
,
127 css::uno::RuntimeException
);
129 virtual css::uno::Sequence
< css::uno::Reference
<css::deployment::XPackage
> >
130 SAL_CALL
getDeployedExtensions(
131 OUString
const & repository
,
132 css::uno::Reference
<css::task::XAbortChannel
> const &,
133 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
134 throw (css::deployment::DeploymentException
,
135 css::ucb::CommandFailedException
,
136 css::ucb::CommandAbortedException
,
137 css::lang::IllegalArgumentException
,
138 css::uno::RuntimeException
);
140 virtual css::uno::Reference
< css::deployment::XPackage
>
141 SAL_CALL
getDeployedExtension(
142 OUString
const & repository
,
143 OUString
const & identifier
,
144 OUString
const & filename
,
145 css::uno::Reference
< css::ucb::XCommandEnvironment
> const & xCmdEnv
)
147 css::deployment::DeploymentException
,
148 css::ucb::CommandFailedException
,
149 css::lang::IllegalArgumentException
,
150 css::uno::RuntimeException
);
152 virtual css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> >
153 SAL_CALL
getExtensionsWithSameIdentifier(
154 OUString
const & identifier
,
155 OUString
const & filename
,
156 css::uno::Reference
< css::ucb::XCommandEnvironment
> const & xCmdEnv
)
158 css::deployment::DeploymentException
,
159 css::ucb::CommandFailedException
,
160 css::lang::IllegalArgumentException
,
161 css::uno::RuntimeException
);
163 virtual css::uno::Sequence
< css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> > >
164 SAL_CALL
getAllExtensions(
165 css::uno::Reference
<css::task::XAbortChannel
> const &,
166 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
167 throw (css::deployment::DeploymentException
,
168 css::ucb::CommandFailedException
,
169 css::ucb::CommandAbortedException
,
170 css::lang::IllegalArgumentException
,
171 css::uno::RuntimeException
);
173 virtual void SAL_CALL
reinstallDeployedExtensions(
174 sal_Bool force
, OUString
const & repository
,
175 css::uno::Reference
< css::task::XAbortChannel
> const & xAbortChannel
,
176 css::uno::Reference
< css::ucb::XCommandEnvironment
> const & xCmdEnv
)
178 css::deployment::DeploymentException
,
179 css::ucb::CommandFailedException
,
180 css::ucb::CommandAbortedException
,
181 css::lang::IllegalArgumentException
,
182 css::uno::RuntimeException
);
184 virtual sal_Bool SAL_CALL
synchronize(
185 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
186 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
187 throw (css::deployment::DeploymentException
,
188 css::ucb::CommandFailedException
,
189 css::ucb::CommandAbortedException
,
190 css::lang::IllegalArgumentException
,
191 css::uno::RuntimeException
);
193 virtual css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> > SAL_CALL
194 getExtensionsWithUnacceptedLicenses(
195 OUString
const & repository
,
196 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
197 throw (css::deployment::DeploymentException
,
198 css::uno::RuntimeException
);
200 virtual sal_Bool SAL_CALL
isReadOnlyRepository(OUString
const & repository
)
201 throw (css::uno::RuntimeException
);
205 struct StrSyncRepository
: public ::dp_misc::StaticResourceString
<
206 StrSyncRepository
, RID_STR_SYNCHRONIZING_REPOSITORY
> {};
208 struct ExtensionInfos
212 OUString displayName
;
216 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
217 css::uno::Reference
<css::deployment::XPackageManagerFactory
> m_xPackageManagerFactory
;
219 //only to be used within addExtension
220 ::osl::Mutex m_addMutex
;
221 /* contains the names of all repositories (except tmp) in order of there
222 priority. That is, the first element is "user" follod by "shared" and
225 ::std::list
< OUString
> m_repositoryNames
;
227 css::uno::Reference
<css::deployment::XPackageManager
> getUserRepository();
228 css::uno::Reference
<css::deployment::XPackageManager
> getSharedRepository();
229 css::uno::Reference
<css::deployment::XPackageManager
> getBundledRepository();
230 css::uno::Reference
<css::deployment::XPackageManager
> getTmpRepository();
231 css::uno::Reference
<css::deployment::XPackageManager
> getBakRepository();
233 bool isUserDisabled(OUString
const & identifier
,
234 OUString
const & filename
);
237 css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> > const & seqExtSameId
);
239 void activateExtension(
240 OUString
const & identifier
,
241 OUString
const & fileName
,
242 bool bUserDisabled
, bool bStartup
,
243 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
244 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
246 void activateExtension(
247 css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> > const & seqExt
,
248 bool bUserDisabled
, bool bStartup
,
249 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
250 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
252 ::std::list
<css::uno::Reference
<css::deployment::XPackage
> >
253 getExtensionsWithSameId(OUString
const & identifier
,
254 OUString
const & fileName
,
255 css::uno::Reference
< css::ucb::XCommandEnvironment
> const & xCmdEnv
=
256 css::uno::Reference
< css::ucb::XCommandEnvironment
>());
258 css::uno::Reference
<css::deployment::XPackage
> backupExtension(
259 OUString
const & identifier
, OUString
const & fileName
,
260 css::uno::Reference
<css::deployment::XPackageManager
> const & xPackageManager
,
261 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
264 OUString
const & displayName
,
265 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & cmdEnv
);
268 OUString
const & newVersion
,
269 OUString
const & newDisplayName
,
270 css::uno::Reference
<css::deployment::XPackage
> const & oldExtension
,
271 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
273 void addExtensionsToMap(
274 id2extensions
& mapExt
,
275 css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> > const & seqExt
,
276 OUString
const & repository
);
278 css::uno::Reference
<css::deployment::XPackageManager
>
279 getPackageManager(OUString
const & repository
)
280 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
282 bool doChecksForAddExtension(
283 css::uno::Reference
<css::deployment::XPackageManager
> const & xPackageMgr
,
284 css::uno::Sequence
<css::beans::NamedValue
> const & properties
,
285 css::uno::Reference
<css::deployment::XPackage
> const & xTmpExtension
,
286 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
287 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
,
288 css::uno::Reference
<css::deployment::XPackage
> & out_existingExtension
)
289 throw (css::deployment::DeploymentException
,
290 css::ucb::CommandFailedException
,
291 css::ucb::CommandAbortedException
,
292 css::lang::IllegalArgumentException
,
293 css::uno::RuntimeException
);
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */