1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_MANAGER_DP_MANAGER_H
21 #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_MANAGER_DP_MANAGER_H
24 #include <dp_interact.h>
25 #include "dp_activepackages.hxx"
26 #include <rtl/ref.hxx>
27 #include <cppuhelper/compbase.hxx>
28 #include <cppuhelper/implbase.hxx>
29 #include <ucbhelper/content.hxx>
30 #include <com/sun/star/deployment/XPackageRegistry.hpp>
31 #include <com/sun/star/deployment/XPackageManager.hpp>
35 namespace dp_manager
{
37 typedef ::cppu::WeakComponentImplHelper
<
38 css::deployment::XPackageManager
> t_pm_helper
;
41 class PackageManagerImpl final
: private ::dp_misc::MutexHolder
, public t_pm_helper
43 css::uno::Reference
<css::uno::XComponentContext
> m_xComponentContext
;
45 OUString m_registrationData
;
46 OUString m_registrationData_expanded
;
47 OUString m_registryCache
;
50 OUString m_activePackages
;
51 OUString m_activePackages_expanded
;
52 std::unique_ptr
< ActivePackages
> m_activePackagesDB
;
53 //This mutex is only used for synchronization in addPackage
54 ::osl::Mutex m_addMutex
;
55 css::uno::Reference
<css::ucb::XProgressHandler
> m_xLogFile
;
56 inline void logIntern( css::uno::Any
const & status
);
59 css::uno::Reference
<css::deployment::XPackageRegistry
> m_xRegistry
;
61 void initRegistryBackends();
62 void initActivationLayer(
63 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
64 OUString
detectMediaType(
65 ::ucbhelper::Content
const & ucbContent
, bool throw_exc
= true );
66 OUString
insertToActivationLayer(
67 css::uno::Sequence
<css::beans::NamedValue
> const & properties
,
68 OUString
const & mediaType
,
69 ::ucbhelper::Content
const & sourceContent
,
70 OUString
const & title
, ActivePackages::Data
* dbData
);
71 void insertToActivationLayerDB(
72 OUString
const & id
, ActivePackages::Data
const & dbData
);
74 static void deletePackageFromCache(
75 css::uno::Reference
<css::deployment::XPackage
> const & xPackage
,
76 OUString
const & destFolder
);
79 css::uno::Reference
<css::deployment::XPackage
> const & package
);
81 bool synchronizeRemovedExtensions(
82 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
83 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
85 bool synchronizeAddedExtensions(
86 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
87 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
89 class CmdEnvWrapperImpl
90 : public ::cppu::WeakImplHelper
< css::ucb::XCommandEnvironment
,
91 css::ucb::XProgressHandler
>
93 css::uno::Reference
<css::ucb::XProgressHandler
> m_xLogFile
;
94 css::uno::Reference
<css::ucb::XProgressHandler
> m_xUserProgress
;
95 css::uno::Reference
<css::task::XInteractionHandler
>
96 m_xUserInteractionHandler
;
99 virtual ~CmdEnvWrapperImpl() override
;
101 css::uno::Reference
<css::ucb::XCommandEnvironment
>
103 css::uno::Reference
<css::ucb::XProgressHandler
> const & xLogFile
);
105 // XCommandEnvironment
106 virtual css::uno::Reference
<css::task::XInteractionHandler
> SAL_CALL
107 getInteractionHandler() override
;
108 virtual css::uno::Reference
<css::ucb::XProgressHandler
> SAL_CALL
109 getProgressHandler() override
;
112 virtual void SAL_CALL
push( css::uno::Any
const & Status
) override
;
113 virtual void SAL_CALL
update( css::uno::Any
const & Status
) override
;
114 virtual void SAL_CALL
pop() override
;
118 virtual void SAL_CALL
disposing() override
;
120 virtual ~PackageManagerImpl() override
;
122 css::uno::Reference
<css::uno::XComponentContext
>
123 const & xComponentContext
, OUString
const & context
)
124 : t_pm_helper( getMutex() ),
125 m_xComponentContext( xComponentContext
),
126 m_context( context
),
131 static css::uno::Reference
<css::deployment::XPackageManager
> create(
132 css::uno::Reference
<css::uno::XComponentContext
>
133 const & xComponentContext
, OUString
const & context
);
136 virtual void SAL_CALL
dispose() override
;
137 virtual void SAL_CALL
addEventListener(
138 css::uno::Reference
<css::lang::XEventListener
> const & xListener
) override
;
139 virtual void SAL_CALL
removeEventListener(
140 css::uno::Reference
<css::lang::XEventListener
> const & xListener
) override
;
142 // XModifyBroadcaster
143 virtual void SAL_CALL
addModifyListener(
144 css::uno::Reference
<css::util::XModifyListener
> const & xListener
) override
;
145 virtual void SAL_CALL
removeModifyListener(
146 css::uno::Reference
<css::util::XModifyListener
> const & xListener
) override
;
149 virtual OUString SAL_CALL
getContext() override
;
150 virtual css::uno::Sequence
<
151 css::uno::Reference
<css::deployment::XPackageTypeInfo
> > SAL_CALL
152 getSupportedPackageTypes() override
;
154 virtual css::uno::Reference
<css::task::XAbortChannel
> SAL_CALL
155 createAbortChannel() override
;
157 virtual css::uno::Reference
<css::deployment::XPackage
> SAL_CALL
addPackage(
158 OUString
const & url
,
159 css::uno::Sequence
<css::beans::NamedValue
> const & properties
,
160 OUString
const & mediaType
,
161 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
162 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
164 virtual css::uno::Reference
<css::deployment::XPackage
> SAL_CALL
importExtension(
165 css::uno::Reference
<css::deployment::XPackage
> const & extension
,
166 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
167 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
169 virtual void SAL_CALL
removePackage(
170 OUString
const & id
, OUString
const & fileName
,
171 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
172 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
174 OUString
getDeployPath( ActivePackages::Data
const & data
);
175 css::uno::Reference
<css::deployment::XPackage
> getDeployedPackage_(
176 OUString
const & id
, OUString
const & fileName
,
177 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
178 css::uno::Reference
<css::deployment::XPackage
> getDeployedPackage_(
179 OUString
const & id
, ActivePackages::Data
const & data
,
180 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
,
181 bool ignoreAlienPlatforms
= false );
182 virtual css::uno::Reference
<css::deployment::XPackage
> SAL_CALL
184 OUString
const & id
, OUString
const & fileName
,
185 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
187 css::uno::Sequence
< css::uno::Reference
<css::deployment::XPackage
> >
188 getDeployedPackages_(
189 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
);
190 virtual css::uno::Sequence
< css::uno::Reference
<css::deployment::XPackage
> >
191 SAL_CALL
getDeployedPackages(
192 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
193 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
195 virtual void SAL_CALL
reinstallDeployedPackages(
197 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
198 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
200 virtual ::sal_Bool SAL_CALL
isReadOnly( ) override
;
202 virtual ::sal_Bool SAL_CALL
synchronize(
203 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
204 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
206 virtual css::uno::Sequence
<css::uno::Reference
<css::deployment::XPackage
> > SAL_CALL
207 getExtensionsWithUnacceptedLicenses(
208 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
210 virtual sal_Int32 SAL_CALL
checkPrerequisites(
211 css::uno::Reference
<css::deployment::XPackage
> const & extension
,
212 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
,
213 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
) override
;
217 inline void PackageManagerImpl::check()
219 ::osl::MutexGuard
guard( getMutex() );
220 if (rBHelper
.bInDispose
|| rBHelper
.bDisposed
)
221 throw css::lang::DisposedException(
222 "PackageManager instance has already been disposed!",
223 static_cast< ::cppu::OWeakObject
* >(this) );
227 inline void PackageManagerImpl::logIntern( css::uno::Any
const & status
)
230 m_xLogFile
->update( status
);
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */