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 <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>
34 #include <vector>
35 #include <unordered_map>
36 
37 namespace dp_manager {
38 
39 typedef std::unordered_map<
40  OUString,
41  std::vector<css::uno::Reference<css::deployment::XPackage> > > id2extensions;
42 
44  public ::cppu::WeakComponentImplHelper< css::deployment::XExtensionManager >
45 {
46 public:
47  explicit ExtensionManager( css::uno::Reference< css::uno::XComponentContext >const& xContext);
48  virtual ~ExtensionManager() override;
49 
50  void check();
51  void fireModified();
52 
53 public:
54 
55 // XModifyBroadcaster
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;
60 
61 //XExtensionManager
62  virtual css::uno::Sequence<
63  css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL
64  getSupportedPackageTypes() override;
65 
66  virtual css::uno::Reference<css::task::XAbortChannel> SAL_CALL
67  createAbortChannel() override;
68 
69  virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL addExtension(
70  OUString const & url,
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;
75 
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;
82 
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;
87 
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;
92 
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;
97 
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;
103 
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;
110 
111  virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> >
113  OUString const & identifier,
114  OUString const & filename,
115  css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
116 
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;
121 
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;
126 
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;
130 
131  virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL
133  OUString const & repository,
134  css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv) override;
135 
136  virtual sal_Bool SAL_CALL isReadOnlyRepository(OUString const & repository) override;
137 
138 private:
139 
140  static OUString StrSyncRepository() { return DpResId(RID_STR_SYNCHRONIZING_REPOSITORY); }
141 
142  css::uno::Reference< css::uno::XComponentContext> m_xContext;
143  css::uno::Reference<css::deployment::XPackageManagerFactory> m_xPackageManagerFactory;
144 
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
149  then "bundled"
150  */
151  std::vector< OUString > m_repositoryNames;
152 
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();
158 
159  bool isUserDisabled(OUString const & identifier,
160  OUString const & filename);
161 
162  static bool isUserDisabled(
163  css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExtSameId);
164 
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);
171 
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 );
177 
178  std::vector<css::uno::Reference<css::deployment::XPackage> >
179  getExtensionsWithSameId(OUString const & identifier,
180  OUString const & fileName);
181 
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);
186 
187  void checkInstall(
188  OUString const & displayName,
189  css::uno::Reference<css::ucb::XCommandEnvironment> const & cmdEnv);
190 
191  void checkUpdate(
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);
196 
197  void addExtensionsToMap(
198  id2extensions & mapExt,
199  css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExt,
200  OUString const & repository);
201 
204  css::uno::Reference<css::deployment::XPackageManager>
205  getPackageManager(OUString const & repository);
206 
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 );
219 
220 };
221 
222 }
223 
224 #endif
225 
226 /* 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)
static uno::Reference< css::uno::XComponentContext > xContext
Definition: init.cxx:1858
std::vector< css::uno::Reference< css::deployment::XPackage > > getExtensionsWithSameId(OUString const &identifier, OUString const &fileName)
css::uno::Reference< css::deployment::XPackageManager > getBundledRepository()
::boost::spirit::rule< ScannerT > identifier
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:38
virtual void SAL_CALL addModifyListener(css::uno::Reference< css::util::XModifyListener > const &xListener) override