From 776d5631f5089f94cbe87b6f869f7887aeff2092 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 28 May 2010 17:50:38 +0200 Subject: jl152 #i77196# new update behavior for extensions --- .../deployment/manager/dp_extensionmanager.cxx | 77 ++++++++++++++++++++-- 1 file changed, 70 insertions(+), 7 deletions(-) (limited to 'desktop/source/deployment/manager/dp_extensionmanager.cxx') diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index fddefb5ad277..251e70a19ce6 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -250,7 +250,8 @@ void ExtensionManager::addExtensionsToMap( */ ::std::list > ExtensionManager::getExtensionsWithSameId( - OUString const & identifier, OUString const & fileName) + OUString const & identifier, OUString const & fileName, + Reference< ucb::XCommandEnvironment> const & xCmdEnv) { ::std::list > extensionList; @@ -282,13 +283,70 @@ void ExtensionManager::addExtensionsToMap( return extensionList; } +uno::Sequence > +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 > listExtensions = + getExtensionsWithSameId( + identifier, fileName, xCmdEnv); + sal_Bool bHasExtension = false; + + //throw an IllegalArgumentException if there is no extension at all. + typedef ::std::list >::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(this), -1); + + return comphelper::containerToSequence< + Reference, + ::std::list > + > (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(this), exc); + } +} + bool ExtensionManager::isUserDisabled( OUString const & identifier, OUString const & fileName) { - ::std::list > listExtensions = - getExtensionsWithSameId(identifier, fileName); + ::std::list > listExtensions; + + try { + listExtensions = getExtensionsWithSameId(identifier, fileName); + } catch (lang::IllegalArgumentException & ) { + } OSL_ASSERT(listExtensions.size() == 3); return isUserDisabled( ::comphelper::containerToSequence< @@ -339,8 +397,11 @@ void ExtensionManager::activateExtension( Reference const & xAbortChannel, Reference const & xCmdEnv ) { - ::std::list > listExtensions = - getExtensionsWithSameId(identifier, fileName); + ::std::list > listExtensions; + try { + listExtensions = getExtensionsWithSameId(identifier, fileName); + } catch (lang::IllegalArgumentException &) { + } OSL_ASSERT(listExtensions.size() == 3); activateExtension( @@ -510,9 +571,11 @@ Reference ExtensionManager::addExtension( ExtensionProperties props(OUString(), properties, Reference()); if (licenseAttributes && licenseAttributes->suppressIfRequired && props.isSuppressedLicense()) - _xCmdEnv = Reference(new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler())); + _xCmdEnv = Reference( + new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler())); + bCanInstall = xTmpExtension->checkPrerequisites( - xAbortChannel, _xCmdEnv, xOldExtension.is()) == 0 ? true : false; + xAbortChannel, _xCmdEnv, xOldExtension.is() || props.isExtensionUpdate()) == 0 ? true : false; } catch (deploy::DeploymentException& ) { excOccurred1 = ::cppu::getCaughtException(); -- cgit