LibreOffice Module desktop (master) 1
dp_extensionmanager.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <strings.hrc>
23#include <dp_shared.hxx>
26#include <com/sun/star/deployment/XExtensionManager.hpp>
27#include <com/sun/star/deployment/XPackageManager.hpp>
28#include <com/sun/star/deployment/XPackageManagerFactory.hpp>
29#include <com/sun/star/lang/XServiceInfo.hpp>
30#include <com/sun/star/uno/XComponentContext.hpp>
31#include <mutex>
32#include <vector>
33#include <unordered_map>
34
35namespace dp_manager {
36
37typedef std::unordered_map<
38 OUString,
39 std::vector<css::uno::Reference<css::deployment::XPackage> > > id2extensions;
40
42 public ::cppu::WeakComponentImplHelper< css::deployment::XExtensionManager, css::lang::XServiceInfo >
43{
44public:
45 explicit ExtensionManager( css::uno::Reference< css::uno::XComponentContext >const& xContext);
46 virtual ~ExtensionManager() override;
47
48 void check();
49 void fireModified();
50
51public:
52
53 // XServiceInfo
54 virtual OUString SAL_CALL getImplementationName() override;
55 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
56 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
57
58// XModifyBroadcaster
59 virtual void SAL_CALL addModifyListener(
60 css::uno::Reference<css::util::XModifyListener> const & xListener ) override;
61 virtual void SAL_CALL removeModifyListener(
62 css::uno::Reference<css::util::XModifyListener> const & xListener ) override;
63
64//XExtensionManager
65 virtual css::uno::Sequence<
66 css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL
67 getSupportedPackageTypes() override;
68
69 virtual css::uno::Reference<css::task::XAbortChannel> SAL_CALL
70 createAbortChannel() override;
71
72 virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL addExtension(
73 OUString const & url,
74 css::uno::Sequence<css::beans::NamedValue> const & properties,
75 OUString const & repository,
76 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
77 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
78
79 virtual void SAL_CALL removeExtension(
80 OUString const & identifier,
81 OUString const & filename,
82 OUString const & repository,
83 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
84 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
85
86 virtual void SAL_CALL enableExtension(
87 css::uno::Reference<css::deployment::XPackage> const & extension,
88 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
89 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
90
91 virtual void SAL_CALL disableExtension(
92 css::uno::Reference<css::deployment::XPackage> const & extension,
93 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
94 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
95
96 virtual sal_Int32 SAL_CALL checkPrerequisitesAndEnable(
97 css::uno::Reference<css::deployment::XPackage> const & extension,
98 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
99 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
100
101 virtual css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
102 SAL_CALL getDeployedExtensions(
103 OUString const & repository,
104 css::uno::Reference<css::task::XAbortChannel> const &,
105 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
106
107 virtual css::uno::Reference< css::deployment::XPackage>
108 SAL_CALL getDeployedExtension(
109 OUString const & repository,
110 OUString const & identifier,
111 OUString const & filename,
112 css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
113
114 virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> >
116 OUString const & identifier,
117 OUString const & filename,
118 css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
119
120 virtual css::uno::Sequence< css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > >
121 SAL_CALL getAllExtensions(
122 css::uno::Reference<css::task::XAbortChannel> const &,
123 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
124
125 virtual void SAL_CALL reinstallDeployedExtensions(
126 sal_Bool force, OUString const & repository,
127 css::uno::Reference< css::task::XAbortChannel> const & xAbortChannel,
128 css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
129
130 virtual sal_Bool SAL_CALL synchronize(
131 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
132 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
133
134 virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL
136 OUString const & repository,
137 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv) override;
138
139 virtual sal_Bool SAL_CALL isReadOnlyRepository(OUString const & repository) override;
140
141private:
142
143 static OUString StrSyncRepository() { return DpResId(RID_STR_SYNCHRONIZING_REPOSITORY); }
144
145 css::uno::Reference< css::uno::XComponentContext> m_xContext;
146 css::uno::Reference<css::deployment::XPackageManagerFactory> m_xPackageManagerFactory;
147
148 //only to be used within addExtension
149 std::mutex m_addMutex;
150 /* contains the names of all repositories (except tmp) in order of there
151 priority. That is, the first element is "user" followed by "shared" and
152 then "bundled"
153 */
154 std::vector< OUString > m_repositoryNames;
155
156 css::uno::Reference<css::deployment::XPackageManager> getUserRepository();
157 css::uno::Reference<css::deployment::XPackageManager> getSharedRepository();
158 css::uno::Reference<css::deployment::XPackageManager> getBundledRepository();
159 css::uno::Reference<css::deployment::XPackageManager> getTmpRepository();
160 css::uno::Reference<css::deployment::XPackageManager> getBakRepository();
161
162 bool isUserDisabled(OUString const & identifier,
163 OUString const & filename);
164
165 static bool isUserDisabled(
166 css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExtSameId);
167
169 OUString const & identifier,
170 OUString const & fileName,
171 bool bUserDisabled, bool bStartup,
172 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
173 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
174
175 static void activateExtension(
176 css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExt,
177 bool bUserDisabled, bool bStartup,
178 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
179 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
180
181 std::vector<css::uno::Reference<css::deployment::XPackage> >
182 getExtensionsWithSameId(OUString const & identifier,
183 OUString const & fileName);
184
185 css::uno::Reference<css::deployment::XPackage> backupExtension(
186 OUString const & identifier, OUString const & fileName,
187 css::uno::Reference<css::deployment::XPackageManager> const & xPackageManager,
188 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
189
190 void checkInstall(
191 OUString const & displayName,
192 css::uno::Reference<css::ucb::XCommandEnvironment> const & cmdEnv);
193
194 void checkUpdate(
195 OUString const & newVersion,
196 OUString const & newDisplayName,
197 css::uno::Reference<css::deployment::XPackage> const & oldExtension,
198 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
199
201 id2extensions & mapExt,
202 css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExt,
203 std::u16string_view repository);
204
207 css::uno::Reference<css::deployment::XPackageManager>
208 getPackageManager(std::u16string_view repository);
209
216 css::uno::Reference<css::deployment::XPackageManager> const & xPackageMgr,
217 css::uno::Sequence<css::beans::NamedValue> const & properties,
218 css::uno::Reference<css::deployment::XPackage> const & xTmpExtension,
219 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
220 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
221 css::uno::Reference<css::deployment::XPackage> & out_existingExtension );
222
223};
224
225}
226
227/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Sequence< css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > > SAL_CALL getAllExtensions(css::uno::Reference< css::task::XAbortChannel > const &, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual void SAL_CALL removeExtension(OUString const &identifier, OUString const &filename, OUString const &repository, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual css::uno::Reference< css::task::XAbortChannel > SAL_CALL createAbortChannel() override
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > SAL_CALL getExtensionsWithSameIdentifier(OUString const &identifier, OUString const &filename, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual sal_Bool SAL_CALL synchronize(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual css::uno::Reference< css::deployment::XPackage > SAL_CALL getDeployedExtension(OUString const &repository, OUString const &identifier, OUString const &filename, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Reference< css::deployment::XPackageManager > getTmpRepository()
virtual sal_Bool SAL_CALL isReadOnlyRepository(OUString const &repository) override
css::uno::Reference< css::deployment::XPackageManagerFactory > m_xPackageManagerFactory
css::uno::Reference< css::deployment::XPackageManager > getSharedRepository()
void checkUpdate(OUString const &newVersion, OUString const &newDisplayName, css::uno::Reference< css::deployment::XPackage > const &oldExtension, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
virtual void SAL_CALL disableExtension(css::uno::Reference< css::deployment::XPackage > const &extension, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::deployment::XPackageManager > getBundledRepository()
void addExtensionsToMap(id2extensions &mapExt, css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > const &seqExt, std::u16string_view repository)
css::uno::Reference< css::deployment::XPackageManager > getUserRepository()
static void activateExtension(css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > const &seqExt, bool bUserDisabled, bool bStartup, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
static bool isUserDisabled(css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > const &seqExtSameId)
bool doChecksForAddExtension(css::uno::Reference< css::deployment::XPackageManager > const &xPackageMgr, css::uno::Sequence< css::beans::NamedValue > const &properties, css::uno::Reference< css::deployment::XPackage > const &xTmpExtension, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, css::uno::Reference< css::deployment::XPackage > &out_existingExtension)
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > SAL_CALL getExtensionsWithUnacceptedLicenses(OUString const &repository, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
css::uno::Reference< css::deployment::XPackageManager > getBakRepository()
css::uno::Reference< css::deployment::XPackage > backupExtension(OUString const &identifier, OUString const &fileName, css::uno::Reference< css::deployment::XPackageManager > const &xPackageManager, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
std::vector< css::uno::Reference< css::deployment::XPackage > > getExtensionsWithSameId(OUString const &identifier, OUString const &fileName)
bool isUserDisabled(OUString const &identifier, OUString const &filename)
void activateExtension(OUString const &identifier, OUString const &fileName, bool bUserDisabled, bool bStartup, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
virtual void SAL_CALL addModifyListener(css::uno::Reference< css::util::XModifyListener > const &xListener) override
css::uno::Reference< css::deployment::XPackageManager > getPackageManager(std::u16string_view repository)
virtual void SAL_CALL enableExtension(css::uno::Reference< css::deployment::XPackage > const &extension, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackageTypeInfo > > SAL_CALL getSupportedPackageTypes() override
virtual void SAL_CALL removeModifyListener(css::uno::Reference< css::util::XModifyListener > const &xListener) override
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > SAL_CALL getDeployedExtensions(OUString const &repository, css::uno::Reference< css::task::XAbortChannel > const &, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
ExtensionManager(css::uno::Reference< css::uno::XComponentContext >const &xContext)
std::vector< OUString > m_repositoryNames
virtual sal_Int32 SAL_CALL checkPrerequisitesAndEnable(css::uno::Reference< css::deployment::XPackage > const &extension, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
void checkInstall(OUString const &displayName, css::uno::Reference< css::ucb::XCommandEnvironment > const &cmdEnv)
virtual css::uno::Reference< css::deployment::XPackage > SAL_CALL addExtension(OUString const &url, css::uno::Sequence< css::beans::NamedValue > const &properties, OUString const &repository, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL reinstallDeployedExtensions(sal_Bool force, OUString const &repository, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
OUString DpResId(TranslateId aId)
Definition: dp_misc.cxx:555
static uno::Reference< css::uno::XComponentContext > xContext
Definition: init.cxx:2642
std::unordered_map< OUString, std::vector< css::uno::Reference< css::deployment::XPackage > > > id2extensions
::boost::spirit::classic::rule< ScannerT > identifier
unsigned char sal_Bool