summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Lingner <jl@openoffice.org>2010-04-20 10:04:52 +0200
committerJoachim Lingner <jl@openoffice.org>2010-04-20 10:04:52 +0200
commite1703d7ac3e485fb7b94787ecdf04a7910bb20c5 (patch)
treea1ff7a1d3b783efd2fd7b4c54b45c00b2cf30abe
parent85c93f5779b0382769cf9dfb5a6306a018c17edd (diff)
jl152 import 263448 from native0jl:#i77196# XExtensionManager supports XModifyBroadcaster
-rw-r--r--desktop/source/deployment/manager/dp_extensionmanager.cxx66
-rw-r--r--desktop/source/deployment/manager/dp_extensionmanager.hxx51
-rw-r--r--desktop/source/deployment/manager/dp_manager.cxx8
3 files changed, 74 insertions, 51 deletions
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx
index 15bd9a581611..c4581556749f 100644
--- a/desktop/source/deployment/manager/dp_extensionmanager.cxx
+++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx
@@ -49,6 +49,7 @@
#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"
@@ -60,6 +61,8 @@
#include "dp_extensionmanager.hxx"
#include "dp_commandenvironments.hxx"
#include "dp_properties.hxx"
+#include "boost/bind.hpp"
+
#include <list>
#include <hash_map>
#include <algorithm>
@@ -71,8 +74,10 @@ 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;
@@ -121,6 +126,7 @@ 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(
@@ -433,7 +439,7 @@ Reference<deploy::XPackage> ExtensionManager::addExtension(
OUSTR("No valid repository name provided."),
static_cast<cppu::OWeakObject*>(this), 0);
- ::osl::MutexGuard guard(m_mutex);
+ ::osl::MutexGuard guard(getMutex());
Reference<deploy::XPackage> xTmpExtension =
getTempExtension(url, xAbortChannel, xCmdEnv);
const OUString sIdentifier = dp_misc::getIdentifier(xTmpExtension);
@@ -529,6 +535,7 @@ Reference<deploy::XPackage> ExtensionManager::addExtension(
activateExtension(
dp_misc::getIdentifier(xNewExtension),
xNewExtension->getName(), xAbortChannel, xCmdEnv);
+ fireModified();
}
}
catch (deploy::DeploymentException& ) {
@@ -573,6 +580,7 @@ Reference<deploy::XPackage> ExtensionManager::addExtension(
if (xTmpExtension.is() || xExtensionBackup.is())
m_tmpRepository->removePackage(
sIdentifier, OUString(), xAbortChannel, xCmdEnv);
+ fireModified();
}
catch (...)
{
@@ -616,7 +624,7 @@ void ExtensionManager::removeExtension(
OUSTR("No valid repository name provided."),
static_cast<cppu::OWeakObject*>(this), 0);
- ::osl::MutexGuard guard(m_mutex);
+ ::osl::MutexGuard guard(getMutex());
//Backup the extension, in case the user cancels the action
xExtensionBackup = backupExtension(
identifier, fileName, xPackageManager, xCmdEnv);
@@ -630,6 +638,7 @@ void ExtensionManager::removeExtension(
xPackageManager->removePackage(
identifier, fileName, xAbortChannel, xCmdEnv);
activateExtension(identifier, fileName, xAbortChannel, xCmdEnv);
+ fireModified();
}
catch (deploy::DeploymentException& ) {
excOccurred1 = ::cppu::getCaughtException();
@@ -670,6 +679,7 @@ void ExtensionManager::removeExtension(
m_tmpRepository->removePackage(
dp_misc::getIdentifier(xExtensionBackup),
xExtensionBackup->getName(), xAbortChannel, xCmdEnv);
+ fireModified();
}
}
catch (...)
@@ -705,7 +715,7 @@ void ExtensionManager::enableExtension(
throw lang::IllegalArgumentException(
OUSTR("No valid repository name provided."),
static_cast<cppu::OWeakObject*>(this), 0);
- ::osl::MutexGuard guard(m_mutex);
+ ::osl::MutexGuard guard(getMutex());
//if it is already registered or if it cannot be registered
//because it does not contain any files which need to be processed
@@ -790,7 +800,7 @@ long ExtensionManager::checkPrerequisitesAndEnable(
{
if (!extension.is())
return 0;
- ::osl::MutexGuard guard(m_mutex);
+ ::osl::MutexGuard guard(getMutex());
sal_Int32 ret = 0;
Reference<deploy::XPackageManager> mgr =
getPackageManager(extension->getRepositoryName());
@@ -840,7 +850,7 @@ void ExtensionManager::disableExtension(
if (!extension.is())
return;
- ::osl::MutexGuard guard(m_mutex);
+ ::osl::MutexGuard guard(getMutex());
OUString repository = extension->getRepositoryName();
if (!repository.equals(OUSTR("user")))
throw lang::IllegalArgumentException(
@@ -999,7 +1009,7 @@ void ExtensionManager::reinstallDeployedExtensions(
Reference<deploy::XPackageManager>
xPackageManager = getPackageManager(repository);
- ::osl::MutexGuard guard(m_mutex);
+ ::osl::MutexGuard guard(getMutex());
xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv);
const uno::Sequence< Reference<deploy::XPackage> > extensions(
xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv));
@@ -1072,7 +1082,7 @@ void ExtensionManager::synchronize(
OUSTR("No valid repository name provided."),
static_cast<cppu::OWeakObject*>(this), 0);
- ::osl::MutexGuard guard(m_mutex);
+ ::osl::MutexGuard guard(getMutex());
dp_misc::ProgressLevel progress(
xCmdEnv, OUSTR("Synchronizing ") + repository + OUSTR(" repository\n"));
@@ -1235,7 +1245,7 @@ ExtensionManager::getExtensionsWithUnacceptedLicenses(
{
Reference<deploy::XPackageManager>
xPackageManager = getPackageManager(repository);
- ::osl::MutexGuard guard(m_mutex);
+ ::osl::MutexGuard guard(getMutex());
return xPackageManager->getExtensionsWithUnacceptedLicenses(xCmdEnv);
}
@@ -1273,6 +1283,46 @@ bool singleton_entries(
}
}
+// 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
index bafa97c24944..b11a2c64f546 100644
--- a/desktop/source/deployment/manager/dp_extensionmanager.hxx
+++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx
@@ -35,11 +35,9 @@
#include "dp_activepackages.hxx"
#include "rtl/ref.hxx"
#include "cppuhelper/compbase1.hxx"
-//#include "cppuhelper/implbase2.hxx"
#include "ucbhelper/content.hxx"
#include "com/sun/star/deployment/XPackageRegistry.hpp"
#include "com/sun/star/deployment/XPackageManager.hpp"
-//#include <memory>
#include "osl/mutex.hxx"
#include <list>
@@ -53,50 +51,31 @@ typedef ::std::hash_map<
::std::vector<css::uno::Reference<css::deployment::XPackage> >,
::rtl::OUStringHash > id2extensions;
-class ExtensionManager :
- public ::cppu::WeakImplHelper1< css::deployment::XExtensionManager >
+class ExtensionManager : private ::dp_misc::MutexHolder,
+ public ::cppu::WeakComponentImplHelper1< css::deployment::XExtensionManager >
{
-private:
- ::osl::Mutex m_mutex;
-
- public:
+public:
ExtensionManager( css::uno::Reference< css::uno::XComponentContext >const& xContext);
virtual ~ExtensionManager();
static css::uno::Sequence< ::rtl::OUString > getServiceNames();
static ::rtl::OUString getImplName();
-// // XInteractionHandler
-// virtual void SAL_CALL handle( const uno::Reference< task::XInteractionRequest >& Request )
-// throw( uno::RuntimeException );
-// // XCommandEnvironment
-// virtual uno::Reference< task::XInteractionHandler > SAL_CALL getInteractionHandler()
-// throw ( uno::RuntimeException ) { return static_cast<task::XInteractionHandler*>(this); };
+ void check();
+ void fireModified();
-// virtual uno::Reference< css_ucb::XProgressHandler > SAL_CALL getProgressHandler()
-// throw ( uno::RuntimeException ) { return uno::Reference< css_ucb::XProgressHandler >(); };
public:
- // XComponent
- //virtual void SAL_CALL dispose() throw (css::uno::RuntimeException);
- //virtual void SAL_CALL addEventListener(
- // css::uno::Reference<css::lang::XEventListener> const & xListener )
- // throw (css::uno::RuntimeException);
- //virtual void SAL_CALL removeEventListener(
- // css::uno::Reference<css::lang::XEventListener> const & xListener )
- // throw (css::uno::RuntimeException);
- //
- //// 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);
-
- // XPackageManager
-// virtual ::rtl::OUString SAL_CALL getContext()
-// throw (css::uno::RuntimeException);
+
+// 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(::rtl::OUString const & repository)
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index 0464d0de62d5..8c55f2508680 100644
--- a/desktop/source/deployment/manager/dp_manager.cxx
+++ b/desktop/source/deployment/manager/dp_manager.cxx
@@ -827,13 +827,7 @@ Reference<deployment::XPackage> PackageManagerImpl::addPackage(
try
{
OUString const id = dp_misc::getIdentifier( 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);
if (isInstalled(xPackage))
{