diff options
19 files changed, 697 insertions, 406 deletions
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 1519e1f40596..6e76cfb574bd 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -284,9 +284,6 @@ Reference<deploy::XPackage> ExtensionManager::getExtensionAndStatus( contain any items which need to be registered then the extension cannot actually be disabled (because it cannot be registered). In this case false is returned. If there is no user extension then also false is returned. - - A user extension is regarded as disabled if there is an extension in a - repository with a lower priority that is registered. */ bool ExtensionManager::isUserExtensionDisabled( OUString const & identifier, OUString const & fileName, @@ -295,36 +292,19 @@ bool ExtensionManager::isUserExtensionDisabled( { bool bDisabled = false; - ::std::list<Reference<deploy::XPackage> > listExtensions = - getExtensionsWithSameId(identifier, fileName); - ::std::list<Reference<deploy::XPackage> >::const_iterator - iext = listExtensions.begin(); - bool bCheckOptional = false; - Reference<deploy::XPackage> xActive; - for (; iext != listExtensions.end(); iext++) + Reference<deploy::XPackage> xExtension; + try + { //will throw an exception if the extension does not exist + xExtension = m_userRepository->getDeployedPackage( + identifier, fileName, Reference<ucb::XCommandEnvironment>()); + } catch(lang::IllegalArgumentException &) { - if (iext->is()) - { - if (!(*iext)->isRegistered(xAbortChannel, xCmdEnv).IsPresent) - { - // IsPresent must be the same for all extnesions - OSL_ASSERT(!bCheckOptional); - break; - } - else - { - bCheckOptional = true; - if ((*iext)->isRegistered(xAbortChannel, xCmdEnv).Value.Value) - { - xActive = *iext; - break; - } - } - } - Reference<deploy::XPackage> const & xUser = listExtensions.front(); - if (xUser.is() - && xActive.is() - && xUser != xActive) + } + if (xExtension.is()) + { + beans::Optional<beans::Ambiguous<sal_Bool> > reg = + xExtension->isRegistered(xAbortChannel, xCmdEnv); + if (reg.IsPresent && ! reg.Value.Value) bDisabled = true; } return bDisabled; @@ -1105,13 +1085,13 @@ void ExtensionManager::synchronize( const OUString id = dp_misc::getIdentifier(xExtension); const OUString fileName = xExtension->getName(); - bool bUserDisabled = isUserExtensionDisabled( - id, xExtension->getName(), xAbortChannel, xCmdEnv); + bool bUserDisabled = isUserExtensionDisabled( + id, xExtension->getName(), xAbortChannel, xCmdEnv); xExtension->revokePackage(xAbortChannel, xCmdEnv); xPackageManager->removePackage( id, fileName, xAbortChannel, xCmdEnv); activateExtension( - id, fileName, bUserDisabled, xAbortChannel, xCmdEnv); + id, fileName, /*bUserDisabled*/ false, xAbortChannel, xCmdEnv); } catch (...) { diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 59e9f2049722..9b4f51ea89dd 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -567,7 +567,7 @@ OUString PackageManagerImpl::detectMediaType( try { Reference<deployment::XPackage> xPackage( m_xRegistry->bindPackage( - url, OUString(), false, ucbContent.getCommandEnvironment() ) ); + url, OUString(), false, OUString(), ucbContent.getCommandEnvironment() ) ); const Reference<deployment::XPackageTypeInfo> xPackageType( xPackage->getPackageType() ); OSL_ASSERT( xPackageType.is() ); @@ -785,7 +785,7 @@ Reference<deployment::XPackage> PackageManagerImpl::addPackage( //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, false, xCmdEnv ); + makeURL( destFolder, title_enc ), mediaType, false, OUString(), xCmdEnv ); OSL_ASSERT( xPackage.is() ); if (xPackage.is()) @@ -877,16 +877,6 @@ void PackageManagerImpl::removePackage( 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()) @@ -900,7 +890,12 @@ void PackageManagerImpl::removePackage( 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 @@ -908,7 +903,7 @@ void PackageManagerImpl::removePackage( //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 (m_context.equals(OUSTR("shared"))) + if (! m_readOnly && !xPackage->isRemoved() && m_context.equals(OUSTR("shared"))) { ActivePackages::Data val; m_activePackagesDB->get( & val, id, fileName); @@ -1010,8 +1005,17 @@ Reference<deployment::XPackage> PackageManagerImpl::getDeployedPackage_( static_cast<sal_Int16>(-1) ); } } - return m_xRegistry->bindPackage( - getDeployPath( data ), data.mediaType, false, xCmdEnv ); + Reference<deployment::XPackage> xExtension; + try + { + xExtension = m_xRegistry->bindPackage( + getDeployPath( data ), data.mediaType, false, OUString(), xCmdEnv ); + } + catch (deployment::InvalidRemovedParameterException& e) + { + xExtension = e.Extension; + } + return xExtension; } //______________________________________________________________________________ @@ -1149,17 +1153,6 @@ void PackageManagerImpl::reinstallDeployedPackages( 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 " @@ -1303,8 +1296,10 @@ void PackageManagerImpl::synchronizeRemovedExtensions( OSL_ENSURE(infoset.hasDescription(), "Extension Manager: bundled and shared extensions " "must have an identifer and a version"); - if ( ! i->first.equals(*(infoset.getIdentifier())) - || ! i->second.version.equals(infoset.getVersion())) + if (infoset.hasDescription() && + infoset.getIdentifier() && + (! i->first.equals(*(infoset.getIdentifier())) + || ! i->second.version.equals(infoset.getVersion()))) { bRemoved = true; } @@ -1313,7 +1308,7 @@ void PackageManagerImpl::synchronizeRemovedExtensions( if (bRemoved) { Reference<deployment::XPackage> xPackage = m_xRegistry->bindPackage( - url, i->second.mediaType, true, xCmdEnv ); + url, i->second.mediaType, true, i->first, xCmdEnv ); OSL_ASSERT(xPackage.is()); //Even if the files are removed, we must get the object. removedExtensions.push_back(xPackage); } @@ -1382,7 +1377,7 @@ void PackageManagerImpl::synchronizeAddedExtensions( url = appendURLSegement(url, sExtFolder); } Reference<deployment::XPackage> xPackage = m_xRegistry->bindPackage( - url, OUString(), false, xCmdEnv ); + url, OUString(), false, OUString(), xCmdEnv ); if (xPackage.is()) { try diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx index edaf642a2ab1..a942b81a7e32 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx @@ -92,6 +92,16 @@ void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data root->appendChild(componentNode); +// Reference<css::xml::dom::XNode> name( +// doc->createElement(OUSTR("name")), UNO_QUERY_THROW); + +// componentNode->appendChild(name); + +// Reference<css::xml::dom::XNode> nameValue( +// doc->createTextNode(data.name), +// UNO_QUERY_THROW); +// name->appendChild(nameValue); + Reference<css::xml::dom::XNode> javaTypeLibNode( doc->createElement(OUSTR("java-type-library")), UNO_QUERY_THROW); @@ -134,6 +144,54 @@ void ComponentBackendDb::removeEntry(::rtl::OUString const & url) removeElement(sExpression); } +ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & url) +{ + try + { + ComponentBackendDb::Data retData; + const OUString sExpression( + OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + Reference<css::xml::dom::XDocument> doc = getDocument(); + Reference<css::xml::dom::XNode> root = doc->getFirstChild(); + + Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference<css::xml::dom::XNode> aNode = + xpathApi->selectSingleNode(root, sExpression); + if (aNode.is()) + { +// const OUString sExprName(OUSTR("reg:name/text()")); + +// Reference<css::xml::dom::XNode> nameValue = +// xpathApi->selectSingleNode(aNode, sExprName); +// retData.name = nameValue->getNodeValue(); + + const OUString sExprJavaTypeLib(OUSTR("reg:java-type-library/text()")); + + Reference<css::xml::dom::XNode> idValueNode = + xpathApi->selectSingleNode(aNode, sExprJavaTypeLib); + retData.javaTypeLibrary = + idValueNode->getNodeValue().equals(OUSTR("true")) ? true : false; + + retData.implementationNames = + readList( + aNode, OUSTR("reg:implementation-names"), OUSTR("reg:name")); + + retData.singletons = + readVectorOfPair( + aNode, OUSTR("reg:singletons"), OUSTR("item"), OUSTR("key"), + OUSTR("value")); + } + return retData; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); + } +} } // namespace bundle diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx index 0dde24beed3f..29ac4e50fe88 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx @@ -60,6 +60,7 @@ namespace component { <?xml version="1.0"?> <component-backend-db xmlns="http://openoffice.org/extensionmanager/component-registry/2010"> <component url="vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages/5CD5.tmp_/leaves1.oxt/extensionoptions.jar"> + <name>FileName</name> <java-type-library>true</java-type-library> <implementation-names> <name>com.sun.star.comp.extensionoptions.OptionsEventHandler$_OptionsEventHandler</name> @@ -80,6 +81,11 @@ namespace component { */ class ComponentBackendDb: public dp_registry::backend::BackendDb { +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getRootElementName(); + public: struct Data { @@ -99,10 +105,7 @@ public: void addEntry(::rtl::OUString const & url, Data const & data); void removeEntry(::rtl::OUString const & url); - - virtual ::rtl::OUString getDbNSName(); - - virtual ::rtl::OUString getRootElementName(); + Data getEntry(::rtl::OUString const & url); }; diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index e4e5efff9e81..667f1588e247 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -123,6 +123,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend const OUString m_loader; Reference<XComponentContext> m_xRemoteContext; + ComponentBackendDb::Data m_registeredComponentsDb; enum reg { REG_UNINIT, REG_VOID, REG_REGISTERED, REG_NOT_REGISTERED, REG_MAYBE_REGISTERED @@ -152,16 +153,11 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend const Reference<registry::XSimpleRegistry> getRDB_RO() const; public: - inline ComponentPackageImpl( + ComponentPackageImpl( ::rtl::Reference<PackageRegistryBackend> const & myBackend, OUString const & url, OUString const & name, Reference<deployment::XPackageTypeInfo> const & xPackageType, - OUString const & loader, bool bUseDb ) - : Package( myBackend, url, name, name /* display-name */, - xPackageType, bUseDb ), - m_loader( loader ), - m_registered( REG_UNINIT ) - {} + OUString const & loader, bool bRemoved, OUString const & identifier); }; friend class ComponentPackageImpl; @@ -186,15 +182,11 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference<XCommandEnvironment> const & xCmdEnv ); public: - inline TypelibraryPackageImpl( + TypelibraryPackageImpl( ::rtl::Reference<PackageRegistryBackend> const & myBackend, OUString const & url, OUString const & name, Reference<deployment::XPackageTypeInfo> const & xPackageType, - bool jarFile, bool bUseDb ) - : Package( myBackend, url, name, name /* display-name */, - xPackageType, bUseDb), - m_jarFile( jarFile ) - {} + bool jarFile, bool bRemoved, OUString const & identifier); }; friend class TypelibraryPackageImpl; @@ -215,7 +207,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference<deployment::XPackage> bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bNoFileAccess, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -238,6 +230,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend void addDataToDb(OUString const & url, ComponentBackendDb::Data const & data); void deleteDataFromDb(OUString const & url); + ComponentBackendDb::Data readDataFromDb(OUString const & url); //These rdbs are for writing new service entries. The rdb files are copies @@ -285,6 +278,24 @@ public: }; //______________________________________________________________________________ + +BackendImpl::ComponentPackageImpl::ComponentPackageImpl( + ::rtl::Reference<PackageRegistryBackend> const & myBackend, + OUString const & url, OUString const & name, + Reference<deployment::XPackageTypeInfo> const & xPackageType, + OUString const & loader, bool bRemoved, OUString const & identifier) + : Package( myBackend, url, name, name /* display-name */, + xPackageType, bRemoved, identifier), + m_loader( loader ), + m_registered( REG_UNINIT ) +{ + if (bRemoved) + { + m_registeredComponentsDb = getMyBackend()->readDataFromDb(url); + } +} + + const Reference<registry::XSimpleRegistry> BackendImpl::ComponentPackageImpl::getRDB() const { @@ -593,6 +604,14 @@ void BackendImpl::deleteDataFromDb(OUString const & url) m_backendDb->removeEntry(url); } +ComponentBackendDb::Data BackendImpl::readDataFromDb(OUString const & url) +{ + ComponentBackendDb::Data data; + if (m_backendDb.get()) + data = m_backendDb->getEntry(url); + return data; +} + // XPackageRegistry //______________________________________________________________________________ Sequence< Reference<deployment::XPackageTypeInfo> > @@ -605,7 +624,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ) { OUString mediaType(mediaType_); @@ -661,9 +680,14 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); - const OUString name( ucbContent.getPropertyValue( - StrTitle::get() ).get<OUString>() ); + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); + name = ucbContent.getPropertyValue( + StrTitle::get() ).get<OUString>(); + } + if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.uno-component")) { // xxx todo: probe and evaluate component xml description @@ -679,19 +703,19 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( return new BackendImpl::ComponentPackageImpl( this, url, name, m_xDynComponentTypeInfo, OUSTR("com.sun.star.loader.SharedLibrary"), - bNoFileAccess ); + bRemoved, identifier); } if (value.EqualsIgnoreCaseAscii("Java")) { return new BackendImpl::ComponentPackageImpl( this, url, name, m_xJavaComponentTypeInfo, OUSTR("com.sun.star.loader.Java2"), - bNoFileAccess ); + bRemoved, identifier); } if (value.EqualsIgnoreCaseAscii("Python")) { return new BackendImpl::ComponentPackageImpl( this, url, name, m_xPythonComponentTypeInfo, OUSTR("com.sun.star.loader.Python"), - bNoFileAccess); + bRemoved, identifier); } } } @@ -707,12 +731,12 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( { return new BackendImpl::TypelibraryPackageImpl( this, url, name, m_xRDBTypelibTypeInfo, - false /* rdb */, bNoFileAccess); + false /* rdb */, bRemoved, identifier); } if (value.EqualsIgnoreCaseAscii("Java")) { return new BackendImpl::TypelibraryPackageImpl( this, url, name, m_xJavaTypelibTypeInfo, - true /* jar */, bNoFileAccess); + true /* jar */, bRemoved, identifier); } } } @@ -749,16 +773,13 @@ void BackendImpl::unorc_verify_init( sal_Int32 index = sizeof ("UNO_JAVA_CLASSPATH=") - 1; do { OUString token( line.getToken( 0, ' ', index ).trim() ); - if (token.getLength() > 0) { - // cleanup, check if existing: - if (create_ucb_content( - 0, expandUnoRcTerm(token), xCmdEnv, - false /* no throw */ )) { - m_jar_typelibs.push_back( token ); - } - else - OSL_ENSURE( - 0, "### invalid UNO_JAVA_CLASSPATH entry!" ); + if (token.getLength() > 0) + { + //The jar file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the unorc + //After running XExtensionManager::synchronize, the unorc is + //cleaned up + m_jar_typelibs.push_back( token ); } } while (index >= 0); @@ -768,17 +789,15 @@ void BackendImpl::unorc_verify_init( sal_Int32 index = sizeof ("UNO_TYPES=") - 1; do { OUString token( line.getToken( 0, ' ', index ).trim() ); - if (token.getLength() > 0) { + if (token.getLength() > 0) + { if (token[ 0 ] == '?') token = token.copy( 1 ); - // cleanup, check if existing: - if (create_ucb_content( - 0, expandUnoRcTerm(token), - xCmdEnv, false /* no throw */ )) { - m_rdb_typelibs.push_back( token ); - } - else - OSL_ENSURE( 0, "### invalid UNO_TYPES entry!" ); + //The RDB file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the unorc. + //After running XExtensionManager::synchronize, the unorc is + //cleaned up + m_rdb_typelibs.push_back( token ); } } while (index >= 0); @@ -1211,8 +1230,12 @@ void BackendImpl::ComponentPackageImpl::processPackage_( const bool java = m_loader.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.Java2") ); const OUString url( getURL() ); - bool isJavaTypelib = java && - !jarManifestHeaderPresent( url, OUSTR("UNO-Type-Path"), xCmdEnv ); + bool isJavaTypelib; + if (m_bRemoved) + isJavaTypelib = m_registeredComponentsDb.javaTypeLibrary; + else + isJavaTypelib = java && + !jarManifestHeaderPresent( url, OUSTR("UNO-Type-Path"), xCmdEnv ); ComponentBackendDb::Data data; data.javaTypeLibrary = isJavaTypelib; @@ -1330,8 +1353,15 @@ void BackendImpl::ComponentPackageImpl::processPackage_( t_stringlist implNames; t_stringpairvec singletons; - getComponentInfo( &implNames, &singletons, xContext ); - + if (m_bRemoved) + { + implNames = m_registeredComponentsDb.implementationNames; + singletons = m_registeredComponentsDb.singletons; + } + else + { + getComponentInfo( &implNames, &singletons, xContext ); + } // factories live removal: const Reference<container::XSet> xSet( that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW ); @@ -1405,6 +1435,16 @@ void BackendImpl::ComponentPackageImpl::processPackage_( } //############################################################################## +BackendImpl::TypelibraryPackageImpl::TypelibraryPackageImpl( + ::rtl::Reference<PackageRegistryBackend> const & myBackend, + OUString const & url, OUString const & name, + Reference<deployment::XPackageTypeInfo> const & xPackageType, + bool jarFile, bool bRemoved, OUString const & identifier) + : Package( myBackend, url, name, name /* display-name */, + xPackageType, bRemoved, identifier), + m_jarFile( jarFile ) +{ +} // Package BackendImpl * BackendImpl::TypelibraryPackageImpl::getMyBackend() const diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 7118e6d1b2d5..354676fd56ff 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -94,9 +94,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference<PackageRegistryBackend> const & myBackend, OUString const & url, OUString const & name, Reference<deployment::XPackageTypeInfo> const & xPackageType, - bool isSchema, bool bUseDb) + bool isSchema, bool bRemoved, OUString const & identifier) : Package( myBackend, url, name, name /* display-name */, - xPackageType, bUseDb), + xPackageType, bRemoved, identifier), m_isSchema( isSchema ) {} }; @@ -113,8 +113,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference<deployment::XPackage> bindPackage_( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference<XCommandEnvironment> const & xCmdEnv ); + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ); ::std::auto_ptr<PersistentMap> m_registeredPackages; // for backwards compatibility @@ -215,7 +215,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -250,20 +250,27 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); + name = ucbContent.getPropertyValue( + StrTitle::get() ).get<OUString>(); + } + ::ucbhelper::Content ucbContent( url, xCmdEnv ); if (subType.EqualsIgnoreCaseAscii( - "vnd.sun.star.configuration-data")) { + "vnd.sun.star.configuration-data")) + { return new PackageImpl( - this, url, ucbContent.getPropertyValue( - StrTitle::get() ).get<OUString>(), - m_xConfDataTypeInfo, false /* data file */, bNoFileAccess); + this, url, name, m_xConfDataTypeInfo, false /* data file */, + bRemoved, identifier); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.configuration-schema")) { return new PackageImpl( - this, url, ucbContent.getPropertyValue( - StrTitle::get() ).get<OUString>(), - m_xConfSchemaTypeInfo, true /* schema file */, bNoFileAccess); + this, url, name, m_xConfSchemaTypeInfo, true /* schema file */, + bRemoved, identifier); } } } diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index 31bb30de7315..7ee49fc46734 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -36,6 +36,7 @@ #include "comphelper/unwrapargs.hxx" #include "ucbhelper/content.hxx" #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" +#include "com/sun/star/deployment/InvalidRemovedParameterException.hpp" #include "com/sun/star/beans/StringPair.hpp" @@ -131,29 +132,40 @@ void PackageRegistryBackend::disposing() // XPackageRegistry //______________________________________________________________________________ Reference<deployment::XPackage> PackageRegistryBackend::bindPackage( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess , - Reference<XCommandEnvironment> const & xCmdEnv ) - throw (deployment::DeploymentException, CommandFailedException, + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ) + throw (deployment::DeploymentException, + deployment::InvalidRemovedParameterException, + ucb::CommandFailedException, lang::IllegalArgumentException, RuntimeException) { ::osl::ResettableMutexGuard guard( getMutex() ); check(); - if (!bNoFileAccess) + + t_string2ref::const_iterator const iFind( m_bound.find( url ) ); + if (iFind != m_bound.end()) { - //We only save those object which were created with bNoFileAccess = false - t_string2ref::const_iterator const iFind( m_bound.find( url ) ); - if (iFind != m_bound.end()) + Reference<deployment::XPackage> xPackage( iFind->second ); + if (xPackage.is()) { - Reference<deployment::XPackage> xPackage( iFind->second ); - if (xPackage.is()) - return xPackage; + if (mediaType.getLength() && + mediaType != xPackage->getPackageType()->getMediaType()) + throw lang::IllegalArgumentException + (OUSTR("XPackageRegistry::bindPackage: media type does not match"), + static_cast<OWeakObject*>(this), 1); + if (xPackage->isRemoved() != bRemoved) + throw deployment::InvalidRemovedParameterException( + OUSTR("XPackageRegistry::bindPackage: bRemoved parameter does not match"), + static_cast<OWeakObject*>(this), xPackage->isRemoved(), xPackage); + return xPackage; } } + guard.clear(); Reference<deployment::XPackage> xNewPackage; try { - xNewPackage = bindPackage_( url, mediaType, bNoFileAccess, xCmdEnv ); + xNewPackage = bindPackage_( url, mediaType, bRemoved, identifier, xCmdEnv ); } catch (RuntimeException &) { throw; @@ -175,24 +187,22 @@ Reference<deployment::XPackage> PackageRegistryBackend::bindPackage( } guard.reset(); - if (!bNoFileAccess) - { - //We only save those object which were created with bNoFileAccess = false - ::std::pair< t_string2ref::iterator, bool > insertion( - m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) ); - if (insertion.second) - { // first insertion - OSL_ASSERT( Reference<XInterface>(insertion.first->second) - == xNewPackage ); - } - else - { // found existing entry - Reference<deployment::XPackage> xPackage( insertion.first->second ); - if (xPackage.is()) - return xPackage; - insertion.first->second = xNewPackage; - } + + ::std::pair< t_string2ref::iterator, bool > insertion( + m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) ); + if (insertion.second) + { // first insertion + OSL_ASSERT( Reference<XInterface>(insertion.first->second) + == xNewPackage ); } + else + { // found existing entry + Reference<deployment::XPackage> xPackage( insertion.first->second ); + if (xPackage.is()) + return xPackage; + insertion.first->second = xNewPackage; + } + guard.clear(); xNewPackage->addEventListener( this ); // listen for disposing events return xNewPackage; @@ -211,14 +221,16 @@ Package::Package( ::rtl::Reference<PackageRegistryBackend> const & myBackend, OUString const & name, OUString const & displayName, Reference<deployment::XPackageTypeInfo> const & xPackageType, - bool bUseDb) + bool bRemoved, + OUString const & identifier) : t_PackageBase( getMutex() ), m_myBackend( myBackend ), m_url( url ), m_name( name ), m_displayName( displayName ), m_xPackageType( xPackageType ), - m_bUseDb(bUseDb) + m_bRemoved(bRemoved), + m_identifier(identifier) { } @@ -314,10 +326,13 @@ sal_Bool Package::isBundle() throw (RuntimeException) const css::uno::Reference< css::ucb::XCommandEnvironment >&, sal_Bool, ::rtl::OUString const &) throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::ucb::CommandAbortedException, - css::uno::RuntimeException) + css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::uno::RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return true; } @@ -325,9 +340,12 @@ sal_Bool Package::isBundle() throw (RuntimeException) ::sal_Bool Package::checkDependencies( const css::uno::Reference< css::ucb::XCommandEnvironment >& ) throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::uno::RuntimeException) + css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, + css::uno::RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return true; } @@ -351,12 +369,19 @@ OUString Package::getName() throw (RuntimeException) beans::Optional<OUString> Package::getIdentifier() throw (RuntimeException) { + if (m_bRemoved) + return beans::Optional<OUString>(true, m_identifier); + return beans::Optional<OUString>(); } //______________________________________________________________________________ -OUString Package::getVersion() throw (RuntimeException) +OUString Package::getVersion() throw ( + deployment::ExtensionRemovedException, + RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return OUString(); } @@ -367,33 +392,49 @@ OUString Package::getURL() throw (RuntimeException) } //______________________________________________________________________________ -OUString Package::getDisplayName() throw (RuntimeException) +OUString Package::getDisplayName() throw ( + deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return m_displayName; } //______________________________________________________________________________ -OUString Package::getDescription() throw (RuntimeException) +OUString Package::getDescription() throw ( + deployment::ExtensionRemovedException,RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return OUString(); } //______________________________________________________________________________ -Sequence<OUString> Package::getUpdateInformationURLs() throw (RuntimeException) +Sequence<OUString> Package::getUpdateInformationURLs() throw ( + deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return Sequence<OUString>(); } //______________________________________________________________________________ -css::beans::StringPair Package::getPublisherInfo() throw (RuntimeException) +css::beans::StringPair Package::getPublisherInfo() throw ( + deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); css::beans::StringPair aEmptyPair; return aEmptyPair; } //______________________________________________________________________________ -uno::Reference< css::graphic::XGraphic > Package::getIcon( sal_Bool /*bHighContrast*/ ) throw ( RuntimeException ) +uno::Reference< css::graphic::XGraphic > Package::getIcon( sal_Bool /*bHighContrast*/ ) + throw (deployment::ExtensionRemovedException, RuntimeException ) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + uno::Reference< css::graphic::XGraphic > aEmpty; return aEmpty; } @@ -409,8 +450,12 @@ Reference<deployment::XPackageTypeInfo> Package::getPackageType() void Package::exportTo( OUString const & destFolderURL, OUString const & newTitle, sal_Int32 nameClashAction, Reference<XCommandEnvironment> const & xCmdEnv ) - throw (CommandFailedException, CommandAbortedException, RuntimeException) + throw (deployment::ExtensionRemovedException, + CommandFailedException, CommandAbortedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + ::ucbhelper::Content destFolder( destFolderURL, xCmdEnv ); ::ucbhelper::Content sourceContent( getURL(), xCmdEnv ); if (! destFolder.transferContent( @@ -493,7 +538,8 @@ void Package::processPackage_impl( (doRegisterPackage ? !option.Value.Value : option.Value.Value))); if (action) { - OUString displayName( getDisplayName() ); + + OUString displayName = isRemoved() ? getName() : getDisplayName(); ProgressLevel progress( xCmdEnv, (doRegisterPackage @@ -542,9 +588,12 @@ void Package::registerPackage( Reference<task::XAbortChannel> const & xAbortChannel, Reference<XCommandEnvironment> const & xCmdEnv ) throw (deployment::DeploymentException, + deployment::ExtensionRemovedException, CommandFailedException, CommandAbortedException, lang::IllegalArgumentException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); processPackage_impl( true /* register */, xAbortChannel, xCmdEnv ); } @@ -579,7 +628,13 @@ OUString Package::getRepositoryName() { PackageRegistryBackend * backEnd = getMyBackend(); return backEnd->getContext(); - } +} + +sal_Bool Package::isRemoved() + throw (RuntimeException) +{ + return m_bRemoved; +} //############################################################################## @@ -596,13 +651,15 @@ OUString Package::TypeInfo::getMediaType() throw (RuntimeException) } //______________________________________________________________________________ -OUString Package::TypeInfo::getDescription() throw (RuntimeException) +OUString Package::TypeInfo::getDescription() + throw (deployment::ExtensionRemovedException, RuntimeException) { return getShortDescription(); } //______________________________________________________________________________ -OUString Package::TypeInfo::getShortDescription() throw (RuntimeException) +OUString Package::TypeInfo::getShortDescription() + throw (deployment::ExtensionRemovedException, RuntimeException) { return m_shortDescr; } diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index fb0b99c3363c..339236126796 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -259,31 +259,41 @@ BackendDb::readVectorOfPair( OUString const & sFirstTagName, OUString const & sSecondTagName) { - OSL_ASSERT(parent.is()); - Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI(); - OUString sExprPairs( - sListTagName + OUSTR("/") + sPairTagName); - Reference<css::xml::dom::XNodeList> listPairs = - xpathApi->selectNodeList(parent, sExprPairs); - - ::std::vector< ::std::pair< OUString, OUString > > retVector; - sal_Int32 length = listPairs->getLength(); - for (sal_Int32 i = 0; i < length; i++) + try { - Reference<css::xml::dom::XNode> aPair = listPairs->item(i); - OUString sExprFirst(sFirstTagName + OUSTR("/text()")); - Reference<css::xml::dom::XNode> first = - xpathApi->selectSingleNode(aPair, sExprFirst); - - OUString sExprSecond(sSecondTagName + OUSTR("/text()")); - Reference<css::xml::dom::XNode> second = - xpathApi->selectSingleNode(aPair, sExprSecond); - OSL_ASSERT(first.is() && second.is()); - - retVector.push_back(::std::make_pair( - first->getNodeValue(), second->getNodeValue())); + OSL_ASSERT(parent.is()); + Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI(); + OUString sExprPairs( + sListTagName + OUSTR("/") + sPairTagName); + Reference<css::xml::dom::XNodeList> listPairs = + xpathApi->selectNodeList(parent, sExprPairs); + + ::std::vector< ::std::pair< OUString, OUString > > retVector; + sal_Int32 length = listPairs->getLength(); + for (sal_Int32 i = 0; i < length; i++) + { + Reference<css::xml::dom::XNode> aPair = listPairs->item(i); + OUString sExprFirst(sFirstTagName + OUSTR("/text()")); + Reference<css::xml::dom::XNode> first = + xpathApi->selectSingleNode(aPair, sExprFirst); + + OUString sExprSecond(sSecondTagName + OUSTR("/text()")); + Reference<css::xml::dom::XNode> second = + xpathApi->selectSingleNode(aPair, sExprSecond); + OSL_ASSERT(first.is() && second.is()); + + retVector.push_back(::std::make_pair( + first->getNodeValue(), second->getNodeValue())); + } + return retVector; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); } - return retVector; } void BackendDb::writeSimpleList( @@ -327,6 +337,40 @@ void BackendDb::writeSimpleList( } +::std::list< OUString> BackendDb::readList( + Reference<css::xml::dom::XNode> const & parent, + OUString const & sListTagName, + OUString const & sMemberTagName) +{ + try + { + OSL_ASSERT(parent.is()); + Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI(); + OUString sExprList( + sListTagName + OUSTR("/") + sMemberTagName + OUSTR("/text()")); + Reference<css::xml::dom::XNodeList> list = + xpathApi->selectNodeList(parent, sExprList); + + ::std::list<OUString > retList; + sal_Int32 length = list->getLength(); + for (sal_Int32 i = 0; i < length; i++) + { + Reference<css::xml::dom::XNode> member = list->item(i); + retList.push_back(member->getNodeValue()); + } + return retList; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + + + } // namespace backend } // namespace dp_registry diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index 9ea13ad2c91f..0b3b9e80a7d7 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -127,7 +127,7 @@ public: // XPackageRegistry virtual Reference<deployment::XPackage> SAL_CALL bindPackage( OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference<XCommandEnvironment> const & xCmdEnv ) + OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException); virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL @@ -458,8 +458,8 @@ void PackageRegistryImpl::update() throw (RuntimeException) // XPackageRegistry //______________________________________________________________________________ Reference<deployment::XPackage> PackageRegistryImpl::bindPackage( - OUString const & url, OUString const & mediaType_, sal_Bool bNoFileAccess, - Reference<XCommandEnvironment> const & xCmdEnv ) + OUString const & url, OUString const & mediaType_, sal_Bool bRemoved, + OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException) { @@ -497,7 +497,7 @@ Reference<deployment::XPackage> PackageRegistryImpl::bindPackage( for ( ; iPos != iEnd; ++iPos ) { try { - return (*iPos)->bindPackage( url, mediaType, bNoFileAccess, xCmdEnv ); + return (*iPos)->bindPackage( url, mediaType, bRemoved, identifier, xCmdEnv ); } catch (lang::IllegalArgumentException &) { } @@ -526,7 +526,7 @@ Reference<deployment::XPackage> PackageRegistryImpl::bindPackage( getResourceString(RID_STR_UNSUPPORTED_MEDIA_TYPE) + mediaType, static_cast<OWeakObject *>(this), static_cast<sal_Int16>(-1) ); } - return iFind->second->bindPackage( url, mediaType, bNoFileAccess, xCmdEnv ); + return iFind->second->bindPackage( url, mediaType, bRemoved, identifier, xCmdEnv ); } } diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index a5fe1b99746f..39fd3cdc892e 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -72,9 +72,10 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend inline ExecutablePackageImpl( ::rtl::Reference<PackageRegistryBackend> const & myBackend, OUString const & url, OUString const & name, - Reference<deployment::XPackageTypeInfo> const & xPackageType, bool bUseDb) + Reference<deployment::XPackageTypeInfo> const & xPackageType, + bool bRemoved, OUString const & identifier) : Package( myBackend, url, name, name /* display-name */, - xPackageType, bUseDb) //, + xPackageType, bRemoved, identifier) {} }; friend class ExecutablePackageImpl; @@ -84,8 +85,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference<deployment::XPackage> bindPackage_( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference<XCommandEnvironment> const & xCmdEnv ); + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ); Reference<deployment::XPackageTypeInfo> m_xExecutableTypeInfo; @@ -125,8 +126,8 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) // PackageRegistryBackend Reference<deployment::XPackage> BackendImpl::bindPackage_( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference<XCommandEnvironment> const & xCmdEnv ) + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ) { if (mediaType.getLength() == 0) { @@ -141,13 +142,17 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); - const OUString name( ucbContent.getPropertyValue( - dp_misc::StrTitle::get() ).get<OUString>() ); + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); + name = ucbContent.getPropertyValue( + dp_misc::StrTitle::get() ).get<OUString>(); + } if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.executable")) { return new BackendImpl::ExecutablePackageImpl( - this, url, name, m_xExecutableTypeInfo, bNoFileAccess); + this, url, name, m_xExecutableTypeInfo, bRemoved, identifier); } } } diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 05ff8dda0e01..9fd9e7ae79fc 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -79,8 +79,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference<PackageRegistryBackend> const & myBackend, OUString const & url, OUString const & name, Reference<deployment::XPackageTypeInfo> const & xPackageType, - bool bUseDb) - : Package( myBackend, url, name, name, xPackageType, bUseDb) + bool bRemoved, OUString const & identifier) + : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) {} }; friend class PackageImpl; @@ -88,7 +88,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference<deployment::XPackage> bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ); void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage ); @@ -140,7 +140,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ) { // we don't support auto detection: @@ -155,14 +155,19 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); + name = ucbContent.getPropertyValue( + StrTitle::get() ).get<OUString>(); + } + if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.help")) { return new PackageImpl( - this, url, - ucbContent.getPropertyValue( StrTitle::get() ).get<OUString>(), - m_xHelpTypeInfo, bNoFileAccess); + this, url, name, m_xHelpTypeInfo, bRemoved, identifier); } } } diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 09b25caedc2b..371faf579caf 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -40,6 +40,7 @@ #include "com/sun/star/lang/XEventListener.hpp" #include "com/sun/star/deployment/XPackageRegistry.hpp" #include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/InvalidRemovedParameterException.hpp" #include <memory> #include <hash_map> #include "dp_registry.hrc" @@ -74,7 +75,9 @@ protected: ::rtl::OUString m_name; ::rtl::OUString m_displayName; const css::uno::Reference<css::deployment::XPackageTypeInfo> m_xPackageType; - const bool m_bUseDb; + const bool m_bRemoved; + //Only set if m_bRemoved = true; + const ::rtl::OUString m_identifier; void check() const; void fireModified(); @@ -104,7 +107,8 @@ protected: ::rtl::OUString const & displayName, css::uno::Reference<css::deployment::XPackageTypeInfo> const & xPackageType, - bool bUseDb); + bool bRemoved, + ::rtl::OUString const & identifier); public: @@ -129,9 +133,11 @@ public: virtual ::rtl::OUString SAL_CALL getMediaType() throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getDescription() - throw (css::uno::RuntimeException); + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getShortDescription() - throw (css::uno::RuntimeException); + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getFileFilter() throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getIcon( sal_Bool highContrast, @@ -173,20 +179,23 @@ public: const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, sal_Bool bInstalled, ::rtl::OUString const & aContextName) throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::ucb::CommandAbortedException, - css::uno::RuntimeException); + css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL checkDependencies( const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv ) throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::uno::RuntimeException); + css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, + css::uno::RuntimeException); virtual void SAL_CALL registerPackage( css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) throw (css::deployment::DeploymentException, + css::deployment::ExtensionRemovedException, css::ucb::CommandFailedException, css::ucb::CommandAbortedException, css::lang::IllegalArgumentException, css::uno::RuntimeException); @@ -214,19 +223,27 @@ public: virtual css::beans::Optional< ::rtl::OUString > SAL_CALL getIdentifier() throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getVersion() - throw (css::uno::RuntimeException); + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getURL() throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getDisplayName() - throw (css::uno::RuntimeException); + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getDescription() - throw (css::uno::RuntimeException); + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL - getUpdateInformationURLs() throw (css::uno::RuntimeException); - - virtual css::beans::StringPair SAL_CALL getPublisherInfo() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getIcon( sal_Bool bHighContrast ) throw (css::uno::RuntimeException); - + getUpdateInformationURLs() + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); + virtual css::beans::StringPair SAL_CALL getPublisherInfo() + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); + virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL + getIcon( sal_Bool bHighContrast ) + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual css::uno::Reference<css::deployment::XPackageTypeInfo> SAL_CALL getPackageType() throw (css::uno::RuntimeException); virtual void SAL_CALL exportTo( @@ -234,11 +251,14 @@ public: ::rtl::OUString const & newTitle, sal_Int32 nameClashAction, css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) - throw (css::ucb::CommandFailedException, + throw (css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, css::ucb::CommandAbortedException, css::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getRepositoryName() + throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL isRemoved() + throw (css::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getRepositoryName() - throw (css::uno::RuntimeException); }; typedef ::cppu::WeakComponentImplHelper2< @@ -282,7 +302,7 @@ protected: // @@@ to be implemented by specific backend: virtual css::uno::Reference<css::deployment::XPackage> bindPackage_( ::rtl::OUString const & url, ::rtl::OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, ::rtl::OUString const & identifier, css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) = 0; @@ -315,14 +335,12 @@ public: // XPackageRegistry virtual css::uno::Reference<css::deployment::XPackage> SAL_CALL bindPackage( ::rtl::OUString const & url, ::rtl::OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, ::rtl::OUString const & identifier, css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) throw (css::deployment::DeploymentException, + css::deployment::InvalidRemovedParameterException, css::ucb::CommandFailedException, css::lang::IllegalArgumentException, css::uno::RuntimeException); -// virtual css::uno::Sequence< -// css::uno::Reference<css::deployment::XPackageTypeInfo> > SAL_CALL -// getSupportedPackageTypes() throw (css::uno::RuntimeException); }; } diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index 3005ffcafb5b..dbac54e10c6d 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -97,6 +97,12 @@ protected: ::rtl::OUString const & sFirstTagName, ::rtl::OUString const & sSecondTagName); + ::std::list< ::rtl::OUString> readList( + css::uno::Reference<css::xml::dom::XNode> const & parent, + ::rtl::OUString const & sListTagName, + ::rtl::OUString const & sMemberTagName); + + /* returns the namespace which is to be written as xmlns attribute diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx index 97cfc136049c..93aa62174e0f 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx @@ -46,22 +46,6 @@ using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/extension-registry/2010" #define ROOT_ELEMENT_NAME "extension-backend-db" -// /extension-backend-db/extension -#define EXTENSION_ELEMENT "extension" - -// /extension-backend-db/extension/extension-items -#define EXTENSION_ITEMS "extension-items" - -// /extension-backend-db/extension/extension-items/item -#define EXTENSION_ITEMS_ITEM "item" - -// /extension-backend-db/extension/extension-items/item/url -#define ITEM_URL "url" - -// /extension-backend-db/extension/extension-items/item/media-type -#define ITEM_MEDIA_TYP "media-type" - - namespace dp_registry { namespace backend { namespace bundle { @@ -109,13 +93,13 @@ void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data root->appendChild(extensionNodeNode); // <identifier>...</identifier> - Reference<css::xml::dom::XNode> identifierNode( - doc->createElement(OUSTR("identifier")), UNO_QUERY_THROW); - extensionNodeNode->appendChild(identifierNode); +// Reference<css::xml::dom::XNode> identifierNode( +// doc->createElement(OUSTR("identifier")), UNO_QUERY_THROW); +// extensionNodeNode->appendChild(identifierNode); - Reference<css::xml::dom::XNode> identifierValue( - doc->createTextNode(data.identifier), UNO_QUERY_THROW); - identifierNode->appendChild(identifierValue); +// Reference<css::xml::dom::XNode> identifierValue( +// doc->createTextNode(data.identifier), UNO_QUERY_THROW); +// identifierNode->appendChild(identifierValue); writeVectorOfPair( @@ -145,30 +129,41 @@ void ExtensionBackendDb::removeEntry(::rtl::OUString const & url) ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & url) { - ExtensionBackendDb::Data retData; - const OUString sExpression( - OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); - Reference<css::xml::dom::XDocument> doc = getDocument(); - Reference<css::xml::dom::XNode> root = doc->getFirstChild(); - - Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI(); - //find the extension element that is to be removed - Reference<css::xml::dom::XNode> aNode = - xpathApi->selectSingleNode(root, sExpression); - OSL_ASSERT(aNode.is()); - - const OUString sExprIdentifier(OUSTR("reg:identifier/text()")); - - Reference<css::xml::dom::XNode> idValueNode = - xpathApi->selectSingleNode(aNode, sExprIdentifier); - retData.identifier = idValueNode->getNodeValue(); - - retData.items = - readVectorOfPair( - aNode, - OUSTR("reg:extension-items"), - OUSTR("reg:item"), OUSTR("reg:url"), OUSTR("reg:media-type")); - return retData; + try + { + ExtensionBackendDb::Data retData; + const OUString sExpression( + OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + Reference<css::xml::dom::XDocument> doc = getDocument(); + Reference<css::xml::dom::XNode> root = doc->getFirstChild(); + + Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI(); + + Reference<css::xml::dom::XNode> aNode = + xpathApi->selectSingleNode(root, sExpression); + if (aNode.is()) + { +// const OUString sExprIdentifier(OUSTR("reg:identifier/text()")); + +// Reference<css::xml::dom::XNode> idValueNode = +// xpathApi->selectSingleNode(aNode, sExprIdentifier); +// retData.identifier = idValueNode->getNodeValue(); + + retData.items = + readVectorOfPair( + aNode, + OUSTR("reg:extension-items"), + OUSTR("reg:item"), OUSTR("reg:url"), OUSTR("reg:media-type")); + } + return retData; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in backend db: ") + + m_urlDb, 0, exc); + } } } // namespace bundle diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx index 156e34155040..4afe6f1a5577 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx @@ -58,11 +58,15 @@ namespace bundle { */ class ExtensionBackendDb: public dp_registry::backend::BackendDb { +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getRootElementName(); + public: struct Data { - ::rtl::OUString identifier; - /* every element consists of a pair of the url to the item (jar,rdb, etc) + /* every element consists of a pair of the url to the item (jar,rdb, etc) and the media type */ ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString> > items; @@ -80,9 +84,6 @@ public: void removeEntry(::rtl::OUString const & url); Data getEntry(::rtl::OUString const & url); - virtual ::rtl::OUString getDbNSName(); - - virtual ::rtl::OUString getRootElementName(); }; diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 8fe7874f247f..467ff5ca89fa 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -77,9 +77,9 @@ using namespace ::dp_misc; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::ucb; + namespace css = ::com::sun::star; -namespace cssu = ::com::sun::star::uno; + using ::rtl::OUString; namespace dp_registry { @@ -105,46 +105,49 @@ class BackendImpl : public ImplBaseT Sequence< Reference<deployment::XPackage> > m_bundle; Sequence< Reference<deployment::XPackage> > * m_pBundle; - ExtensionBackendDb::Data m_data; + ExtensionBackendDb::Data m_dbData; Reference<deployment::XPackage> bindBundleItem( OUString const & url, OUString const & mediaType, - Reference<XCommandEnvironment> const & xCmdEnv, + sal_Bool bRemoved, //that is, useing data base information + OUString const & identifier, + Reference<ucb::XCommandEnvironment> const & xCmdEnv, bool notifyDetectionError = true ); typedef ::std::vector< Reference<deployment::XPackage> > t_packagevec; void scanBundle( t_packagevec & bundle, ::rtl::Reference<AbortChannel> const & abortChannel, - Reference<XCommandEnvironment> const & xCmdEnv ); + Reference<ucb::XCommandEnvironment> const & xCmdEnv ); void scanLegacyBundle( t_packagevec & bundle, OUString const & url, ::rtl::Reference<AbortChannel> const & abortChannel, - Reference<XCommandEnvironment> const & xCmdEnv, + Reference<ucb::XCommandEnvironment> const & xCmdEnv, bool skip_registration = false ); - ::std::vector<Reference<deployment::XPackage> > getPackagesFromDb(); + ::std::vector<Reference<deployment::XPackage> > getPackagesFromDb( + Reference<ucb::XCommandEnvironment> const & xCmdEnv); bool checkPlatform( - css::uno::Reference< css::ucb::XCommandEnvironment > const & environment); + Reference<ucb::XCommandEnvironment > const & environment); bool checkDependencies( - css::uno::Reference< css::ucb::XCommandEnvironment > const & + Reference<ucb::XCommandEnvironment > const & environment, DescriptionInfoset const & description); // throws css::uno::RuntimeException, // css::deployment::DeploymentException ::sal_Bool checkLicense( - css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv, + Reference< ucb::XCommandEnvironment > const & xCmdEnv, DescriptionInfoset const & description, bool bInstalled, OUString const & aContextName ) - throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::ucb::CommandAbortedException, - css::uno::RuntimeException); + throw (deployment::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + RuntimeException); // @throws DeploymentException OUString getTextFromURL( - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, + const Reference< ucb::XCommandEnvironment >& xCmdEnv, const OUString& licenseUrl); DescriptionInfoset getDescriptionInfoset(); @@ -153,12 +156,12 @@ class BackendImpl : public ImplBaseT virtual beans::Optional< beans::Ambiguous<sal_Bool> > isRegistered_( ::osl::ResettableMutexGuard & guard, ::rtl::Reference<AbortChannel> const & abortChannel, - Reference<XCommandEnvironment> const & xCmdEnv ); + Reference<ucb::XCommandEnvironment> const & xCmdEnv ); virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, ::rtl::Reference<AbortChannel> const & abortChannel, - Reference<XCommandEnvironment> const & xCmdEnv ); + Reference<ucb::XCommandEnvironment> const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -171,51 +174,66 @@ class BackendImpl : public ImplBaseT OUString const & name, Reference<deployment::XPackageTypeInfo> const & xPackageType, bool legacyBundle, - bool useDb); + bool bRemoved, + OUString const & identifier); // XPackage virtual sal_Bool SAL_CALL isBundle() throw (RuntimeException); + virtual Sequence< Reference<deployment::XPackage> > SAL_CALL getBundle( Reference<task::XAbortChannel> const & xAbortChannel, - Reference<XCommandEnvironment> const & xCmdEnv ) + Reference<ucb::XCommandEnvironment> const & xCmdEnv ) throw (deployment::DeploymentException, - CommandFailedException, CommandAbortedException, + ucb::CommandFailedException, + ucb::CommandAbortedException, lang::IllegalArgumentException, RuntimeException); - virtual OUString SAL_CALL getDescription() throw (RuntimeException); + virtual OUString SAL_CALL getDescription() + throw (deployment::ExtensionRemovedException, RuntimeException); + virtual void SAL_CALL exportTo( OUString const & destFolderURL, OUString const & newTitle, sal_Int32 nameClashAction, - Reference<XCommandEnvironment> const & xCmdEnv ) - throw (CommandFailedException, CommandAbortedException, + Reference<ucb::XCommandEnvironment> const & xCmdEnv ) + throw (deployment::ExtensionRemovedException, + ucb::CommandFailedException, + ucb::CommandAbortedException, RuntimeException); virtual ::sal_Bool SAL_CALL checkPrerequisites( - const css::uno::Reference< css::task::XAbortChannel >& xAbortChannel, - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, + const Reference< task::XAbortChannel >& xAbortChannel, + const Reference< ucb::XCommandEnvironment >& xCmdEnv, ::sal_Bool bInstalled, OUString const & aContextName) - throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::ucb::CommandAbortedException, - css::uno::RuntimeException); + throw (deployment::ExtensionRemovedException, + deployment::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + RuntimeException); virtual ::sal_Bool SAL_CALL checkDependencies( - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv ) - throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::uno::RuntimeException); + const Reference< ucb::XCommandEnvironment >& xCmdEnv ) + throw (deployment::DeploymentException, + deployment::ExtensionRemovedException, + ucb::CommandFailedException, + RuntimeException); virtual beans::Optional<OUString> SAL_CALL getIdentifier() throw (RuntimeException); - virtual OUString SAL_CALL getVersion() throw (RuntimeException); + virtual OUString SAL_CALL getVersion() + throw (deployment::ExtensionRemovedException, RuntimeException); virtual Sequence<OUString> SAL_CALL getUpdateInformationURLs() - throw (RuntimeException); + throw (deployment::ExtensionRemovedException, RuntimeException); - virtual css::beans::StringPair SAL_CALL getPublisherInfo() throw (css::uno::RuntimeException); + virtual beans::StringPair SAL_CALL getPublisherInfo() + throw (deployment::ExtensionRemovedException, RuntimeException); virtual OUString SAL_CALL getDisplayName() throw (RuntimeException); - virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getIcon( ::sal_Bool bHighContrast ) throw (css::uno::RuntimeException); + + virtual Reference< graphic::XGraphic > SAL_CALL + getIcon( ::sal_Bool bHighContrast ) + throw (deployment::ExtensionRemovedException, + RuntimeException); }; friend class PackageImpl; @@ -233,8 +251,8 @@ class BackendImpl : public ImplBaseT // PackageRegistryBackend virtual Reference<deployment::XPackage> bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, - Reference<XCommandEnvironment> const & xCmdEnv ); + sal_Bool bRemoved, OUString const & identifier, + Reference<ucb::XCommandEnvironment> const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -344,8 +362,8 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, - Reference<XCommandEnvironment> const & xCmdEnv ) + sal_Bool bRemoved, OUString const & identifier, + Reference<ucb::XCommandEnvironment> const & xCmdEnv ) { OUString mediaType( mediaType_ ); if (mediaType.getLength() == 0) @@ -393,21 +411,24 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent; - OUString name; + //In case a XPackage is created for a removed extension, we cannot //obtain the name - if (create_ucb_content(&ucbContent, url, xCmdEnv, false )) + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); name = ucbContent.getPropertyValue( StrTitle::get() ).get<OUString>(); + } if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.package-bundle")) { return new PackageImpl( - this, url, name, m_xBundleTypeInfo, false, bNoFileAccess); + this, url, name, m_xBundleTypeInfo, false, bRemoved, identifier); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.legacy-package-bundle")) { return new PackageImpl( - this, url, name, m_xLegacyBundleTypeInfo, true, bNoFileAccess); + this, url, name, m_xLegacyBundleTypeInfo, true, bRemoved, identifier); } } } @@ -447,16 +468,15 @@ BackendImpl::PackageImpl::PackageImpl( OUString const & url, OUString const & name, Reference<deployment::XPackageTypeInfo> const & xPackageType, - bool legacyBundle, - bool useDb) + bool legacyBundle, bool bRemoved, OUString const & identifier) : Package( myBackend, url, name, name /* display-name */, - xPackageType, useDb ), + xPackageType, bRemoved, identifier), m_url_expanded( expandUnoRcUrl( url ) ), m_legacyBundle( legacyBundle ), m_pBundle( 0 ) { - if (useDb) - m_data = getMyBackend()->readDataFromDb(url); + if (bRemoved) + m_dbData = getMyBackend()->readDataFromDb(url); } BackendImpl * BackendImpl::PackageImpl::getMyBackend() const @@ -491,10 +511,17 @@ beans::Optional< beans::Ambiguous<sal_Bool> > BackendImpl::PackageImpl::isRegistered_( ::osl::ResettableMutexGuard &, ::rtl::Reference<AbortChannel> const & abortChannel, - Reference<XCommandEnvironment> const & xCmdEnv ) + Reference<ucb::XCommandEnvironment> const & xCmdEnv ) { + //In case the object was created for a removed extension (m_bRemoved = true) + //but the extension is not registered, then bundle will be empty. Then + //the return value will be Optional<...>.IsPresent= false. Althoug this is + //not true, this does not matter. Then registerPackage or revokePackage + //would never be called for the items. But since the extension is removed + //and not registered anyway, this does not matter. const Sequence< Reference<deployment::XPackage> > bundle( getBundle( abortChannel.get(), xCmdEnv ) ); + bool reg = false; bool present = false; bool ambig = false; @@ -723,10 +750,13 @@ bool BackendImpl::PackageImpl::checkDependencies( const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, sal_Bool bInstalled, OUString const & aContextName) throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::ucb::CommandAbortedException, - css::uno::RuntimeException) + css::deployment::ExtensionRemovedException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::uno::RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); DescriptionInfoset info = getDescriptionInfoset(); if (!info.hasDescription()) return sal_True; @@ -742,6 +772,8 @@ bool BackendImpl::PackageImpl::checkDependencies( css::ucb::CommandFailedException, css::uno::RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); DescriptionInfoset info = getDescriptionInfoset(); if (!info.hasDescription()) return sal_True; @@ -753,8 +785,8 @@ beans::Optional<OUString> BackendImpl::PackageImpl::getIdentifier() throw (RuntimeException) { OUString identifier; - if (m_bUseDb) - identifier = m_data.identifier; + if (m_bRemoved) + identifier = m_identifier; else identifier = dp_misc::generateIdentifier( getDescriptionInfoset().getIdentifier(), m_name); @@ -765,18 +797,24 @@ beans::Optional<OUString> BackendImpl::PackageImpl::getIdentifier() OUString BackendImpl::PackageImpl::getVersion() throw (RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return getDescriptionInfoset().getVersion(); } Sequence<OUString> BackendImpl::PackageImpl::getUpdateInformationURLs() - throw (RuntimeException) + throw (deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return getDescriptionInfoset().getUpdateInformationUrls(); } beans::StringPair BackendImpl::PackageImpl::getPublisherInfo() - throw (RuntimeException) + throw (deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); ::std::pair< OUString, OUString > aInfo = getDescriptionInfoset().getLocalizedPublisherNameAndURL(); beans::StringPair aStrPair( aInfo.first, aInfo.second ); return aStrPair; @@ -784,8 +822,11 @@ beans::StringPair BackendImpl::PackageImpl::getPublisherInfo() //______________________________________________________________________________ uno::Reference< graphic::XGraphic > BackendImpl::PackageImpl::getIcon( sal_Bool bHighContrast ) - throw ( RuntimeException ) + throw (deployment::ExtensionRemovedException, RuntimeException ) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + uno::Reference< graphic::XGraphic > xGraphic; OUString aIconURL = getDescriptionInfoset().getIconURL( bHighContrast ); @@ -816,7 +857,7 @@ void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, ::rtl::Reference<AbortChannel> const & abortChannel, - Reference<XCommandEnvironment> const & xCmdEnv ) + Reference<ucb::XCommandEnvironment> const & xCmdEnv ) { const Sequence< Reference<deployment::XPackage> > bundle( getBundle( abortChannel.get(), xCmdEnv ) ); @@ -838,7 +879,7 @@ void BackendImpl::PackageImpl::processPackage_( catch (RuntimeException &) { throw; } - catch (CommandAbortedException &) { + catch (ucb::CommandAbortedException &) { throw; } catch (Exception &) { @@ -876,7 +917,7 @@ void BackendImpl::PackageImpl::processPackage_( catch (RuntimeException &) { throw; } - catch (CommandAbortedException &) { + catch (ucb::CommandAbortedException &) { throw; } catch (Exception &) { @@ -893,7 +934,7 @@ void BackendImpl::PackageImpl::processPackage_( deployment::DeploymentException dpExc; if (exc >>= dpExc) { - throw CommandFailedException( + throw ucb::CommandFailedException( dpExc.Message, dpExc.Context, dpExc.Cause ); } else { @@ -905,7 +946,6 @@ void BackendImpl::PackageImpl::processPackage_( ::std::make_pair(xPackage->getURL(), xPackage->getPackageType()->getMediaType())); } - data.identifier = getIdentifier().Value; getMyBackend()->addDataToDb(getURL(), data); } else @@ -924,7 +964,7 @@ void BackendImpl::PackageImpl::processPackage_( catch (RuntimeException &) { throw; } - catch (CommandAbortedException &) { + catch (ucb::CommandAbortedException &) { throw; } catch (Exception &) { @@ -957,6 +997,9 @@ void BackendImpl::PackageImpl::processPackage_( //______________________________________________________________________________ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + const OUString sRelativeURL(getDescriptionInfoset().getLocalizedDescriptionURL()); OUString sDescription; if (sRelativeURL.getLength()) @@ -977,9 +1020,14 @@ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) //______________________________________________________________________________ void BackendImpl::PackageImpl::exportTo( OUString const & destFolderURL, OUString const & newTitle, - sal_Int32 nameClashAction, Reference<XCommandEnvironment> const & xCmdEnv ) - throw (CommandFailedException, CommandAbortedException, RuntimeException) + sal_Int32 nameClashAction, Reference<ucb::XCommandEnvironment> const & xCmdEnv ) + throw (ucb::CommandFailedException, + deployment::ExtensionRemovedException, + ucb::CommandAbortedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + ::ucbhelper::Content sourceContent( m_url_expanded, xCmdEnv ); OUString title(newTitle); if (title.getLength() == 0) @@ -989,25 +1037,25 @@ void BackendImpl::PackageImpl::exportTo( rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ) ) ); - if (nameClashAction == NameClash::ASK) + if (nameClashAction == ucb::NameClash::ASK) { if (create_ucb_content( 0, destURL, xCmdEnv, false /* no throw */ )) { bool replace = false, abort = false; if (! interactContinuation( - Any( NameClashResolveRequest( + Any( ucb::NameClashResolveRequest( OUSTR("file already exists: ") + title, static_cast<OWeakObject *>(this), task::InteractionClassification_QUERY, destFolderURL, title, OUString() ) ), - XInteractionReplaceExistingData::static_type(), xCmdEnv, + ucb::XInteractionReplaceExistingData::static_type(), xCmdEnv, &replace, &abort ) || !replace) { return; } } } - else if (nameClashAction != NameClash::OVERWRITE) { - throw CommandFailedException( + else if (nameClashAction != ucb::NameClash::OVERWRITE) { + throw ucb::CommandFailedException( OUSTR("unsupported nameClashAction!"), static_cast<OWeakObject *>(this), Any() ); } @@ -1033,11 +1081,11 @@ void BackendImpl::PackageImpl::exportTo( while (xResultSet->next()) { ::ucbhelper::Content subContent( - Reference<XContentAccess>( + Reference<ucb::XContentAccess>( xResultSet, UNO_QUERY_THROW )->queryContent(), xCmdEnv ); if (! destFolderContent.transferContent( subContent, ::ucbhelper::InsertOperation_COPY, - OUString(), NameClash::OVERWRITE )) + OUString(), ucb::NameClash::OVERWRITE )) throw RuntimeException( OUSTR("UCB transferContent() failed!"), static_cast<OWeakObject *>(this) ); progress.update( Any() ); // animating progress bar @@ -1145,7 +1193,7 @@ void BackendImpl::PackageImpl::exportTo( if (! metainfFolderContent.transferContent( manifestContent, ::ucbhelper::InsertOperation_COPY, - OUString(), NameClash::OVERWRITE )) + OUString(), ucb::NameClash::OVERWRITE )) throw RuntimeException( OUSTR("UCB transferContent() failed!"), static_cast<OWeakObject *>(this) ); } @@ -1154,7 +1202,7 @@ void BackendImpl::PackageImpl::exportTo( try { destFolderContent.executeCommand( OUSTR("flush"), Any() ); } - catch (UnsupportedCommandException &) { + catch (ucb::UnsupportedCommandException &) { } } @@ -1167,18 +1215,18 @@ sal_Bool BackendImpl::PackageImpl::isBundle() throw (RuntimeException) //______________________________________________________________________________ Sequence< Reference<deployment::XPackage> > BackendImpl::PackageImpl::getBundle( Reference<task::XAbortChannel> const & xAbortChannel, - Reference<XCommandEnvironment> const & xCmdEnv ) + Reference<ucb::XCommandEnvironment> const & xCmdEnv ) throw (deployment::DeploymentException, - CommandFailedException, CommandAbortedException, + ucb::CommandFailedException, ucb::CommandAbortedException, lang::IllegalArgumentException, RuntimeException) { Sequence< Reference<deployment::XPackage> > * pBundle = m_pBundle; if (pBundle == 0) { t_packagevec bundle; - if (m_bUseDb) + if (m_bRemoved) { - bundle = getPackagesFromDb(); + bundle = getPackagesFromDb(xCmdEnv); } else { @@ -1203,7 +1251,8 @@ Sequence< Reference<deployment::XPackage> > BackendImpl::PackageImpl::getBundle( if (mediaType.getLength() > 0) { const Reference<deployment::XPackage> xPackage( - bindBundleItem( getURL(), mediaType, xCmdEnv ) ); + bindBundleItem( getURL(), mediaType, false, OUString(), + xCmdEnv ) ); if (xPackage.is()) bundle.push_back( xPackage ); // continue scanning: @@ -1221,10 +1270,10 @@ Sequence< Reference<deployment::XPackage> > BackendImpl::PackageImpl::getBundle( catch (RuntimeException &) { throw; } - catch (CommandFailedException &) { + catch (ucb::CommandFailedException &) { throw; } - catch (CommandAbortedException &) { + catch (ucb::CommandAbortedException &) { throw; } catch (deployment::DeploymentException &) { @@ -1302,7 +1351,8 @@ inline bool isBundle_( OUString const & mediaType ) //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::PackageImpl::bindBundleItem( OUString const & url, OUString const & mediaType, - Reference<XCommandEnvironment> const & xCmdEnv, + sal_Bool bRemoved, OUString const & identifier, + Reference<ucb::XCommandEnvironment> const & xCmdEnv, bool notifyDetectionError ) { // ignore any nested bundles: @@ -1312,13 +1362,13 @@ Reference<deployment::XPackage> BackendImpl::PackageImpl::bindBundleItem( Reference<deployment::XPackage>xPackage; try { xPackage.set( getMyBackend()->m_xRootRegistry->bindPackage( - url, mediaType, false, xCmdEnv ) ); + url, mediaType, bRemoved, identifier, xCmdEnv ) ); OSL_ASSERT( xPackage.is() ); } catch (RuntimeException &) { throw; } - catch (CommandFailedException &) { + catch (ucb::CommandFailedException &) { // ignore already handled error } catch (Exception &) { @@ -1351,7 +1401,7 @@ Reference<deployment::XPackage> BackendImpl::PackageImpl::bindBundleItem( void BackendImpl::PackageImpl::scanBundle( t_packagevec & bundle, ::rtl::Reference<AbortChannel> const & abortChannel, - Reference<XCommandEnvironment> const & xCmdEnv ) + Reference<ucb::XCommandEnvironment> const & xCmdEnv ) { OSL_ASSERT( !m_legacyBundle ); @@ -1448,7 +1498,7 @@ void BackendImpl::PackageImpl::scanBundle( if (bundle.end() == std::find_if(bundle.begin(), bundle.end(), XPackage_eq(url))) { const Reference<deployment::XPackage> xPackage( - bindBundleItem( url, mediaType, xCmdEnv ) ); + bindBundleItem( url, mediaType, false, OUString(), xCmdEnv ) ); if (xPackage.is()) bundle.push_back( xPackage ); } @@ -1487,7 +1537,7 @@ void BackendImpl::PackageImpl::scanLegacyBundle( t_packagevec & bundle, OUString const & url, ::rtl::Reference<AbortChannel> const & abortChannel, - Reference<XCommandEnvironment> const & xCmdEnv, + Reference<ucb::XCommandEnvironment> const & xCmdEnv, bool skip_registration ) { ::ucbhelper::Content ucbContent( url, xCmdEnv ); @@ -1523,8 +1573,8 @@ void BackendImpl::PackageImpl::scanLegacyBundle( OUString mediaType; const Reference<deployment::XPackage> xPackage( - bindBundleItem( path, OUString() /* detect */, xCmdEnv, - false /* ignore detection errors */ ) ); + bindBundleItem( path, OUString() /* detect */, false, OUString(), + xCmdEnv, false /* ignore detection errors */ ) ); if (xPackage.is()) { const Reference<deployment::XPackageTypeInfo> xPackageType( xPackage->getPackageType() ); @@ -1559,8 +1609,12 @@ void BackendImpl::PackageImpl::scanLegacyBundle( } } -OUString BackendImpl::PackageImpl::getDisplayName() throw (RuntimeException) +OUString BackendImpl::PackageImpl::getDisplayName() + throw (deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + OUString sName = getDescriptionInfoset().getLocalizedDisplayName(); if (sName.getLength() == 0) return m_displayName; @@ -1568,11 +1622,22 @@ OUString BackendImpl::PackageImpl::getDisplayName() throw (RuntimeException) return sName; } -::std::vector<Reference<deployment::XPackage> > BackendImpl::PackageImpl::getPackagesFromDb() +::std::vector<Reference<deployment::XPackage> > +BackendImpl::PackageImpl::getPackagesFromDb( + Reference<ucb::XCommandEnvironment> const & xCmdEnv) { - //get the data base entry for this extension + ::std::vector<Reference<deployment::XPackage> > retVector; + + typedef ::std::vector< ::std::pair<OUString, OUString> >::const_iterator ITC; + for (ITC i = m_dbData.items.begin(); i != m_dbData.items.end(); i++) + { + Reference<deployment::XPackage> xExtension = + bindBundleItem(i->first, i->second, true, m_identifier, xCmdEnv); + OSL_ASSERT(xExtension.is()); + retVector.push_back(xExtension); + } - return ::std::vector<Reference<deployment::XPackage> >(); + return retVector; } } // anon namespace diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index 6d503d33d51d..b645c9b2af7a 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -89,14 +89,14 @@ class BackendImpl : public t_helper OUString const & url, Reference<XCommandEnvironment> const &xCmdEnv, OUString const & scriptURL, OUString const & dialogURL, - bool bUseDb); + bool bRemoved, OUString const & identifier); }; friend class PackageImpl; // PackageRegistryBackend virtual Reference<deployment::XPackage> bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ); rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); @@ -125,11 +125,12 @@ BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference<BackendImpl> const & myBackend, OUString const & url, Reference<XCommandEnvironment> const &xCmdEnv, - OUString const & scriptURL, OUString const & dialogURL, bool bUseDb ) + OUString const & scriptURL, OUString const & dialogURL, bool bRemoved, + OUString const & identifier) : Package( myBackend.get(), url, OUString(), OUString(), // will be late-initialized scriptURL.getLength() > 0 ? myBackend->m_xBasicLibTypeInfo - : myBackend->m_xDialogLibTypeInfo, bUseDb), + : myBackend->m_xDialogLibTypeInfo, bRemoved, identifier), m_scriptURL( scriptURL ), m_dialogURL( dialogURL ) { @@ -191,7 +192,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -234,7 +235,7 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( } return new PackageImpl( this, url, xCmdEnv, makeURL( url, OUSTR("script.xlb") ), - dialogURL, bNoFileAccess); + dialogURL, bRemoved, identifier); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.dialog-library")) { @@ -242,7 +243,7 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( this, url, xCmdEnv, OUString() /* no script lib */, makeURL( url, OUSTR("dialog.xlb") ), - bNoFileAccess); + bRemoved, identifier); } } } diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx index 47b6430f1a1e..704f4f810928 100644 --- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx +++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx @@ -83,7 +83,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend public: PackageImpl( ::rtl::Reference<BackendImpl> const & myBackend, - OUString const & url, OUString const & libType, bool bUseDb); + OUString const & url, OUString const & libType, bool bRemoved, + OUString const & identifier); // XPackage virtual OUString SAL_CALL getDescription() throw (RuntimeException); }; @@ -92,7 +93,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference<deployment::XPackage> bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ); const Reference<deployment::XPackageTypeInfo> m_xTypeInfo; @@ -133,9 +134,10 @@ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) //______________________________________________________________________________ BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference<BackendImpl> const & myBackend, - OUString const & url, OUString const & libType, bool bUseDb) + OUString const & url, OUString const & libType, bool bRemoved, + OUString const & identifier) : Package( myBackend.get(), url, OUString(), OUString(), - myBackend->m_xTypeInfo, bUseDb ), + myBackend->m_xTypeInfo, bRemoved, identifier), m_descr(libType) { initPackageHandler(); @@ -219,8 +221,8 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) // PackageRegistryBackend //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( - OUString const & url, OUString const & mediaType_, sal_Bool bNoFileAccess, - Reference<XCommandEnvironment> const & xCmdEnv ) + OUString const & url, OUString const & mediaType_, sal_Bool bRemoved, + OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ) { OUString mediaType( mediaType_ ); if (mediaType.getLength() == 0) @@ -296,7 +298,7 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( dp_misc::TRACE(OUSTR(" BackEnd detected lang = ") + lang + OUSTR("\n")); dp_misc::TRACE(OUSTR(" for url ") + sParcelDescURL + OUSTR("\n") ); dp_misc::TRACE("******************************\n"); - return new PackageImpl( this, url, sfwkLibType, bNoFileAccess); + return new PackageImpl( this, url, sfwkLibType, bRemoved, identifier); } } } diff --git a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java index 3b9e04a27210..4c6a4f1eda2b 100644 --- a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java +++ b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java @@ -44,6 +44,7 @@ import com.sun.star.io.XOutputStream; import com.sun.star.io.XTruncate; import com.sun.star.deployment.XPackage; +import com.sun.star.deployment.ExtensionRemovedException; public class UnoPkgContainer extends ParcelContainer { @@ -336,7 +337,15 @@ public class UnoPkgContainer extends ParcelContainer LogUtils.DEBUG("** processUnoPackage getURL() -> " + uri ); LogUtils.DEBUG("** processUnoPackage getName() -> " + dPackage.getName() ); LogUtils.DEBUG("** processUnoPackage getMediaType() -> " + dPackage.getPackageType().getMediaType() ); - LogUtils.DEBUG("** processUnoPackage getDisplayName() -> " + dPackage.getDisplayName() ); + try + { + LogUtils.DEBUG("** processUnoPackage getDisplayName() -> " + dPackage.getDisplayName() ); + } + catch (com.sun.star.deployment.ExtensionRemovedException e) + { + throw new com.sun.star.lang.WrappedTargetException(e.toString(), this, e); + } + processUnoPackage( uri, language ); db = getUnoPackagesDB(); |