diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /desktop/source/deployment/inc | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'desktop/source/deployment/inc')
-rw-r--r-- | desktop/source/deployment/inc/dp_dependencies.hxx | 75 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_descriptioninfoset.hxx | 288 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_identifier.hxx | 85 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_interact.h | 142 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_misc_api.hxx | 34 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_package.hxx | 45 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_persmap.h | 66 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_platform.hxx | 48 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_registry.hxx | 43 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_resource.h | 34 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_services.hxx | 65 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_ucb.h | 97 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_update.hxx | 139 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_version.hxx | 39 | ||||
-rw-r--r-- | desktop/source/deployment/inc/dp_xml.h | 45 | ||||
-rw-r--r-- | desktop/source/deployment/inc/lockfile.hxx | 92 |
16 files changed, 1337 insertions, 0 deletions
diff --git a/desktop/source/deployment/inc/dp_dependencies.hxx b/desktop/source/deployment/inc/dp_dependencies.hxx new file mode 100644 index 000000000..24c8a86fd --- /dev/null +++ b/desktop/source/deployment/inc/dp_dependencies.hxx @@ -0,0 +1,75 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_DEPENDENCIES_HXX +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_DEPENDENCIES_HXX + +#include <sal/config.h> + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include "dp_misc_api.hxx" + +/// @HTML + +namespace com::sun::star::xml::dom { + class XElement; +} +namespace dp_misc { class DescriptionInfoset; } + +namespace dp_misc { + +/** + Dependency handling. +*/ +namespace Dependencies { + /** + Check for unsatisfied dependencies. + + @param infoset + the infoset containing the dependencies to check + + @return + a list of the unsatisfied dependencies from <code>infoset</code> (in no + specific order) + */ + DESKTOP_DEPLOYMENTMISC_DLLPUBLIC css::uno::Sequence< + css::uno::Reference< css::xml::dom::XElement > > + check(dp_misc::DescriptionInfoset const & infoset); + + /** + Obtain the (human-readable) error message of a failed dependency. + + @param dependency + a dependency represented as a non-null XML element + + @return + the name of the dependency; will never be empty, as a localized + “unknown” is substituted for an empty/missing name + */ + DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getErrorText( + css::uno::Reference< css::xml::dom::XElement > + const & dependency); +} + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_descriptioninfoset.hxx b/desktop/source/deployment/inc/dp_descriptioninfoset.hxx new file mode 100644 index 000000000..b404751fc --- /dev/null +++ b/desktop/source/deployment/inc/dp_descriptioninfoset.hxx @@ -0,0 +1,288 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_DESCRIPTIONINFOSET_HXX +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_DESCRIPTIONINFOSET_HXX + +#include <sal/config.h> + +#include <optional> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <sal/types.h> +#include "dp_misc_api.hxx" + +/// @HTML + +namespace com::sun::star { + namespace uno { class XComponentContext; } + namespace xml { + namespace dom { + class XNode; + class XNodeList; + } + namespace xpath { class XXPathAPI; } + } +} + +namespace dp_misc { + +struct DESKTOP_DEPLOYMENTMISC_DLLPUBLIC SimpleLicenseAttributes +{ + OUString acceptBy; + //Attribute suppress-on-update. Default is false. + bool suppressOnUpdate; + //Attribute suppress-if-required. Default is false. + bool suppressIfRequired; +}; + + +/** + Access to the content of an XML <code>description</code> element. + + <p>This works for <code>description</code> elements in both the + <code>description.xml</code> file and online update information formats.</p> +*/ +class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC DescriptionInfoset { +public: + /** + Create an instance. + + @param context + a non-null component context + + @param element + a <code>description</code> element; may be null (equivalent to an element + with no content) + */ + DescriptionInfoset( + css::uno::Reference< css::uno::XComponentContext > const & context, + css::uno::Reference< css::xml::dom::XNode > const & element); + + ~DescriptionInfoset(); + + /** + Return the identifier. + + @return + the identifier, or an empty <code>optional</code> if none is specified + */ + ::std::optional< OUString > getIdentifier() const; + + /** + Return the textual version representation. + + @return + textual version representation + */ + OUString getVersion() const; + + /** + Returns a list of supported platforms. + + If the extension does not specify a platform by leaving out the platform element + then we assume that the extension supports all platforms. In this case the returned + sequence will have one element, which is "all". + If the platform element is present but does not specify a platform then an empty + sequence is returned. Examples for invalid platform elements: + <pre> + <platform />, <platform value="" />, <platform value=","> + </pre> + + The value attribute can contain various platform tokens. They must be separated by + commas.Each token will be stripped from leading and trailing white space (trim()). + */ + css::uno::Sequence< OUString > getSupportedPlatforms() const; + + /** + Returns the localized publisher name and the corresponding URL. + + In case there is no publisher element then a pair of two empty strings is returned. + */ + std::pair< OUString, OUString > getLocalizedPublisherNameAndURL() const; + + /** + Returns the URL for the release notes corresponding to the office's locale. + + In case there is no release-notes element then an empty string is returned. + */ + OUString getLocalizedReleaseNotesURL() const; + + /** returns the relative path to the license file. + + In case there is no simple-license element then an empty string is returned. + */ + OUString getLocalizedLicenseURL() const; + + /** returns the attributes of the simple-license element + + As long as there is a simple-license element, the function will return + the structure. If it does not exist, then the optional object is uninitialized. + */ + ::std::optional<SimpleLicenseAttributes> getSimpleLicenseAttributes() const; + + /** returns the localized display name of the extensions. + + In case there is no localized display-name then an empty string is returned. + */ + OUString getLocalizedDisplayName() const; + + /** + returns the download website URL from the update information. + + There can be multiple URLs where each is assigned to a particular locale. + The function returns the URL which locale matches best the one used in the office. + + The return value is an optional because it may be necessary to find out if there + was a value provided or not. This is necessary to flag the extension in the update dialog + properly as "browser based update". The return value will only then not be initialized + if there is no <code><update-website></code>. If the element exists, then it must + have at least one child element containing a URL. + + The <code><update-website></code> and <code><update-download></code> + elements are mutually exclusive. + + @return + the download website URL, or an empty <code>optional</code> if none is + specified + */ + ::std::optional< OUString > getLocalizedUpdateWebsiteURL() const; + + /** returns the relative URL to the description. + + The URL is relative to the root directory of the extensions. + */ + OUString getLocalizedDescriptionURL() const; + /** + Return the dependencies. + + @return + dependencies; will never be null + */ + css::uno::Reference< css::xml::dom::XNodeList > + getDependencies() const; + + /** + Return the update information URLs. + + @return + update information URLs + */ + css::uno::Sequence< OUString > getUpdateInformationUrls() const; + + /** + Return the download URLs from the update information. + + Because the <code><update-download></code> and the <code><update-website></code> + elements are mutually exclusive one may need to determine exactly if the element + was provided. + + @return + download URLs + */ + css::uno::Sequence< OUString > getUpdateDownloadUrls() const; + + /** + Returns the URL for the icon image. + */ + OUString getIconURL( bool bHighContrast ) const; + + bool hasDescription() const; + +private: + SAL_DLLPRIVATE ::std::optional< OUString > getOptionalValue( + OUString const & expression) const; + + SAL_DLLPRIVATE css::uno::Sequence< OUString > getUrls( + OUString const & expression) const; + + /** Retrieves a child element which as lang attribute which matches the office locale. + + Only top-level children are taken into account. It is also assumed that they are all + of the same element type and have a lang attribute. The matching algorithm is according + to RFC 3066, with the exception that only one variant is allowed. + @param parent + the expression used to obtain the parent of the localized children. It can be null. + Then a null reference is returned. + */ + SAL_DLLPRIVATE css::uno::Reference< css::xml::dom::XNode > + getLocalizedChild( OUString const & sParent) const; + SAL_DLLPRIVATE css::uno::Reference< css::xml::dom::XNode> + matchLanguageTag( + css::uno::Reference< css::xml::dom::XNode > const & xParent, + OUString const & rTag) const; + + /** If there is no child element with a locale matching the office locale, then we use + the first child. In the case of the simple-license we also use the former default locale, which + was determined by the default-license-id (/description/registration/simple-license/@default-license-id) + and the license-id attributes (/description/registration/simple-license/license-text/@license-id). + However, since OOo 2.4 we use also the first child as default for the license + unless the two attributes are present. + */ + SAL_DLLPRIVATE css::uno::Reference< css::xml::dom::XNode> + getChildWithDefaultLocale( + css::uno::Reference< css::xml::dom::XNode > const & xParent) const; + /** + @param out_bParentExists + indicates if the element node specified in sXPathParent exists. + */ + SAL_DLLPRIVATE OUString getLocalizedHREFAttrFromChild( + OUString const & sXPathParent, bool * out_bParentExists) const; + + /** Gets the node value for a given expression. The expression is used in + m_xpath-selectSingleNode. The value of the returned node is return value + of this function. + */ + SAL_DLLPRIVATE OUString + getNodeValueFromExpression(OUString const & expression) const; + + /** Check the extensions blacklist if additional extension meta data (e.g. dependencies) + are defined for this extension and have to be taken into account. + */ + SAL_DLLPRIVATE void + checkBlacklist() const; + + /** Helper method to compare the versions with the current version + */ + SAL_DLLPRIVATE static bool + checkBlacklistVersion(const OUString& currentversion, + css::uno::Sequence< OUString > const & versions); + + css::uno::Reference< css::uno::XComponentContext > m_context; + css::uno::Reference< css::xml::dom::XNode > m_element; + css::uno::Reference< css::xml::xpath::XXPathAPI > m_xpath; +}; + +inline bool DescriptionInfoset::hasDescription() const +{ + return m_element.is(); +} + +/** creates a DescriptionInfoset object. + + The argument sExtensionFolderURL is a file URL to extension folder containing + the description.xml. + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +DescriptionInfoset getDescriptionInfoset(OUString const & sExtensionFolderURL); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_identifier.hxx b/desktop/source/deployment/inc/dp_identifier.hxx new file mode 100644 index 000000000..5d766d5b2 --- /dev/null +++ b/desktop/source/deployment/inc/dp_identifier.hxx @@ -0,0 +1,85 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_IDENTIFIER_HXX +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_IDENTIFIER_HXX + +#include <sal/config.h> + +#include <optional> +#include <com/sun/star/uno/Reference.hxx> + +#include "dp_misc_api.hxx" + +namespace com::sun::star::deployment { + class XPackage; +} + +namespace dp_misc { + +/** + Generates an identifier from an optional identifier. + + @param optional + an optional identifier + + @param fileName + a file name + + @return + the given optional identifier if present, otherwise a legacy identifier based + on the given file name +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString generateIdentifier( + ::std::optional< OUString > const & optional, + OUString const & fileName); + +/** + Gets the identifier of a package. + + @param package + a non-null package + + @return + the explicit identifier of the given package if present, otherwise the + implicit legacy identifier of the given package + + @throws css::uno::RuntimeException +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getIdentifier( + css::uno::Reference< css::deployment::XPackage > + const & package); + +/** + Generates a legacy identifier based on a file name. + + @param fileName + a file name + + @return + a legacy identifier based on the given file name +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString generateLegacyIdentifier( + OUString const & fileName); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_interact.h b/desktop/source/deployment/inc/dp_interact.h new file mode 100644 index 000000000..a908af3b5 --- /dev/null +++ b/desktop/source/deployment/inc/dp_interact.h @@ -0,0 +1,142 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_INTERACT_H +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_INTERACT_H + +#include <config_options.h> +#include <rtl/ref.hxx> +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/ucb/XCommandEnvironment.hpp> +#include <com/sun/star/task/XAbortChannel.hpp> +#include "dp_misc_api.hxx" + +namespace dp_misc +{ + +inline void progressUpdate( + OUString const & status, + css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) +{ + if (xCmdEnv.is()) { + css::uno::Reference<css::ucb::XProgressHandler> xProgressHandler( + xCmdEnv->getProgressHandler() ); + if (xProgressHandler.is()) { + xProgressHandler->update( css::uno::makeAny(status) ); + } + } +} + + +class ProgressLevel +{ + css::uno::Reference<css::ucb::XProgressHandler> m_xProgressHandler; + +public: + inline ~ProgressLevel(); + inline ProgressLevel( + css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv, + OUString const & status ); + + inline void update( OUString const & status ) const; + inline void update( css::uno::Any const & status ) const; +}; + + +inline ProgressLevel::ProgressLevel( + css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv, + OUString const & status ) +{ + if (xCmdEnv.is()) + m_xProgressHandler = xCmdEnv->getProgressHandler(); + if (m_xProgressHandler.is()) + m_xProgressHandler->push( css::uno::makeAny(status) ); +} + + +inline ProgressLevel::~ProgressLevel() +{ + if (m_xProgressHandler.is()) + m_xProgressHandler->pop(); +} + + +inline void ProgressLevel::update( OUString const & status ) const +{ + if (m_xProgressHandler.is()) + m_xProgressHandler->update( css::uno::makeAny(status) ); +} + + +inline void ProgressLevel::update( css::uno::Any const & status ) const +{ + if (m_xProgressHandler.is()) + m_xProgressHandler->update( status ); +} + + + +/** @return true if ia handler is present and any selection has been chosen + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool interactContinuation( + css::uno::Any const & request, + css::uno::Type const & continuation, + css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv, + bool * pcont, bool * pabort ); + + + + +class UNLESS_MERGELIBS(DESKTOP_DEPLOYMENTMISC_DLLPUBLIC) AbortChannel : + public ::cppu::WeakImplHelper<css::task::XAbortChannel> +{ + bool m_aborted; + css::uno::Reference<css::task::XAbortChannel> m_xNext; + +public: + AbortChannel() : m_aborted( false ) {} + static AbortChannel * get( + css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel ) + { return static_cast<AbortChannel *>(xAbortChannel.get()); } + + bool isAborted() const { return m_aborted; } + + // XAbortChannel + virtual void SAL_CALL sendAbort() override; + + class SAL_DLLPRIVATE Chain + { + const ::rtl::Reference<AbortChannel> m_abortChannel; + public: + Chain( + ::rtl::Reference<AbortChannel> const & abortChannel, + css::uno::Reference<css::task::XAbortChannel> const & xNext ) + : m_abortChannel( abortChannel ) + { if (m_abortChannel.is()) m_abortChannel->m_xNext = xNext; } + ~Chain() + { if (m_abortChannel.is()) m_abortChannel->m_xNext.clear(); } + }; + friend class Chain; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_misc_api.hxx b/desktop/source/deployment/inc/dp_misc_api.hxx new file mode 100644 index 000000000..0f4d1b469 --- /dev/null +++ b/desktop/source/deployment/inc/dp_misc_api.hxx @@ -0,0 +1,34 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_MISC_API_HXX +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_MISC_API_HXX + +#include <sal/config.h> +#include <sal/types.h> + +#if defined DESKTOP_DEPLOYMENTMISC_DLLIMPLEMENTATION +#define DESKTOP_DEPLOYMENTMISC_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define DESKTOP_DEPLOYMENTMISC_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_package.hxx b/desktop/source/deployment/inc/dp_package.hxx new file mode 100644 index 000000000..cf788c40b --- /dev/null +++ b/desktop/source/deployment/inc/dp_package.hxx @@ -0,0 +1,45 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_PACKAGE_HXX +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_PACKAGE_HXX + +#include <sal/config.h> + +#include <com/sun/star/uno/Reference.hxx> +#include <rtl/ustring.hxx> + +namespace com::sun::star { + namespace deployment { class XPackageRegistry; } + namespace uno { class XComponentContext; } +} + +namespace dp_registry::backend::bundle { + +css::uno::Reference<css::deployment::XPackageRegistry> create( + css::uno::Reference<css::deployment::XPackageRegistry> const & + xRootRegistry, + OUString const & context, OUString const & cachePath, + css::uno::Reference<css::uno::XComponentContext> const & xComponentContext); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_persmap.h b/desktop/source/deployment/inc/dp_persmap.h new file mode 100644 index 000000000..c42841c83 --- /dev/null +++ b/desktop/source/deployment/inc/dp_persmap.h @@ -0,0 +1,66 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_PERSMAP_H +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_PERSMAP_H + +#include <rtl/ustring.hxx> +#include <osl/file.hxx> +#include <unordered_map> + +namespace dp_misc +{ + +typedef std::unordered_map< + OString, OString > t_string2string_map; + +// Class to read obsolete registered extensions +// should be removed for LibreOffice 4.0 +class PersistentMap final +{ + ::osl::File m_MapFile; + t_string2string_map m_entries; + bool m_bIsOpen; + bool m_bToBeCreated; + bool m_bIsDirty; + +public: + ~PersistentMap(); + PersistentMap( OUString const & url ); + /** in mem db */ + PersistentMap(); + + bool has( OString const & key ) const; + bool get( OString * value, OString const & key ) const; + const t_string2string_map& getEntries() const { return m_entries; } + void put( OString const & key, OString const & value ); + bool erase( OString const & key ); + +private: + void open(); + void readAll(); + void add( OString const & key, OString const & value ); + void flush(); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_platform.hxx b/desktop/source/deployment/inc/dp_platform.hxx new file mode 100644 index 000000000..43c7ad8c5 --- /dev/null +++ b/desktop/source/deployment/inc/dp_platform.hxx @@ -0,0 +1,48 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_PLATFORM_HXX +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_PLATFORM_HXX + + +#include "dp_misc_api.hxx" + +#include <com/sun/star/uno/Sequence.hxx> +#include <rtl/ustring.hxx> + +namespace dp_misc +{ + + +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString const & getPlatformString(); + +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC + bool platform_fits( OUString const & platform_string ); + +/** determines if the current platform corresponds to one of the platform strings. + +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +bool hasValidPlatform( css::uno::Sequence< OUString > const & platformStrings); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_registry.hxx b/desktop/source/deployment/inc/dp_registry.hxx new file mode 100644 index 000000000..d58ec9a59 --- /dev/null +++ b/desktop/source/deployment/inc/dp_registry.hxx @@ -0,0 +1,43 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_REGISTRY_HXX +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_REGISTRY_HXX + +#include <sal/config.h> + +#include <com/sun/star/uno/Reference.hxx> +#include <rtl/ustring.hxx> + +namespace com::sun::star { + namespace deployment { class XPackageRegistry; } + namespace uno { class XComponentContext; } +} + +namespace dp_registry { + +css::uno::Reference<css::deployment::XPackageRegistry> create( + OUString const & context, OUString const & cachePath, + css::uno::Reference<css::uno::XComponentContext> const & xComponentContext); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_resource.h b/desktop/source/deployment/inc/dp_resource.h new file mode 100644 index 000000000..f7840819c --- /dev/null +++ b/desktop/source/deployment/inc/dp_resource.h @@ -0,0 +1,34 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_RESOURCE_H +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_RESOURCE_H + +#include <i18nlangtag/languagetag.hxx> +#include "dp_misc_api.hxx" + +namespace dp_misc { + +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC const LanguageTag & getOfficeLanguageTag(); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_services.hxx b/desktop/source/deployment/inc/dp_services.hxx new file mode 100644 index 000000000..f40f908de --- /dev/null +++ b/desktop/source/deployment/inc/dp_services.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_SERVICES_HXX +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_SERVICES_HXX + +#include <sal/config.h> + +namespace comphelper::service_decl { class ServiceDecl; } + +namespace dp_info { +extern comphelper::service_decl::ServiceDecl const serviceDecl; +} + +namespace dp_log { +extern comphelper::service_decl::ServiceDecl const serviceDecl; +} + +namespace dp_manager { + +namespace factory { +extern comphelper::service_decl::ServiceDecl const serviceDecl; +} + +extern comphelper::service_decl::ServiceDecl const serviceDecl; + +} + +namespace dp_registry::backend { + +namespace component { +extern comphelper::service_decl::ServiceDecl const serviceDecl; +} + +namespace configuration { +extern comphelper::service_decl::ServiceDecl const serviceDecl; +} + +namespace executable { +extern comphelper::service_decl::ServiceDecl const serviceDecl; +} + +namespace help { +extern comphelper::service_decl::ServiceDecl const serviceDecl; +} + +namespace script { +extern comphelper::service_decl::ServiceDecl const serviceDecl; +} + +namespace sfwk { +extern comphelper::service_decl::ServiceDecl const serviceDecl; +} + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/desktop/source/deployment/inc/dp_ucb.h b/desktop/source/deployment/inc/dp_ucb.h new file mode 100644 index 000000000..abfad2992 --- /dev/null +++ b/desktop/source/deployment/inc/dp_ucb.h @@ -0,0 +1,97 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_UCB_H +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_UCB_H + +#include <vector> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/ucb/XCommandEnvironment.hpp> +#include "dp_misc_api.hxx" +#include <ucbhelper/content.hxx> + +namespace ucbhelper +{ +class Content; +} + +namespace dp_misc { + +struct DESKTOP_DEPLOYMENTMISC_DLLPUBLIC StrTitle +{ + static css::uno::Sequence< OUString > getTitleSequence() + { + css::uno::Sequence<OUString> aSeq { "Title" }; + return aSeq; + } + static OUString getTitle( ::ucbhelper::Content &rContent ) + { + return rContent.getPropertyValue("Title").get<OUString>(); + } + // just return titles - the ucbhelper should have a simpler API for this [!] + static css::uno::Reference< css::sdbc::XResultSet > + createCursor( ::ucbhelper::Content &rContent, + ucbhelper::ResultSetInclude eInclude ) + { + return rContent.createCursor( StrTitle::getTitleSequence(), eInclude ); + } +}; + + +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool create_ucb_content( + ::ucbhelper::Content * ucb_content, + OUString const & url, + css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv, + bool throw_exc = true ); + + +/** @return true if previously non-existing folder has been created + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool create_folder( + ::ucbhelper::Content * ucb_content, + OUString const & url, + css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv, + bool throw_exc = true ); + + +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool erase_path( + OUString const & url, + css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv, + bool throw_exc = true ); + + +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +std::vector<sal_Int8> readFile( ::ucbhelper::Content & ucb_content ); + + +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +bool readLine( OUString * res, OUString const & startingWith, + ::ucbhelper::Content & ucb_content, rtl_TextEncoding textenc ); + +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +bool readProperties( std::vector< std::pair< OUString, OUString> > & out_result, + ::ucbhelper::Content & ucb_content); + + + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_update.hxx b/desktop/source/deployment/inc/dp_update.hxx new file mode 100644 index 000000000..c0e5bb2c0 --- /dev/null +++ b/desktop/source/deployment/inc/dp_update.hxx @@ -0,0 +1,139 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_UPDATE_HXX +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_UPDATE_HXX + + +#include <com/sun/star/deployment/XPackage.hpp> +#include <com/sun/star/deployment/XExtensionManager.hpp> +#include <com/sun/star/deployment/XUpdateInformationProvider.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/xml/dom/XNode.hpp> + +#include "dp_misc_api.hxx" + +#include <map> +#include <vector> + +namespace dp_misc { + +/** returns the default update URL (for the update information) which + is used when an extension does not provide its own URL. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +OUString getExtensionDefaultUpdateURL(); + +enum UPDATE_SOURCE +{ + UPDATE_SOURCE_NONE, + UPDATE_SOURCE_SHARED, + UPDATE_SOURCE_BUNDLED, + UPDATE_SOURCE_ONLINE +}; + +/* determine if an update is available which is installed in the + user repository. + + If the return value is UPDATE_SOURCE_NONE, then no update is + available, otherwise the return value determine from which the + repository the update is used. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UPDATE_SOURCE isUpdateUserExtension( + bool bReadOnlyShared, + OUString const & userVersion, + OUString const & sharedVersion, + OUString const & bundledVersion, + OUString const & onlineVersion); + +/* determine if an update is available which is installed in the + shared repository. + + If the return value is UPDATE_SOURCE_NONE, then no update is + available, otherwise the return value determine from which the + repository the update is used. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UPDATE_SOURCE isUpdateSharedExtension( + bool bReadOnlyShared, + OUString const & sharedVersion, + OUString const & bundledVersion, + OUString const & onlineVersion); + +/* determines the extension with the highest identifier and returns it + + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +css::uno::Reference< css::deployment::XPackage> +getExtensionWithHighestVersion( + css::uno::Sequence< + css::uno::Reference< + css::deployment::XPackage> > const & seqExtensionsWithSameId); + + +struct UpdateInfo +{ + UpdateInfo( css::uno::Reference< css::deployment::XPackage> const & ext); + + css::uno::Reference< css::deployment::XPackage> extension; + //version of the update + OUString version; + css::uno::Reference< css::xml::dom::XNode > info; +}; + +typedef std::map< OUString, UpdateInfo > UpdateInfoMap; + +/* + @param extensionList + List of extension for which online update information is to be obtained. If NULL, then + for update information is obtained for all installed extension. There may be only one extension + with a particular identifier contained in the list. If one extension is installed + in several repositories, then the one with the highest version must be used, because it contains + the more recent URLs for getting the update information (if at all). + @param out_errors + the first member of the pair is the extension and the second the exception that was produced + when processing the extension. + + @return + A map of UpdateInfo instances. If the parameter extensionList was given, then the map contains + at only information for those extensions. + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UpdateInfoMap getOnlineUpdateInfos( + css::uno::Reference< css::uno::XComponentContext> const &xContext, + css::uno::Reference< css::deployment::XExtensionManager> const & xExtMgr, + css::uno::Reference< css::deployment::XUpdateInformationProvider > const & updateInformation, + std::vector< css::uno::Reference< css::deployment::XPackage > > const * extensionList, + std::vector< std::pair< css::uno::Reference< + css::deployment::XPackage>, css::uno::Any> > & out_errors); + +/* returns the highest version from the provided arguments. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +OUString getHighestVersion( + OUString const & sharedVersion, + OUString const & bundledVersion, + OUString const & onlineVersion); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_version.hxx b/desktop/source/deployment/inc/dp_version.hxx new file mode 100644 index 000000000..a74f5fdca --- /dev/null +++ b/desktop/source/deployment/inc/dp_version.hxx @@ -0,0 +1,39 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_VERSION_HXX +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_VERSION_HXX + +#include <sal/config.h> + +#include <rtl/ustring.hxx> +#include "dp_misc_api.hxx" + + +namespace dp_misc { + +enum Order { LESS, EQUAL, GREATER }; + +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Order compareVersions( + OUString const & version1, OUString const & version2); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/dp_xml.h b/desktop/source/deployment/inc/dp_xml.h new file mode 100644 index 000000000..1831e2b32 --- /dev/null +++ b/desktop/source/deployment/inc/dp_xml.h @@ -0,0 +1,45 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_XML_H +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_XML_H + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> + + +namespace ucbhelper +{ +class Content; +} + +namespace dp_misc +{ + + +void xml_parse( + css::uno::Reference< css::xml::sax::XDocumentHandler > const & xDocHandler, + ::ucbhelper::Content & ucb_content, + css::uno::Reference< css::uno::XComponentContext > const & xContext ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/deployment/inc/lockfile.hxx b/desktop/source/deployment/inc/lockfile.hxx new file mode 100644 index 000000000..18a0f1a62 --- /dev/null +++ b/desktop/source/deployment/inc/lockfile.hxx @@ -0,0 +1,92 @@ +/* -*- 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 . + */ + +/* Information: + * This class implements a mechanism to lock a users installation directory, + * which is necessary because instances of staroffice could be running on + * different hosts while using the same directory thus causing data + * inconsistency. + * When an existing lock is detected, the user will be asked whether he wants + * to continue anyway, thus removing the lock and replacing it with a new one + * + * ideas: + * - store information about user and host and time in the lockfile and display + * these when asking whether to remove the lockfile. + * - periodically check the lockfile and warn the user when it gets replaced + * + */ + +#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_LOCKFILE_HXX +#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_LOCKFILE_HXX + +#include <rtl/ustring.hxx> + +#include "dp_misc_api.hxx" + +#define LOCKFILE_GROUP "Lockdata" +#define LOCKFILE_USERKEY "User" +#define LOCKFILE_HOSTKEY "Host" +#define LOCKFILE_STAMPKEY "Stamp" +#define LOCKFILE_TIMEKEY "Time" +#define LOCKFILE_IPCKEY "IPCServer" + +namespace desktop { + + class Lockfile; + bool Lockfile_execWarning( Lockfile const * that ); + + class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Lockfile + { + public: + + // constructs a new lockfile object + Lockfile( bool bIPCserver = true ); + + // separating GUI code: + typedef bool (* fpExecWarning)( Lockfile const * that ); + + // checks the lockfile, asks user when lockfile is + // found (iff gui) and returns false when we may not continue + bool check( fpExecWarning execWarning ); + + // removes the lockfile + ~Lockfile(); + + private: + bool m_bIPCserver; + // full qualified name (file://-url) of the lockfile + OUString m_aLockname; + // flag whether the d'tor should delete the lock + bool m_bRemove; + bool m_bIsLocked; + // ID + OUString m_aId; + OUString m_aDate; + // access to data in file + void syncToFile() const; + bool isStale() const; + friend bool Lockfile_execWarning( Lockfile const * that ); + + }; + +} + +#endif // INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_LOCKFILE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |