summaryrefslogtreecommitdiff
path: root/desktop/source/deployment/manager
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/source/deployment/manager')
-rw-r--r--desktop/source/deployment/manager/dp_activepackages.cxx28
-rw-r--r--desktop/source/deployment/manager/dp_activepackages.hxx19
-rw-r--r--desktop/source/deployment/manager/dp_commandenvironments.cxx286
-rw-r--r--desktop/source/deployment/manager/dp_commandenvironments.hxx160
-rw-r--r--desktop/source/deployment/manager/dp_extensionmanager.cxx1361
-rw-r--r--desktop/source/deployment/manager/dp_extensionmanager.hxx307
-rw-r--r--desktop/source/deployment/manager/dp_informationprovider.cxx380
-rw-r--r--desktop/source/deployment/manager/dp_manager.cxx909
-rw-r--r--desktop/source/deployment/manager/dp_manager.h69
-rw-r--r--desktop/source/deployment/manager/dp_manager.hrc2
-rw-r--r--desktop/source/deployment/manager/dp_manager.src4
-rw-r--r--desktop/source/deployment/manager/dp_managerfac.cxx4
-rw-r--r--desktop/source/deployment/manager/dp_properties.cxx169
-rw-r--r--desktop/source/deployment/manager/dp_properties.hxx81
-rw-r--r--desktop/source/deployment/manager/makefile.mk5
15 files changed, 3255 insertions, 529 deletions
diff --git a/desktop/source/deployment/manager/dp_activepackages.cxx b/desktop/source/deployment/manager/dp_activepackages.cxx
index 04dc22b77a77..8f6b6b82c0b7 100644
--- a/desktop/source/deployment/manager/dp_activepackages.cxx
+++ b/desktop/source/deployment/manager/dp_activepackages.cxx
@@ -96,9 +96,27 @@ static char const legacyPrefix[] = "org.openoffice.legacy.";
OSL_ASSERT(i2 >= 0);
d.fileName = ::rtl::OUString(
value.getStr() + i1 + 1, i2 - i1 - 1, RTL_TEXTENCODING_UTF8);
- d.mediaType = ::rtl::OUString(
- value.getStr() + i2 + 1, value.getLength() - i2 - 1,
- RTL_TEXTENCODING_UTF8);
+ sal_Int32 i3 = value.indexOf(separator, i2 + 1);
+
+ if (i3 < 0)
+ {
+ //Before ActivePackages::Data::version was added
+ d.mediaType = ::rtl::OUString(
+ value.getStr() + i2 + 1, value.getLength() - i2 - 1,
+ RTL_TEXTENCODING_UTF8);
+ }
+ else
+ {
+ sal_Int32 i4 = value.indexOf(separator, i3 + 1);
+ d.mediaType = ::rtl::OUString(
+ value.getStr() + i2 + 1, i3 - i2 -1, RTL_TEXTENCODING_UTF8);
+ d.version = ::rtl::OUString(
+ value.getStr() + i3 + 1, i4 - i3 - 1,
+ RTL_TEXTENCODING_UTF8);
+ d.failedPrerequisites = ::rtl::OUString(
+ value.getStr() + i4 + 1, value.getLength() - i4 - 1,
+ RTL_TEXTENCODING_UTF8);
+ }
return d;
}
@@ -172,6 +190,10 @@ void ActivePackages::put(::rtl::OUString const & id, Data const & data) {
b.append(::rtl::OUStringToOString(data.fileName, RTL_TEXTENCODING_UTF8));
b.append(separator);
b.append(::rtl::OUStringToOString(data.mediaType, RTL_TEXTENCODING_UTF8));
+ b.append(separator);
+ b.append(::rtl::OUStringToOString(data.version, RTL_TEXTENCODING_UTF8));
+ b.append(separator);
+ b.append(::rtl::OUStringToOString(data.failedPrerequisites, RTL_TEXTENCODING_UTF8));
m_map.put(newKey(id), b.makeStringAndClear());
}
diff --git a/desktop/source/deployment/manager/dp_activepackages.hxx b/desktop/source/deployment/manager/dp_activepackages.hxx
index 1c58f76be245..7d9c7e32cfb4 100644
--- a/desktop/source/deployment/manager/dp_activepackages.hxx
+++ b/desktop/source/deployment/manager/dp_activepackages.hxx
@@ -42,9 +42,28 @@ namespace dp_manager {
class ActivePackages {
public:
struct Data {
+ Data(): failedPrerequisites(::rtl::OUString::valueOf((sal_Int32)0))
+ {}
+ /* name of the temporary file (shared, user extension) or the name of
+ the folder of the bundled extension.
+ It does not contain the trailing '_' of the folder.
+ UTF-8 encoded
+ */
::rtl::OUString temporaryName;
+ /* The file name (shared, user) or the folder name (bundled)
+ If the key is the file name, then file name is not encoded.
+ If the key is the idendifier then the file name is UTF-8 encoded.
+ */
::rtl::OUString fileName;
::rtl::OUString mediaType;
+ ::rtl::OUString version;
+ /* If this string contains the value according to
+ com::sun::star::deployment::Prerequisites or "0". That is, if
+ the value is > 0 then
+ the call to XPackage::checkPrerequisites failed.
+ In this case the extension must not be registered.
+ */
+ ::rtl::OUString failedPrerequisites;
};
typedef ::std::vector< ::std::pair< ::rtl::OUString, Data > > Entries;
diff --git a/desktop/source/deployment/manager/dp_commandenvironments.cxx b/desktop/source/deployment/manager/dp_commandenvironments.cxx
new file mode 100644
index 000000000000..c2801ba1d965
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_commandenvironments.cxx
@@ -0,0 +1,286 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_desktop.hxx"
+
+#include "com/sun/star/deployment/VersionException.hpp"
+#include "com/sun/star/deployment/LicenseException.hpp"
+#include "com/sun/star/deployment/InstallException.hpp"
+#include "com/sun/star/task/XInteractionApprove.hpp"
+#include "com/sun/star/task/XInteractionAbort.hpp"
+#include "com/sun/star/task/XInteractionHandler.hpp"
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "dp_commandenvironments.hxx"
+
+namespace deployment = com::sun::star::deployment;
+namespace lang = com::sun::star::lang;
+namespace task = com::sun::star::task;
+namespace ucb = com::sun::star::ucb;
+namespace uno = com::sun::star::uno;
+namespace css = com::sun::star;
+
+#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+using ::com::sun::star::uno::Reference;
+using ::rtl::OUString;
+
+namespace dp_manager {
+
+BaseCommandEnv::BaseCommandEnv()
+{
+}
+
+BaseCommandEnv::BaseCommandEnv(
+ Reference< task::XInteractionHandler> const & handler)
+ : m_forwardHandler(handler)
+{
+}
+
+BaseCommandEnv::~BaseCommandEnv()
+{
+}
+// XCommandEnvironment
+//______________________________________________________________________________
+Reference<task::XInteractionHandler> BaseCommandEnv::getInteractionHandler()
+throw (uno::RuntimeException)
+{
+ return this;
+}
+
+//______________________________________________________________________________
+Reference<ucb::XProgressHandler> BaseCommandEnv::getProgressHandler()
+throw (uno::RuntimeException)
+{
+ return this;
+}
+
+void BaseCommandEnv::handle(
+ Reference< task::XInteractionRequest> const & /*xRequest*/ )
+ throw (uno::RuntimeException)
+{
+}
+
+void BaseCommandEnv::handle_(bool approve, bool abort,
+ Reference< task::XInteractionRequest> const & xRequest )
+{
+ if (approve == false && abort == false)
+ {
+ //not handled so far -> forwarding
+ if (m_forwardHandler.is())
+ m_forwardHandler->handle(xRequest);
+ else
+ return; //cannot handle
+ }
+ else
+ {
+ // select:
+ uno::Sequence< Reference< task::XInteractionContinuation > > conts(
+ xRequest->getContinuations() );
+ Reference< task::XInteractionContinuation > const * pConts =
+ conts.getConstArray();
+ sal_Int32 len = conts.getLength();
+ for ( sal_Int32 pos = 0; pos < len; ++pos )
+ {
+ if (approve) {
+ Reference< task::XInteractionApprove > xInteractionApprove(
+ pConts[ pos ], uno::UNO_QUERY );
+ if (xInteractionApprove.is()) {
+ xInteractionApprove->select();
+ // don't query again for ongoing continuations:
+ approve = false;
+ }
+ }
+ else if (abort) {
+ Reference< task::XInteractionAbort > xInteractionAbort(
+ pConts[ pos ], uno::UNO_QUERY );
+ if (xInteractionAbort.is()) {
+ xInteractionAbort->select();
+ // don't query again for ongoing continuations:
+ abort = false;
+ }
+ }
+ }
+ }
+
+}
+
+// XProgressHandler
+void BaseCommandEnv::push( uno::Any const & /*Status*/ )
+throw (uno::RuntimeException)
+{
+}
+
+
+void BaseCommandEnv::update( uno::Any const & /*Status */)
+throw (uno::RuntimeException)
+{
+}
+
+void BaseCommandEnv::pop() throw (uno::RuntimeException)
+{
+}
+//==============================================================================
+
+TmpRepositoryCommandEnv::TmpRepositoryCommandEnv()
+{
+}
+
+TmpRepositoryCommandEnv::TmpRepositoryCommandEnv(
+ css::uno::Reference< css::task::XInteractionHandler> const & handler):
+ BaseCommandEnv(handler)
+{
+}
+// XInteractionHandler
+void TmpRepositoryCommandEnv::handle(
+ Reference< task::XInteractionRequest> const & xRequest )
+ throw (uno::RuntimeException)
+{
+ uno::Any request( xRequest->getRequest() );
+ OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
+
+ deployment::VersionException verExc;
+ deployment::LicenseException licExc;
+ deployment::InstallException instExc;
+
+ bool approve = false;
+ bool abort = false;
+
+ if ((request >>= verExc)
+ || (request >>= licExc)
+ || (request >>= instExc))
+ {
+ approve = true;
+ }
+
+ handle_(approve, abort, xRequest);
+}
+//================================================================================
+
+LicenseCommandEnv::LicenseCommandEnv(
+ css::uno::Reference< css::task::XInteractionHandler> const & handler,
+ bool bSuppressLicense,
+ OUString const & repository):
+ BaseCommandEnv(handler), m_repository(repository),
+ m_bSuppressLicense(bSuppressLicense)
+{
+}
+// XInteractionHandler
+void LicenseCommandEnv::handle(
+ Reference< task::XInteractionRequest> const & xRequest )
+ throw (uno::RuntimeException)
+{
+ uno::Any request( xRequest->getRequest() );
+ OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
+
+
+ deployment::LicenseException licExc;
+
+ bool approve = false;
+ bool abort = false;
+
+ if (request >>= licExc)
+ {
+ if (m_bSuppressLicense
+ || m_repository.equals(OUSTR("bundled"))
+ || licExc.AcceptBy.equals(OUSTR("admin")))
+ {
+ //always approve in bundled case, because we do not support
+ //showing licenses anyway.
+ //The "admin" already accepted the license when installing the
+ // shared extension
+ approve = true;
+ }
+ }
+
+ handle_(approve, abort, xRequest);
+}
+
+//================================================================================
+//================================================================================
+
+NoLicenseCommandEnv::NoLicenseCommandEnv(
+ css::uno::Reference< css::task::XInteractionHandler> const & handler):
+ BaseCommandEnv(handler)
+{
+}
+// XInteractionHandler
+void NoLicenseCommandEnv::handle(
+ Reference< task::XInteractionRequest> const & xRequest )
+ throw (uno::RuntimeException)
+{
+ uno::Any request( xRequest->getRequest() );
+ OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
+
+
+ deployment::LicenseException licExc;
+
+ bool approve = false;
+ bool abort = false;
+
+ if (request >>= licExc)
+ {
+ approve = true;
+ }
+ handle_(approve, abort, xRequest);
+}
+
+
+// NoExceptionCommandEnv::NoExceptionCommandEnv(
+// css::uno::Reference< css::task::XInteractionHandler> const & handler,
+// css::uno::Type const & type):
+// BaseCommandEnv(handler),
+// m_type(type)
+// {
+// }
+// // XInteractionHandler
+// void NoExceptionCommandEnv::handle(
+// Reference< task::XInteractionRequest> const & xRequest )
+// throw (uno::RuntimeException)
+// {
+// uno::Any request( xRequest->getRequest() );
+// OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
+
+
+// deployment::LicenseException licExc;
+
+// bool approve = false;
+// bool abort = false;
+
+// if (request.getValueType() == m_type)
+// {
+// approve = true;
+// }
+// handle_(approve, abort, xRequest);
+// }
+
+
+
+} // namespace dp_manager
+
+
diff --git a/desktop/source/deployment/manager/dp_commandenvironments.hxx b/desktop/source/deployment/manager/dp_commandenvironments.hxx
new file mode 100644
index 000000000000..aa21f8281c72
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_commandenvironments.hxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_COMMANDENVIRONMENTS_HXX
+#define INCLUDED_DP_COMMANDENVIRONMENTS_HXX
+
+
+#include "cppuhelper/compbase3.hxx"
+//#include "cppuhelper/implbase2.hxx"
+#include "ucbhelper/content.hxx"
+#include "com/sun/star/uno/Type.hxx"
+
+
+namespace css = ::com::sun::star;
+
+namespace dp_manager {
+
+
+
+/**
+ This command environment is to be used when an extension is temporarily
+ stored in the "tmp" repository. It prevents all kind of user interaction.
+ */
+class BaseCommandEnv
+ : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment,
+ css::task::XInteractionHandler,
+ css::ucb::XProgressHandler >
+{
+protected:
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+ css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler;
+
+ void handle_(bool approve, bool abort,
+ css::uno::Reference< css::task::XInteractionRequest> const & xRequest );
+public:
+ virtual ~BaseCommandEnv();
+ BaseCommandEnv();
+ BaseCommandEnv(
+ css::uno::Reference< css::task::XInteractionHandler> const & handler);
+
+ // XCommandEnvironment
+ virtual css::uno::Reference<css::task::XInteractionHandler > SAL_CALL
+ getInteractionHandler() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference<css::ucb::XProgressHandler >
+ SAL_CALL getProgressHandler() throw (css::uno::RuntimeException);
+
+ // XInteractionHandler
+ virtual void SAL_CALL handle(
+ css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
+ throw (css::uno::RuntimeException);
+
+ // XProgressHandler
+ virtual void SAL_CALL push( css::uno::Any const & Status )
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL update( css::uno::Any const & Status )
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL pop() throw (css::uno::RuntimeException);
+};
+
+class TmpRepositoryCommandEnv : public BaseCommandEnv
+{
+public:
+ TmpRepositoryCommandEnv();
+ TmpRepositoryCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler);
+
+// XInteractionHandler
+ virtual void SAL_CALL handle(
+ css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
+ throw (css::uno::RuntimeException);
+
+};
+
+/** this class is for use in XPackageManager::synchronize.
+
+ It handles particular license cases.
+ */
+class LicenseCommandEnv : public BaseCommandEnv
+{
+private:
+ ::rtl::OUString m_repository;
+ bool m_bSuppressLicense;
+public:
+ LicenseCommandEnv(){};
+ LicenseCommandEnv(
+ css::uno::Reference< css::task::XInteractionHandler> const & handler,
+ bool bSuppressLicense,
+ ::rtl::OUString const & repository);
+
+// XInteractionHandler
+ virtual void SAL_CALL handle(
+ css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
+ throw (css::uno::RuntimeException);
+
+};
+
+/** this class is for use in XPackageManager::checkPrerequisites
+
+ It always prohibits a license interaction
+ */
+class NoLicenseCommandEnv : public BaseCommandEnv
+{
+
+public:
+ NoLicenseCommandEnv(){};
+ NoLicenseCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler);
+
+// XInteractionHandler
+ virtual void SAL_CALL handle(
+ css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
+ throw (css::uno::RuntimeException);
+
+};
+
+// class NoExceptionCommandEnv : public BaseCommandEnv
+// {
+// css::uno::Type m_type;
+// public:
+// NoExceptionCommandEnv::NoExceptionCommandEnv(){};
+// NoExceptionCommandEnv::NoExceptionCommandEnv(
+// css::uno::Reference< css::task::XInteractionHandler> const & handler,
+// css::uno::Type const & type);
+
+// // XInteractionHandler
+// virtual void SAL_CALL handle(
+// css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
+// throw (css::uno::RuntimeException);
+
+// };
+
+}
+
+
+
+
+#endif
+
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx
new file mode 100644
index 000000000000..de9d97db2b48
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx
@@ -0,0 +1,1361 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_desktop.hxx"
+
+#include <cppuhelper/implbase1.hxx>
+
+#include "comphelper/servicedecl.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+#include "rtl/bootstrap.hxx"
+#include "com/sun/star/deployment/ExtensionManager.hpp"
+#include "com/sun/star/deployment/XExtensionManager.hpp"
+#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
+#include "com/sun/star/deployment/XPackageManager.hpp"
+#include "com/sun/star/deployment/XPackageManagerFactory.hpp"
+#include "com/sun/star/deployment/XPackage.hpp"
+#include "com/sun/star/deployment/InstallException.hpp"
+#include "com/sun/star/deployment/VersionException.hpp"
+#include "com/sun/star/deployment/LicenseException.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/registry/XRegistryKey.hpp"
+#include "com/sun/star/beans/Optional.hpp"
+#include "com/sun/star/task/XInteractionApprove.hpp"
+#include "com/sun/star/beans/Ambiguous.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/io/XInputStream.hpp"
+#include "com/sun/star/util/XModifyBroadcaster.hpp"
+#include "comphelper/sequence.hxx"
+#include "xmlscript/xml_helper.hxx"
+#include "osl/diagnose.h"
+#include "dp_interact.h"
+#include "dp_resource.h"
+#include "dp_ucb.h"
+#include "dp_identifier.hxx"
+#include "dp_descriptioninfoset.hxx"
+#include "dp_extensionmanager.hxx"
+#include "dp_commandenvironments.hxx"
+#include "dp_properties.hxx"
+#include "boost/bind.hpp"
+
+#include <list>
+#include <hash_map>
+#include <algorithm>
+
+namespace deploy = com::sun::star::deployment;
+namespace lang = com::sun::star::lang;
+namespace registry = com::sun::star::registry;
+namespace task = com::sun::star::task;
+namespace ucb = com::sun::star::ucb;
+namespace uno = com::sun::star::uno;
+namespace beans = com::sun::star::beans;
+namespace util = com::sun::star::util;
+namespace css = com::sun::star;
+
+
+//#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+using ::com::sun::star::uno::Reference;
+using ::rtl::OUString;
+
+namespace {
+
+struct CompIdentifiers
+{
+ bool operator() (::std::vector<Reference<deploy::XPackage> > const & a,
+ ::std::vector<Reference<deploy::XPackage> > const & b)
+ {
+
+ if (getName(a).compareTo(getName(b)) < 0)
+ return true;
+ return false;
+ }
+
+ OUString getName(::std::vector<Reference<deploy::XPackage> > const & a);
+};
+
+OUString CompIdentifiers::getName(::std::vector<Reference<deploy::XPackage> > const & a)
+{
+ OSL_ASSERT(a.size() == 3);
+ //get the first non-null reference
+ Reference<deploy::XPackage> extension;
+ ::std::vector<Reference<deploy::XPackage> >::const_iterator it = a.begin();
+ for (; it != a.end(); it++)
+ {
+ if (it->is())
+ {
+ extension = *it;
+ break;
+ }
+ }
+ OSL_ASSERT(extension.is());
+ return extension->getDisplayName();
+}
+
+void writeLastModified(OUString & url, Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+{
+ //Write the lastmodified file
+ try {
+ ::rtl::Bootstrap::expandMacros(url);
+ ::ucbhelper::Content ucbStamp(url, xCmdEnv );
+ dp_misc::erase_path( url, xCmdEnv );
+ ::rtl::OString stamp("1" );
+ Reference<css::io::XInputStream> xData(
+ ::xmlscript::createInputStream(
+ ::rtl::ByteSequence(
+ reinterpret_cast<sal_Int8 const *>(stamp.getStr()),
+ stamp.getLength() ) ) );
+ ucbStamp.writeStream( xData, true /* replace existing */ );
+ }
+ catch(...)
+ {
+ uno::Any exc(::cppu::getCaughtException());
+ throw deploy::DeploymentException(
+ OUSTR("Failed to update") + url, 0, exc);
+ }
+}
+} //end namespace
+
+namespace dp_manager {
+
+
+
+//------------------------------------------------------------------------------
+
+//ToDo: bundled extension
+ExtensionManager::ExtensionManager( Reference< uno::XComponentContext > const& xContext) :
+ ::cppu::WeakComponentImplHelper1< css::deployment::XExtensionManager >(getMutex()),
+ m_xContext( xContext )
+{
+ Reference<deploy::XPackageManagerFactory> xPackageManagerFactory(
+ deploy::thePackageManagerFactory::get(m_xContext));
+ m_userRepository = xPackageManagerFactory->getPackageManager(OUSTR("user"));
+ m_sharedRepository = xPackageManagerFactory->getPackageManager(OUSTR("shared"));
+ m_bundledRepository = xPackageManagerFactory->getPackageManager(OUSTR("bundled"));
+ m_tmpRepository = xPackageManagerFactory->getPackageManager(OUSTR("tmp"));
+
+ m_repositoryNames.push_back(OUSTR("user"));
+ m_repositoryNames.push_back(OUSTR("shared"));
+ m_repositoryNames.push_back(OUSTR("bundled"));
+}
+
+//------------------------------------------------------------------------------
+
+ExtensionManager::~ExtensionManager()
+{
+}
+
+Reference<task::XAbortChannel> ExtensionManager::createAbortChannel()
+ throw (uno::RuntimeException)
+{
+ return new dp_misc::AbortChannel;
+}
+
+css::uno::Reference<css::deployment::XPackageManager>
+ExtensionManager::getPackageManager(::rtl::OUString const & repository)
+ throw (css::lang::IllegalArgumentException)
+{
+ Reference<deploy::XPackageManager> xPackageManager;
+ if (repository.equals(OUSTR("user")))
+ xPackageManager = m_userRepository;
+ else if (repository.equals(OUSTR("shared")))
+ xPackageManager = m_sharedRepository;
+ else if (repository.equals(OUSTR("bundled")))
+ xPackageManager = m_bundledRepository;
+ else
+ throw lang::IllegalArgumentException(
+ OUSTR("No valid repository name provided."),
+ static_cast<cppu::OWeakObject*>(this), 0);
+ return xPackageManager;
+}
+
+
+/*
+ Enters the XPackage objects into a map. They must be all from the
+ same repository. The value type of the map is a vector, where each vector
+ represents an extension with a particular identifier. The first member
+ is represents the user extension, the second the shared extension and the
+ third the bundled extension.
+ */
+void ExtensionManager::addExtensionsToMap(
+ id2extensions & mapExt,
+ uno::Sequence<Reference<deploy::XPackage> > const & seqExt,
+ OUString const & repository)
+{
+ //Determine the index in the vector where these extensions are to be
+ //added.
+ ::std::list<OUString>::const_iterator citNames =
+ m_repositoryNames.begin();
+ int index = 0;
+ for (;citNames != m_repositoryNames.end(); citNames++, index++)
+ {
+ if (citNames->equals(repository))
+ break;
+ }
+
+ for (int i = 0; i < seqExt.getLength(); i++)
+ {
+ Reference<deploy::XPackage> const & xExtension = seqExt[i];
+ OUString id = dp_misc::getIdentifier(xExtension);
+ id2extensions::iterator ivec = mapExt.find(id);
+ if (ivec == mapExt.end())
+ {
+ ::std::vector<Reference<deploy::XPackage> > vec(3);
+ vec[index] = xExtension;
+ mapExt[id] = vec;
+ }
+ else
+ {
+ ivec->second[index] = xExtension;
+ }
+ }
+}
+
+/*
+ returns a list containing extensions with the same identifier from
+ all repositories (user, shared, bundled) If one repository does not
+ have this extension, then the list contains an empty Referenc. The list
+ is ordered according to the priority of the repostories:
+ 1. user
+ 2. shared
+ 3. bundled
+
+ The number of elements is always three, unless the number of repository
+ changes.
+ */
+::std::list<Reference<deploy::XPackage> >
+ ExtensionManager::getExtensionsWithSameId(
+ OUString const & identifier, OUString const & fileName,
+ Reference< ucb::XCommandEnvironment> const & /*xCmdEnv*/)
+
+{
+ ::std::list<Reference<deploy::XPackage> > extensionList;
+ try
+ { //will throw an exception if the extension does not exist
+ extensionList.push_back(m_userRepository->getDeployedPackage(
+ identifier, fileName, Reference<ucb::XCommandEnvironment>()));
+ } catch(lang::IllegalArgumentException &)
+ {
+ extensionList.push_back(Reference<deploy::XPackage>());
+ }
+ try
+ {
+ extensionList.push_back(m_sharedRepository->getDeployedPackage(
+ identifier, fileName, Reference<ucb::XCommandEnvironment>()));
+ } catch (lang::IllegalArgumentException &)
+ {
+ extensionList.push_back(Reference<deploy::XPackage>());
+ }
+ try
+ {
+ extensionList.push_back(m_bundledRepository->getDeployedPackage(
+ identifier, fileName, Reference<ucb::XCommandEnvironment>()));
+ } catch (lang::IllegalArgumentException &)
+ {
+ extensionList.push_back(Reference<deploy::XPackage>());
+ }
+ OSL_ASSERT(extensionList.size() == 3);
+ return extensionList;
+}
+
+uno::Sequence<Reference<deploy::XPackage> >
+ExtensionManager::getExtensionsWithSameIdentifier(
+ OUString const & identifier,
+ OUString const & fileName,
+ Reference< ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (
+ deploy::DeploymentException,
+ ucb::CommandFailedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ try
+ {
+ ::std::list<Reference<deploy::XPackage> > listExtensions =
+ getExtensionsWithSameId(
+ identifier, fileName, xCmdEnv);
+ sal_Bool bHasExtension = false;
+
+ //throw an IllegalArgumentException if there is no extension at all.
+ typedef ::std::list<Reference<deploy::XPackage> >::const_iterator CIT;
+ for (CIT i = listExtensions.begin(); i != listExtensions.end(); i++)
+ bHasExtension |= i->is();
+ if (!bHasExtension)
+ throw lang::IllegalArgumentException(
+ OUSTR("Could not find extension: ") + identifier + OUSTR(", ") + fileName,
+ static_cast<cppu::OWeakObject*>(this), -1);
+
+ return comphelper::containerToSequence<
+ Reference<deploy::XPackage>,
+ ::std::list<Reference<deploy::XPackage> >
+ > (listExtensions);
+ }
+ catch (deploy::DeploymentException & )
+ {
+ throw;
+ }
+ catch ( ucb::CommandFailedException & )
+ {
+ throw;
+ }
+ catch (lang::IllegalArgumentException &)
+ {
+ throw;
+ }
+ catch (...)
+ {
+ uno::Any exc = ::cppu::getCaughtException();
+ throw deploy::DeploymentException(
+ OUSTR("Extension Manager: exception during getExtensionsWithSameIdentifier"),
+ static_cast<OWeakObject*>(this), exc);
+ }
+}
+
+
+
+bool ExtensionManager::isUserDisabled(
+ OUString const & identifier, OUString const & fileName)
+{
+ ::std::list<Reference<deploy::XPackage> > listExtensions;
+
+ try {
+ listExtensions = getExtensionsWithSameId(identifier, fileName);
+ } catch (lang::IllegalArgumentException & ) {
+ }
+ OSL_ASSERT(listExtensions.size() == 3);
+
+ return isUserDisabled( ::comphelper::containerToSequence<
+ Reference<deploy::XPackage>,
+ ::std::list<Reference<deploy::XPackage> >
+ > (listExtensions));
+}
+
+bool ExtensionManager::isUserDisabled(
+ uno::Sequence<Reference<deploy::XPackage> > const & seqExtSameId)
+{
+ OSL_ASSERT(seqExtSameId.getLength() == 3);
+ Reference<deploy::XPackage> const & userExtension = seqExtSameId[0];
+ if (userExtension.is())
+ {
+ beans::Optional<beans::Ambiguous<sal_Bool> > reg =
+ userExtension->isRegistered(Reference<task::XAbortChannel>(),
+ Reference<ucb::XCommandEnvironment>());
+ //If the value is ambiguous is than we assume that the extension
+ //is enabled, but something went wrong during enabling. We do not
+ //automatically disable user extensions.
+ if (reg.IsPresent &&
+ ! reg.Value.IsAmbiguous && ! reg.Value.Value)
+ return true;
+ }
+ return false;
+}
+
+/*
+ This method determines the active extension (XPackage.registerPackage) with a
+ particular identifier.
+
+ The parameter bUserDisabled determines if the user extension is disabled.
+
+ When the user repository contains an extension with the given identifier and
+ it is not disabled by the user, then it is always registered. Otherwise an
+ extension is only registered when there is no registered extension in one of
+ the repositories with a higher priority. That is, if the extension is from
+ the shared repository and an active extension with the same identifer is in
+ the user repository, then the extension is not registered. Similarly a
+ bundled extension is not registered if there is an active extension with the
+ same identifier in the shared or user repository.
+*/
+void ExtensionManager::activateExtension(
+ OUString const & identifier, OUString const & fileName,
+ bool bUserDisabled,
+ bool bStartup,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+{
+ ::std::list<Reference<deploy::XPackage> > listExtensions;
+ try {
+ listExtensions = getExtensionsWithSameId(identifier, fileName);
+ } catch (lang::IllegalArgumentException &) {
+ }
+ OSL_ASSERT(listExtensions.size() == 3);
+
+ activateExtension(
+ ::comphelper::containerToSequence<
+ Reference<deploy::XPackage>,
+ ::std::list<Reference<deploy::XPackage> >
+ > (listExtensions),
+ bUserDisabled, bStartup, xAbortChannel, xCmdEnv);
+
+ fireModified();
+}
+
+void ExtensionManager::activateExtension(
+ uno::Sequence<Reference<deploy::XPackage> > const & seqExt,
+ bool bUserDisabled,
+ bool bStartup,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+{
+ bool bActive = false;
+ sal_Int32 len = seqExt.getLength();
+ for (sal_Int32 i = 0; i < len; i++)
+ {
+ Reference<deploy::XPackage> const & aExt = seqExt[i];
+ if (aExt.is())
+ {
+ //get the registration value of the current iteration
+ beans::Optional<beans::Ambiguous<sal_Bool> > optReg =
+ aExt->isRegistered(xAbortChannel, xCmdEnv);
+ //If nothing can be registered then break
+ if (!optReg.IsPresent)
+ break;
+
+ //Check if this is a disabled user extension,
+ if (i == 0 && bUserDisabled)
+ {
+ aExt->revokePackage(xAbortChannel, xCmdEnv);
+ continue;
+ }
+
+ //If we have already determined an active extension then we must
+ //make sure to unregister all extensions with the same id in
+ //repositories with a lower priority
+ if (bActive)
+ {
+ aExt->revokePackage(xAbortChannel, xCmdEnv);
+ }
+ else
+ {
+ //This is the first extension in the ordered list, which becomes
+ //the active extension
+ bActive = true;
+ //Register if not already done.
+ //reregister if the value is ambiguous, which indicates that
+ //something went wrong during last registration.
+ aExt->registerPackage(bStartup, xAbortChannel, xCmdEnv);
+ }
+ }
+ }
+}
+
+Reference<deploy::XPackage> ExtensionManager::backupExtension(
+ OUString const & identifier, OUString const & fileName,
+ Reference<deploy::XPackageManager> const & xPackageManager,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+{
+ Reference<deploy::XPackage> xBackup;
+ Reference<ucb::XCommandEnvironment> tmpCmdEnv(
+ new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler()));
+ Reference<deploy::XPackage> xOldExtension;
+ xOldExtension = xPackageManager->getDeployedPackage(
+ identifier, fileName, tmpCmdEnv);
+
+ if (xOldExtension.is())
+ {
+ xBackup = m_tmpRepository->addPackage(
+ xOldExtension->getURL(), uno::Sequence<beans::NamedValue>(),
+ OUString(), Reference<task::XAbortChannel>(), tmpCmdEnv);
+
+ OSL_ENSURE(xBackup.is(), "Failed to backup extension");
+ }
+ return xBackup;
+}
+
+//The supported package types are actually determined by the registry. However
+//creating a registry
+//(desktop/source/deployment/registry/dp_registry.cxx:PackageRegistryImpl) will
+//create all the backends, so that the registry can obtain from them the package
+//types. Creating the registry will also set up the registry folder containing
+//all the subfolders for the respective backends.
+//Because all repositories support the same backends, we can just delegate this
+//call to one of the repositories.
+uno::Sequence< Reference<deploy::XPackageTypeInfo> >
+ExtensionManager::getSupportedPackageTypes()
+ throw (uno::RuntimeException)
+{
+ return m_userRepository->getSupportedPackageTypes();
+}
+
+// Only add to shared and user repository
+Reference<deploy::XPackage> ExtensionManager::addExtension(
+ OUString const & url, uno::Sequence<beans::NamedValue> const & properties,
+ OUString const & repository,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ Reference<deploy::XPackage> xNewExtension;
+ //Determine the repository to use
+ Reference<deploy::XPackageManager> xPackageManager;
+ if (repository.equals(OUSTR("user")))
+ xPackageManager = m_userRepository;
+ else if (repository.equals(OUSTR("shared")))
+ xPackageManager = m_sharedRepository;
+ else
+ throw lang::IllegalArgumentException(
+ OUSTR("No valid repository name provided."),
+ static_cast<cppu::OWeakObject*>(this), 0);
+ ::osl::MutexGuard guard(getMutex());
+ Reference<deploy::XPackage> xTmpExtension =
+ getTempExtension(url, xAbortChannel, xCmdEnv);
+ const OUString sIdentifier = dp_misc::getIdentifier(xTmpExtension);
+ const OUString sFileName = xTmpExtension->getName();
+ const OUString sDisplayName = xTmpExtension->getDisplayName();
+ const OUString sVersion = xTmpExtension->getVersion();
+ dp_misc::DescriptionInfoset info(dp_misc::getDescriptionInfoset(xTmpExtension->getURL()));
+ const ::boost::optional<dp_misc::SimpleLicenseAttributes> licenseAttributes =
+ info.getSimpleLicenseAttributes();
+ Reference<deploy::XPackage> xOldExtension;
+ Reference<deploy::XPackage> xExtensionBackup;
+
+ uno::Any excOccurred1;
+ uno::Any excOccurred2;
+ bool bUserDisabled = false;
+ try
+ {
+ bUserDisabled = isUserDisabled(sIdentifier, sFileName);
+ try
+ {
+ xOldExtension = xPackageManager->getDeployedPackage(
+ sIdentifier, sFileName, xCmdEnv);
+ }
+ catch (lang::IllegalArgumentException &)
+ {
+ }
+ bool bCanInstall = false;
+ try
+ {
+ if (xOldExtension.is())
+ {
+ //throws a CommandFailedException if the user cancels
+ //the action.
+ checkUpdate(sVersion, sDisplayName,xOldExtension, xCmdEnv);
+ }
+ else
+ {
+ //throws a CommandFailedException if the user cancels
+ //the action.
+ checkInstall(sDisplayName, xCmdEnv);
+ }
+ //Prevent showing the license if requested.
+ Reference<ucb::XCommandEnvironment> _xCmdEnv(xCmdEnv);
+ ExtensionProperties props(OUString(), properties, Reference<ucb::XCommandEnvironment>());
+ if (licenseAttributes && licenseAttributes->suppressIfRequired
+ && props.isSuppressedLicense())
+ _xCmdEnv = Reference<ucb::XCommandEnvironment>(
+ new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler()));
+
+ bCanInstall = xTmpExtension->checkPrerequisites(
+ xAbortChannel, _xCmdEnv, xOldExtension.is() || props.isExtensionUpdate()) == 0 ? true : false;
+ }
+ catch (deploy::DeploymentException& ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (ucb::CommandFailedException & ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (ucb::CommandAbortedException & ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (lang::IllegalArgumentException &) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (uno::RuntimeException &) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (...) {
+ excOccurred1 = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during addExtension, url: ")
+ + url, static_cast<OWeakObject*>(this), excOccurred1);
+ excOccurred1 <<= exc;
+ }
+
+ if (bCanInstall)
+ {
+ if (xOldExtension.is())
+ {
+ xOldExtension->revokePackage(xAbortChannel, xCmdEnv);
+ //save the old user extension in case the user aborts
+ //store the extension in the tmp repository, this will overwrite
+ //xTmpPackage (same identifier). Do not let the user abort or
+ //interact
+ Reference<ucb::XCommandEnvironment> tmpCmdEnv(
+ new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler()));
+ //importing the old extension in the tmp repository will remove
+ //the xTmpExtension
+ xTmpExtension = 0;
+ xExtensionBackup = m_tmpRepository->importExtension(
+ xOldExtension, Reference<task::XAbortChannel>(),
+ tmpCmdEnv);
+ }
+ xNewExtension = xPackageManager->addPackage(
+ url, properties, OUString(), xAbortChannel, xCmdEnv);
+ //If we add a user extension and there is already one which was
+ //disabled by a user, then the newly installed one is enabled. If we
+ //add to another repository then the user extension remains
+ //disabled.
+ bool bUserDisabled2 = bUserDisabled;
+ if (repository.equals(OUSTR("user")))
+ bUserDisabled2 = false;
+ activateExtension(
+ dp_misc::getIdentifier(xNewExtension),
+ xNewExtension->getName(), bUserDisabled2, false, xAbortChannel, xCmdEnv);
+ fireModified();
+ }
+ }
+ catch (deploy::DeploymentException& ) {
+ excOccurred2 = ::cppu::getCaughtException();
+ } catch (ucb::CommandFailedException & ) {
+ excOccurred2 = ::cppu::getCaughtException();
+ } catch (ucb::CommandAbortedException & ) {
+ excOccurred2 = ::cppu::getCaughtException();
+ } catch (lang::IllegalArgumentException &) {
+ excOccurred2 = ::cppu::getCaughtException();
+ } catch (uno::RuntimeException &) {
+ excOccurred2 = ::cppu::getCaughtException();
+ } catch (...) {
+ excOccurred2 = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during addExtension, url: ")
+ + url, static_cast<OWeakObject*>(this), excOccurred2);
+ excOccurred2 <<= exc;
+ }
+
+ if (excOccurred2.hasValue())
+ {
+ //It does not matter what exception is thrown. We try to
+ //recover the original status.
+ //If the user aborted installation then a ucb::CommandAbortedException
+ //is thrown.
+ //Use a private AbortChannel so the user cannot interrupt.
+ try
+ {
+ Reference<ucb::XCommandEnvironment> tmpCmdEnv(
+ new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler()));
+ if (xExtensionBackup.is())
+ {
+ Reference<deploy::XPackage> xRestored =
+ xPackageManager->importExtension(
+ xExtensionBackup, Reference<task::XAbortChannel>(),
+ tmpCmdEnv);
+ }
+ activateExtension(
+ sIdentifier, sFileName, bUserDisabled, false,
+ Reference<task::XAbortChannel>(), tmpCmdEnv);
+ if (xTmpExtension.is() || xExtensionBackup.is())
+ m_tmpRepository->removePackage(
+ sIdentifier, OUString(), xAbortChannel, xCmdEnv);
+ fireModified();
+ }
+ catch (...)
+ {
+ }
+ ::cppu::throwException(excOccurred2);
+ }
+ if (xTmpExtension.is() || xExtensionBackup.is())
+ m_tmpRepository->removePackage(
+ sIdentifier,OUString(), xAbortChannel, xCmdEnv);
+
+ if (excOccurred1.hasValue())
+ ::cppu::throwException(excOccurred1);
+
+ return xNewExtension;
+}
+
+void ExtensionManager::removeExtension(
+ OUString const & identifier, OUString const & fileName,
+ OUString const & repository,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ uno::Any excOccurred1;
+ Reference<deploy::XPackage> xExtensionBackup;
+ Reference<deploy::XPackageManager> xPackageManager;
+ bool bUserDisabled = false;
+ ::osl::MutexGuard guard(getMutex());
+ try
+ {
+//Determine the repository to use
+ if (repository.equals(OUSTR("user")))
+ xPackageManager = m_userRepository;
+ else if (repository.equals(OUSTR("shared")))
+ xPackageManager = m_sharedRepository;
+ else
+ throw lang::IllegalArgumentException(
+ OUSTR("No valid repository name provided."),
+ static_cast<cppu::OWeakObject*>(this), 0);
+
+ bUserDisabled = isUserDisabled(identifier, fileName);
+ //Backup the extension, in case the user cancels the action
+ xExtensionBackup = backupExtension(
+ identifier, fileName, xPackageManager, xCmdEnv);
+
+ //revoke the extension if it is active
+ Reference<deploy::XPackage> xOldExtension =
+ xPackageManager->getDeployedPackage(
+ identifier, fileName, xCmdEnv);
+ xOldExtension->revokePackage(xAbortChannel, xCmdEnv);
+
+ xPackageManager->removePackage(
+ identifier, fileName, xAbortChannel, xCmdEnv);
+ activateExtension(identifier, fileName, bUserDisabled, false,
+ xAbortChannel, xCmdEnv);
+ fireModified();
+ }
+ catch (deploy::DeploymentException& ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (ucb::CommandFailedException & ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (ucb::CommandAbortedException & ) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (lang::IllegalArgumentException &) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (uno::RuntimeException &) {
+ excOccurred1 = ::cppu::getCaughtException();
+ } catch (...) {
+ excOccurred1 = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during removeEtension"),
+ static_cast<OWeakObject*>(this), excOccurred1);
+ excOccurred1 <<= exc;
+ }
+
+ if (excOccurred1.hasValue())
+ {
+ //User aborted installation, restore the previous situation.
+ //Use a private AbortChannel so the user cannot interrupt.
+ try
+ {
+ Reference<ucb::XCommandEnvironment> tmpCmdEnv(
+ new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler()));
+ if (xExtensionBackup.is())
+ {
+ Reference<deploy::XPackage> xRestored =
+ xPackageManager->importExtension(
+ xExtensionBackup, Reference<task::XAbortChannel>(),
+ tmpCmdEnv);
+ activateExtension(
+ identifier, fileName, bUserDisabled, false,
+ Reference<task::XAbortChannel>(),
+ tmpCmdEnv);
+
+ m_tmpRepository->removePackage(
+ dp_misc::getIdentifier(xExtensionBackup),
+ xExtensionBackup->getName(), xAbortChannel, xCmdEnv);
+ fireModified();
+ }
+ }
+ catch (...)
+ {
+ }
+ ::cppu::throwException(excOccurred1);
+ }
+
+ if (xExtensionBackup.is())
+ m_tmpRepository->removePackage(
+ dp_misc::getIdentifier(xExtensionBackup),
+ xExtensionBackup->getName(), xAbortChannel, xCmdEnv);
+}
+
+// Only enable extensions from shared and user repository
+void ExtensionManager::enableExtension(
+ Reference<deploy::XPackage> const & extension,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ ::osl::MutexGuard guard(getMutex());
+ bool bUserDisabled = false;
+ uno::Any excOccurred;
+ try
+ {
+ if (!extension.is())
+ return;
+ OUString repository = extension->getRepositoryName();
+ if (!repository.equals(OUSTR("user")))
+ throw lang::IllegalArgumentException(
+ OUSTR("No valid repository name provided."),
+ static_cast<cppu::OWeakObject*>(this), 0);
+
+ bUserDisabled = isUserDisabled(dp_misc::getIdentifier(extension),
+ extension->getName());
+
+ activateExtension(dp_misc::getIdentifier(extension),
+ extension->getName(), false, false,
+ xAbortChannel, xCmdEnv);
+ }
+ catch (deploy::DeploymentException& ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (ucb::CommandFailedException & ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (ucb::CommandAbortedException & ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (lang::IllegalArgumentException &) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (uno::RuntimeException &) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (...) {
+ excOccurred = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during enableExtension"),
+ static_cast<OWeakObject*>(this), excOccurred);
+ excOccurred <<= exc;
+ }
+
+ if (excOccurred.hasValue())
+ {
+ try
+ {
+ activateExtension(dp_misc::getIdentifier(extension),
+ extension->getName(), bUserDisabled, false,
+ xAbortChannel, xCmdEnv);
+ }
+ catch (...)
+ {
+ }
+ ::cppu::throwException(excOccurred);
+ }
+}
+
+/**
+ */
+sal_Int32 ExtensionManager::checkPrerequisitesAndEnable(
+ Reference<deploy::XPackage> const & extension,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ try
+ {
+ if (!extension.is())
+ return 0;
+ ::osl::MutexGuard guard(getMutex());
+ sal_Int32 ret = 0;
+ Reference<deploy::XPackageManager> mgr =
+ getPackageManager(extension->getRepositoryName());
+ ret = mgr->checkPrerequisites(extension, xAbortChannel, xCmdEnv);
+ if (ret)
+ {
+ //There are some unfulfilled prerequisites, try to revoke
+ extension->revokePackage(xAbortChannel, xCmdEnv);
+ }
+ const OUString id(dp_misc::getIdentifier(extension));
+ activateExtension(id, extension->getName(),
+ isUserDisabled(id, extension->getName()), false,
+ xAbortChannel, xCmdEnv);
+ return ret;
+ }
+ catch (deploy::DeploymentException& ) {
+ throw;
+ } catch (ucb::CommandFailedException & ) {
+ throw;
+ } catch (ucb::CommandAbortedException & ) {
+ throw;
+ } catch (lang::IllegalArgumentException &) {
+ throw;
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (...) {
+ uno::Any excOccurred = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during disableExtension"),
+ static_cast<OWeakObject*>(this), excOccurred);
+ throw exc;
+ }
+}
+
+
+void ExtensionManager::disableExtension(
+ Reference<deploy::XPackage> const & extension,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ ::osl::MutexGuard guard(getMutex());
+ uno::Any excOccurred;
+ bool bUserDisabled = false;
+ try
+ {
+ if (!extension.is())
+ return;
+ const OUString repository( extension->getRepositoryName());
+ if (!repository.equals(OUSTR("user")))
+ throw lang::IllegalArgumentException(
+ OUSTR("No valid repository name provided."),
+ static_cast<cppu::OWeakObject*>(this), 0);
+
+ const OUString id(dp_misc::getIdentifier(extension));
+ bUserDisabled = isUserDisabled(id, extension->getName());
+
+ activateExtension(id, extension->getName(), true, false,
+ xAbortChannel, xCmdEnv);
+ }
+ catch (deploy::DeploymentException& ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (ucb::CommandFailedException & ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (ucb::CommandAbortedException & ) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (lang::IllegalArgumentException &) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (uno::RuntimeException &) {
+ excOccurred = ::cppu::getCaughtException();
+ } catch (...) {
+ excOccurred = ::cppu::getCaughtException();
+ deploy::DeploymentException exc(
+ OUSTR("Extension Manager: exception during disableExtension"),
+ static_cast<OWeakObject*>(this), excOccurred);
+ excOccurred <<= exc;
+ }
+
+ if (excOccurred.hasValue())
+ {
+ try
+ {
+ activateExtension(dp_misc::getIdentifier(extension),
+ extension->getName(), bUserDisabled, false,
+ xAbortChannel, xCmdEnv);
+ }
+ catch (...)
+ {
+ }
+ ::cppu::throwException(excOccurred);
+ }
+}
+
+uno::Sequence< Reference<deploy::XPackage> >
+ ExtensionManager::getDeployedExtensions(
+ OUString const & repository,
+ Reference<task::XAbortChannel> const &xAbort,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ return getPackageManager(repository)->getDeployedPackages(
+ xAbort, xCmdEnv);
+}
+
+Reference<deploy::XPackage>
+ ExtensionManager::getDeployedExtension(
+ OUString const & repository,
+ OUString const & identifier,
+ OUString const & filename,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ return getPackageManager(repository)->getDeployedPackage(
+ identifier, filename, xCmdEnv);
+}
+
+uno::Sequence< uno::Sequence<Reference<deploy::XPackage> > >
+ ExtensionManager::getAllExtensions(
+ Reference<task::XAbortChannel> const & xAbort,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ try
+ {
+ id2extensions mapExt;
+
+ uno::Sequence<Reference<deploy::XPackage> > userExt =
+ m_userRepository->getDeployedPackages(xAbort, xCmdEnv);
+ addExtensionsToMap(mapExt, userExt, OUSTR("user"));
+ uno::Sequence<Reference<deploy::XPackage> > sharedExt =
+ m_sharedRepository->getDeployedPackages(xAbort, xCmdEnv);
+ addExtensionsToMap(mapExt, sharedExt, OUSTR("shared"));
+ uno::Sequence<Reference<deploy::XPackage> > bundledExt =
+ m_bundledRepository->getDeployedPackages(xAbort, xCmdEnv);
+ addExtensionsToMap(mapExt, bundledExt, OUSTR("bundled"));
+
+ //copy the values of the map to a vector for sorting
+ ::std::vector< ::std::vector<Reference<deploy::XPackage> > >
+ vecExtensions;
+ id2extensions::const_iterator mapIt = mapExt.begin();
+ for (;mapIt != mapExt.end(); mapIt++)
+ vecExtensions.push_back(mapIt->second);
+
+ //sort the element according to the identifier
+ ::std::sort(vecExtensions.begin(), vecExtensions.end(), CompIdentifiers());
+
+ ::std::vector< ::std::vector<Reference<deploy::XPackage> > >::const_iterator
+ citVecVec = vecExtensions.begin();
+ sal_Int32 j = 0;
+ uno::Sequence< uno::Sequence<Reference<deploy::XPackage> > > seqSeq(vecExtensions.size());
+ for (;citVecVec != vecExtensions.end(); citVecVec++, j++)
+ {
+ seqSeq[j] = comphelper::containerToSequence(*citVecVec);
+ }
+ return seqSeq;
+
+ } catch (deploy::DeploymentException& ) {
+ throw;
+ } catch (ucb::CommandFailedException & ) {
+ throw;
+ } catch (ucb::CommandAbortedException & ) {
+ throw;
+ } catch (lang::IllegalArgumentException &) {
+ throw;
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (...) {
+ uno::Any exc = ::cppu::getCaughtException();
+ throw deploy::DeploymentException(
+ OUSTR("Extension Manager: exception during enableExtension"),
+ static_cast<OWeakObject*>(this), exc);
+ }
+}
+
+//only to be called from unopkg!!!
+void ExtensionManager::reinstallDeployedExtensions(
+ OUString const & repository,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException, ucb::CommandAbortedException,
+ lang::IllegalArgumentException, uno::RuntimeException)
+{
+ try
+ {
+ Reference<deploy::XPackageManager>
+ xPackageManager = getPackageManager(repository);
+
+ ::osl::MutexGuard guard(getMutex());
+ xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv);
+ //We must sync here, otherwise we will get exceptions when extensions
+ //are removed.
+ dp_misc::syncRepositories(xCmdEnv);
+ const uno::Sequence< Reference<deploy::XPackage> > extensions(
+ xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv));
+
+ for ( sal_Int32 pos = 0; pos < extensions.getLength(); ++pos )
+ {
+ try
+ {
+ const OUString id = dp_misc::getIdentifier(extensions[ pos ]);
+ const OUString fileName = extensions[ pos ]->getName();
+ OSL_ASSERT(id.getLength());
+ activateExtension(id, fileName, false, false, xAbortChannel, xCmdEnv );
+ }
+ catch (lang::DisposedException &)
+ {
+ }
+ }
+ } catch (deploy::DeploymentException& ) {
+ throw;
+ } catch (ucb::CommandFailedException & ) {
+ throw;
+ } catch (ucb::CommandAbortedException & ) {
+ throw;
+ } catch (lang::IllegalArgumentException &) {
+ throw;
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (...) {
+ uno::Any exc = ::cppu::getCaughtException();
+ throw deploy::DeploymentException(
+ OUSTR("Extension Manager: exception during enableExtension"),
+ static_cast<OWeakObject*>(this), exc);
+ }
+}
+
+sal_Bool ExtensionManager::synchronize(
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (deploy::DeploymentException,
+ ucb::CommandFailedException,
+ ucb::CommandAbortedException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ try
+ {
+ sal_Bool bModified = sal_False;
+
+ ::osl::MutexGuard guard(getMutex());
+ String sSynchronizingShared(StrSyncRepository::get());
+ sSynchronizingShared.SearchAndReplaceAllAscii( "%NAME", OUSTR("shared"));
+ dp_misc::ProgressLevel progressShared(xCmdEnv, sSynchronizingShared);
+ bModified = m_sharedRepository->synchronize(xAbortChannel, xCmdEnv);
+ progressShared.update(OUSTR("\n\n"));
+
+ String sSynchronizingBundled(StrSyncRepository::get());
+ sSynchronizingBundled.SearchAndReplaceAllAscii( "%NAME", OUSTR("bundled"));
+ dp_misc::ProgressLevel progressBundled(xCmdEnv, sSynchronizingBundled);
+ bModified |= m_bundledRepository->synchronize(xAbortChannel, xCmdEnv);
+ progressBundled.update(OUSTR("\n\n"));
+
+ try
+ {
+ const uno::Sequence<uno::Sequence<Reference<deploy::XPackage> > >
+ seqSeqExt = getAllExtensions(xAbortChannel, xCmdEnv);
+ for (sal_Int32 i = 0; i < seqSeqExt.getLength(); i++)
+ {
+ uno::Sequence<Reference<deploy::XPackage> > const & seqExt =
+ seqSeqExt[i];
+ activateExtension(seqExt, isUserDisabled(seqExt), true,
+ xAbortChannel, xCmdEnv);
+ }
+ }
+ catch (...)
+ {
+ //We catch the exception, so we can write the lastmodified file
+ //so we will no repeat this everytime OOo starts.
+ OSL_ENSURE(0, "Extensions Manager: synchronize");
+ }
+ OUString lastSyncBundled(RTL_CONSTASCII_USTRINGPARAM(
+ "$BUNDLED_EXTENSIONS_USER/lastsynchronized"));
+ writeLastModified(lastSyncBundled, xCmdEnv);
+ OUString lastSyncShared(RTL_CONSTASCII_USTRINGPARAM(
+ "$SHARED_EXTENSIONS_USER/lastsynchronized"));
+ writeLastModified(lastSyncShared, xCmdEnv);
+ return bModified;
+ } catch (deploy::DeploymentException& ) {
+ throw;
+ } catch (ucb::CommandFailedException & ) {
+ throw;
+ } catch (ucb::CommandAbortedException & ) {
+ throw;
+ } catch (lang::IllegalArgumentException &) {
+ throw;
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (...) {
+ uno::Any exc = ::cppu::getCaughtException();
+ throw deploy::DeploymentException(
+ OUSTR("Extension Manager: exception in synchronize"),
+ static_cast<OWeakObject*>(this), exc);
+ }
+}
+
+// Notify the user when a new extension is to be installed. This is only the
+// case when one uses the system integration to install an extension (double
+// clicking on .oxt file etc.)). The function must only be called if there is no
+// extension with the same identifier already deployed. Then the checkUpdate
+// function will inform the user that the extension is about to be installed In
+// case the user cancels the installation a CommandFailed exception is
+// thrown.
+void ExtensionManager::checkInstall(
+ OUString const & displayName,
+ Reference<ucb::XCommandEnvironment> const & cmdEnv)
+{
+ uno::Any request(
+ deploy::InstallException(
+ OUSTR("Extension ") + displayName +
+ OUSTR(" is about to be installed."),
+ static_cast<OWeakObject *>(this), displayName));
+ bool approve = false, abort = false;
+ if (! dp_misc::interactContinuation(
+ request, task::XInteractionApprove::static_type(),
+ cmdEnv, &approve, &abort ))
+ {
+ OSL_ASSERT( !approve && !abort );
+ throw deploy::DeploymentException(
+ dp_misc::getResourceString(RID_STR_ERROR_WHILE_ADDING) + displayName,
+ static_cast<OWeakObject *>(this), request );
+ }
+ if (abort || !approve)
+ throw ucb::CommandFailedException(
+ dp_misc::getResourceString(RID_STR_ERROR_WHILE_ADDING) + displayName,
+ static_cast<OWeakObject *>(this), request );
+}
+
+/* The function will make the user interaction in case there is an extension
+installed with the same id. This function may only be called if there is already
+an extension.
+*/
+void ExtensionManager::checkUpdate(
+ OUString const & newVersion,
+ OUString const & newDisplayName,
+ Reference<deploy::XPackage> const & oldExtension,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv )
+{
+ // package already deployed, interact --force:
+ uno::Any request(
+ (deploy::VersionException(
+ dp_misc::getResourceString(
+ RID_STR_PACKAGE_ALREADY_ADDED ) + newDisplayName,
+ static_cast<OWeakObject *>(this), newVersion, newDisplayName,
+ oldExtension ) ) );
+ bool replace = false, abort = false;
+ if (! dp_misc::interactContinuation(
+ request, task::XInteractionApprove::static_type(),
+ xCmdEnv, &replace, &abort )) {
+ OSL_ASSERT( !replace && !abort );
+ throw deploy::DeploymentException(
+ dp_misc::getResourceString(
+ RID_STR_ERROR_WHILE_ADDING) + newDisplayName,
+ static_cast<OWeakObject *>(this), request );
+ }
+ if (abort || !replace)
+ throw ucb::CommandFailedException(
+ dp_misc::getResourceString(
+ RID_STR_PACKAGE_ALREADY_ADDED) + newDisplayName,
+ static_cast<OWeakObject *>(this), request );
+}
+
+Reference<deploy::XPackage> ExtensionManager::getTempExtension(
+ OUString const & url,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<ucb::XCommandEnvironment> const & /*xCmdEnv*/)
+
+{
+ Reference<ucb::XCommandEnvironment> tmpCmdEnvA(new TmpRepositoryCommandEnv());
+ Reference<deploy::XPackage> xTmpPackage = m_tmpRepository->addPackage(
+ url, uno::Sequence<beans::NamedValue>(),OUString(), xAbortChannel, tmpCmdEnvA);
+ if (!xTmpPackage.is())
+ {
+ throw deploy::DeploymentException(
+ OUSTR("Extension Manager: Failed to create temporary XPackage for url: ") + url,
+ static_cast<OWeakObject*>(this), uno::Any());
+
+ }
+ return xTmpPackage;
+}
+
+uno::Sequence<Reference<deploy::XPackage> > SAL_CALL
+ExtensionManager::getExtensionsWithUnacceptedLicenses(
+ OUString const & repository,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (deploy::DeploymentException,
+ uno::RuntimeException)
+{
+ Reference<deploy::XPackageManager>
+ xPackageManager = getPackageManager(repository);
+ ::osl::MutexGuard guard(getMutex());
+ return xPackageManager->getExtensionsWithUnacceptedLicenses(xCmdEnv);
+}
+
+sal_Bool ExtensionManager::isReadOnlyRepository(::rtl::OUString const & repository)
+ throw (uno::RuntimeException)
+{
+ return getPackageManager(repository)->isReadOnly();
+}
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+namespace sdecl = comphelper::service_decl;
+sdecl::class_<ExtensionManager> servicePIP;
+extern sdecl::ServiceDecl const serviceDecl(
+ servicePIP,
+ // a private one:
+ "com.sun.star.comp.deployment.ExtensionManager",
+ "com.sun.star.comp.deployment.ExtensionManager");
+
+//------------------------------------------------------------------------------
+bool singleton_entries(
+ uno::Reference< registry::XRegistryKey > const & xRegistryKey )
+{
+ try {
+ uno::Reference< registry::XRegistryKey > xKey(
+ xRegistryKey->createKey(
+ serviceDecl.getImplementationName() +
+ // xxx todo: use future generated function to get singleton name
+ OUSTR("/UNO/SINGLETONS/"
+ "com.sun.star.deployment.ExtensionManager") ) );
+ xKey->setStringValue( serviceDecl.getSupportedServiceNames()[0] );
+ return true;
+ }
+ catch (registry::InvalidRegistryException & exc) {
+ (void) exc; // avoid warnings
+ OSL_ENSURE( 0, ::rtl::OUStringToOString(
+ exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+ return false;
+ }
+}
+
+// XModifyBroadcaster
+//______________________________________________________________________________
+void ExtensionManager::addModifyListener(
+ Reference<util::XModifyListener> const & xListener )
+ throw (uno::RuntimeException)
+{
+ check();
+ rBHelper.addListener( ::getCppuType( &xListener ), xListener );
+}
+
+//______________________________________________________________________________
+void ExtensionManager::removeModifyListener(
+ Reference<util::XModifyListener> const & xListener )
+ throw (uno::RuntimeException)
+{
+ check();
+ rBHelper.removeListener( ::getCppuType( &xListener ), xListener );
+}
+
+void ExtensionManager::check()
+{
+ ::osl::MutexGuard guard( getMutex() );
+ if (rBHelper.bInDispose || rBHelper.bDisposed) {
+ throw lang::DisposedException(
+ OUSTR("ExtensionManager instance has already been disposed!"),
+ static_cast<OWeakObject *>(this) );
+ }
+}
+
+void ExtensionManager::fireModified()
+{
+ ::cppu::OInterfaceContainerHelper * pContainer = rBHelper.getContainer(
+ util::XModifyListener::static_type() );
+ if (pContainer != 0) {
+ pContainer->forEach<util::XModifyListener>(
+ boost::bind(&util::XModifyListener::modified, _1,
+ lang::EventObject(static_cast<OWeakObject *>(this))) );
+ }
+}
+
+} // namespace dp_manager
+
+
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx
new file mode 100644
index 000000000000..64cada7da3ac
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx
@@ -0,0 +1,307 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#if ! defined INCLUDED_DP_EXTENSIONMANAGER_H
+#define INCLUDED_DP_EXTENSIONMANAGER_H
+
+#include "dp_manager.hrc"
+#include "dp_misc.h"
+#include "dp_interact.h"
+#include "dp_activepackages.hxx"
+#include "rtl/ref.hxx"
+#include "cppuhelper/compbase1.hxx"
+#include "ucbhelper/content.hxx"
+#include "com/sun/star/deployment/XPackageRegistry.hpp"
+#include "com/sun/star/deployment/XPackageManager.hpp"
+#include "osl/mutex.hxx"
+#include <list>
+
+
+namespace css = ::com::sun::star;
+
+namespace dp_manager {
+
+typedef ::std::hash_map<
+ ::rtl::OUString,
+ ::std::vector<css::uno::Reference<css::deployment::XPackage> >,
+ ::rtl::OUStringHash > id2extensions;
+
+
+class ExtensionManager : private ::dp_misc::MutexHolder,
+ public ::cppu::WeakComponentImplHelper1< css::deployment::XExtensionManager >
+{
+public:
+ ExtensionManager( css::uno::Reference< css::uno::XComponentContext >const& xContext);
+ virtual ~ExtensionManager();
+
+ static css::uno::Sequence< ::rtl::OUString > getServiceNames();
+ static ::rtl::OUString getImplName();
+
+ void check();
+ void fireModified();
+
+public:
+
+// XModifyBroadcaster
+ virtual void SAL_CALL addModifyListener(
+ css::uno::Reference<css::util::XModifyListener> const & xListener )
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL removeModifyListener(
+ css::uno::Reference<css::util::XModifyListener> const & xListener )
+ throw (css::uno::RuntimeException);
+
+//XExtensionManager
+ virtual css::uno::Sequence<
+ css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL
+ getSupportedPackageTypes()
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::task::XAbortChannel> SAL_CALL
+ createAbortChannel() throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL addExtension(
+ ::rtl::OUString const & url,
+ css::uno::Sequence<css::beans::NamedValue> const & properties,
+ ::rtl::OUString const & repository,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual void SAL_CALL removeExtension(
+ ::rtl::OUString const & identifier,
+ ::rtl::OUString const & filename,
+ ::rtl::OUString const & repository,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual void SAL_CALL enableExtension(
+ css::uno::Reference<css::deployment::XPackage> const & extension,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual void SAL_CALL disableExtension(
+ css::uno::Reference<css::deployment::XPackage> const & extension,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+
+ virtual sal_Int32 SAL_CALL checkPrerequisitesAndEnable(
+ css::uno::Reference<css::deployment::XPackage> const & extension,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+
+ virtual css::uno::Sequence< css::uno::Reference<css::deployment::XPackage> >
+ SAL_CALL getDeployedExtensions(
+ ::rtl::OUString const & repository,
+ css::uno::Reference<css::task::XAbortChannel> const &,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Reference< css::deployment::XPackage>
+ SAL_CALL getDeployedExtension(
+ ::rtl::OUString const & repository,
+ ::rtl::OUString const & identifier,
+ ::rtl::OUString const & filename,
+ css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (
+ css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> >
+ SAL_CALL getExtensionsWithSameIdentifier(
+ ::rtl::OUString const & identifier,
+ ::rtl::OUString const & filename,
+ css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (
+ css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Sequence< css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > >
+ SAL_CALL getAllExtensions(
+ css::uno::Reference<css::task::XAbortChannel> const &,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+
+ virtual void SAL_CALL reinstallDeployedExtensions(
+ ::rtl::OUString const & repository,
+ css::uno::Reference< css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (
+ css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL synchronize(
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL
+ getExtensionsWithUnacceptedLicenses(
+ ::rtl::OUString const & repository,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (css::deployment::DeploymentException,
+ css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL isReadOnlyRepository(::rtl::OUString const & repository)
+ throw (css::uno::RuntimeException);
+
+private:
+
+ struct StrSyncRepository : public ::dp_misc::StaticResourceString<
+ StrSyncRepository, RID_STR_SYNCHRONIZING_REPOSITORY> {};
+
+ struct ExtensionInfos
+ {
+ ::rtl::OUString identifier;
+ ::rtl::OUString fileName;
+ ::rtl::OUString displayName;
+ ::rtl::OUString version;
+ };
+
+ css::uno::Reference< css::uno::XComponentContext> m_xContext;
+
+ css::uno::Reference<css::deployment::XPackageManager> m_userRepository;
+ css::uno::Reference<css::deployment::XPackageManager> m_sharedRepository;
+ css::uno::Reference<css::deployment::XPackageManager> m_bundledRepository;
+ css::uno::Reference<css::deployment::XPackageManager> m_tmpRepository;
+
+ /* contains the names of all repositories (except tmp) in order of there
+ priority. That is, the first element is "user" follod by "shared" and
+ then "bundled"
+ */
+ ::std::list< ::rtl::OUString > m_repositoryNames;
+
+ bool isUserDisabled(::rtl::OUString const & identifier,
+ ::rtl::OUString const & filename);
+
+ bool isUserDisabled(
+ css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExtSameId);
+
+ void activateExtension(
+ ::rtl::OUString const & identifier,
+ ::rtl::OUString const & fileName,
+ bool bUserDisabled, bool bStartup,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+ void activateExtension(
+ css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExt,
+ bool bUserDisabled, bool bStartup,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv );
+
+
+ ::std::list<css::uno::Reference<css::deployment::XPackage> >
+ getExtensionsWithSameId(::rtl::OUString const & identifier,
+ ::rtl::OUString const & fileName,
+ css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv =
+ css::uno::Reference< css::ucb::XCommandEnvironment>());
+
+ css::uno::Reference<css::deployment::XPackage> backupExtension(
+ ::rtl::OUString const & identifier, ::rtl::OUString const & fileName,
+ css::uno::Reference<css::deployment::XPackageManager> const & xPackageManager,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+ void checkInstall(
+ ::rtl::OUString const & displayName,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & cmdEnv);
+
+ void checkUpdate(
+ ::rtl::OUString const & newVersion,
+ ::rtl::OUString const & newDisplayName,
+ css::uno::Reference<css::deployment::XPackage> const & oldExtension,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+ css::uno::Reference<css::deployment::XPackage> getTempExtension(
+ ::rtl::OUString const & url,
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+
+ void addExtensionsToMap(
+ id2extensions & mapExt,
+ css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExt,
+ ::rtl::OUString const & repository);
+
+ css::uno::Reference<css::deployment::XPackageManager>
+ getPackageManager(::rtl::OUString const & repository)
+ throw (css::lang::IllegalArgumentException);
+};
+
+}
+
+
+
+
+#endif
+
diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx
index 9f2e0c9e1177..4cc43a8386d8 100644
--- a/desktop/source/deployment/manager/dp_informationprovider.cxx
+++ b/desktop/source/deployment/manager/dp_informationprovider.cxx
@@ -32,11 +32,10 @@
#include "comphelper/servicedecl.hxx"
-#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
#include "com/sun/star/deployment/UpdateInformationProvider.hpp"
#include "com/sun/star/deployment/XPackage.hpp"
#include "com/sun/star/deployment/XPackageInformationProvider.hpp"
-#include "com/sun/star/deployment/XPackageManager.hpp"
+#include "com/sun/star/deployment/ExtensionManager.hpp"
#include "com/sun/star/deployment/XUpdateInformationProvider.hpp"
#include "com/sun/star/lang/XServiceInfo.hpp"
#include "com/sun/star/registry/XRegistryKey.hpp"
@@ -56,6 +55,7 @@
#include "dp_identifier.hxx"
#include "dp_version.hxx"
#include "dp_misc.h"
+#include "dp_update.hxx"
namespace beans = com::sun::star::beans ;
namespace deployment = com::sun::star::deployment ;
@@ -104,21 +104,10 @@ private:
uno::Reference< uno::XComponentContext> mxContext;
- rtl::OUString getPackageLocation( const uno::Reference< deployment::XPackageManager > _xManager,
+ rtl::OUString getPackageLocation( const rtl::OUString& repository,
const rtl::OUString& _sExtensionId );
uno::Reference< deployment::XUpdateInformationProvider > mxUpdateInformation;
-
- uno::Sequence< uno::Reference< xml::dom::XElement > >
- getUpdateInformation( uno::Sequence< rtl::OUString > const & urls,
- rtl::OUString const & identifier ) const;
- uno::Sequence< uno::Reference< deployment::XPackage > >
- getPackages( const uno::Reference< deployment::XPackageManager > _xManager );
- uno::Sequence< uno::Sequence< rtl::OUString > > isUpdateAvailable( const uno::Reference< deployment::XPackageManager > _xManager,
- const rtl::OUString& _sExtensionId );
- uno::Sequence< uno::Sequence< rtl::OUString > > getExtensionList( const uno::Reference< deployment::XPackageManager > _xManager );
- uno::Sequence< uno::Sequence< rtl::OUString > > concatLists( uno::Sequence< uno::Sequence< rtl::OUString > > aFirst,
- uno::Sequence< uno::Sequence< rtl::OUString > > aSecond );
};
//------------------------------------------------------------------------------
@@ -148,15 +137,18 @@ void SAL_CALL PackageInformationProvider::handle( uno::Reference< task::XInterac
//------------------------------------------------------------------------------
rtl::OUString PackageInformationProvider::getPackageLocation(
- const uno::Reference< deployment::XPackageManager > _xManager,
- const rtl::OUString& _rExtensionId )
+ const rtl::OUString & repository,
+ const rtl::OUString& _rExtensionId )
{
rtl::OUString aLocationURL;
+ uno::Reference<deployment::XExtensionManager> xManager =
+ deployment::ExtensionManager::get(mxContext);
- if ( _xManager.is() )
+ if ( xManager.is() )
{
const uno::Sequence< uno::Reference< deployment::XPackage > > packages(
- _xManager->getDeployedPackages(
+ xManager->getDeployedExtensions(
+ repository,
uno::Reference< task::XAbortChannel >(),
static_cast < XCommandEnvironment *> (this) ) );
@@ -187,32 +179,21 @@ rtl::OUString SAL_CALL
PackageInformationProvider::getPackageLocation( const rtl::OUString& _sExtensionId )
throw ( uno::RuntimeException )
{
- uno::Reference< deployment::XPackageManager > xManager;
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- rtl::OUString aLocationURL = getPackageLocation( xManager, _sExtensionId );
+ rtl::OUString aLocationURL = getPackageLocation( UNISTRING("user"), _sExtensionId );
if ( aLocationURL.getLength() == 0 )
{
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- aLocationURL = getPackageLocation( xManager, _sExtensionId );
+ aLocationURL = getPackageLocation( UNISTRING("shared"), _sExtensionId );
+ }
+ if ( aLocationURL.getLength() == 0 )
+ {
+ aLocationURL = getPackageLocation( UNISTRING("bundled"), _sExtensionId );
}
-
if ( aLocationURL.getLength() )
{
::ucbhelper::Content aContent( aLocationURL, NULL );
aLocationURL = aContent.getURL();
}
-
return aLocationURL;
}
@@ -222,252 +203,157 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL
PackageInformationProvider::isUpdateAvailable( const rtl::OUString& _sExtensionId )
throw ( uno::RuntimeException )
{
- uno::Sequence< uno::Sequence< rtl::OUString > > aUpdateListUser;
-
- uno::Reference< deployment::XPackageManager > xManager;
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- aUpdateListUser = isUpdateAvailable( xManager, _sExtensionId );
-
- uno::Sequence< uno::Sequence< rtl::OUString > > aUpdateListShared;
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- aUpdateListShared = isUpdateAvailable( xManager, _sExtensionId );
-
- if ( !aUpdateListUser.hasElements() )
- return aUpdateListShared;
- else if ( !aUpdateListShared.hasElements() )
- return aUpdateListUser;
- else
- return concatLists( aUpdateListUser, aUpdateListShared );
-}
-
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvider::getExtensionList()
- throw ( uno::RuntimeException )
-{
- uno::Sequence< uno::Sequence< rtl::OUString > > aListUser;
-
- uno::Reference< deployment::XPackageManager > xManager;
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- aListUser = getExtensionList( xManager );
-
- uno::Sequence< uno::Sequence< rtl::OUString > > aListShared;
- try {
- xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") );
- }
- catch ( css_ucb::CommandFailedException & ){}
- catch ( uno::RuntimeException & ) {}
-
- aListShared = getExtensionList( xManager );
+ uno::Sequence< uno::Sequence< rtl::OUString > > aList;
- if ( !aListUser.hasElements() )
- return aListShared;
- else if ( !aListShared.hasElements() )
- return aListUser;
- else
- return concatLists( aListUser, aListShared );
-}
+ uno::Reference<deployment::XExtensionManager> extMgr =
+ deployment::ExtensionManager::get(mxContext);
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Reference< deployment::XPackage > >
- PackageInformationProvider::getPackages( const uno::Reference< deployment::XPackageManager > _xMgr )
-{
- uno::Sequence< uno::Reference< deployment::XPackage > > packages;
- try {
- packages = _xMgr->getDeployedPackages( uno::Reference< task::XAbortChannel >(),
- static_cast < XCommandEnvironment *> (this) );
- }
- catch ( deployment::DeploymentException & )
- {}
- catch ( css_ucb::CommandFailedException & )
- {}
- catch ( css_ucb::CommandAbortedException & )
- {}
- catch ( lang::IllegalArgumentException & e )
+ if (!extMgr.is())
{
- throw uno::RuntimeException(e.Message, e.Context);
+ OSL_ASSERT(0);
+ return aList;
}
-
- return packages;
-}
-
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Reference< xml::dom::XElement > >
- PackageInformationProvider::getUpdateInformation( uno::Sequence< rtl::OUString > const & urls,
- rtl::OUString const & identifier ) const
-{
- try
+ std::vector<std::pair<uno::Reference<deployment::XPackage>, uno::Any > > errors;
+ dp_misc::UpdateInfoMap updateInfoMap;
+ if (_sExtensionId.getLength())
{
- return mxUpdateInformation->getUpdateInformation( urls, identifier );
+ std::vector<uno::Reference<deployment::XPackage> > vecExtensions;
+ uno::Reference<deployment::XPackage> extension;
+ try
+ {
+ extension = dp_misc::getExtensionWithHighestVersion(
+ extMgr->getExtensionsWithSameIdentifier(
+ _sExtensionId, _sExtensionId, uno::Reference<css_ucb::XCommandEnvironment>()));
+ vecExtensions.push_back(extension);
+ }
+ catch (lang::IllegalArgumentException &)
+ {
+ OSL_ASSERT(0);
+ }
+ updateInfoMap = dp_misc::getOnlineUpdateInfos(
+ mxContext, extMgr, mxUpdateInformation, &vecExtensions, errors);
}
- catch ( uno::RuntimeException & ) {
- throw;
+ else
+ {
+ updateInfoMap = dp_misc::getOnlineUpdateInfos(
+ mxContext, extMgr, mxUpdateInformation, NULL, errors);
}
- catch ( css_ucb::CommandFailedException & ) {}
- catch ( css_ucb::CommandAbortedException & ) {}
- catch ( uno::Exception & ) {}
-
- return uno::Sequence< uno::Reference< xml::dom::XElement > >();
-}
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Sequence< rtl::OUString > >
- PackageInformationProvider::isUpdateAvailable(
- const uno::Reference< deployment::XPackageManager > _xManager,
- const rtl::OUString& _sExtensionId )
-{
- uno::Sequence< uno::Sequence< rtl::OUString > > aList;
- sal_Int32 nCount = 0;
- bool bPackageFound = false;
-
- // If the package manager is readonly then the user cannot modify anything anyway
- // so we can abort the search here
- if ( _xManager.is() && ! _xManager->isReadOnly() )
+ int nCount = 0;
+ for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); i++)
{
- uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( _xManager ) );
- uno::Sequence< uno::Reference< xml::dom::XElement > > defaultInfos;
+ dp_misc::UpdateInfo const & info = i->second;
- for ( int pos = packages.getLength(); pos-- && !bPackageFound; )
+ rtl::OUString sOnlineVersion;
+ if (info.info.is())
{
- uno::Reference< deployment::XPackage > package( packages[ pos ] );
- uno::Sequence< rtl::OUString > urls( package->getUpdateInformationURLs());
- uno::Sequence< uno::Reference< xml::dom::XElement > > infos;
- rtl::OUString id( dp_misc::getIdentifier( package ) );
-
- if ( _sExtensionId.getLength() )
- {
- if ( _sExtensionId == id )
- bPackageFound = true;
- else /* we have an ID and the IDs don't match, continue with next package */
- continue;
- }
-
- if ( urls.getLength() != 0)
- {
- infos = getUpdateInformation( urls, id );
- }
- else
- {
- if ( defaultInfos.getLength() == 0 )
- {
- const rtl::OUString defaultURL( dp_misc::getExtensionDefaultUpdateURL() );
- if ( defaultURL.getLength() )
- defaultInfos = getUpdateInformation( uno::Sequence< rtl::OUString >( &defaultURL, 1 ),
- rtl::OUString() );
- }
- infos = defaultInfos;
- }
- rtl::OUString latestVersion( package->getVersion() );
- sal_Int32 latestIndex = -1;
- for ( sal_Int32 i = 0; i < infos.getLength(); ++i )
- {
- dp_misc::DescriptionInfoset infoset( mxContext,
- uno::Reference< xml::dom::XNode >( infos[i], uno::UNO_QUERY_THROW));
- boost::optional< rtl::OUString > id2( infoset.getIdentifier() );
+ // check, if there are unsatisfied dependencies and ignore this online update
+ dp_misc::DescriptionInfoset infoset(mxContext, info.info);
+ uno::Sequence< uno::Reference< xml::dom::XElement > >
+ ds( dp_misc::Dependencies::check( infoset ) );
+ if ( ! ds.getLength() )
+ sOnlineVersion = info.version;
+ }
- if (!id2)
- continue;
+ rtl::OUString sVersionUser;
+ rtl::OUString sVersionShared;
+ rtl::OUString sVersionBundled;
+ uno::Sequence< uno::Reference< deployment::XPackage> > extensions;
+ try {
+ extensions = extMgr->getExtensionsWithSameIdentifier(
+ dp_misc::getIdentifier(info.extension), info.extension->getName(),
+ uno::Reference<css_ucb::XCommandEnvironment>());
+ } catch (lang::IllegalArgumentException& ) {
+ OSL_ASSERT(0);
+ }
+ OSL_ASSERT(extensions.getLength() == 3);
+ if (extensions[0].is() )
+ sVersionUser = extensions[0]->getVersion();
+ if (extensions[1].is() )
+ sVersionShared = extensions[1]->getVersion();
+ if (extensions[2].is() )
+ sVersionBundled = extensions[2]->getVersion();
+
+ bool bSharedReadOnly = extMgr->isReadOnlyRepository(OUSTR("shared"));
+
+ dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension(
+ bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion);
+ dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension(
+ bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion);
+
+ rtl::OUString updateVersionUser;
+ rtl::OUString updateVersionShared;
+ if (sourceUser != dp_misc::UPDATE_SOURCE_NONE)
+ updateVersionUser = dp_misc::getHighestVersion(
+ rtl::OUString(), sVersionShared, sVersionBundled, sOnlineVersion);
+ if (sourceShared != dp_misc::UPDATE_SOURCE_NONE)
+ updateVersionShared = dp_misc::getHighestVersion(
+ rtl::OUString(), rtl::OUString(), sVersionBundled, sOnlineVersion);
+ rtl::OUString updateVersion;
+ if (dp_misc::compareVersions(updateVersionUser, updateVersionShared) == dp_misc::GREATER)
+ updateVersion = updateVersionUser;
+ else
+ updateVersion = updateVersionShared;
+ if (updateVersion.getLength())
+ {
- if (*id2 == id)
- {
- // check, if there are unsatisfied dependencies and ignore those updates
- uno::Sequence< uno::Reference< xml::dom::XElement > > ds( dp_misc::Dependencies::check( infoset ) );
- if ( ds.getLength() )
- continue;
-
- rtl::OUString v( infoset.getVersion() );
- if ( dp_misc::compareVersions( v, latestVersion ) == dp_misc::GREATER )
- {
- latestVersion = v;
- latestIndex = i;
- }
- }
- }
- if ( latestIndex != -1 )
- {
- rtl::OUString aNewEntry[2];
- aNewEntry[0] = id;
- aNewEntry[1] = latestVersion;
- aList.realloc( ++nCount );
- aList[ nCount-1 ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
- }
+ rtl::OUString aNewEntry[2];
+ aNewEntry[0] = i->first;
+ aNewEntry[1] = updateVersion;
+ aList.realloc( ++nCount );
+ aList[ nCount-1 ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
}
}
return aList;
}
//------------------------------------------------------------------------------
-uno::Sequence< uno::Sequence< rtl::OUString > >
- PackageInformationProvider::getExtensionList(
- const uno::Reference< deployment::XPackageManager > _xManager )
+uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvider::getExtensionList()
+ throw ( uno::RuntimeException )
{
- uno::Sequence< uno::Sequence< rtl::OUString > > aList;
+ const uno::Reference<deployment::XExtensionManager> mgr =
+ deployment::ExtensionManager::get(mxContext);
- if ( _xManager.is() )
- {
- uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( _xManager ) );
+ if (!mgr.is())
+ return uno::Sequence< uno::Sequence< rtl::OUString > >();
- aList.realloc( packages.getLength() );
+ const uno::Sequence< uno::Sequence< uno::Reference<deployment::XPackage > > >
+ allExt = mgr->getAllExtensions(
+ uno::Reference< task::XAbortChannel >(),
+ static_cast < XCommandEnvironment *> (this) );
- for ( int pos = packages.getLength(); pos--; )
- {
- uno::Reference< deployment::XPackage > package( packages[ pos ] );
- rtl::OUString aNewEntry[2];
-
- aNewEntry[0] = dp_misc::getIdentifier( package );
- aNewEntry[1] = package->getVersion();
- aList[ pos ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
- }
- }
- return aList;
-}
+ uno::Sequence< uno::Sequence< rtl::OUString > > retList;
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Sequence< rtl::OUString > > PackageInformationProvider::concatLists(
- uno::Sequence< uno::Sequence< rtl::OUString > > aFirst,
- uno::Sequence< uno::Sequence< rtl::OUString > > aSecond )
-{
- sal_Int32 nFirstCount = aFirst.getLength();
- sal_Int32 nSecondCount = aSecond.getLength();
- sal_Int32 nIndex = nFirstCount;
+ sal_Int32 cAllIds = allExt.getLength();
+ retList.realloc(cAllIds);
- for ( sal_Int32 i=0; i < nSecondCount; i++ )
+ for (sal_Int32 i = 0; i < cAllIds; i++)
{
- bool bDuplicateEntry = false;
- for ( sal_Int32 j=0; j < nFirstCount; j++ )
+ //The inner sequence contains extensions with the same identifier from
+ //all the different repositories, that is user, share, bundled.
+ const uno::Sequence< uno::Reference< deployment::XPackage > > &
+ seqExtension = allExt[i];
+ sal_Int32 cExt = seqExtension.getLength();
+ OSL_ASSERT(cExt == 3);
+ for (sal_Int32 j = 0; j < cExt; j++)
{
- if ( aFirst[ j ][0] == aSecond[ i ][0] )
+ //ToDo according to the old code the first found extenions is used
+ //even if another one with the same id has a better version.
+ uno::Reference< deployment::XPackage > const & xExtension( seqExtension[j] );
+ if (xExtension.is())
{
- bDuplicateEntry = true;
+ rtl::OUString aNewEntry[2];
+ aNewEntry[0] = dp_misc::getIdentifier(xExtension);
+ aNewEntry[1] = xExtension->getVersion();
+ retList[i] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 );
break;
}
}
- if ( !bDuplicateEntry )
- {
- nIndex += 1;
- aFirst.realloc( nIndex );
- aFirst[ nIndex - 1 ] = aSecond[ i ];
- }
}
- return aFirst;
+ return retList;
}
+
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index 3f13cb021aae..44bc4d469f2f 100644
--- a/desktop/source/deployment/manager/dp_manager.cxx
+++ b/desktop/source/deployment/manager/dp_manager.cxx
@@ -39,6 +39,7 @@
#include "rtl/bootstrap.hxx"
#include "osl/diagnose.h"
#include "osl/file.hxx"
+#include "osl/security.hxx"
#include "cppuhelper/weakref.hxx"
#include "cppuhelper/exc_hlp.hxx"
#include "cppuhelper/implbase1.hxx"
@@ -57,11 +58,18 @@
#include "com/sun/star/ucb/NameClash.hpp"
#include "com/sun/star/deployment/VersionException.hpp"
#include "com/sun/star/deployment/InstallException.hpp"
+#include "com/sun/star/deployment/Prerequisites.hpp"
#include "com/sun/star/task/XInteractionApprove.hpp"
#include "com/sun/star/ucb/UnsupportedCommandException.hpp"
#include "boost/bind.hpp"
-#include <vector>
+#include "tools/urlobj.hxx"
+#include "osl/file.hxx"
+#include <vector>
+#include <list>
+#include "dp_descriptioninfoset.hxx"
+#include "dp_commandenvironments.hxx"
+#include "dp_properties.hxx"
using namespace ::dp_misc;
using namespace ::com::sun::star;
@@ -91,6 +99,28 @@ struct MatchTempDir
}
};
+
+namespace {
+OUString getExtensionFolder(OUString const & parentFolder,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+{
+ ::ucbhelper::Content tempFolder(
+ parentFolder, xCmdEnv );
+ Reference<sdbc::XResultSet> xResultSet(
+ tempFolder.createCursor(
+ Sequence<OUString>( &StrTitle::get(), 1 ),
+ ::ucbhelper::INCLUDE_FOLDERS_ONLY ) );
+
+ OUString title;
+ while (xResultSet->next())
+ {
+ title = Reference<sdbc::XRow>(
+ xResultSet, UNO_QUERY_THROW )->getString(1 /* Title */ ) ;
+ break;
+ }
+ return title;
+}
+}
//______________________________________________________________________________
void PackageManagerImpl::initActivationLayer(
Reference<XCommandEnvironment> const & xCmdEnv )
@@ -135,7 +165,8 @@ void PackageManagerImpl::initActivationLayer(
{
ActivePackages::Data dbData;
insertToActivationLayer(
- mediaType, sourceContent, title, &dbData );
+ Sequence<css::beans::NamedValue>(),mediaType, sourceContent,
+ title, &dbData );
insertToActivationLayerDB( title, dbData );
//TODO #i73136#: insertToActivationLayerDB needs id not
@@ -151,12 +182,24 @@ void PackageManagerImpl::initActivationLayer(
// user|share:
OSL_ASSERT( m_activePackages.getLength() > 0 );
m_activePackages_expanded = expandUnoRcUrl( m_activePackages );
- create_folder( 0, m_activePackages_expanded, xCmdEnv, !m_readOnly );
+ m_registrationData_expanded = expandUnoRcUrl(m_registrationData);
+ if (!m_readOnly)
+ create_folder( 0, m_activePackages_expanded, xCmdEnv, true);
+
+ OUString dbName;
+ if (m_context.equals(OUSTR("user")))
+ dbName = m_activePackages_expanded + OUSTR(".db");
+ else
+ {
+ //Create the extension data base in the user installation
+ create_folder( 0, m_registrationData_expanded, xCmdEnv, true);
+ dbName = m_registrationData_expanded + OUSTR("/extensions.db");
+ }
+ //The data base can always be written because it it always in the user installation
m_activePackagesDB.reset(
- new ActivePackages(
- m_activePackages_expanded + OUSTR(".db"), m_readOnly ) );
+ new ActivePackages( dbName, false ) );
- if (! m_readOnly)
+ if (! m_readOnly && ! m_context.equals(OUSTR("bundled")))
{
// clean up activation layer, scan for zombie temp dirs:
ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() );
@@ -169,17 +212,37 @@ void PackageManagerImpl::initActivationLayer(
::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) );
// get all temp directories:
::std::vector<OUString> tempEntries;
- while (xResultSet->next()) {
+ ::std::vector<OUString> removedEntries;
+ while (xResultSet->next())
+ {
OUString title(
Reference<sdbc::XRow>(
xResultSet, UNO_QUERY_THROW )->getString(
1 /* Title */ ) );
- tempEntries.push_back( ::rtl::Uri::encode(
- title, rtl_UriCharClassPchar,
- rtl_UriEncodeIgnoreEscapes,
- RTL_TEXTENCODING_UTF8 ) );
+
+ const char extensionRemoved[] = "removed";
+ if (title.endsWithAsciiL(
+ extensionRemoved, sizeof(extensionRemoved) - 1))
+ {
+ //save the file name withouth the "removed" part
+ sal_Int32 index = title.lastIndexOfAsciiL(
+ extensionRemoved, sizeof(extensionRemoved) - 1);
+ OUString remFile = title.copy(0, index);
+ removedEntries.push_back(::rtl::Uri::encode(
+ remFile, rtl_UriCharClassPchar,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8 ) );
+ }
+ else
+ {
+ tempEntries.push_back( ::rtl::Uri::encode(
+ title, rtl_UriCharClassPchar,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8 ) );
+ }
}
+ bool bShared = m_context.equals(OUSTR("shared")) ? true : false;
for ( ::std::size_t pos = 0; pos < tempEntries.size(); ++pos )
{
OUString const & tempEntry = tempEntries[ pos ];
@@ -187,14 +250,52 @@ void PackageManagerImpl::initActivationLayer(
if (::std::find_if( id2temp.begin(), id2temp.end(), match ) ==
id2temp.end())
{
+ const OUString url(
+ makeURL(m_activePackages_expanded, tempEntry ) );
+
+ //In case of shared extensions, new entries are regarded as
+ //added extensions if there is no xxx.tmpremoved file.
+ if (bShared)
+ {
+ if (::std::find(removedEntries.begin(), removedEntries.end(), tempEntry) ==
+ removedEntries.end())
+ {
+ continue;
+ }
+ else
+ {
+ //Make sure only the same user removes the extension, who
+ //previously unregistered it. This is avoid races if multiple instances
+ //of OOo are running which all have write access to the shared installation.
+ //For example, a user removes the extension, but keeps OOo
+ //running. Parts of the extension may still be loaded and used by OOo.
+ //Therefore the extension is only deleted the next time the extension manager is
+ //run after restarting OOo. While OOo is still running, another user starts OOo
+ //which would deleted the extension files. If the same user starts another
+ //instance of OOo then the lock file will prevent this.
+ OUString aUserName;
+ ::osl::Security aSecurity;
+ aSecurity.getUserName( aUserName );
+ ucbhelper::Content remFileContent(
+ url + OUSTR("removed"), Reference<XCommandEnvironment>());
+ ::rtl::ByteSequence data = dp_misc::readFile(remFileContent);
+ ::rtl::OString osData(reinterpret_cast<const sal_Char*>(data.getConstArray()),
+ data.getLength());
+ OUString sData = ::rtl::OStringToOUString(
+ osData, RTL_TEXTENCODING_UTF8);
+ if (!sData.equals(aUserName))
+ continue;
+ }
+ }
// temp entry not needed anymore:
- const OUString url( makeURL( m_activePackages_expanded,
- tempEntry ) );
erase_path( url + OUSTR("_"),
Reference<XCommandEnvironment>(),
false /* no throw: ignore errors */ );
erase_path( url, Reference<XCommandEnvironment>(),
false /* no throw: ignore errors */ );
+ //delete the xxx.tmpremoved file
+ erase_path(url + OUSTR("removed"),
+ Reference<XCommandEnvironment>(), false);
}
}
}
@@ -206,9 +307,9 @@ void PackageManagerImpl::initRegistryBackends()
{
if (m_registryCache.getLength() > 0)
create_folder( 0, m_registryCache,
- Reference<XCommandEnvironment>(), !m_readOnly );
+ Reference<XCommandEnvironment>(), false);
m_xRegistry.set( ::dp_registry::create(
- m_context, m_registryCache, m_readOnly,
+ m_context, m_registryCache, false,
m_xComponentContext ) );
}
@@ -223,12 +324,14 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create(
OUString packages, logFile, stampURL;
if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("user") )) {
- that->m_activePackages = OUSTR("vnd.sun.star.expand:$UNO_"
- "USER_PACKAGES_CACHE/uno_packages");
- that->m_registryCache = OUSTR("vnd.sun.star.expand:$UNO_"
- "USER_PACKAGES_CACHE/registry");
- logFile = OUSTR("vnd.sun.star.expand:$UNO_"
- "USER_PACKAGES_CACHE/log.txt");
+ that->m_activePackages = OUSTR(
+ "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages");
+ that->m_registrationData = OUSTR(
+ "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE");
+ that->m_registryCache = OUSTR(
+ "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/registry");
+ logFile = OUSTR(
+ "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/log.txt");
//We use the extension .sys for the file because on Windows Vista a sys
//(as well as exe and dll) file
//will not be written in the VirtualStore. For example if the process has no
@@ -240,25 +343,42 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create(
//using virtualization it appears that he/she can. Then a shared extension can
//be installed but is only visible for the user (because the extension is in
//the virtual store).
- stampURL = OUSTR("vnd.sun.star.expand:$UNO_"
- "USER_PACKAGES_CACHE/stamp.sys");
+ stampURL = OUSTR(
+ "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/stamp.sys");
}
else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") )) {
- that->m_activePackages = OUSTR("vnd.sun.star.expand:$UNO_"
- "SHARED_PACKAGES_CACHE/uno_packages");
- that->m_registryCache = OUSTR("vnd.sun.star.expand:$UNO_"
- "SHARED_PACKAGES_CACHE/registry");
-// The current logging implementation does not work for shared, because it requires
-// write access to the logfile. When two users run OOo at the same time on the same machine
-// then the
-// second will fail because it does not get write access. One cannot write into the
-// user's home, because then people may complain that when installing shared extension
-// stuff is written in their home.
-// logFile = OUSTR("vnd.sun.star.expand:$UNO_"
-// "SHARED_PACKAGES_CACHE/log.txt");
- //See description for stampURL for user packages.
- stampURL = OUSTR("vnd.sun.star.expand:$UNO_"
- "SHARED_PACKAGES_CACHE/stamp.sys");
+ that->m_activePackages = OUSTR(
+ "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages");
+ that->m_registrationData = OUSTR(
+ "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER");
+ that->m_registryCache = OUSTR(
+ "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER/registry");
+ logFile = OUSTR(
+ "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER/log.txt");
+ stampURL = OUSTR(
+ "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/stamp.sys");
+ }
+ else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") )) {
+ that->m_activePackages = OUSTR(
+ "vnd.sun.star.expand:$BUNDLED_EXTENSIONS");
+ that->m_registrationData = OUSTR(
+ "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER");
+ that->m_registryCache = OUSTR(
+ "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER/registry");
+ logFile = OUSTR(
+ "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER/log.txt");
+ //No stamp file. We assume that bundled is always readonly. It must not be
+ //modified from ExtensionManager but only by the installer
+ }
+ else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") )) {
+ that->m_activePackages = OUSTR(
+ "vnd.sun.star.expand:$TMP_EXTENSIONS/extensions");
+ that->m_registrationData = OUSTR(
+ "vnd.sun.star.expand:$TMP_EXTENSIONS");
+ that->m_registryCache = OUSTR(
+ "vnd.sun.star.expand:$TMP_EXTENSIONS/registry");
+ stampURL = OUSTR(
+ "vnd.sun.star.expand:$TMP_EXTENSIONS/stamp.sys");
}
else if (! context.matchAsciiL(
RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:/") )) {
@@ -270,29 +390,15 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create(
Reference<XCommandEnvironment> xCmdEnv;
try {
- bool renewal = false;
-
+ //There is no stampURL for the bundled folder
if (stampURL.getLength() > 0)
{
- // currently no automatic renewal possible, because quickstarter
- // already hinders from deleting registry directory...
-
#define CURRENT_STAMP "1"
-// renewal = true;
-// {
-// ::ucbhelper::Content ucbStamp;
-// if (create_ucb_content(
-// &ucbStamp, stampURL, xCmdEnv, false /* no throw */ ))
-// {
-// OUString line;
-// renewal = !readLine( &line, OUSTR(CURRENT_STAMP), ucbStamp,
-// RTL_TEXTENCODING_ASCII_US );
-// }
-// }
-
try {
+ //The osl file API does not allow to find out if one can write
+ //into a folder. Therefore we try to write a file. Then we delete
+ //it, so that it does not hinder uninstallation of OOo
// probe writing:
- erase_path( stampURL, xCmdEnv );
::ucbhelper::Content ucbStamp( stampURL, xCmdEnv );
::rtl::OString stamp(
RTL_CONSTASCII_STRINGPARAM(CURRENT_STAMP) );
@@ -302,8 +408,15 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create(
reinterpret_cast<sal_Int8 const *>(stamp.getStr()),
stamp.getLength() ) ) );
ucbStamp.writeStream( xData, true /* replace existing */ );
+ that->m_readOnly = false;
+ erase_path( stampURL, xCmdEnv );
}
catch (RuntimeException &) {
+ try {
+ erase_path( stampURL, xCmdEnv );
+ } catch (...)
+ {
+ }
throw;
}
catch (Exception &) {
@@ -324,12 +437,6 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create(
xCmdEnv.set( new CmdEnvWrapperImpl( xCmdEnv, that->m_xLogFile ) );
}
- OSL_ENSURE( !that->m_readOnly || !renewal,
- "### ought to reinstall all packages, but cannot write!" );
- if (!that->m_readOnly && renewal) // try to reinstall
- that->reinstallDeployedPackages(
- Reference<task::XAbortChannel>(), xCmdEnv );
-
that->initRegistryBackends();
that->initActivationLayer( xCmdEnv );
@@ -484,7 +591,7 @@ OUString PackageManagerImpl::detectMediaType(
try {
Reference<deployment::XPackage> xPackage(
m_xRegistry->bindPackage(
- url, OUString(), ucbContent.getCommandEnvironment() ) );
+ url, OUString(), false, OUString(), ucbContent.getCommandEnvironment() ) );
const Reference<deployment::XPackageTypeInfo> xPackageType(
xPackage->getPackageType() );
OSL_ASSERT( xPackageType.is() );
@@ -504,6 +611,7 @@ OUString PackageManagerImpl::detectMediaType(
//______________________________________________________________________________
OUString PackageManagerImpl::insertToActivationLayer(
+ Sequence<beans::NamedValue> const & properties,
OUString const & mediaType, ::ucbhelper::Content const & sourceContent_,
OUString const & title, ActivePackages::Data * dbData )
{
@@ -564,10 +672,22 @@ OUString PackageManagerImpl::insertToActivationLayer(
title, NameClash::OVERWRITE ))
throw RuntimeException( OUSTR("UCB transferContent() failed!"), 0 );
+
// write to DB:
+ //bundled extensions should only be added by the synchronizeAddedExtensions
+ //functions. Moreover, there is no "temporary folder" for bundled extensions.
+ OSL_ASSERT(!m_context.equals(OUSTR("bundled")));
+ OUString sFolderUrl = makeURLAppendSysPathSegment(destFolderContent.getURL(), title);
+ DescriptionInfoset info =
+ dp_misc::getDescriptionInfoset(sFolderUrl);
dbData->temporaryName = tempEntry;
dbData->fileName = title;
dbData->mediaType = mediaType;
+ dbData->version = info.getVersion();
+
+ //No write the properties file next to the extension
+ ExtensionProperties props(sFolderUrl, properties, xCmdEnv);
+ props.write();
return destFolder;
}
@@ -575,6 +695,8 @@ OUString PackageManagerImpl::insertToActivationLayer(
void PackageManagerImpl::insertToActivationLayerDB(
OUString const & id, ActivePackages::Data const & dbData )
{
+ //access to the database must be guarded. See removePackage
+ const ::osl::MutexGuard guard( getMutex() );
m_activePackagesDB->put( id, dbData );
}
@@ -582,81 +704,40 @@ void PackageManagerImpl::insertToActivationLayerDB(
/* The function returns true if there is an extension with the same id already
installed which needs to be uninstalled, before the new extension can be installed.
*/
-bool PackageManagerImpl::checkUpdate(
- Reference<deployment::XPackage> const & package,
- Reference<XCommandEnvironment> const & origCmdEnv,
- Reference<XCommandEnvironment> const & wrappedCmdEnv )
+bool PackageManagerImpl::isInstalled(
+ Reference<deployment::XPackage> const & package)
{
OUString id(dp_misc::getIdentifier(package));
OUString fn(package->getName());
- bool removeExisting = false;
+ bool bInstalled = false;
if (m_activePackagesDB->has( id, fn ))
{
- // package already deployed, interact --force:
- Any request(
- (deployment::VersionException(
- getResourceString( RID_STR_PACKAGE_ALREADY_ADDED ) + id,
- static_cast<OWeakObject *>(this), package,
- getDeployedPackage_( id, fn, origCmdEnv ) ) ) );
- bool replace = false, abort = false;
- if (! interactContinuation(
- request, task::XInteractionApprove::static_type(),
- wrappedCmdEnv, &replace, &abort )) {
- OSL_ASSERT( !replace && !abort );
- throw deployment::DeploymentException(
- getResourceString(RID_STR_ERROR_WHILE_ADDING) + id,
- static_cast<OWeakObject *>(this), request );
- }
- if (abort || !replace)
- throw CommandFailedException(
- getResourceString(RID_STR_PACKAGE_ALREADY_ADDED) + id,
- static_cast<OWeakObject *>(this), request );
-
- // remove clashing package before registering new version:
- removeExisting = true;
+ bInstalled = true;
}
- return removeExisting;
+ return bInstalled;
}
+
+// XPackageManager
//______________________________________________________________________________
-// Notify the user when a new extension is to be installed. This is only the case
-//when unopkg gui extension1 is used (used by system integration (double click on .oxt
-// file etc.)). In case there is already this extension then the function returns
-//true.
-//ToDo: Function always returns true or throws an exception
-bool PackageManagerImpl::checkInstall(
- Reference<deployment::XPackage> const & package,
- Reference<XCommandEnvironment> const & cmdEnv)
+Reference<deployment::XPackage> PackageManagerImpl::importExtension(
+ Reference<deployment::XPackage> const & extension,
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<XCommandEnvironment> const & xCmdEnv_ )
+ throw (deployment::DeploymentException, CommandFailedException,
+ CommandAbortedException, lang::IllegalArgumentException,
+ RuntimeException)
{
- OUString id(dp_misc::getIdentifier(package));
- if ( ! m_activePackagesDB->has( id, package->getName() ))
- {
- Any request(
- deployment::InstallException(
- OUSTR("Extension ") + id + OUSTR(" is about to be installed."),
- static_cast<OWeakObject *>(this), package));
- bool approve = false, abort = false;
- if (! interactContinuation(
- request, task::XInteractionApprove::static_type(),
- cmdEnv, &approve, &abort ))
- {
- OSL_ASSERT( !approve && !abort );
- throw deployment::DeploymentException(
- getResourceString(RID_STR_ERROR_WHILE_ADDING) + id,
- static_cast<OWeakObject *>(this), request );
- }
- if (abort || !approve)
- throw CommandFailedException(
- getResourceString(RID_STR_ERROR_WHILE_ADDING) + id,
- static_cast<OWeakObject *>(this), request );
-
- }
- return true;
+ return addPackage(extension->getURL(), Sequence<beans::NamedValue>(),
+ OUString(), xAbortChannel, xCmdEnv_);
}
-// XPackageManager
-//______________________________________________________________________________
+/* The function adds an extension but does not register it!!!
+ It may not do any user interaction. This is done in XExtensionManager::addExtension
+*/
Reference<deployment::XPackage> PackageManagerImpl::addPackage(
- OUString const & url, OUString const & mediaType_,
+ OUString const & url,
+ css::uno::Sequence<css::beans::NamedValue> const & properties,
+ OUString const & mediaType_,
Reference<task::XAbortChannel> const & xAbortChannel,
Reference<XCommandEnvironment> const & xCmdEnv_ )
throw (deployment::DeploymentException, CommandFailedException,
@@ -729,84 +810,34 @@ Reference<deployment::XPackage> PackageManagerImpl::addPackage(
}
ActivePackages::Data dbData;
destFolder = insertToActivationLayer(
- mediaType, sourceContent, title, &dbData );
+ properties, mediaType, sourceContent, title, &dbData );
// bind activation package:
- //Because every extension will be unpacked in a folder, which was created with a unique name
- //we will always have two different XPackage objects, even if the second extension is the same.
+ //Because every shared/user extension will be unpacked in a folder,
+ //which was created with a unique name we will always have two different
+ //XPackage objects, even if the second extension is the same.
//Therefore bindPackage does not need a guard here.
xPackage = m_xRegistry->bindPackage(
- makeURL( destFolder, title_enc ), mediaType, xCmdEnv );
+ makeURL( destFolder, title_enc ), mediaType, false, OUString(), xCmdEnv );
OSL_ASSERT( xPackage.is() );
if (xPackage.is())
{
bool install = false;
- OUString id;
-
try
{
- id = dp_misc::getIdentifier( xPackage );
- //checkInstall throws an exception if the user denies the installation
- checkInstall(xPackage, xCmdEnv);
- //checkUpdate throws an exception if the user cancels the interaction.
- //For example, he may be asked if he wants to replace the older version
- //with the new version.
- //checkUpdates must be called before checkPrerequisites
- bool bAlreadyInstalled = checkUpdate(
- xPackage, xCmdEnv_, xCmdEnv );
-
- if (xPackage->checkPrerequisites(xAbortChannel, xCmdEnv, bAlreadyInstalled, m_context))
+ OUString const id = dp_misc::getIdentifier( xPackage );
+
+ ::osl::MutexGuard g(m_addMutex);
+ if (isInstalled(xPackage))
{
- //This guard is used to prevent that an extension is installed twice. Do not use it in other
- //functions.
- //Imagine addPackage is called two times by different threads for the same extension quickly
- //after each other.
- //The second call would calculate "bAlreadyInstalled = false" if the first thread has not yet reached
- //insertToActivationLayerDB.
- ::osl::MutexGuard g(m_addMutex);
-
- //Holds the database data of the old extension, in case we need to roll back.
- ActivePackages::Data oldDbData;
- if (bAlreadyInstalled)
- {
- // Remove extension which is already installed. It is not removed from disk, only
- // the different contents are being unregisterd. We remember the databas information
- // in case we need to roll back this operation.
- // When the user canceled the operation (CommandAbortedException) than the package is still
- // fully functional.
- // Do not guard the complete function with the getMutex
- removePackage_(id, xPackage->getName(), xAbortChannel,
- xCmdEnv, & oldDbData);
- }
- install = true;
- const ::osl::MutexGuard guard( getMutex() );
- try
- {
- //throws CommandAbortedException if the user cancelled the installation.
- xPackage->registerPackage(xAbortChannel, xCmdEnv);
- }
- catch(CommandAbortedException & )
- { //ToDo: Interaction so that the gui can display an appropriate string.
- //See also removePackage_
- //User aborted installation, restore the previous situation.
- //Use a private AbortChannel so the user cannot interrupt.
- xPackage->revokePackage(new AbortChannel(), xCmdEnv);
- if (bAlreadyInstalled)
- {
- OUString instFolder = makeURL( m_activePackages, oldDbData.temporaryName)
- + OUSTR("_");
- Reference<deployment::XPackage> xOldPgk = m_xRegistry->bindPackage(
- makeURL( instFolder, oldDbData.fileName ), oldDbData.mediaType, xCmdEnv );
- xOldPgk->registerPackage(new AbortChannel(), xCmdEnv);
- insertToActivationLayerDB(dp_misc::getIdentifier( xOldPgk ), oldDbData);
- }
- throw;
- }
- //access to the database must be guarded. See removePackage_
- insertToActivationLayerDB(id, dbData);
+ //Do not guard the complete function with the getMutex
+ removePackage(id, xPackage->getName(), xAbortChannel,
+ xCmdEnv);
}
+ install = true;
+ insertToActivationLayerDB(id, dbData);
}
catch (...)
{
@@ -817,6 +848,7 @@ Reference<deployment::XPackage> PackageManagerImpl::addPackage(
{
deletePackageFromCache( xPackage, destFolder );
}
+ //ToDo: We should notify only if the extension is registered
fireModified();
}
return xPackage;
@@ -861,57 +893,15 @@ void PackageManagerImpl::deletePackageFromCache(
}
//______________________________________________________________________________
-void PackageManagerImpl::removePackage_(
- OUString const & id, OUString const & fileName,
- Reference<task::XAbortChannel> const & xAbortChannel,
- Reference<XCommandEnvironment> const & xCmdEnv,
- ActivePackages::Data * out_dbData)
-{
- Reference<deployment::XPackage> xPackage;
- {
- try {
- const ::osl::MutexGuard guard(getMutex());
- xPackage = getDeployedPackage_(id, fileName, xCmdEnv );
- m_activePackagesDB->get(out_dbData, id, fileName);
- beans::Optional< beans::Ambiguous<sal_Bool> > option(
- xPackage->isRegistered( Reference<task::XAbortChannel>(),
- xCmdEnv ) );
- if (!option.IsPresent || option.Value.IsAmbiguous || option.Value.Value)
- xPackage->revokePackage( xAbortChannel, xCmdEnv );
- m_activePackagesDB->erase( id, fileName ); // to be removed upon next start
- }
- catch (CommandAbortedException &)
- {
- //ToDo: interaction, so that gui can show an appropriate string
- //reregister the package
- //Create our own XAbortChannel, so the user cannot interrupt the registration.
- xPackage->registerPackage(new AbortChannel(), xCmdEnv);
- throw;
- }
- }
- try_dispose( xPackage );
-}
-
-//______________________________________________________________________________
void PackageManagerImpl::removePackage(
OUString const & id, ::rtl::OUString const & fileName,
- Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<task::XAbortChannel> const & /*xAbortChannel*/,
Reference<XCommandEnvironment> const & xCmdEnv_ )
throw (deployment::DeploymentException, CommandFailedException,
CommandAbortedException, lang::IllegalArgumentException,
RuntimeException)
{
check();
- if (m_readOnly)
- {
- OUString message;
- if (m_context == OUSTR("shared"))
- message = OUSTR("You need write permissions in order to remove a shared extension!");
- else
- message = OUSTR("You need write permissions in order to remove this extension!");
- throw deployment::DeploymentException(
- message, static_cast<OWeakObject *>(this), Any() );
- }
Reference<XCommandEnvironment> xCmdEnv;
if (m_xLogFile.is())
@@ -920,7 +910,48 @@ void PackageManagerImpl::removePackage(
xCmdEnv.set( xCmdEnv_ );
try {
- removePackage_( id, fileName, xAbortChannel, xCmdEnv, NULL);
+ Reference<deployment::XPackage> xPackage;
+ {
+ const ::osl::MutexGuard guard(getMutex());
+ //Check if this extension exist and throw an IllegalArgumentException
+ //if it does not
+ //If the files of the extension are already removed, or there is a
+ //different extension at the same place, for example after updating the
+ //extension, then the returned object is that which uses the database data.
+ xPackage = getDeployedPackage_(id, fileName, xCmdEnv );
+
+
+ //Because the extension is only removed the next time the extension
+ //manager runs after restarting OOo, we need to indicate that a
+ //shared extension was "deleted". When a user starts OOo, then it
+ //will check if something changed in the shared repository. Based on
+ //the flag file it will then recognize, that the extension was
+ //deleted and can then update the extnesion database of the shared
+ //extensions in the user installation.
+ if ( xPackage.is() && !m_readOnly && !xPackage->isRemoved() && m_context.equals(OUSTR("shared")))
+ {
+ ActivePackages::Data val;
+ m_activePackagesDB->get( & val, id, fileName);
+ OSL_ASSERT(val.temporaryName.getLength());
+ OUString url(makeURL(m_activePackages_expanded,
+ val.temporaryName + OUSTR("removed")));
+ ::ucbhelper::Content contentRemoved(url, xCmdEnv );
+ OUString aUserName;
+ ::osl::Security aSecurity;
+ aSecurity.getUserName( aUserName );
+
+ ::rtl::OString stamp = ::rtl::OUStringToOString(aUserName, RTL_TEXTENCODING_UTF8);
+ Reference<css::io::XInputStream> xData(
+ ::xmlscript::createInputStream(
+ ::rtl::ByteSequence(
+ reinterpret_cast<sal_Int8 const *>(stamp.getStr()),
+ stamp.getLength() ) ) );
+ contentRemoved.writeStream( xData, true /* replace existing */ );
+ }
+ m_activePackagesDB->erase( id, fileName ); // to be removed upon next start
+ }
+ try_dispose( xPackage );
+
fireModified();
}
catch (RuntimeException &) {
@@ -955,10 +986,16 @@ OUString PackageManagerImpl::getDeployPath( ActivePackages::Data const & data )
{
::rtl::OUStringBuffer buf;
buf.append( data.temporaryName );
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_/") );
- buf.append( ::rtl::Uri::encode( data.fileName, rtl_UriCharClassPchar,
+ //The bundled extensions are not contained in an additional folder
+ //with a unique name. data.temporaryName contains already the
+ //UTF8 encoded folder name. See PackageManagerImpl::synchronize
+ if (!m_context.equals(OUSTR("bundled")))
+ {
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_/") );
+ buf.append( ::rtl::Uri::encode( data.fileName, rtl_UriCharClassPchar,
rtl_UriEncodeIgnoreEscapes,
RTL_TEXTENCODING_UTF8 ) );
+ }
return makeURL( m_activePackages, buf.makeStringAndClear() );
}
@@ -997,8 +1034,22 @@ Reference<deployment::XPackage> PackageManagerImpl::getDeployedPackage_(
static_cast<sal_Int16>(-1) );
}
}
- return m_xRegistry->bindPackage(
- getDeployPath( data ), data.mediaType, xCmdEnv );
+ Reference<deployment::XPackage> xExtension;
+ try
+ {
+ //Ignore extensions where XPackage::checkPrerequisites failed.
+ //They must not be usable for this user.
+ if (data.failedPrerequisites.equals(OUSTR("0")))
+ {
+ xExtension = m_xRegistry->bindPackage(
+ getDeployPath( data ), data.mediaType, false, OUString(), xCmdEnv );
+ }
+ }
+ catch (deployment::InvalidRemovedParameterException& e)
+ {
+ xExtension = e.Extension;
+ }
+ return xExtension;
}
//______________________________________________________________________________
@@ -1012,6 +1063,8 @@ PackageManagerImpl::getDeployedPackages_(
ActivePackages::Entries::const_iterator const iEnd( id2temp.end() );
for ( ; iPos != iEnd; ++iPos )
{
+ if (! iPos->second.failedPrerequisites.equals(OUSTR("0")))
+ continue;
try {
packages.push_back(
getDeployedPackage_(
@@ -1124,25 +1177,18 @@ PackageManagerImpl::getDeployedPackages(
}
//______________________________________________________________________________
+
+
+//ToDo: the function must not call registerPackage, do this in
+//XExtensionManager.reinstallDeployedExtensions
void PackageManagerImpl::reinstallDeployedPackages(
- Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<task::XAbortChannel> const & /*xAbortChannel*/,
Reference<XCommandEnvironment> const & xCmdEnv_ )
throw (deployment::DeploymentException,
CommandFailedException, CommandAbortedException,
lang::IllegalArgumentException, RuntimeException)
{
check();
- if (m_readOnly)
- {
- OUString message;
- if (m_context == OUSTR("shared"))
- message = OUSTR("You need write permissions in order to install shared extensions!");
- else
- message = OUSTR("You need write permissions in order to install extensions!");
- throw deployment::DeploymentException(
- message, static_cast<OWeakObject *>(this), Any() );
- }
-
if (office_is_running())
throw RuntimeException(
OUSTR("You must close any running Office process before "
@@ -1167,12 +1213,7 @@ void PackageManagerImpl::reinstallDeployedPackages(
if (xUpdatable.is())
xUpdatable->update();
- // reregister all:
- const ::osl::MutexGuard guard( getMutex() );
- const Sequence< Reference<deployment::XPackage> > packages(
- getDeployedPackages_( xCmdEnv ) );
- for ( sal_Int32 pos = 0; pos < packages.getLength(); ++pos )
- packages[ pos ]->registerPackage( xAbortChannel, xCmdEnv );
+ //registering is done by the ExtensionManager service.
}
catch (RuntimeException &) {
throw;
@@ -1205,6 +1246,362 @@ void PackageManagerImpl::reinstallDeployedPackages(
{
return m_readOnly;
}
+bool PackageManagerImpl::synchronizeRemovedExtensions(
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
+{
+
+ //find all which are in the extension data base but which
+ //are removed already.
+ OSL_ASSERT(!m_context.equals(OUSTR("user")));
+ bool bModified = false;
+ ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() );
+
+ typedef ActivePackages::Entries::const_iterator ITActive;
+ bool bShared = m_context.equals(OUSTR("shared"));
+
+ for (ITActive i = id2temp.begin(); i != id2temp.end(); i++)
+ {
+ try
+ {
+ //Get the URL to the extensions folder, first make the url for the
+ //shared repository including the temporary name
+ OUString url = makeURL(m_activePackages, i->second.temporaryName);
+ if (bShared)
+ url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName);
+
+ bool bRemoved = false;
+ //Check if the URL to the extension is still the same
+ ::ucbhelper::Content contentExtension;
+
+ if (!create_ucb_content(
+ &contentExtension, url,
+ Reference<XCommandEnvironment>(), false))
+ {
+ bRemoved = true;
+ }
+
+ //The folder is in the extension database, but it can still be deleted.
+ //look for the xxx.tmpremoved file
+ //There can also be the case that a different extension was installed
+ //in a "temp" folder with name that is already used.
+ if (!bRemoved && bShared)
+ {
+ ::ucbhelper::Content contentRemoved;
+
+ if (create_ucb_content(
+ &contentRemoved,
+ m_activePackages_expanded + OUSTR("/") +
+ i->second.temporaryName + OUSTR("removed"),
+ Reference<XCommandEnvironment>(), false))
+ {
+ bRemoved = true;
+ }
+ }
+
+ if (!bRemoved)
+ {
+ //There may be another extensions at the same place
+ dp_misc::DescriptionInfoset infoset =
+ dp_misc::getDescriptionInfoset(url);
+ OSL_ENSURE(infoset.hasDescription(),
+ "Extension Manager: bundled and shared extensions "
+ "must have an identifer and a version");
+ if (infoset.hasDescription() &&
+ infoset.getIdentifier() &&
+ (! i->first.equals(*(infoset.getIdentifier()))
+ || ! i->second.version.equals(infoset.getVersion())))
+ {
+ bRemoved = true;
+ }
+
+ }
+ if (bRemoved)
+ {
+ Reference<deployment::XPackage> xPackage = m_xRegistry->bindPackage(
+ url, i->second.mediaType, true, i->first, xCmdEnv );
+ OSL_ASSERT(xPackage.is()); //Even if the files are removed, we must get the object.
+ xPackage->revokePackage(xAbortChannel, xCmdEnv);
+ removePackage(xPackage->getIdentifier().Value, xPackage->getName(),
+ xAbortChannel, xCmdEnv);
+ bModified |= true;
+ }
+ }
+ catch( uno::Exception & )
+ {
+ OSL_ASSERT(0);
+ }
+ }
+ return bModified;
+}
+
+
+bool PackageManagerImpl::synchronizeAddedExtensions(
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
+{
+ bool bModified = false;
+ ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() );
+ //check if the folder exist at all. The shared extension folder
+ //may not exist for a normal user.
+ if (!create_ucb_content(
+ NULL, m_activePackages_expanded, Reference<css::ucb::XCommandEnvironment>(), false))
+ return bModified;
+ ::ucbhelper::Content tempFolder(
+ m_activePackages_expanded, xCmdEnv );
+
+ Reference<sdbc::XResultSet> xResultSet(
+ tempFolder.createCursor(
+ Sequence<OUString>( &StrTitle::get(), 1 ),
+ ::ucbhelper::INCLUDE_FOLDERS_ONLY ) );
+
+ while (xResultSet->next())
+ {
+ try
+ {
+ OUString title(
+ Reference<sdbc::XRow>(
+ xResultSet, UNO_QUERY_THROW )->getString(
+ 1 /* Title */ ) );
+ //The temporary folders of user and shared have an '_' at then end.
+ //But the name in ActivePackages.temporaryName is saved without.
+ OUString title2 = title;
+ bool bNotBundled = !m_context.equals(OUSTR("bundled"));
+ if (bNotBundled)
+ {
+ OSL_ASSERT(title2[title2.getLength() -1] == '_');
+ title2 = title2.copy(0, title2.getLength() -1);
+ }
+ OUString titleEncoded = ::rtl::Uri::encode(
+ title2, rtl_UriCharClassPchar,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8);
+
+ //It it sufficient to check for the folder name, because when the administor
+ //installed the extension it was already checked if there is one with the
+ //same identifier.
+ const MatchTempDir match(titleEncoded);
+ if (::std::find_if( id2temp.begin(), id2temp.end(), match ) ==
+ id2temp.end())
+ {
+
+ // The folder was not found in the data base, so it must be
+ // an added extension
+ OUString url(m_activePackages_expanded + OUSTR("/") + titleEncoded);
+ OUString sExtFolder;
+ if (bNotBundled) //that is, shared
+ {
+ //Check if the extension was not "deleted" already which is indicated
+ //by a xxx.tmpremoved file
+ ::ucbhelper::Content contentRemoved;
+ if (create_ucb_content(&contentRemoved, url + OUSTR("removed"),
+ Reference<XCommandEnvironment>(), false))
+ continue;
+ sExtFolder = getExtensionFolder(
+ m_activePackages_expanded +
+ OUString(OUSTR("/")) + titleEncoded + OUSTR("_"), xCmdEnv);
+ url = makeURLAppendSysPathSegment(m_activePackages_expanded, title);
+ url = makeURLAppendSysPathSegment(url, sExtFolder);
+ }
+ Reference<deployment::XPackage> xPackage = m_xRegistry->bindPackage(
+ url, OUString(), false, OUString(), xCmdEnv );
+ if (xPackage.is())
+ {
+ //Prepare the database entry
+ ActivePackages::Data dbData;
+
+ dbData.temporaryName = titleEncoded;
+ if (bNotBundled)
+ dbData.fileName = sExtFolder;
+ else
+ dbData.fileName = title;
+ dbData.mediaType = xPackage->getPackageType()->getMediaType();
+ dbData.version = xPackage->getVersion();
+ OSL_ENSURE(dbData.version.getLength() > 0,
+ "Extension Manager: bundled and shared extensions must have "
+ "an identifier and a version");
+
+ OUString id = dp_misc::getIdentifier( xPackage );
+
+ //We provide a special command environment that will prevent
+ //showing a license if simple-licens/@accept-by = "admin"
+ //It will also prevent showing the license for bundled extensions
+ //which is not supported.
+ OSL_ASSERT(!m_context.equals(OUSTR("user")));
+
+ // shall the license be suppressed?
+ DescriptionInfoset info =
+ dp_misc::getDescriptionInfoset(url);
+ ::boost::optional<dp_misc::SimpleLicenseAttributes>
+ attr = info.getSimpleLicenseAttributes();
+ ExtensionProperties props(url,xCmdEnv);
+ bool bNoLicense = false;
+ if (attr && attr->suppressIfRequired && props.isSuppressedLicense())
+ bNoLicense = true;
+
+ Reference<ucb::XCommandEnvironment> licCmdEnv(
+ new LicenseCommandEnv(xCmdEnv->getInteractionHandler(),
+ bNoLicense, m_context));
+ sal_Int32 failedPrereq = xPackage->checkPrerequisites(
+ xAbortChannel, licCmdEnv, false);
+ //Remember that this failed. For example, the user
+ //could have declined the license. Then the next time the
+ //extension folder is investigated we do not want to
+ //try to install the extension again.
+ dbData.failedPrerequisites = OUString::valueOf(failedPrereq);
+ insertToActivationLayerDB(id, dbData);
+ bModified |= true;
+ }
+ }
+ }
+ catch (uno::Exception &)
+ {
+ OSL_ASSERT(0);
+ }
+ }
+ return bModified;
+}
+
+sal_Bool PackageManagerImpl::synchronize(
+ Reference<task::XAbortChannel> const & xAbortChannel,
+ Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::uno::RuntimeException)
+{
+ check();
+ bool bModified = false;
+ if (m_context.equals(OUSTR("user")))
+ return bModified;
+ bModified |=
+ synchronizeRemovedExtensions(xAbortChannel, xCmdEnv);
+ bModified |= synchronizeAddedExtensions(xAbortChannel, xCmdEnv);
+
+ return bModified;
+}
+
+Sequence< Reference<deployment::XPackage> > PackageManagerImpl::getExtensionsWithUnacceptedLicenses(
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (deployment::DeploymentException, RuntimeException)
+{
+ ::std::vector<Reference<deployment::XPackage> > vec;
+
+ try
+ {
+ const ::osl::MutexGuard guard( getMutex() );
+ // clean up activation layer, scan for zombie temp dirs:
+ ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() );
+
+ ActivePackages::Entries::const_iterator i = id2temp.begin();
+ bool bShared = m_context.equals(OUSTR("shared"));
+
+ for (; i != id2temp.end(); i++ )
+ {
+ //Get the database entry
+ ActivePackages::Data const & dbData = i->second;
+ sal_Int32 failedPrereq = dbData.failedPrerequisites.toInt32();
+ //If the installation failed for other reason then the license then we
+ //ignore it.
+ if (failedPrereq ^= deployment::Prerequisites::LICENSE)
+ continue;
+
+ //Prepare the URL to the extension
+ OUString url = makeURL(m_activePackages, i->second.temporaryName);
+ if (bShared)
+ url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName);
+
+ Reference<deployment::XPackage> p = m_xRegistry->bindPackage(
+ url, OUString(), false, OUString(), xCmdEnv );
+
+ if (p.is())
+ vec.push_back(p);
+
+ }
+ return ::comphelper::containerToSequence(vec);
+ }
+ catch (deployment::DeploymentException &)
+ {
+ throw;
+ }
+ catch (RuntimeException&)
+ {
+ throw;
+ }
+ catch (...)
+ {
+ Any exc = ::cppu::getCaughtException();
+ deployment::DeploymentException de(
+ OUSTR("PackageManagerImpl::getExtensionsWithUnacceptedLicenses"),
+ static_cast<OWeakObject*>(this), exc);
+ exc <<= de;
+ ::cppu::throwException(exc);
+ }
+
+ return ::comphelper::containerToSequence(vec);
+}
+
+sal_Int32 PackageManagerImpl::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 )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException)
+{
+ try
+ {
+ if (!extension.is())
+ return 0;
+ if (!m_context.equals(extension->getRepositoryName()))
+ throw lang::IllegalArgumentException(
+ OUSTR("PackageManagerImpl::checkPrerequisites: extension is not"
+ " from this repository."), 0, 0);
+
+ ActivePackages::Data dbData;
+ OUString id = dp_misc::getIdentifier(extension);
+ if (m_activePackagesDB->get( &dbData, id, OUString()))
+ {
+ //If the license was already displayed, then do not show it again
+ Reference<ucb::XCommandEnvironment> _xCmdEnv = xCmdEnv;
+ sal_Int32 prereq = dbData.failedPrerequisites.toInt32();
+ if ( !(prereq & deployment::Prerequisites::LICENSE))
+ _xCmdEnv = new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler());
+
+ sal_Int32 failedPrereq = extension->checkPrerequisites(
+ xAbortChannel, _xCmdEnv, false);
+ dbData.failedPrerequisites = OUString::valueOf(failedPrereq);
+ insertToActivationLayerDB(id, dbData);
+ }
+ else
+ {
+ throw lang::IllegalArgumentException(
+ OUSTR("PackageManagerImpl::checkPrerequisites: unknown extension"),
+ 0, 0);
+
+ }
+ return 0;
+ }
+ catch (deployment::DeploymentException& ) {
+ throw;
+ } catch (ucb::CommandFailedException & ) {
+ throw;
+ } catch (ucb::CommandAbortedException & ) {
+ throw;
+ } catch (lang::IllegalArgumentException &) {
+ throw;
+ } catch (uno::RuntimeException &) {
+ throw;
+ } catch (...) {
+ uno::Any excOccurred = ::cppu::getCaughtException();
+ deployment::DeploymentException exc(
+ OUSTR("PackageManagerImpl::checkPrerequisites: exception "),
+ static_cast<OWeakObject*>(this), excOccurred);
+ throw exc;
+ }
+}
//##############################################################################
diff --git a/desktop/source/deployment/manager/dp_manager.h b/desktop/source/deployment/manager/dp_manager.h
index ffa7252d7883..8fe0f662011b 100644
--- a/desktop/source/deployment/manager/dp_manager.h
+++ b/desktop/source/deployment/manager/dp_manager.h
@@ -53,6 +53,8 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper
{
css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
::rtl::OUString m_context;
+ ::rtl::OUString m_registrationData;
+ ::rtl::OUString m_registrationData_expanded;
::rtl::OUString m_registryCache;
bool m_readOnly;
@@ -73,6 +75,7 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper
::rtl::OUString detectMediaType(
::ucbhelper::Content const & ucbContent, bool throw_exc = true );
::rtl::OUString insertToActivationLayer(
+ css::uno::Sequence<css::beans::NamedValue> const & properties,
::rtl::OUString const & mediaType,
::ucbhelper::Content const & sourceContent,
::rtl::OUString const & title, ActivePackages::Data * dbData );
@@ -83,16 +86,16 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper
css::uno::Reference<css::deployment::XPackage> const & xPackage,
::rtl::OUString const & destFolder );
- bool checkUpdate(
- css::uno::Reference<css::deployment::XPackage> const & package,
- css::uno::Reference<css::ucb::XCommandEnvironment> const & origCmdEnv,
- css::uno::Reference<css::ucb::XCommandEnvironment> const &
- wrappedCmdEnv );
+ bool isInstalled(
+ css::uno::Reference<css::deployment::XPackage> const & package);
- bool checkInstall(
- css::uno::Reference<css::deployment::XPackage> const & package,
- css::uno::Reference<css::ucb::XCommandEnvironment> const & cmdEnv);
+ bool synchronizeRemovedExtensions(
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+ bool synchronizeAddedExtensions(
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
class CmdEnvWrapperImpl
: public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment,
@@ -135,7 +138,7 @@ protected:
: t_pm_helper( getMutex() ),
m_xComponentContext( xComponentContext ),
m_context( context ),
- m_readOnly( false )
+ m_readOnly( true )
{}
public:
@@ -171,7 +174,9 @@ public:
createAbortChannel() throw (css::uno::RuntimeException);
virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL addPackage(
- ::rtl::OUString const & url, ::rtl::OUString const & mediaType,
+ ::rtl::OUString const & url,
+ css::uno::Sequence<css::beans::NamedValue> const & properties,
+ ::rtl::OUString const & mediaType,
css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
throw (css::deployment::DeploymentException,
@@ -180,17 +185,15 @@ public:
css::lang::IllegalArgumentException,
css::uno::RuntimeException);
- /* Unregisters the package but does not remove it from disk.
- When the operation is canceled by the user, a CommandAbortedException
- is thrown. Then the package is still fully functional.
- @param out_oldData
- can be NULL
- */
- void removePackage_(
- ::rtl::OUString const & id, ::rtl::OUString const & fileName,
+ 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,
- ActivePackages::Data * out_oldData);
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
virtual void SAL_CALL removePackage(
::rtl::OUString const & id, ::rtl::OUString const & fileName,
@@ -242,7 +245,31 @@ public:
virtual ::sal_Bool SAL_CALL isReadOnly( )
throw (::com::sun::star::uno::RuntimeException);
-};
+
+ virtual ::sal_Bool SAL_CALL synchronize(
+ css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::uno::RuntimeException);
+
+ virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL
+ getExtensionsWithUnacceptedLicenses(
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
+ throw (css::deployment::DeploymentException,
+ css::uno::RuntimeException);
+
+ 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 )
+ throw (css::deployment::DeploymentException,
+ css::ucb::CommandFailedException,
+ css::ucb::CommandAbortedException,
+ css::lang::IllegalArgumentException,
+ css::uno::RuntimeException);
+ };
//______________________________________________________________________________
inline void PackageManagerImpl::check()
diff --git a/desktop/source/deployment/manager/dp_manager.hrc b/desktop/source/deployment/manager/dp_manager.hrc
index bdbfc079cda6..6131cc381abf 100644
--- a/desktop/source/deployment/manager/dp_manager.hrc
+++ b/desktop/source/deployment/manager/dp_manager.hrc
@@ -35,5 +35,5 @@
#define RID_STR_PACKAGE_ALREADY_ADDED (RID_DEPLOYMENT_MANAGER_START+2)
#define RID_STR_COPYING_PACKAGE (RID_DEPLOYMENT_MANAGER_START+3)
#define RID_STR_NO_SUCH_PACKAGE (RID_DEPLOYMENT_MANAGER_START+4)
-
+#define RID_STR_SYNCHRONIZING_REPOSITORY (RID_DEPLOYMENT_MANAGER_START+5)
#endif
diff --git a/desktop/source/deployment/manager/dp_manager.src b/desktop/source/deployment/manager/dp_manager.src
index 95ede4aa6227..7d38b880c37a 100644
--- a/desktop/source/deployment/manager/dp_manager.src
+++ b/desktop/source/deployment/manager/dp_manager.src
@@ -53,3 +53,7 @@ String RID_STR_NO_SUCH_PACKAGE
Text [ en-US ] = "There is no such extension deployed: ";
};
+String RID_STR_SYNCHRONIZING_REPOSITORY
+{
+ Text [ en-US ] = "Synchronizing repository for %NAME extensions";
+};
diff --git a/desktop/source/deployment/manager/dp_managerfac.cxx b/desktop/source/deployment/manager/dp_managerfac.cxx
index d4c9df1d57af..f6fde6b07d60 100644
--- a/desktop/source/deployment/manager/dp_managerfac.cxx
+++ b/desktop/source/deployment/manager/dp_managerfac.cxx
@@ -53,6 +53,7 @@ class PackageManagerFactoryImpl : private MutexHolder, public t_pmfac_helper
Reference<deployment::XPackageManager> m_xUserMgr;
Reference<deployment::XPackageManager> m_xSharedMgr;
+ Reference<deployment::XPackageManager> m_xBundledMgr;
typedef ::std::hash_map<
OUString, WeakReference<deployment::XPackageManager>,
::rtl::OUStringHash > t_string2weakref;
@@ -141,6 +142,7 @@ void PackageManagerFactoryImpl::disposing()
// the below are already disposed:
m_xUserMgr.clear();
m_xSharedMgr.clear();
+ m_xBundledMgr.clear();
}
// XPackageManagerFactory
@@ -172,6 +174,8 @@ PackageManagerFactoryImpl::getPackageManager( OUString const & context )
m_xUserMgr = xRet;
else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") ))
m_xSharedMgr = xRet;
+ else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") ))
+ m_xBundledMgr = xRet;
}
else
{
diff --git a/desktop/source/deployment/manager/dp_properties.cxx b/desktop/source/deployment/manager/dp_properties.cxx
new file mode 100644
index 000000000000..df579944c6e4
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_properties.cxx
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_desktop.hxx"
+
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "xmlscript/xml_helper.hxx"
+#include "ucbhelper/content.hxx"
+#include <list>
+
+#include "dp_ucb.h"
+#include "rtl/ustrbuf.hxx"
+#include "dp_properties.hxx"
+
+namespace lang = com::sun::star::lang;
+namespace task = com::sun::star::task;
+namespace ucb = com::sun::star::ucb;
+namespace uno = com::sun::star::uno;
+namespace css = com::sun::star;
+
+#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+using ::com::sun::star::uno::Reference;
+using ::rtl::OUString;
+
+#define PROP_SUPPRESS_LICENSE "SUPPRESS_LICENSE"
+#define PROP_EXTENSION_UPDATE "EXTENSION_UPDATE"
+
+namespace dp_manager {
+
+//Reading the file
+ExtensionProperties::ExtensionProperties(
+ OUString const & urlExtension,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv) :
+ m_xCmdEnv(xCmdEnv)
+{
+ m_propFileUrl = urlExtension + OUSTR("properties");
+
+ ::std::list< ::std::pair< OUString, OUString> > props;
+ if (! dp_misc::create_ucb_content(NULL, m_propFileUrl, 0, false))
+ return;
+
+ ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv);
+ dp_misc::readProperties(props, contentProps);
+
+ typedef ::std::list< ::std::pair< OUString, OUString> >::const_iterator CI;
+ for (CI i = props.begin(); i != props.end(); i++)
+ {
+ if (i->first.equals(OUSTR(PROP_SUPPRESS_LICENSE)))
+ m_prop_suppress_license = i->second;
+ }
+}
+
+//Writing the file
+ExtensionProperties::ExtensionProperties(
+ OUString const & urlExtension,
+ uno::Sequence<css::beans::NamedValue> const & properties,
+ Reference<ucb::XCommandEnvironment> const & xCmdEnv) :
+ m_xCmdEnv(xCmdEnv)
+{
+ m_propFileUrl = urlExtension + OUSTR("properties");
+
+ for (sal_Int32 i = 0; i < properties.getLength(); i++)
+ {
+ css::beans::NamedValue const & v = properties[i];
+ if (v.Name.equals(OUSTR(PROP_SUPPRESS_LICENSE)))
+ {
+ m_prop_suppress_license = getPropertyValue(v);
+ }
+ else if (v.Name.equals(OUSTR(PROP_EXTENSION_UPDATE)))
+ {
+ m_prop_extension_update = getPropertyValue(v);
+ }
+ else
+ {
+ throw lang::IllegalArgumentException(
+ OUSTR("Extension Manager: unknown property"), 0, -1);
+ }
+ }
+}
+
+OUString ExtensionProperties::getPropertyValue(css::beans::NamedValue const & v)
+{
+ OUString value(OUSTR("0"));
+ if (v.Value >>= value)
+ {
+ if (value.equals(OUSTR("1")))
+ value = OUSTR("1");
+ }
+ else
+ {
+ throw lang::IllegalArgumentException(
+ OUSTR("Extension Manager: wrong property value"), 0, -1);
+ }
+ return value;
+}
+void ExtensionProperties::write()
+{
+ ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv);
+ ::rtl::OUStringBuffer buf;
+
+ if (m_prop_suppress_license)
+ {
+ buf.append(OUSTR(PROP_SUPPRESS_LICENSE));
+ buf.append(OUSTR("="));
+ buf.append(*m_prop_suppress_license);
+ }
+
+ ::rtl::OString stamp = ::rtl::OUStringToOString(
+ buf.makeStringAndClear(), RTL_TEXTENCODING_UTF8);
+ Reference<css::io::XInputStream> xData(
+ ::xmlscript::createInputStream(
+ ::rtl::ByteSequence(
+ reinterpret_cast<sal_Int8 const *>(stamp.getStr()),
+ stamp.getLength() ) ) );
+ contentProps.writeStream( xData, true /* replace existing */ );
+}
+
+bool ExtensionProperties::isSuppressedLicense()
+{
+ bool ret = false;
+ if (m_prop_suppress_license)
+ {
+ if (m_prop_suppress_license->equals(OUSTR("1")))
+ ret = true;
+ }
+ return ret;
+}
+
+bool ExtensionProperties::isExtensionUpdate()
+{
+ bool ret = false;
+ if (m_prop_extension_update)
+ {
+ if (m_prop_extension_update->equals(OUSTR("1")))
+ ret = true;
+ }
+ return ret;
+}
+
+} // namespace dp_manager
+
+
diff --git a/desktop/source/deployment/manager/dp_properties.hxx b/desktop/source/deployment/manager/dp_properties.hxx
new file mode 100644
index 000000000000..97fc8b8c5394
--- /dev/null
+++ b/desktop/source/deployment/manager/dp_properties.hxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dp_manager.h,v $
+ * $Revision: 1.17 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_PROPERTIES_HXX
+#define INCLUDED_DP_PROPERTIES_HXX
+
+
+
+#include "com/sun/star/beans/NamedValue.hpp"
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include "boost/optional.hpp"
+
+
+namespace css = ::com::sun::star;
+
+namespace dp_manager {
+
+
+
+/**
+
+ */
+class ExtensionProperties
+{
+protected:
+ ::rtl::OUString m_propFileUrl;
+ const css::uno::Reference<css::ucb::XCommandEnvironment> m_xCmdEnv;
+ ::boost::optional< ::rtl::OUString> m_prop_suppress_license;
+ ::boost::optional< ::rtl::OUString> m_prop_extension_update;
+
+ ::rtl::OUString getPropertyValue(css::beans::NamedValue const & v);
+public:
+
+ virtual ~ExtensionProperties() {};
+ ExtensionProperties(::rtl::OUString const & urlExtension,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+ ExtensionProperties(::rtl::OUString const & urlExtension,
+ css::uno::Sequence<css::beans::NamedValue> const & properties,
+ css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
+
+ void write();
+
+ bool isSuppressedLicense();
+
+ bool isExtensionUpdate();
+};
+}
+
+
+
+
+#endif
+
diff --git a/desktop/source/deployment/manager/makefile.mk b/desktop/source/deployment/manager/makefile.mk
index a9ff47881fc3..4dc6405e34bf 100644
--- a/desktop/source/deployment/manager/makefile.mk
+++ b/desktop/source/deployment/manager/makefile.mk
@@ -45,7 +45,10 @@ SLOFILES = \
$(SLO)$/dp_activepackages.obj \
$(SLO)$/dp_manager.obj \
$(SLO)$/dp_managerfac.obj \
- $(SLO)$/dp_informationprovider.obj
+ $(SLO)$/dp_informationprovider.obj \
+ $(SLO)$/dp_extensionmanager.obj \
+ $(SLO)$/dp_commandenvironments.obj \
+ $(SLO)$/dp_properties.obj
.INCLUDE : ..$/target.pmk
.INCLUDE : target.mk