LibreOffice Module desktop (master) 1
dp_manager.h
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 "dp_activepackages.hxx"
26#include <ucbhelper/content.hxx>
27#include <com/sun/star/deployment/XPackageRegistry.hpp>
28#include <com/sun/star/deployment/XPackageManager.hpp>
29#include <memory>
30#include <mutex>
31#include <string_view>
32#include <utility>
33
34namespace dp_manager {
35
36typedef ::cppu::WeakComponentImplHelper<
37 css::deployment::XPackageManager > t_pm_helper;
38
39
40class PackageManagerImpl final : private cppu::BaseMutex, public t_pm_helper
41{
42 css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
43 OUString m_context;
48
51 std::unique_ptr< ActivePackages > m_activePackagesDB;
52 //This mutex is only used for synchronization in addPackage
53 std::mutex m_addMutex;
54 css::uno::Reference<css::ucb::XProgressHandler> m_xLogFile;
55 inline void logIntern( css::uno::Any const & status );
56 void fireModified();
57
58 css::uno::Reference<css::deployment::XPackageRegistry> m_xRegistry;
59
62 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
63 OUString detectMediaType(
64 ::ucbhelper::Content const & ucbContent, bool throw_exc = true );
66 css::uno::Sequence<css::beans::NamedValue> const & properties,
67 OUString const & mediaType,
68 ::ucbhelper::Content const & sourceContent,
69 OUString const & title, ActivePackages::Data * dbData );
71 OUString const & id, ActivePackages::Data const & dbData );
72
73 static void deletePackageFromCache(
74 css::uno::Reference<css::deployment::XPackage> const & xPackage,
75 OUString const & destFolder );
76
77 bool isInstalled(
78 css::uno::Reference<css::deployment::XPackage> const & package);
79
81 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
82 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
83
85 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
86 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
87
89 : public ::cppu::WeakImplHelper< css::ucb::XCommandEnvironment,
90 css::ucb::XProgressHandler >
91 {
92 css::uno::Reference<css::ucb::XProgressHandler> m_xLogFile;
93 css::uno::Reference<css::ucb::XProgressHandler> m_xUserProgress;
94 css::uno::Reference<css::task::XInteractionHandler>
96
97 public:
98 virtual ~CmdEnvWrapperImpl() override;
100 css::uno::Reference<css::ucb::XCommandEnvironment>
101 const & xUserCmdEnv,
102 css::uno::Reference<css::ucb::XProgressHandler> const & xLogFile );
103
104 // XCommandEnvironment
105 virtual css::uno::Reference<css::task::XInteractionHandler> SAL_CALL
106 getInteractionHandler() override;
107 virtual css::uno::Reference<css::ucb::XProgressHandler> SAL_CALL
108 getProgressHandler() override;
109
110 // XProgressHandler
111 virtual void SAL_CALL push( css::uno::Any const & Status ) override;
112 virtual void SAL_CALL update( css::uno::Any const & Status ) override;
113 virtual void SAL_CALL pop() override;
114 };
115
116 inline void check();
117 virtual void SAL_CALL disposing() override;
118
119 virtual ~PackageManagerImpl() override;
121 css::uno::Reference<css::uno::XComponentContext> xComponentContext, OUString context )
123 m_xComponentContext(std::move( xComponentContext )),
124 m_context(std::move( context )),
125 m_readOnly( true )
126 {}
127
128public:
129 static css::uno::Reference<css::deployment::XPackageManager> create(
130 css::uno::Reference<css::uno::XComponentContext>
131 const & xComponentContext, OUString const & context );
132
133 // XComponent
134 virtual void SAL_CALL dispose() override;
135 virtual void SAL_CALL addEventListener(
136 css::uno::Reference<css::lang::XEventListener> const & xListener ) override;
137 virtual void SAL_CALL removeEventListener(
138 css::uno::Reference<css::lang::XEventListener> const & xListener ) override;
139
140 // XModifyBroadcaster
141 virtual void SAL_CALL addModifyListener(
142 css::uno::Reference<css::util::XModifyListener> const & xListener ) override;
143 virtual void SAL_CALL removeModifyListener(
144 css::uno::Reference<css::util::XModifyListener> const & xListener ) override;
145
146 // XPackageManager
147 virtual OUString SAL_CALL getContext() override;
148 virtual css::uno::Sequence<
149 css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL
150 getSupportedPackageTypes() override;
151
152 virtual css::uno::Reference<css::task::XAbortChannel> SAL_CALL
153 createAbortChannel() override;
154
155 virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL addPackage(
156 OUString const & url,
157 css::uno::Sequence<css::beans::NamedValue> const & properties,
158 OUString const & mediaType,
159 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
160 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
161
162 virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL importExtension(
163 css::uno::Reference<css::deployment::XPackage> const & extension,
164 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
165 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
166
167 virtual void SAL_CALL removePackage(
168 OUString const & id, OUString const & fileName,
169 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
170 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
171
172 OUString getDeployPath( ActivePackages::Data const & data );
173 css::uno::Reference<css::deployment::XPackage> getDeployedPackage_(
174 OUString const & id, OUString const & fileName,
175 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
176 css::uno::Reference<css::deployment::XPackage> getDeployedPackage_(
177 std::u16string_view id, ActivePackages::Data const & data,
178 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv,
179 bool ignoreAlienPlatforms = false );
180 virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL
182 OUString const & id, OUString const & fileName,
183 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
184
185 css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
187 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
188 virtual css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
189 SAL_CALL getDeployedPackages(
190 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
191 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
192
193 virtual void SAL_CALL reinstallDeployedPackages(
194 sal_Bool force,
195 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
196 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
197
198 virtual ::sal_Bool SAL_CALL isReadOnly( ) override;
199
200 virtual ::sal_Bool SAL_CALL synchronize(
201 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
202 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
203
204 virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL
206 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv) override;
207
208 virtual sal_Int32 SAL_CALL checkPrerequisites(
209 css::uno::Reference<css::deployment::XPackage> const & extension,
210 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
211 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
212 };
213
214
216{
217 ::osl::MutexGuard guard( m_aMutex );
218 if (rBHelper.bInDispose || rBHelper.bDisposed)
219 throw css::lang::DisposedException(
220 "PackageManager instance has already been disposed!",
221 static_cast< ::cppu::OWeakObject * >(this) );
222}
223
224
225inline void PackageManagerImpl::logIntern( css::uno::Any const & status )
226{
227 if (m_xLogFile.is())
228 m_xLogFile->update( status );
229}
230
231}
232
233/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
mutable::osl::Mutex m_aMutex
virtual css::uno::Reference< css::task::XInteractionHandler > SAL_CALL getInteractionHandler() override
virtual css::uno::Reference< css::ucb::XProgressHandler > SAL_CALL getProgressHandler() override
virtual void SAL_CALL push(css::uno::Any const &Status) override
virtual void SAL_CALL update(css::uno::Any const &Status) override
css::uno::Reference< css::ucb::XProgressHandler > m_xLogFile
Definition: dp_manager.h:92
css::uno::Reference< css::task::XInteractionHandler > m_xUserInteractionHandler
Definition: dp_manager.h:95
CmdEnvWrapperImpl(css::uno::Reference< css::ucb::XCommandEnvironment > const &xUserCmdEnv, css::uno::Reference< css::ucb::XProgressHandler > const &xLogFile)
css::uno::Reference< css::ucb::XProgressHandler > m_xUserProgress
Definition: dp_manager.h:93
virtual css::uno::Reference< css::deployment::XPackage > SAL_CALL importExtension(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
Definition: dp_manager.cxx:694
static void deletePackageFromCache(css::uno::Reference< css::deployment::XPackage > const &xPackage, OUString const &destFolder)
Definition: dp_manager.cxx:841
virtual void SAL_CALL reinstallDeployedPackages(sal_Bool force, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual void SAL_CALL addModifyListener(css::uno::Reference< css::util::XModifyListener > const &xListener) override
Definition: dp_manager.cxx:548
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > SAL_CALL getDeployedPackages(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual void SAL_CALL removeEventListener(css::uno::Reference< css::lang::XEventListener > const &xListener) override
Definition: dp_manager.cxx:515
bool synchronizeRemovedExtensions(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
css::uno::Reference< css::deployment::XPackage > getDeployedPackage_(std::u16string_view id, ActivePackages::Data const &data, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool ignoreAlienPlatforms=false)
virtual void SAL_CALL addEventListener(css::uno::Reference< css::lang::XEventListener > const &xListener) override
Definition: dp_manager.cxx:506
css::uno::Reference< css::uno::XComponentContext > m_xComponentContext
Definition: dp_manager.h:42
OUString getDeployPath(ActivePackages::Data const &data)
Definition: dp_manager.cxx:942
bool synchronizeAddedExtensions(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
void insertToActivationLayerDB(OUString const &id, ActivePackages::Data const &dbData)
Definition: dp_manager.cxx:667
virtual void SAL_CALL removePackage(OUString const &id, OUString const &fileName, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
Definition: dp_manager.cxx:858
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackageTypeInfo > > SAL_CALL getSupportedPackageTypes() override
Definition: dp_manager.cxx:533
virtual css::uno::Reference< css::deployment::XPackage > SAL_CALL getDeployedPackage(OUString const &id, OUString const &fileName, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual void SAL_CALL disposing() override
Definition: dp_manager.cxx:470
css::uno::Reference< css::deployment::XPackage > getDeployedPackage_(OUString const &id, OUString const &fileName, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
virtual css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > SAL_CALL getExtensionsWithUnacceptedLicenses(css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
virtual ::sal_Bool SAL_CALL isReadOnly() override
std::unique_ptr< ActivePackages > m_activePackagesDB
Definition: dp_manager.h:51
OUString insertToActivationLayer(css::uno::Sequence< css::beans::NamedValue > const &properties, OUString const &mediaType, ::ucbhelper::Content const &sourceContent, OUString const &title, ActivePackages::Data *dbData)
Definition: dp_manager.cxx:602
virtual sal_Int32 SAL_CALL checkPrerequisites(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::ucb::XProgressHandler > m_xLogFile
Definition: dp_manager.h:54
virtual css::uno::Reference< css::deployment::XPackage > SAL_CALL addPackage(OUString const &url, css::uno::Sequence< css::beans::NamedValue > const &properties, OUString const &mediaType, css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
Definition: dp_manager.cxx:706
virtual OUString SAL_CALL getContext() override
Definition: dp_manager.cxx:525
css::uno::Reference< css::deployment::XPackageRegistry > m_xRegistry
Definition: dp_manager.h:58
OUString detectMediaType(::ucbhelper::Content const &ucbContent, bool throw_exc=true)
Definition: dp_manager.cxx:564
virtual ::sal_Bool SAL_CALL synchronize(css::uno::Reference< css::task::XAbortChannel > const &xAbortChannel, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv) override
void initActivationLayer(css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
Definition: dp_manager.cxx:113
bool isInstalled(css::uno::Reference< css::deployment::XPackage > const &package)
Definition: dp_manager.cxx:679
css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > getDeployedPackages_(css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv)
void logIntern(css::uno::Any const &status)
Definition: dp_manager.h:225
virtual css::uno::Reference< css::task::XAbortChannel > SAL_CALL createAbortChannel() override
Definition: dp_manager.cxx:540
virtual ~PackageManagerImpl() override
Definition: dp_manager.cxx:453
static css::uno::Reference< css::deployment::XPackageManager > create(css::uno::Reference< css::uno::XComponentContext > const &xComponentContext, OUString const &context)
Definition: dp_manager.cxx:341
PackageManagerImpl(css::uno::Reference< css::uno::XComponentContext > xComponentContext, OUString context)
Definition: dp_manager.h:120
virtual void SAL_CALL removeModifyListener(css::uno::Reference< css::util::XModifyListener > const &xListener) override
Definition: dp_manager.cxx:556
virtual void SAL_CALL dispose() override
Definition: dp_manager.cxx:498
::cppu::WeakComponentImplHelper< css::deployment::XPackageManager > t_pm_helper
Definition: dp_manager.h:37
unsigned char sal_Bool