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_DESKTOP_SOURCE_DEPLOYMENT_MANAGER_DP_EXTENSIONMANAGER_HXX
21 #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_MANAGER_DP_EXTENSIONMANAGER_HXX
23 #include <strings.hrc>
25 #include <dp_shared.hxx>
26 #include <dp_interact.h>
27 #include "dp_activepackages.hxx"
28 #include <rtl/ref.hxx>
29 #include <cppuhelper/compbase.hxx>
30 #include <ucbhelper/content.hxx>
31 #include <com/sun/star/deployment/XPackageRegistry.hpp>
32 #include <com/sun/star/deployment/XPackageManager.hpp>
33 #include <osl/mutex.hxx>
35 #include <unordered_map>
37 namespace dp_manager
{
39 typedef std::unordered_map
<
41 std::vector
<css::uno::Reference
<css::deployment::XPackage
> > > id2extensions
;
43 class ExtensionManager
: private ::dp_misc::MutexHolder
,
44 public ::cppu::WeakComponentImplHelper
< css::deployment::XExtensionManager
>
47 explicit ExtensionManager( css::uno::Reference
< css::uno::XComponentContext
>const& xContext
);
48 virtual ~ExtensionManager() override
;
56 virtual void SAL_CALL
addModifyListener(
57 css::uno::Reference
<css::util::XModifyListener
> const & xListener
) override
;
58 virtual void SAL_CALL
removeModifyListener(
59 css::uno::Reference
<css::util::XModifyListener
> const & xListener
) override
;
62 virtual css::uno::Sequence
<
63 css::uno::Reference
<css::deployment::XPackageTypeInfo
> > SAL_CALL
64 getSupportedPackageTypes() override
;
66 virtual css::uno::Reference
<css::task::XAbortChannel
> SAL_CALL
67 createAbortChannel() override
;
69 virtual css::uno::Reference
<css::deployment::XPackage
> SAL_CALL
addExtension(
71 css::uno::Sequence
<css::beans::NamedValue
> const & properties
,
72 OUString
const & repository
,
73 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
74 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
76 virtual void SAL_CALL
removeExtension(
77 OUString
const & identifier
,
78 OUString
const & filename
,
79 OUString
const & repository
,
80 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
81 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
83 virtual void SAL_CALL
enableExtension(
84 css::uno::Reference
<css::deployment::XPackage
> const & extension
,
85 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
86 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
88 virtual void SAL_CALL
disableExtension(
89 css::uno::Reference
<css::deployment::XPackage
> const & extension
,
90 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
91 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
93 virtual sal_Int32 SAL_CALL
checkPrerequisitesAndEnable(
94 css::uno::Reference
<css::deployment::XPackage
> const & extension
,
95 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
96 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
98 virtual css::uno::Sequence
< css::uno::Reference
<css::deployment::XPackage
> >
99 SAL_CALL
getDeployedExtensions(
100 OUString
const & repository
,
101 css::uno::Reference
<css::task::XAbortChannel
> const &,
102 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
104 virtual css::uno::Reference
< css::deployment::XPackage
>
105 SAL_CALL
getDeployedExtension(
106 OUString
const & repository
,
107 OUString
const & identifier
,
108 OUString
const & filename
,
109 css::uno::Reference
< css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
111 virtual css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> >
112 SAL_CALL
getExtensionsWithSameIdentifier(
113 OUString
const & identifier
,
114 OUString
const & filename
,
115 css::uno::Reference
< css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
117 virtual css::uno::Sequence
< css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> > >
118 SAL_CALL
getAllExtensions(
119 css::uno::Reference
<css::task::XAbortChannel
> const &,
120 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
122 virtual void SAL_CALL
reinstallDeployedExtensions(
123 sal_Bool force
, OUString
const & repository
,
124 css::uno::Reference
< css::task::XAbortChannel
> const & xAbortChannel
,
125 css::uno::Reference
< css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
127 virtual sal_Bool SAL_CALL
synchronize(
128 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
129 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
131 virtual css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> > SAL_CALL
132 getExtensionsWithUnacceptedLicenses(
133 OUString
const & repository
,
134 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
136 virtual sal_Bool SAL_CALL
isReadOnlyRepository(OUString
const & repository
) override
;
140 static OUString
StrSyncRepository() { return DpResId(RID_STR_SYNCHRONIZING_REPOSITORY
); }
142 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
143 css::uno::Reference
<css::deployment::XPackageManagerFactory
> m_xPackageManagerFactory
;
145 //only to be used within addExtension
146 ::osl::Mutex m_addMutex
;
147 /* contains the names of all repositories (except tmp) in order of there
148 priority. That is, the first element is "user" followed by "shared" and
151 std::vector
< OUString
> m_repositoryNames
;
153 css::uno::Reference
<css::deployment::XPackageManager
> getUserRepository();
154 css::uno::Reference
<css::deployment::XPackageManager
> getSharedRepository();
155 css::uno::Reference
<css::deployment::XPackageManager
> getBundledRepository();
156 css::uno::Reference
<css::deployment::XPackageManager
> getTmpRepository();
157 css::uno::Reference
<css::deployment::XPackageManager
> getBakRepository();
159 bool isUserDisabled(OUString
const & identifier
,
160 OUString
const & filename
);
162 static bool isUserDisabled(
163 css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> > const & seqExtSameId
);
165 void activateExtension(
166 OUString
const & identifier
,
167 OUString
const & fileName
,
168 bool bUserDisabled
, bool bStartup
,
169 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
170 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
172 static void activateExtension(
173 css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> > const & seqExt
,
174 bool bUserDisabled
, bool bStartup
,
175 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
176 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
178 std::vector
<css::uno::Reference
<css::deployment::XPackage
> >
179 getExtensionsWithSameId(OUString
const & identifier
,
180 OUString
const & fileName
);
182 css::uno::Reference
<css::deployment::XPackage
> backupExtension(
183 OUString
const & identifier
, OUString
const & fileName
,
184 css::uno::Reference
<css::deployment::XPackageManager
> const & xPackageManager
,
185 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
188 OUString
const & displayName
,
189 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & cmdEnv
);
192 OUString
const & newVersion
,
193 OUString
const & newDisplayName
,
194 css::uno::Reference
<css::deployment::XPackage
> const & oldExtension
,
195 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
197 void addExtensionsToMap(
198 id2extensions
& mapExt
,
199 css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> > const & seqExt
,
200 OUString
const & repository
);
202 /// @throws css::lang::IllegalArgumentException
203 /// @throws css::uno::RuntimeException
204 css::uno::Reference
<css::deployment::XPackageManager
>
205 getPackageManager(OUString
const & repository
);
207 /// @throws css::deployment::DeploymentException
208 /// @throws css::ucb::CommandFailedException
209 /// @throws css::ucb::CommandAbortedException
210 /// @throws css::lang::IllegalArgumentException
211 /// @throws css::uno::RuntimeException
212 bool doChecksForAddExtension(
213 css::uno::Reference
<css::deployment::XPackageManager
> const & xPackageMgr
,
214 css::uno::Sequence
<css::beans::NamedValue
> const & properties
,
215 css::uno::Reference
<css::deployment::XPackage
> const & xTmpExtension
,
216 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
217 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
,
218 css::uno::Reference
<css::deployment::XPackage
> & out_existingExtension
);
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */