tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / desktop / source / deployment / manager / dp_manager.h
blobf83e70e123da7c36d6dd8f60822392b51742a1f5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include "dp_activepackages.hxx"
23 #include <cppuhelper/basemutex.hxx>
24 #include <cppuhelper/compbase.hxx>
25 #include <cppuhelper/implbase.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>
34 namespace dp_manager {
36 typedef ::cppu::WeakComponentImplHelper<
37 css::deployment::XPackageManager > t_pm_helper;
40 class PackageManagerImpl final : private cppu::BaseMutex, public t_pm_helper
42 css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
43 OUString m_context;
44 OUString m_registrationData;
45 OUString m_registrationData_expanded;
46 OUString m_registryCache;
47 bool m_readOnly;
49 OUString m_activePackages;
50 OUString m_activePackages_expanded;
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();
58 css::uno::Reference<css::deployment::XPackageRegistry> m_xRegistry;
60 void initRegistryBackends();
61 void initActivationLayer(
62 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
63 OUString detectMediaType(
64 ::ucbhelper::Content const & ucbContent, bool throw_exc = true );
65 OUString insertToActivationLayer(
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 );
70 void insertToActivationLayerDB(
71 OUString const & id, ActivePackages::Data const & dbData );
73 static void deletePackageFromCache(
74 css::uno::Reference<css::deployment::XPackage> const & xPackage,
75 OUString const & destFolder );
77 bool isInstalled(
78 css::uno::Reference<css::deployment::XPackage> const & package);
80 bool synchronizeRemovedExtensions(
81 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
82 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
84 bool synchronizeAddedExtensions(
85 css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
86 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
88 class CmdEnvWrapperImpl
89 : public ::cppu::WeakImplHelper< css::ucb::XCommandEnvironment,
90 css::ucb::XProgressHandler >
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>
95 m_xUserInteractionHandler;
97 public:
98 virtual ~CmdEnvWrapperImpl() override;
99 CmdEnvWrapperImpl(
100 css::uno::Reference<css::ucb::XCommandEnvironment>
101 const & xUserCmdEnv,
102 css::uno::Reference<css::ucb::XProgressHandler> const & xLogFile );
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;
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;
116 inline void check();
117 virtual void SAL_CALL disposing() override;
119 virtual ~PackageManagerImpl() override;
120 PackageManagerImpl(
121 css::uno::Reference<css::uno::XComponentContext> xComponentContext, OUString context )
122 : t_pm_helper( m_aMutex ),
123 m_xComponentContext(std::move( xComponentContext )),
124 m_context(std::move( context )),
125 m_readOnly( true )
128 public:
129 static css::uno::Reference<css::deployment::XPackageManager> create(
130 css::uno::Reference<css::uno::XComponentContext>
131 const & xComponentContext, OUString const & context );
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;
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;
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;
152 virtual css::uno::Reference<css::task::XAbortChannel> SAL_CALL
153 createAbortChannel() override;
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;
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;
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;
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
181 getDeployedPackage(
182 OUString const & id, OUString const & fileName,
183 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) override;
185 css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
186 getDeployedPackages_(
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;
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;
198 virtual ::sal_Bool SAL_CALL isReadOnly( ) override;
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;
204 virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL
205 getExtensionsWithUnacceptedLicenses(
206 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv) override;
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;
215 inline void PackageManagerImpl::check()
217 ::osl::MutexGuard guard( m_aMutex );
218 if (rBHelper.bInDispose || rBHelper.bDisposed)
219 throw css::lang::DisposedException(
220 u"PackageManager instance has already been disposed!"_ustr,
221 static_cast< ::cppu::OWeakObject * >(this) );
225 inline void PackageManagerImpl::logIntern( css::uno::Any const & status )
227 if (m_xLogFile.is())
228 m_xLogFile->update( status );
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */