/src/libreoffice/desktop/source/deployment/manager/dp_extensionmanager.hxx
Line | Count | Source |
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> |
24 | | #include <cppuhelper/basemutex.hxx> |
25 | | #include <cppuhelper/compbase.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 | | |
35 | | namespace dp_manager { |
36 | | |
37 | | typedef std::unordered_map< |
38 | | OUString, |
39 | | std::vector<css::uno::Reference<css::deployment::XPackage> > > id2extensions; |
40 | | |
41 | | class ExtensionManager : private cppu::BaseMutex, |
42 | | public ::cppu::WeakComponentImplHelper< css::deployment::XExtensionManager, css::lang::XServiceInfo > |
43 | | { |
44 | | public: |
45 | | explicit ExtensionManager( css::uno::Reference< css::uno::XComponentContext >const& xContext); |
46 | | virtual ~ExtensionManager() override; |
47 | | |
48 | | void check(); |
49 | | void fireModified(); |
50 | | |
51 | | public: |
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> > |
115 | | SAL_CALL getExtensionsWithSameIdentifier( |
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 |
135 | | getExtensionsWithUnacceptedLicenses( |
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 | | |
141 | | private: |
142 | | |
143 | 0 | 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 | | |
168 | | void activateExtension( |
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 | | |
200 | | void addExtensionsToMap( |
201 | | id2extensions & mapExt, |
202 | | css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExt, |
203 | | std::u16string_view repository); |
204 | | |
205 | | /// @throws css::lang::IllegalArgumentException |
206 | | /// @throws css::uno::RuntimeException |
207 | | css::uno::Reference<css::deployment::XPackageManager> |
208 | | getPackageManager(std::u16string_view repository); |
209 | | |
210 | | /// @throws css::deployment::DeploymentException |
211 | | /// @throws css::ucb::CommandFailedException |
212 | | /// @throws css::ucb::CommandAbortedException |
213 | | /// @throws css::lang::IllegalArgumentException |
214 | | /// @throws css::uno::RuntimeException |
215 | | bool doChecksForAddExtension( |
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: */ |