From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- desktop/source/deployment/manager/dp_manager.h | 232 +++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 desktop/source/deployment/manager/dp_manager.h (limited to 'desktop/source/deployment/manager/dp_manager.h') diff --git a/desktop/source/deployment/manager/dp_manager.h b/desktop/source/deployment/manager/dp_manager.h new file mode 100644 index 000000000..a2079da23 --- /dev/null +++ b/desktop/source/deployment/manager/dp_manager.h @@ -0,0 +1,232 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include "dp_activepackages.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace dp_manager { + +typedef ::cppu::WeakComponentImplHelper< + css::deployment::XPackageManager > t_pm_helper; + + +class PackageManagerImpl final : private cppu::BaseMutex, public t_pm_helper +{ + css::uno::Reference m_xComponentContext; + OUString m_context; + OUString m_registrationData; + OUString m_registrationData_expanded; + OUString m_registryCache; + bool m_readOnly; + + OUString m_activePackages; + OUString m_activePackages_expanded; + std::unique_ptr< ActivePackages > m_activePackagesDB; + //This mutex is only used for synchronization in addPackage + ::osl::Mutex m_addMutex; + css::uno::Reference m_xLogFile; + inline void logIntern( css::uno::Any const & status ); + void fireModified(); + + css::uno::Reference m_xRegistry; + + void initRegistryBackends(); + void initActivationLayer( + css::uno::Reference const & xCmdEnv ); + OUString detectMediaType( + ::ucbhelper::Content const & ucbContent, bool throw_exc = true ); + OUString insertToActivationLayer( + css::uno::Sequence const & properties, + OUString const & mediaType, + ::ucbhelper::Content const & sourceContent, + OUString const & title, ActivePackages::Data * dbData ); + void insertToActivationLayerDB( + OUString const & id, ActivePackages::Data const & dbData ); + + static void deletePackageFromCache( + css::uno::Reference const & xPackage, + OUString const & destFolder ); + + bool isInstalled( + css::uno::Reference const & package); + + bool synchronizeRemovedExtensions( + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); + + bool synchronizeAddedExtensions( + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); + + class CmdEnvWrapperImpl + : public ::cppu::WeakImplHelper< css::ucb::XCommandEnvironment, + css::ucb::XProgressHandler > + { + css::uno::Reference m_xLogFile; + css::uno::Reference m_xUserProgress; + css::uno::Reference + m_xUserInteractionHandler; + + public: + virtual ~CmdEnvWrapperImpl() override; + CmdEnvWrapperImpl( + css::uno::Reference + const & xUserCmdEnv, + css::uno::Reference const & xLogFile ); + + // XCommandEnvironment + virtual css::uno::Reference SAL_CALL + getInteractionHandler() override; + virtual css::uno::Reference SAL_CALL + getProgressHandler() override; + + // XProgressHandler + virtual void SAL_CALL push( css::uno::Any const & Status ) override; + virtual void SAL_CALL update( css::uno::Any const & Status ) override; + virtual void SAL_CALL pop() override; + }; + + inline void check(); + virtual void SAL_CALL disposing() override; + + virtual ~PackageManagerImpl() override; + PackageManagerImpl( + css::uno::Reference xComponentContext, OUString context ) + : t_pm_helper( m_aMutex ), + m_xComponentContext(std::move( xComponentContext )), + m_context(std::move( context )), + m_readOnly( true ) + {} + +public: + static css::uno::Reference create( + css::uno::Reference + const & xComponentContext, OUString const & context ); + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( + css::uno::Reference const & xListener ) override; + virtual void SAL_CALL removeEventListener( + css::uno::Reference const & xListener ) override; + + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener( + css::uno::Reference const & xListener ) override; + virtual void SAL_CALL removeModifyListener( + css::uno::Reference const & xListener ) override; + + // XPackageManager + virtual OUString SAL_CALL getContext() override; + virtual css::uno::Sequence< + css::uno::Reference > SAL_CALL + getSupportedPackageTypes() override; + + virtual css::uno::Reference SAL_CALL + createAbortChannel() override; + + virtual css::uno::Reference SAL_CALL addPackage( + OUString const & url, + css::uno::Sequence const & properties, + OUString const & mediaType, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) override; + + virtual css::uno::Reference SAL_CALL importExtension( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) override; + + virtual void SAL_CALL removePackage( + OUString const & id, OUString const & fileName, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) override; + + OUString getDeployPath( ActivePackages::Data const & data ); + css::uno::Reference getDeployedPackage_( + OUString const & id, OUString const & fileName, + css::uno::Reference const & xCmdEnv ); + css::uno::Reference getDeployedPackage_( + std::u16string_view id, ActivePackages::Data const & data, + css::uno::Reference const & xCmdEnv, + bool ignoreAlienPlatforms = false ); + virtual css::uno::Reference SAL_CALL + getDeployedPackage( + OUString const & id, OUString const & fileName, + css::uno::Reference const & xCmdEnv ) override; + + css::uno::Sequence< css::uno::Reference > + getDeployedPackages_( + css::uno::Reference const & xCmdEnv ); + virtual css::uno::Sequence< css::uno::Reference > + SAL_CALL getDeployedPackages( + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) override; + + virtual void SAL_CALL reinstallDeployedPackages( + sal_Bool force, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) override; + + virtual ::sal_Bool SAL_CALL isReadOnly( ) override; + + virtual ::sal_Bool SAL_CALL synchronize( + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) override; + + virtual css::uno::Sequence > SAL_CALL + getExtensionsWithUnacceptedLicenses( + css::uno::Reference const & xCmdEnv) override; + + virtual sal_Int32 SAL_CALL checkPrerequisites( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) override; + }; + + +inline void PackageManagerImpl::check() +{ + ::osl::MutexGuard guard( m_aMutex ); + if (rBHelper.bInDispose || rBHelper.bDisposed) + throw css::lang::DisposedException( + "PackageManager instance has already been disposed!", + static_cast< ::cppu::OWeakObject * >(this) ); +} + + +inline void PackageManagerImpl::logIntern( css::uno::Any const & status ) +{ + if (m_xLogFile.is()) + m_xLogFile->update( status ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3