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