From 2db393ea0b24fd230d3437d664a25d1cf7e5fb91 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Wed, 10 Feb 2010 10:27:57 +0100 Subject: jl152 copy changeset 263364:4815fbf0d446 from native0: #161641# XPackageManager.addPackage can install a folder, which is an uncompressed extension. --- desktop/source/deployment/manager/dp_manager.cxx | 18 +++++++--- desktop/source/deployment/registry/dp_registry.cxx | 18 +++++++--- .../deployment/registry/package/dp_package.cxx | 41 +++++++++++++++------- 3 files changed, 55 insertions(+), 22 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 165efbaeca5a..3f13cb021aae 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -542,11 +542,19 @@ OUString PackageManagerImpl::insertToActivationLayer( { // inflate content: ::rtl::OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.zip://") ); - buf.append( ::rtl::Uri::encode( sourceContent.getURL(), - rtl_UriCharClassRegName, - rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_UTF8 ) ); + if (!sourceContent.isFolder()) + { + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.zip://") ); + buf.append( ::rtl::Uri::encode( sourceContent.getURL(), + rtl_UriCharClassRegName, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ) ); + } + else + { + //Folder. No need to unzip, just copy + buf.append(sourceContent.getURL()); + } buf.append( static_cast('/') ); sourceContent = ::ucbhelper::Content( buf.makeStringAndClear(), xCmdEnv ); diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index c6572364aac0..c56131a1015c 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -181,6 +181,7 @@ OUString normalizeMediaType( OUString const & mediaType ) } //______________________________________________________________________________ + void PackageRegistryImpl::insertBackend( Reference const & xBackend ) { @@ -201,7 +202,8 @@ void PackageRegistryImpl::insertBackend( ::std::pair mb_insertion( m_mediaType2backend.insert( t_string2registry::value_type( mediaType, xBackend ) ) ); - if (mb_insertion.second) { + if (mb_insertion.second) + { // add parameterless media-type, too: sal_Int32 semi = mediaType.indexOf( ';' ); if (semi >= 0) { @@ -210,9 +212,13 @@ void PackageRegistryImpl::insertBackend( mediaType.copy( 0, semi ), xBackend ) ); } const OUString fileFilter( xPackageType->getFileFilter() ); + //The package backend shall also be called to determine the mediatype + //(XPackageRegistry.bindPackage) when the URL points to a directory. + const bool bExtension = mediaType.equals(OUSTR("application/vnd.sun.star.package-bundle")); if (fileFilter.getLength() == 0 || fileFilter.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("*.*") ) || - fileFilter.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("*") )) + fileFilter.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("*") ) || + bExtension) { m_ambiguousBackends.insert( xBackend ); } @@ -351,7 +357,10 @@ Reference PackageRegistryImpl::create( } } - // insert bundle be: + // Insert bundle back-end. + // Always register as last, because we want to add extensions also as folders + // and as a default we accept every folder, which was not recognized by the other + // backends. that->insertBackend( ::dp_registry::backend::bundle::create( that, context, cachePath, readOnly, xComponentContext ) ); @@ -445,7 +454,8 @@ Reference PackageRegistryImpl::bindPackage( { ::ucbhelper::Content ucbContent; if (create_ucb_content( - &ucbContent, url, xCmdEnv, false /* no throw */ )) + &ucbContent, url, xCmdEnv, false /* no throw */ ) + && !ucbContent.isFolder()) { OUString title( ucbContent.getPropertyValue( StrTitle::get() ).get() ); diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index e45f7fb7ef73..b0b4a918c7a3 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -287,7 +287,7 @@ BackendImpl::BackendImpl( m_xBundleTypeInfo->getShortDescription(), RID_IMG_DEF_PACKAGE_BUNDLE, RID_IMG_DEF_PACKAGE_BUNDLE_HC ) ), - m_typeInfos( 2 ) + m_typeInfos(2) { m_typeInfos[ 0 ] = m_xBundleTypeInfo; m_typeInfos[ 1 ] = m_xLegacyBundleTypeInfo; @@ -342,17 +342,32 @@ Reference BackendImpl::bindPackage_( ::ucbhelper::Content ucbContent; if (create_ucb_content( &ucbContent, url, xCmdEnv )) { - const OUString title( ucbContent.getPropertyValue( - StrTitle::get() ).get() ); - if (title.endsWithIgnoreAsciiCaseAsciiL( - RTL_CONSTASCII_STRINGPARAM(".oxt") ) || - title.endsWithIgnoreAsciiCaseAsciiL( - RTL_CONSTASCII_STRINGPARAM(".uno.pkg") )) - mediaType = OUSTR("application/vnd.sun.star.package-bundle"); - else if (title.endsWithIgnoreAsciiCaseAsciiL( - RTL_CONSTASCII_STRINGPARAM(".zip") )) - mediaType = - OUSTR("application/vnd.sun.star.legacy-package-bundle"); + if (ucbContent.isFolder()) + { + //Every .oxt, uno.pkg file must contain a META-INF folder + ::ucbhelper::Content metaInfContent; + if (create_ucb_content( + &metaInfContent, makeURL( url, OUSTR("META-INF/manifest.xml") ), + xCmdEnv, false /* no throw */ )) + { + mediaType = OUSTR("application/vnd.sun.star.package-bundle"); + } + //No support of legacy bundles, because every folder could be one. + } + else + { + const OUString title( ucbContent.getPropertyValue( + StrTitle::get() ).get() ); + if (title.endsWithIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM(".oxt") ) || + title.endsWithIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM(".uno.pkg") )) + mediaType = OUSTR("application/vnd.sun.star.package-bundle"); + else if (title.endsWithIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM(".zip") )) + mediaType = + OUSTR("application/vnd.sun.star.legacy-package-bundle"); + } } if (mediaType.getLength() == 0) throw lang::IllegalArgumentException( @@ -1303,7 +1318,7 @@ void BackendImpl::PackageImpl::scanBundle( { OSL_ENSURE( 0, "### missing META-INF/manifest.xml file!" ); return; -} + } const lang::Locale officeLocale = getOfficeLocale(); -- cgit From dc3c40a13388625726db26c953910d347cf4a9fc Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 4 May 2010 12:37:01 +0200 Subject: jl152 bundled extensions, import of changeset 263438:8b253e76e957 from native0jl --- desktop/inc/app.hxx | 1 + desktop/source/app/app.cxx | 3 + desktop/source/app/check_ext_deps.cxx | 235 +++- desktop/source/deployment/dp_services.cxx | 13 +- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 20 +- .../deployment/inc/dp_descriptioninfoset.hxx | 15 + desktop/source/deployment/inc/dp_misc.h | 21 + desktop/source/deployment/inc/dp_version.hxx | 7 - .../deployment/manager/dp_activepackages.cxx | 22 +- .../deployment/manager/dp_activepackages.hxx | 10 + .../deployment/manager/dp_extensionmanager.cxx | 1301 ++++++++++++++++++++ .../deployment/manager/dp_extensionmanager.hxx | 287 +++++ desktop/source/deployment/manager/dp_manager.cxx | 696 +++++++---- desktop/source/deployment/manager/dp_manager.h | 53 +- .../source/deployment/manager/dp_managerfac.cxx | 4 + .../source/deployment/manager/dp_tmprepocmdenv.cxx | 166 +++ .../source/deployment/manager/dp_tmprepocmdenv.hxx | 84 ++ desktop/source/deployment/manager/makefile.mk | 4 +- .../deployment/misc/dp_descriptioninfoset.cxx | 250 +++- desktop/source/deployment/misc/dp_misc.cxx | 31 + desktop/source/deployment/misc/dp_version.cxx | 6 - desktop/source/deployment/misc/makefile.mk | 3 +- .../registry/component/dp_compbackenddb.cxx | 142 +++ .../registry/component/dp_compbackenddb.hxx | 116 ++ .../deployment/registry/component/dp_component.cxx | 171 ++- .../deployment/registry/component/makefile.mk | 3 +- .../registry/configuration/dp_configuration.cxx | 13 +- desktop/source/deployment/registry/dp_backend.cxx | 81 +- .../source/deployment/registry/dp_backenddb.cxx | 332 +++++ desktop/source/deployment/registry/dp_registry.cxx | 27 +- .../registry/executable/dp_executable.cxx | 10 +- .../source/deployment/registry/help/dp_help.cxx | 13 +- .../source/deployment/registry/inc/dp_backend.h | 16 +- .../deployment/registry/inc/dp_backenddb.hxx | 121 ++ desktop/source/deployment/registry/makefile.mk | 3 +- .../deployment/registry/package/dp_description.cxx | 205 --- .../deployment/registry/package/dp_description.hxx | 125 -- .../registry/package/dp_extbackenddb.cxx | 177 +++ .../registry/package/dp_extbackenddb.hxx | 94 ++ .../deployment/registry/package/dp_package.cxx | 282 +++-- .../source/deployment/registry/package/makefile.mk | 2 +- .../deployment/registry/script/dp_script.cxx | 19 +- .../source/deployment/registry/sfwk/dp_sfwk.cxx | 18 +- desktop/source/pkgchk/unopkg/unopkg_app.cxx | 80 +- desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx | 2 +- 45 files changed, 4396 insertions(+), 888 deletions(-) create mode 100644 desktop/source/deployment/manager/dp_extensionmanager.cxx create mode 100644 desktop/source/deployment/manager/dp_extensionmanager.hxx create mode 100644 desktop/source/deployment/manager/dp_tmprepocmdenv.cxx create mode 100644 desktop/source/deployment/manager/dp_tmprepocmdenv.hxx create mode 100644 desktop/source/deployment/registry/component/dp_compbackenddb.cxx create mode 100644 desktop/source/deployment/registry/component/dp_compbackenddb.hxx create mode 100644 desktop/source/deployment/registry/dp_backenddb.cxx create mode 100644 desktop/source/deployment/registry/inc/dp_backenddb.hxx delete mode 100644 desktop/source/deployment/registry/package/dp_description.cxx delete mode 100644 desktop/source/deployment/registry/package/dp_description.hxx create mode 100644 desktop/source/deployment/registry/package/dp_extbackenddb.cxx create mode 100644 desktop/source/deployment/registry/package/dp_extbackenddb.hxx (limited to 'desktop') diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 0ae632a6e968..4f5a3b176be3 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -132,6 +132,7 @@ class Desktop : public Application static sal_Bool LicenseNeedsAcceptance(); static sal_Bool IsFirstStartWizardNeeded(); static sal_Bool CheckExtensionDependencies(); + static void SynchronizeExtensionRepositories(); private: // Bootstrap methods diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index efba60ca75b9..b82915871566 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1395,6 +1395,9 @@ void Desktop::Main() bool bAbort = CheckExtensionDependencies(); if ( bAbort ) return; + //Check if bundled or shared extensions were added /removed + //and process those extensions + SynchronizeExtensionRepositories(); // First Start Wizard allowed ? if ( ! pCmdLineArgs->IsNoFirstStartWizard()) diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 8b73e0c2c525..17dc20e1a129 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -27,21 +27,27 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_desktop.hxx" +#include #include #include +#include +#include "cppuhelper/compbase3.hxx" + #include #include #include #include - +#include #include #include #include "com/sun/star/deployment/XPackage.hpp" #include "com/sun/star/deployment/XPackageManager.hpp" #include "com/sun/star/deployment/thePackageManagerFactory.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include #include +#include #include #include @@ -53,9 +59,91 @@ using namespace com::sun::star; #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) +namespace +{ +//For use with XExtensionManager.synchronize +class SilentCommandEnv + : public ::cppu::WeakImplHelper3< ucb::XCommandEnvironment, + task::XInteractionHandler, + ucb::XProgressHandler > +{ +public: + virtual ~SilentCommandEnv(){}; + SilentCommandEnv(){}; + + // XCommandEnvironment + virtual uno::Reference SAL_CALL + getInteractionHandler() throw (uno::RuntimeException); + virtual uno::Reference + SAL_CALL getProgressHandler() throw (uno::RuntimeException); + + // XInteractionHandler + virtual void SAL_CALL handle( + uno::Reference const & xRequest ) + throw (uno::RuntimeException); + + // XProgressHandler + virtual void SAL_CALL push( uno::Any const & Status ) + throw (uno::RuntimeException); + virtual void SAL_CALL update( uno::Any const & Status ) + throw (uno::RuntimeException); + virtual void SAL_CALL pop() throw (uno::RuntimeException); +}; +Reference SilentCommandEnv::getInteractionHandler() +throw (uno::RuntimeException) +{ + return this; +} + +Reference SilentCommandEnv::getProgressHandler() +throw (uno::RuntimeException) +{ + return this; +} + +// XInteractionHandler +void SilentCommandEnv::handle( + Reference< task::XInteractionRequest> const & xRequest ) + throw (uno::RuntimeException) +{ + uno::Any request( xRequest->getRequest() ); + + // We approve everything here + uno::Sequence< Reference< task::XInteractionContinuation > > conts( + xRequest->getContinuations() ); + Reference< task::XInteractionContinuation > const * pConts = + conts.getConstArray(); + sal_Int32 len = conts.getLength(); + for ( sal_Int32 pos = 0; pos < len; ++pos ) + { + + Reference< task::XInteractionApprove > xInteractionApprove( + pConts[ pos ], uno::UNO_QUERY ); + if (xInteractionApprove.is()) { + xInteractionApprove->select(); + } + } +} + +// XProgressHandler +void SilentCommandEnv::push( uno::Any const & /*Status*/ ) +throw (uno::RuntimeException) +{ +} + + +void SilentCommandEnv::update( uno::Any const & /*Status */) +throw (uno::RuntimeException) +{ +} + +void SilentCommandEnv::pop() throw (uno::RuntimeException) +{ +} + +} // end namespace static const OUString sConfigSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); static const OUString sAccessSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ); - //------------------------------------------------------------------------------ static sal_Int16 impl_showExtensionDialog( uno::Reference< uno::XComponentContext > &xContext ) { @@ -254,3 +342,146 @@ sal_Bool Desktop::CheckExtensionDependencies() return bAbort; } +//Returns true if the Folder was more recently modified then +//the lastsynchronized file. That is the repository needs to +//be synchronized. +static bool compareExtensionFolderWithLastSynchronizedFile( + OUString const & folderURL, OUString const & fileURL) +{ + bool bNeedsSync = false; + ::osl::DirectoryItem itemExtFolder; + ::osl::File::RC err1 = + ::osl::DirectoryItem::get(folderURL, itemExtFolder); + //If it does not exist, then there is nothing to be done + if (err1 == ::osl::File::E_NOENT) + { + return false; + } + else if (err1 != ::osl::File::E_None) + { + OSL_ENSURE(0, "Cannot access extension folder"); + return true; //sync just in case + } + + //If last synchronized does not exist, then OOo is started for the first time + ::osl::DirectoryItem itemFile; + ::osl::File::RC err2 = ::osl::DirectoryItem::get(fileURL, itemFile); + if (err2 == ::osl::File::E_NOENT) + { + return true; + + } + else if (err2 != ::osl::File::E_None) + { + OSL_ENSURE(0, "Cannot access file lastsynchronized"); + return true; //sync just in case + } + + //compare the modification time of the extension folder and the last + //modified file + ::osl::FileStatus statFolder(FileStatusMask_ModifyTime); + ::osl::FileStatus statFile(FileStatusMask_ModifyTime); + if (itemExtFolder.getFileStatus(statFolder) == ::osl::File::E_None) + { + if (itemFile.getFileStatus(statFile) == ::osl::File::E_None) + { + TimeValue timeFolder = statFolder.getModifyTime(); + TimeValue timeFile = statFile.getModifyTime(); + + if (timeFile.Seconds < timeFolder.Seconds) + bNeedsSync = true; + } + else + { + OSL_ASSERT(0); + bNeedsSync = true; + } + } + else + { + OSL_ASSERT(0); + bNeedsSync = true; + } + return bNeedsSync; +} + +static bool needToSyncRepostitory(OUString const & name) +{ + OUString folder; + OUString file; + if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("bundled")))) + { + folder = OUString( + RTL_CONSTASCII_USTRINGPARAM("$BUNDLED_EXTENSIONS")); + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); + } + else if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("shared")))) + { + folder = OUString( + RTL_CONSTASCII_USTRINGPARAM( + "$UNO_SHARED_PACKAGES_CACHE/uno_packages")); + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$SHARED_EXTENSIONS_USER/lastsynchronized")); + } + else + { + OSL_ASSERT(0); + return true; + } + ::rtl::Bootstrap::expandMacros(folder); + ::rtl::Bootstrap::expandMacros(file); + return compareExtensionFolderWithLastSynchronizedFile( + folder, file); +} + +void Desktop::SynchronizeExtensionRepositories() +{ + RTL_LOGFILE_CONTEXT(aLog,"desktop (jl97489) ::Desktop::SynchronizeExtensionRepositories"); + OUString sDisable; + ::rtl::Bootstrap::get( + OUString(RTL_CONSTASCII_USTRINGPARAM("DISABLE_SYNC_EXTENSIONS")), + sDisable, + OUString(RTL_CONSTASCII_USTRINGPARAM(""))); + if (sDisable.getLength() > 0) + return; + Reference xExtensionManager; + //synchronize shared before bundled otherewise there are + //more revoke and registration calls. + OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); + if (needToSyncRepostitory(sShared)) + { + xExtensionManager = + deployment::ExtensionManager::get( + comphelper_getProcessComponentContext()); + if (xExtensionManager.is()) + { + Reference cmdEnv( + new SilentCommandEnv()); + xExtensionManager->synchronize( + sShared, Reference(), cmdEnv); + } + + } + + OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); + if (needToSyncRepostitory( sBundled)) + { + if (!xExtensionManager.is()) + { + xExtensionManager = + deployment::ExtensionManager::get( + comphelper_getProcessComponentContext()); + } + if (xExtensionManager.is()) + { + Reference cmdEnv( + new SilentCommandEnv()); + xExtensionManager->synchronize( + sBundled, Reference(), cmdEnv); + + } + } +} diff --git a/desktop/source/deployment/dp_services.cxx b/desktop/source/deployment/dp_services.cxx index c83a62bfd17e..05b9a2a1971a 100644 --- a/desktop/source/deployment/dp_services.cxx +++ b/desktop/source/deployment/dp_services.cxx @@ -28,7 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_desktop.hxx" -#define COMPHELPER_SERVICEDECL_COMPONENT_HELPER_MAX_ARGS 11 +#define COMPHELPER_SERVICEDECL_COMPONENT_HELPER_MAX_ARGS 12 #include "comphelper/servicedecl.hxx" using namespace com::sun::star; @@ -69,6 +69,8 @@ namespace factory { extern sdecl::ServiceDecl const serviceDecl; bool singleton_entries( uno::Reference const& ); } +extern sdecl::ServiceDecl const serviceDecl; +bool singleton_entries( uno::Reference const& ); } namespace dp_log { @@ -109,9 +111,11 @@ sal_Bool SAL_CALL component_writeInfo( dp_manager::factory::serviceDecl, dp_log::serviceDecl, dp_migration::serviceDecl, - dp_info::serviceDecl ) && + dp_info::serviceDecl, + dp_manager::serviceDecl) && dp_manager::factory::singleton_entries( pRegistryKey ) && - dp_info::singleton_entries( pRegistryKey ); + dp_info::singleton_entries( pRegistryKey ) && + dp_manager::singleton_entries( pRegistryKey); } void * SAL_CALL component_getFactory( @@ -130,7 +134,8 @@ void * SAL_CALL component_getFactory( dp_manager::factory::serviceDecl, dp_log::serviceDecl, dp_migration::serviceDecl, - dp_info::serviceDecl ); + dp_info::serviceDecl, + dp_manager::serviceDecl); } } // extern "C" diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 58a5ab1c19ea..89a5ae1e22c8 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -110,12 +110,15 @@ using ::rtl::OUString; namespace { -OUString getVersion( const uno::Reference< deployment::XPackage > &rPackage ) +OUString getVersion( OUString const & sVersion ) { - OUString sVersion( rPackage->getVersion()); return ( sVersion.getLength() == 0 ) ? OUString( RTL_CONSTASCII_USTRINGPARAM( "0" ) ) : sVersion; } +OUString getVersion( const uno::Reference< deployment::XPackage > &rPackage ) +{ + return getVersion( rPackage->getVersion()); +} } @@ -468,7 +471,8 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & else if (request >>= verExc) { sal_uInt32 id; - switch (dp_misc::comparePackageVersions( verExc.New, verExc.Deployed )) + switch (dp_misc::compareVersions( + verExc.NewVersion, verExc.Deployed->getVersion() )) { case dp_misc::LESS: id = RID_WARNINGBOX_VERSION_LESS; @@ -480,8 +484,8 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & id = RID_WARNINGBOX_VERSION_GREATER; break; } - OSL_ASSERT( verExc.New.is() && verExc.Deployed.is() ); - bool bEqualNames = verExc.New->getDisplayName().equals( + OSL_ASSERT( verExc.Deployed.is() ); + bool bEqualNames = verExc.NewDisplayName.equals( verExc.Deployed->getDisplayName()); { vos::OGuard guard(Application::GetSolarMutex()); @@ -506,9 +510,9 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & { s = String(ResId(RID_STR_WARNINGBOX_VERSION_GREATER_DIFFERENT_NAMES, *DeploymentGuiResMgr::get())); } - s.SearchAndReplaceAllAscii( "$NAME", verExc.New->getDisplayName()); + s.SearchAndReplaceAllAscii( "$NAME", verExc.NewDisplayName); s.SearchAndReplaceAllAscii( "$OLDNAME", verExc.Deployed->getDisplayName()); - s.SearchAndReplaceAllAscii( "$NEW", getVersion(verExc.New) ); + s.SearchAndReplaceAllAscii( "$NEW", getVersion(verExc.NewVersion) ); s.SearchAndReplaceAllAscii( "$DEPLOYED", getVersion(verExc.Deployed) ); box.SetMessText(s); approve = box.Execute() == RET_OK; @@ -527,7 +531,7 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & { vos::OGuard guard(Application::GetSolarMutex()); - approve = m_pDialogHelper->installExtensionWarn( instExc.New->getDisplayName() ); + approve = m_pDialogHelper->installExtensionWarn( instExc.displayName ); } else approve = false; diff --git a/desktop/source/deployment/inc/dp_descriptioninfoset.hxx b/desktop/source/deployment/inc/dp_descriptioninfoset.hxx index 38a1870782ed..3d2d56cad00a 100644 --- a/desktop/source/deployment/inc/dp_descriptioninfoset.hxx +++ b/desktop/source/deployment/inc/dp_descriptioninfoset.hxx @@ -62,6 +62,7 @@ struct DESKTOP_DEPLOYMENTMISC_DLLPUBLIC SimpleLicenseAttributes bool suppressIfRequired; }; + /** Access to the content of an XML description element. @@ -226,6 +227,8 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::xml::xpath::XXPathAPI > getXpath() const; + bool hasDescription() const; + private: SAL_DLLPRIVATE ::boost::optional< ::rtl::OUString > getOptionalValue( ::rtl::OUString const & expression) const; @@ -289,6 +292,18 @@ private: ::com::sun::star::xml::xpath::XXPathAPI > m_xpath; }; +inline bool DescriptionInfoset::hasDescription() const +{ + return m_element.is(); +} + +/** creates a DescriptionInfoset object. + + The argument sExtensionFolderURL is a file URL to extension folder containing + the description.xml. + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +DescriptionInfoset getDescriptionInfoset(::rtl::OUString const & sExtensionFolderURL); } #endif diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h index a717e7797c8a..ee5867a655d3 100644 --- a/desktop/source/deployment/inc/dp_misc.h +++ b/desktop/source/deployment/inc/dp_misc.h @@ -74,9 +74,25 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString expandUnoRcUrl( ::rtl::OUString const & url ); //============================================================================== + +/** appends a relative path to a url. + + The relative path must already be correctly encoded for use in an URL. + If the URL starts with vnd.sun.star.expand then the relative path will + be again encoded for use in an "expand" URL. + */ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString makeURL( ::rtl::OUString const & baseURL, ::rtl::OUString const & relPath ); + +/** appends a relative path to a url. + + This is the same as makeURL, but the relative Path must me a segment + of an system path. + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString makeURLAppendSysPathSegment( + ::rtl::OUString const & baseURL, ::rtl::OUString const & relPath ); + //============================================================================== DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString generateRandomPipeId(); @@ -151,6 +167,11 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC void TRACE(::rtl::OUString const & sText); DESKTOP_DEPLOYMENTMISC_DLLPUBLIC void TRACE(::rtl::OString const & sText); + +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +bool hasExtensionRepositoryChanged(::rtl::OUString const & repository); + + } #endif diff --git a/desktop/source/deployment/inc/dp_version.hxx b/desktop/source/deployment/inc/dp_version.hxx index 9808ebaab388..c459333f97a9 100644 --- a/desktop/source/deployment/inc/dp_version.hxx +++ b/desktop/source/deployment/inc/dp_version.hxx @@ -43,13 +43,6 @@ enum Order { LESS, EQUAL, GREATER }; DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Order compareVersions( ::rtl::OUString const & version1, ::rtl::OUString const & version2); - -DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Order comparePackageVersions( - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > - const & package1, - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > - const & package2); - } #endif diff --git a/desktop/source/deployment/manager/dp_activepackages.cxx b/desktop/source/deployment/manager/dp_activepackages.cxx index 04dc22b77a77..bf9071682b2e 100644 --- a/desktop/source/deployment/manager/dp_activepackages.cxx +++ b/desktop/source/deployment/manager/dp_activepackages.cxx @@ -96,9 +96,23 @@ static char const legacyPrefix[] = "org.openoffice.legacy."; OSL_ASSERT(i2 >= 0); d.fileName = ::rtl::OUString( value.getStr() + i1 + 1, i2 - i1 - 1, RTL_TEXTENCODING_UTF8); - d.mediaType = ::rtl::OUString( - value.getStr() + i2 + 1, value.getLength() - i2 - 1, - RTL_TEXTENCODING_UTF8); + sal_Int32 i3 = value.indexOf(separator, i2 + 1); + + if (i3 < 0) + { + //Before ActivePackages::Data::version was added + d.mediaType = ::rtl::OUString( + value.getStr() + i2 + 1, value.getLength() - i2 - 1, + RTL_TEXTENCODING_UTF8); + } + else + { + d.mediaType = ::rtl::OUString( + value.getStr() + i2 + 1, i3 - i2 -1, RTL_TEXTENCODING_UTF8); + d.version = ::rtl::OUString( + value.getStr() + i3 + 1, value.getLength() - i3 - 1, + RTL_TEXTENCODING_UTF8); + } return d; } @@ -172,6 +186,8 @@ void ActivePackages::put(::rtl::OUString const & id, Data const & data) { b.append(::rtl::OUStringToOString(data.fileName, RTL_TEXTENCODING_UTF8)); b.append(separator); b.append(::rtl::OUStringToOString(data.mediaType, RTL_TEXTENCODING_UTF8)); + b.append(separator); + b.append(::rtl::OUStringToOString(data.version, RTL_TEXTENCODING_UTF8)); m_map.put(newKey(id), b.makeStringAndClear()); } diff --git a/desktop/source/deployment/manager/dp_activepackages.hxx b/desktop/source/deployment/manager/dp_activepackages.hxx index 1c58f76be245..36060d26bd02 100644 --- a/desktop/source/deployment/manager/dp_activepackages.hxx +++ b/desktop/source/deployment/manager/dp_activepackages.hxx @@ -42,9 +42,19 @@ namespace dp_manager { class ActivePackages { public: struct Data { + /* name of the temporary file (shared, user extension) or the name of + the folder of the bundled extension. + It does not contain the trailing '_' of the folder. + UTF-8 encoded + */ ::rtl::OUString temporaryName; + /* The file name (shared, user) or the folder name (bundled) + If the key is the file name, then file name is not encoded. + If the key is the idendifier then the file name is UTF-8 encoded. + */ ::rtl::OUString fileName; ::rtl::OUString mediaType; + ::rtl::OUString version; }; typedef ::std::vector< ::std::pair< ::rtl::OUString, Data > > Entries; diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx new file mode 100644 index 000000000000..469245bef340 --- /dev/null +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -0,0 +1,1301 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include + +#include "comphelper/servicedecl.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "rtl/bootstrap.hxx" +#include "com/sun/star/deployment/ExtensionManager.hpp" +#include "com/sun/star/deployment/XExtensionManager.hpp" +#include "com/sun/star/deployment/thePackageManagerFactory.hpp" +#include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/XPackageManagerFactory.hpp" +#include "com/sun/star/deployment/XPackage.hpp" +#include "com/sun/star/deployment/InstallException.hpp" +#include "com/sun/star/deployment/VersionException.hpp" +#include "com/sun/star/deployment/LicenseException.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/registry/XRegistryKey.hpp" +#include "com/sun/star/beans/Optional.hpp" +#include "com/sun/star/task/XInteractionApprove.hpp" +#include "com/sun/star/beans/Ambiguous.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/io/XInputStream.hpp" +#include "comphelper/sequence.hxx" +#include "xmlscript/xml_helper.hxx" +#include "osl/diagnose.h" +#include "dp_interact.h" +#include "dp_resource.h" +#include "dp_ucb.h" +#include "dp_identifier.hxx" + +#include "dp_extensionmanager.hxx" +#include "dp_tmprepocmdenv.hxx" +#include +#include +#include + +namespace deploy = com::sun::star::deployment; +namespace lang = com::sun::star::lang; +namespace registry = com::sun::star::registry; +namespace task = com::sun::star::task; +namespace ucb = com::sun::star::ucb; +namespace uno = com::sun::star::uno; +namespace beans = com::sun::star::beans; +namespace css = com::sun::star; + +//#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) + +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +namespace { + +struct CompIdentifiers +{ + bool operator() (::std::vector > const & a, + ::std::vector > const & b) + { + + if (getName(a).compareTo(getName(b)) < 0) + return true; + return false; + } + + OUString getName(::std::vector > const & a); +}; + +OUString CompIdentifiers::getName(::std::vector > const & a) +{ + OSL_ASSERT(a.size() == 3); + //get the first non-null reference + Reference extension; + ::std::vector >::const_iterator it = a.begin(); + for (; it != a.end(); it++) + { + if (it->is()) + { + extension = *it; + break; + } + } + OSL_ASSERT(extension.is()); + return extension->getDisplayName(); +} +} //end namespace + +namespace dp_manager { + + + +//------------------------------------------------------------------------------ + +//ToDo: bundled extension +ExtensionManager::ExtensionManager( Reference< uno::XComponentContext > const& xContext) : + m_xContext( xContext ) +{ + Reference xPackageManagerFactory( + deploy::thePackageManagerFactory::get(m_xContext)); + m_userRepository = xPackageManagerFactory->getPackageManager(OUSTR("user")); + m_sharedRepository = xPackageManagerFactory->getPackageManager(OUSTR("shared")); + m_bundledRepository = xPackageManagerFactory->getPackageManager(OUSTR("bundled")); + m_tmpRepository = xPackageManagerFactory->getPackageManager(OUSTR("tmp")); + + m_repositoryNames.push_back(OUSTR("user")); + m_repositoryNames.push_back(OUSTR("shared")); + m_repositoryNames.push_back(OUSTR("bundled")); +} + +//------------------------------------------------------------------------------ + +ExtensionManager::~ExtensionManager() +{ +} + +Reference ExtensionManager::createAbortChannel() + throw (uno::RuntimeException) +{ + return new dp_misc::AbortChannel; +} + +/* + Enters the XPackage objects into a map. They must be all from the + same repository. The value type of the map is a vector, where each vector + represents an extension with a particular identifier. The first member + is represents the user extension, the second the shared extension and the + third the bundled extension. + */ +void ExtensionManager::addExtensionsToMap( + id2extensions & mapExt, + uno::Sequence > const & seqExt, + OUString const & repository) +{ + //Determine the index in the vector where these extensions are to be + //added. + ::std::list::const_iterator citNames = + m_repositoryNames.begin(); + int index = 0; + for (;citNames != m_repositoryNames.end(); citNames++, index++) + { + if (citNames->equals(repository)) + break; + } + + for (int i = 0; i < seqExt.getLength(); i++) + { + Reference const & xExtension = seqExt[i]; + OUString id = dp_misc::getIdentifier(xExtension); + id2extensions::iterator ivec = mapExt.find(id); + if (ivec == mapExt.end()) + { + ::std::vector > vec(3); + vec[index] = xExtension; + mapExt[id] = vec; + } + else + { + ivec->second[index] = xExtension; + } + } +} + +/* + returns a list containing extensions with the same identifier from + all repositories (user, shared, bundled) If one repository does not + have this extension, then the list contains an empty Referenc. The list + is ordered according to the priority of the repostories: + 1. user + 2. shared + 3. bundled + + The number of elements is always three, unless the number of repository + changes. + */ +::std::list > + ExtensionManager::getExtensionsWithSameId( + OUString const & identifier, OUString const & fileName) + +{ + ::std::list > extensionList; + try + { //will throw an exception if the extension does not exist + extensionList.push_back(m_userRepository->getDeployedPackage( + identifier, fileName, Reference())); + } catch(lang::IllegalArgumentException &) + { + extensionList.push_back(Reference()); + } + try + { + extensionList.push_back(m_sharedRepository->getDeployedPackage( + identifier, fileName, Reference())); + } catch (lang::IllegalArgumentException &) + { + extensionList.push_back(Reference()); + } + try + { + extensionList.push_back(m_bundledRepository->getDeployedPackage( + identifier, fileName, Reference())); + } catch (lang::IllegalArgumentException &) + { + extensionList.push_back(Reference()); + } + OSL_ASSERT(extensionList.size() == 3); + return extensionList; +} + + +/* + +*/ +Reference ExtensionManager::getExtensionAndStatus( + ::rtl::OUString const & identifier, + ::rtl::OUString const & fileName, + ::rtl::OUString const & repository, + Reference const & xAbortChannel, + Reference const & xCmdEnv, + bool & out_bWasRegistered) +{ + Reference theExtension; + ::std::list > listExtensions = + getExtensionsWithSameId(identifier, fileName); + OSL_ASSERT(listExtensions.size() == m_repositoryNames.size()); + Reference xActiveExtension; + ::std::list::const_iterator + inames = m_repositoryNames.begin(); + ::std::list >::const_iterator + iext = listExtensions.begin(); + for (; inames != m_repositoryNames.end(); inames++, iext++) + { + if (repository.equals(*inames)) + { + theExtension = *iext; + if (iext->is()) + { + beans::Optional > optRegistered = + (*iext)->isRegistered(xAbortChannel, xCmdEnv); + OSL_ENSURE(! optRegistered.Value.IsAmbiguous, + "Extension is not properly registered"); + //IsAmbiguous = true: only partly registered, but we assume + //that this is the active extension, and something went wrong when registering it + //previously. + if (optRegistered.IsPresent + && (optRegistered.Value.Value || optRegistered.Value.IsAmbiguous)) + out_bWasRegistered = true; + } + break; + } + } + return theExtension; +} + +/* + Determines if the user extension was disabled by the user. Currently a user + cannot disable extensions from other repositories. If an extension does not + 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, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + +{ + bool bDisabled = false; + ::std::list > listExtensions = + getExtensionsWithSameId(identifier, fileName); + ::std::list >::const_iterator + iext = listExtensions.begin(); + bool bCheckOptional = false; + Reference xActive; + for (; iext != listExtensions.end(); iext++) + { + 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 const & xUser = listExtensions.front(); + if (xUser.is() + && xActive.is() + && xUser != xActive) + bDisabled = true; + } + return bDisabled; +} +/* + This method determines the active extension (XPackage.registerPackage) with a + particular identifier. + + The parameter bUserDisabled determines if the user extension is disabled. + + When the user repository contains an extension with the given identifier and + it is not disabled by the user, then it is always registered. Otherwise an + extension is only registered when there is no registered extension in one of + the repositories with a higher priority. That is, if the extension is from + the shared repository and an active extension with the same identifer is in + the user repository, then the extension is not registered. Similarly a + bundled extension is not registered if there is an active extension with the + same identifier in the shared or user repository. +*/ +void ExtensionManager::activateExtension( + OUString const & identifier, OUString const & fileName, + bool bUserDisabled, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) +{ + ::std::list > listExtensions = + getExtensionsWithSameId(identifier, fileName); + OSL_ASSERT(listExtensions.size() == 3); + ::std::list >::const_iterator + iext = listExtensions.begin(); + //skip disabled user extension + if (listExtensions.front().is() && bUserDisabled) + iext++; + bool bActive = false; + for (; iext != listExtensions.end(); iext++) + { + if (iext->is()) + { + //get the registration value of the current iteration + beans::Optional > optReg = + (*iext)->isRegistered(xAbortChannel, xCmdEnv); + //If nothing can be registered then break + if (!optReg.IsPresent) + break; + + //If we have already determined an active extension then we must + //make sure to unregister all extensions with the same id in + //repositories with a lower priority + if (bActive) + { + (*iext)->revokePackage(xAbortChannel, xCmdEnv); + } + else + { + //This is the first extension in the ordered list, which becomes + //the active extension + bActive = true; + //Register if not already done. + //reregister if the value is ambiguous, which indicates that + //something went wrong during last registration. + (*iext)->registerPackage(xAbortChannel, xCmdEnv); + } + } + } +} + +Reference ExtensionManager::backupExtension( + OUString const & identifier, OUString const & fileName, + Reference const & xPackageManager, + Reference const & xCmdEnv ) +{ + Reference xBackup; + Reference tmpCmdEnv( + new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler())); + Reference xOldExtension; + xOldExtension = xPackageManager->getDeployedPackage( + identifier, fileName, tmpCmdEnv); + + if (xOldExtension.is()) + { + xBackup = m_tmpRepository->addPackage( + xOldExtension->getURL(), OUString(), + Reference(), tmpCmdEnv); + + OSL_ENSURE(xBackup.is(), "Failed to backup extension"); + } + return xBackup; +} + +uno::Sequence< Reference > +ExtensionManager::getSupportedPackageTypes(OUString const & repository) + throw (uno::RuntimeException) +{ + if (repository.equals(OUSTR("user"))) + return m_userRepository->getSupportedPackageTypes(); + else if (repository.equals(OUSTR("shared"))) + return m_sharedRepository->getSupportedPackageTypes(); + else + return uno::Sequence< Reference >(); +} + +// Only add to shared and user repository +Reference ExtensionManager::addExtension( + OUString const & url, OUString const & repository, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + Reference xNewExtension; + //Determine the repository to use + Reference xPackageManager; + if (repository.equals(OUSTR("user"))) + xPackageManager = m_userRepository; + else if (repository.equals(OUSTR("shared"))) + xPackageManager = m_sharedRepository; + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + + ::osl::MutexGuard guard(m_mutex); + Reference xTmpExtension = + getTempExtension(url, xAbortChannel, xCmdEnv); + const OUString sIdentifier = dp_misc::getIdentifier(xTmpExtension); + const OUString sFileName = xTmpExtension->getName(); + const OUString sDisplayName = xTmpExtension->getDisplayName(); + const OUString sVersion = xTmpExtension->getVersion(); + + Reference xOldExtension; + bool bUserDisabled = false; + Reference xExtensionBackup; + + uno::Any excOccurred1; + uno::Any excOccurred2; + + try + { + //If we add a user extension and there is already one which was + //disabled by a user, then the newly installed one is enabled. If we + //add to another repository then the user extension remains + //disabled. + if (! repository.equals(OUSTR("user"))) + bUserDisabled = isUserExtensionDisabled( + sIdentifier, sFileName, xAbortChannel, xCmdEnv); + + bool bWasRegistered = false; + xOldExtension = getExtensionAndStatus( + sIdentifier, sFileName, repository, xAbortChannel, + xCmdEnv, bWasRegistered); + bool bCanInstall = false; + try + { + if (xOldExtension.is()) + { + //throws a CommandFailedException if the user cancels + //the action. + checkUpdate(sVersion, sDisplayName,xOldExtension, xCmdEnv); + } + else + { + //throws a CommandFailedException if the user cancels + //the action. + checkInstall(sDisplayName, xCmdEnv); + } + + bCanInstall = xTmpExtension->checkPrerequisites( + xAbortChannel, xCmdEnv, xOldExtension.is(), repository); + } + catch (deploy::DeploymentException& ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (ucb::CommandFailedException & ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (ucb::CommandAbortedException & ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (lang::IllegalArgumentException &) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (uno::RuntimeException &) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (...) { + excOccurred1 = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during addExtension, url: ") + + url, static_cast(this), excOccurred1); + excOccurred1 <<= exc; + } + + if (bCanInstall) + { + if (xOldExtension.is()) + { + if (bWasRegistered) + xOldExtension->revokePackage(xAbortChannel, xCmdEnv); + //save the old user extension in case the user aborts + //store the extension in the tmp repository, this will overwrite + //xTmpPackage (same identifier). Do not let the user abort or + //interact + Reference tmpCmdEnv( + new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler())); + //importing the old extension in the tmp repository will remove + //the xTmpExtension + xTmpExtension = 0; + xExtensionBackup = m_tmpRepository->importExtension( + xOldExtension, Reference(), + tmpCmdEnv); + } + + xNewExtension = xPackageManager->addPackage( + url, OUString(), xAbortChannel, xCmdEnv); + activateExtension( + dp_misc::getIdentifier(xNewExtension), + xNewExtension->getName(), bUserDisabled, + xAbortChannel, xCmdEnv); + } + } + catch (deploy::DeploymentException& ) { + excOccurred2 = ::cppu::getCaughtException(); + } catch (ucb::CommandFailedException & ) { + excOccurred2 = ::cppu::getCaughtException(); + } catch (ucb::CommandAbortedException & ) { + excOccurred2 = ::cppu::getCaughtException(); + } catch (lang::IllegalArgumentException &) { + excOccurred2 = ::cppu::getCaughtException(); + } catch (uno::RuntimeException &) { + excOccurred2 = ::cppu::getCaughtException(); + } catch (...) { + excOccurred2 = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during addExtension, url: ") + + url, static_cast(this), excOccurred2); + excOccurred2 <<= exc; + } + + if (excOccurred2.hasValue()) + { + //It does not matter what exception is thrown. We try to + //recover the original status. + //If the user aborted installation then a ucb::CommandAbortedException + //is thrown. + //Use a private AbortChannel so the user cannot interrupt. + try + { + Reference tmpCmdEnv( + new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler())); + if (xExtensionBackup.is()) + { + Reference xRestored = + xPackageManager->importExtension( + xExtensionBackup, Reference(), + tmpCmdEnv); + } + activateExtension( + sIdentifier, sFileName, bUserDisabled, + Reference(), tmpCmdEnv); + if (xTmpExtension.is() || xExtensionBackup.is()) + m_tmpRepository->removePackage( + sIdentifier, OUString(), xAbortChannel, xCmdEnv); + } + catch (...) + { + } + ::cppu::throwException(excOccurred2); + } + if (xTmpExtension.is() || xExtensionBackup.is()) + m_tmpRepository->removePackage( + sIdentifier,OUString(), xAbortChannel, xCmdEnv); + + if (excOccurred1.hasValue()) + ::cppu::throwException(excOccurred1); + + return xNewExtension; +} + +void ExtensionManager::removeExtension( + OUString const & identifier, OUString const & fileName, + OUString const & repository, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + uno::Any excOccurred1; + Reference xExtensionBackup; + Reference xPackageManager; + bool bUserDisabled = false; + try + { +//Determine the repository to use + if (repository.equals(OUSTR("user"))) + xPackageManager = m_userRepository; + else if (repository.equals(OUSTR("shared"))) + xPackageManager = m_sharedRepository; + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + + ::osl::MutexGuard guard(m_mutex); + //Backup the extension, in case the user cancels the action + + bUserDisabled = isUserExtensionDisabled( + identifier, fileName, xAbortChannel, xCmdEnv); + //Backup the extension, in case the user cancels the action + xExtensionBackup = backupExtension( + identifier, fileName, xPackageManager, xCmdEnv); + + //revoke the extension if it is active + Reference xOldExtension = + xPackageManager->getDeployedPackage( + identifier, fileName, xCmdEnv); + xOldExtension->revokePackage(xAbortChannel, xCmdEnv); + + xPackageManager->removePackage( + identifier, fileName, xAbortChannel, xCmdEnv); + activateExtension(identifier, fileName, bUserDisabled, + xAbortChannel, xCmdEnv); + } + catch (deploy::DeploymentException& ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (ucb::CommandFailedException & ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (ucb::CommandAbortedException & ) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (lang::IllegalArgumentException &) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (uno::RuntimeException &) { + excOccurred1 = ::cppu::getCaughtException(); + } catch (...) { + excOccurred1 = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during removeEtension"), + static_cast(this), excOccurred1); + excOccurred1 <<= exc; + } + + if (excOccurred1.hasValue()) + { + //User aborted installation, restore the previous situation. + //Use a private AbortChannel so the user cannot interrupt. + try + { + Reference tmpCmdEnv( + new TmpRepositoryCommandEnv(xCmdEnv->getInteractionHandler())); + if (xExtensionBackup.is()) + { + Reference xRestored = + xPackageManager->importExtension( + xExtensionBackup, Reference(), + tmpCmdEnv); + activateExtension( + identifier, fileName, bUserDisabled, Reference(), + tmpCmdEnv); + + m_tmpRepository->removePackage( + dp_misc::getIdentifier(xExtensionBackup), + xExtensionBackup->getName(), xAbortChannel, xCmdEnv); + } + } + catch (...) + { + } + ::cppu::throwException(excOccurred1); + } + + if (xExtensionBackup.is()) + m_tmpRepository->removePackage( + dp_misc::getIdentifier(xExtensionBackup), + xExtensionBackup->getName(), xAbortChannel, xCmdEnv); +} + +// Only enable extensions from shared and user repository +void ExtensionManager::enableExtension( + Reference const & extension, + Reference const & xAbortChannel, + Reference const & xCmdEnv) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + try + { + if (!extension.is()) + return; + + OUString repository = extension->getRepositoryName(); + if (!repository.equals(OUSTR("user"))) + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + ::osl::MutexGuard guard(m_mutex); + + //if it is already registered or if it cannot be registered + //because it does not contain any files which need to be processed + //then there is nothing to do here + beans::Optional > reg = + extension->isRegistered(xAbortChannel, xCmdEnv); + if (!reg.IsPresent + || (!reg.Value.IsAmbiguous && reg.Value.Value)) + return; + } + catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any exc = ::cppu::getCaughtException(); + throw deploy::DeploymentException( + OUSTR("Extension Manager: exception during enableExtension"), + static_cast(this), exc); + } + + uno::Any excOccurred; + try + { + activateExtension(dp_misc::getIdentifier(extension), + extension->getName(), + false, xAbortChannel, xCmdEnv); + } + catch (deploy::DeploymentException& ) { + excOccurred = ::cppu::getCaughtException(); + } catch (ucb::CommandFailedException & ) { + excOccurred = ::cppu::getCaughtException(); + } catch (ucb::CommandAbortedException & ) { + excOccurred = ::cppu::getCaughtException(); + } catch (lang::IllegalArgumentException &) { + excOccurred = ::cppu::getCaughtException(); + } catch (uno::RuntimeException &) { + excOccurred = ::cppu::getCaughtException(); + } catch (...) { + excOccurred = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during enableExtension"), + static_cast(this), excOccurred); + excOccurred <<= exc; + } + + if (excOccurred.hasValue()) + { + try + { + extension->revokePackage(Reference(), xCmdEnv); + activateExtension(dp_misc::getIdentifier(extension), + extension->getName(), + true, xAbortChannel, xCmdEnv); + } + catch (...) + { + } + ::cppu::throwException(excOccurred); + } +} + +void ExtensionManager::disableExtension( + Reference const & extension, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + uno::Any excOccurred; + try + { + if (!extension.is()) + return; + + ::osl::MutexGuard guard(m_mutex); + OUString repository = extension->getRepositoryName(); + if (!repository.equals(OUSTR("user"))) + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + + //if it is already registered or if it cannot be registered + //because it does not contain any files which need to be processed + //then there is nothing to do here + beans::Optional > reg = + extension->isRegistered(xAbortChannel, xCmdEnv); + if (!reg.IsPresent + || (!reg.Value.IsAmbiguous && !reg.Value.Value)) + return; + + extension->revokePackage(xAbortChannel, xCmdEnv); + activateExtension(dp_misc::getIdentifier(extension), + extension->getName(), + true, xAbortChannel, xCmdEnv); + } + catch (deploy::DeploymentException& ) { + excOccurred = ::cppu::getCaughtException(); + } catch (ucb::CommandFailedException & ) { + excOccurred = ::cppu::getCaughtException(); + } catch (ucb::CommandAbortedException & ) { + excOccurred = ::cppu::getCaughtException(); + } catch (lang::IllegalArgumentException &) { + excOccurred = ::cppu::getCaughtException(); + } catch (uno::RuntimeException &) { + excOccurred = ::cppu::getCaughtException(); + } catch (...) { + excOccurred = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during disableExtension"), + static_cast(this), excOccurred); + excOccurred <<= exc; + } + + if (excOccurred.hasValue()) + { + try + { + activateExtension(dp_misc::getIdentifier(extension), + extension->getName(), + false, xAbortChannel, xCmdEnv); + } + catch (...) + { + } + ::cppu::throwException(excOccurred); + } +} + +uno::Sequence< Reference > + ExtensionManager::getDeployedExtensions( + OUString const & repository, + Reference const &xAbort, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + if (repository.equals(OUSTR("user"))) + { + return m_userRepository->getDeployedPackages( + xAbort, xCmdEnv); + } + else if (repository.equals(OUSTR("shared"))) + { + return m_sharedRepository->getDeployedPackages( + xAbort, xCmdEnv); + } + else if (repository.equals(OUSTR("bundled"))) + { + return m_bundledRepository->getDeployedPackages( + xAbort, xCmdEnv); + } + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + +} + +Reference + ExtensionManager::getDeployedExtension( + OUString const & repository, + OUString const & identifier, + OUString const & filename, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + if (repository.equals(OUSTR("user"))) + { + return m_userRepository->getDeployedPackage( + identifier, filename, xCmdEnv); + } + else if (repository.equals(OUSTR("shared"))) + { + return m_sharedRepository->getDeployedPackage( + identifier, filename, xCmdEnv); + } + else if (repository.equals(OUSTR("bundled"))) + { + return m_bundledRepository->getDeployedPackage( + identifier, filename, xCmdEnv); + } + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); +} + +uno::Sequence< uno::Sequence > > + ExtensionManager::getAllExtensions( + Reference const & xAbort, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + uno::Sequence< uno::Sequence > > seqSeq; + try + { + id2extensions mapExt; + + uno::Sequence > userExt = + m_userRepository->getDeployedPackages(xAbort, xCmdEnv); + addExtensionsToMap(mapExt, userExt, OUSTR("user")); + uno::Sequence > sharedExt = + m_sharedRepository->getDeployedPackages(xAbort, xCmdEnv); + addExtensionsToMap(mapExt, sharedExt, OUSTR("shared")); + uno::Sequence > bundledExt = + m_bundledRepository->getDeployedPackages(xAbort, xCmdEnv); + addExtensionsToMap(mapExt, bundledExt, OUSTR("bundled")); + + //copy the values of the map to a vector for sorting + ::std::vector< ::std::vector > > + vecExtensions; + id2extensions::const_iterator mapIt = mapExt.begin(); + for (;mapIt != mapExt.end(); mapIt++) + vecExtensions.push_back(mapIt->second); + + //sort the element according to the identifier + ::std::sort(vecExtensions.begin(), vecExtensions.end(), CompIdentifiers()); + + ::std::vector< ::std::vector > >::const_iterator + citVecVec = vecExtensions.begin(); + sal_Int32 j = 0; + for (;citVecVec != vecExtensions.end(); citVecVec++, j++) + { + seqSeq[j] = comphelper::containerToSequence(*citVecVec); + } + } catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any exc = ::cppu::getCaughtException(); + throw deploy::DeploymentException( + OUSTR("Extension Manager: exception during enableExtension"), + static_cast(this), exc); + } + + return seqSeq; +} + +void ExtensionManager::reinstallDeployedExtensions( + OUString const & repository, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, ucb::CommandAbortedException, + lang::IllegalArgumentException, uno::RuntimeException) +{ + try + { + Reference xPackageManager; + if (repository.equals(OUSTR("user"))) + xPackageManager = m_userRepository; + else if (repository.equals(OUSTR("shared"))) + xPackageManager = m_sharedRepository; + else if (repository.equals(OUSTR("bundled"))) + xPackageManager = m_bundledRepository; + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + + ::osl::MutexGuard guard(m_mutex); + xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv); + const uno::Sequence< Reference > extensions( + xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv)); + + for ( sal_Int32 pos = 0; pos < extensions.getLength(); ++pos ) + { + try + { + const OUString id = dp_misc::getIdentifier(extensions[ pos ]); + const OUString fileName = extensions[ pos ]->getName(); + OSL_ASSERT(id.getLength()); + activateExtension( + id, fileName, + isUserExtensionDisabled(id, fileName, xAbortChannel, xCmdEnv), + xAbortChannel, xCmdEnv ); + } + catch (lang::DisposedException &) + { + } + } + } catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any exc = ::cppu::getCaughtException(); + throw deploy::DeploymentException( + OUSTR("Extension Manager: exception during enableExtension"), + static_cast(this), exc); + } +} + +void ExtensionManager::synchronize( + OUString const & repository, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + try + { + Reference xPackageManager; + OUString file; + if (repository.equals(OUSTR("user"))) + { + xPackageManager = m_userRepository; + } + else if (repository.equals(OUSTR("shared"))) + { + xPackageManager = m_sharedRepository; + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$SHARED_EXTENSIONS_USER/lastsynchronized")); + } + else if (repository.equals(OUSTR("bundled"))) + { + xPackageManager = m_bundledRepository; + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); + } + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + + ::osl::MutexGuard guard(m_mutex); + uno::Sequence > seqAddedExtensions; + uno::Sequence > seqRemovedExtensions; + xPackageManager->synchronize(seqAddedExtensions, seqRemovedExtensions, + xAbortChannel, xCmdEnv); + + //ToDo: optimize, only call activateExtension once per id. + //Determine which of the extensions was disabled by the user + //iterate of both sequences and add the ids of the user disabled + //to a map + for (sal_Int32 i = 0; i < seqRemovedExtensions.getLength(); i++) + { + try + { + Reference const & xExtension = seqRemovedExtensions[i]; + OSL_ASSERT(xExtension.is()); + const OUString id = dp_misc::getIdentifier(xExtension); + const OUString fileName = xExtension->getName(); + + bool bUserDisabled = isUserExtensionDisabled( + id, xExtension->getName(), xAbortChannel, xCmdEnv); + xExtension->revokePackage(xAbortChannel, xCmdEnv); + xPackageManager->removePackage( + id, fileName, xAbortChannel, xCmdEnv); + activateExtension( + id, fileName, bUserDisabled, xAbortChannel, xCmdEnv); + } + catch (...) + { + OSL_ENSURE(0, "Extensions Manager: synchronize"); + } + } + + for (sal_Int32 i = 0; i < seqAddedExtensions.getLength(); i++) + { + try + { + Reference const & xExtension = seqAddedExtensions[i]; + OSL_ASSERT(xExtension.is()); + const OUString id = dp_misc::getIdentifier(xExtension); + const OUString fileName = xExtension->getName(); + bool bUserDisabled = isUserExtensionDisabled( + id, fileName, xAbortChannel, xCmdEnv); + activateExtension( + id, fileName, bUserDisabled, xAbortChannel, xCmdEnv); + } + catch (...) + { + OSL_ENSURE(0, "Extensions Manager: synchronize"); + } + } + + //Write the lastmodified file + try { + ::rtl::Bootstrap::expandMacros(file); + ::ucbhelper::Content ucbStamp(file, xCmdEnv ); + dp_misc::erase_path( file, xCmdEnv ); + ::rtl::OString stamp("1" ); + Reference xData( + ::xmlscript::createInputStream( + ::rtl::ByteSequence( + reinterpret_cast(stamp.getStr()), + stamp.getLength() ) ) ); + ucbStamp.writeStream( xData, true /* replace existing */ ); + } + catch(...) + { + uno::Any exc(::cppu::getCaughtException()); + throw deploy::DeploymentException( + OUSTR("Failed to update") + file, + static_cast(this), exc); + + } + } catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any exc = ::cppu::getCaughtException(); + throw deploy::DeploymentException( + OUSTR("Extension Manager: exception during enableExtension"), + static_cast(this), exc); + } +} + +// Notify the user when a new extension is to be installed. This is only the +// case when one uses the system integration to install an extension (double +// clicking on .oxt file etc.)). The function must only be called if there is no +// extension with the same identifier already deployed. Then the checkUpdate +// function will inform the user that the extension is about to be installed In +// case the user cancels the installation a CommandFailed exception is +// thrown. +void ExtensionManager::checkInstall( + OUString const & displayName, + Reference const & cmdEnv) +{ + uno::Any request( + deploy::InstallException( + OUSTR("Extension ") + displayName + + OUSTR(" is about to be installed."), + static_cast(this), displayName)); + bool approve = false, abort = false; + if (! dp_misc::interactContinuation( + request, task::XInteractionApprove::static_type(), + cmdEnv, &approve, &abort )) + { + OSL_ASSERT( !approve && !abort ); + throw deploy::DeploymentException( + dp_misc::getResourceString(RID_STR_ERROR_WHILE_ADDING) + displayName, + static_cast(this), request ); + } + if (abort || !approve) + throw ucb::CommandFailedException( + dp_misc::getResourceString(RID_STR_ERROR_WHILE_ADDING) + displayName, + static_cast(this), request ); +} + +/* The function will make the user interaction in case there is an extension +installed with the same id. This function may only be called if there is already +an extension. +*/ +void ExtensionManager::checkUpdate( + OUString const & newVersion, + OUString const & newDisplayName, + Reference const & oldExtension, + Reference const & xCmdEnv ) +{ + // package already deployed, interact --force: + uno::Any request( + (deploy::VersionException( + dp_misc::getResourceString( + RID_STR_PACKAGE_ALREADY_ADDED ) + newDisplayName, + static_cast(this), newVersion, newDisplayName, + oldExtension ) ) ); + bool replace = false, abort = false; + if (! dp_misc::interactContinuation( + request, task::XInteractionApprove::static_type(), + xCmdEnv, &replace, &abort )) { + OSL_ASSERT( !replace && !abort ); + throw deploy::DeploymentException( + dp_misc::getResourceString( + RID_STR_ERROR_WHILE_ADDING) + newDisplayName, + static_cast(this), request ); + } + if (abort || !replace) + throw ucb::CommandFailedException( + dp_misc::getResourceString( + RID_STR_PACKAGE_ALREADY_ADDED) + newDisplayName, + static_cast(this), request ); +} + +Reference ExtensionManager::getTempExtension( + OUString const & url, + Reference const & xAbortChannel, + Reference const & /*xCmdEnv*/) + +{ + Reference tmpCmdEnvA(new TmpRepositoryCommandEnv()); + Reference xTmpPackage = m_tmpRepository->addPackage( + url, OUString(), xAbortChannel, tmpCmdEnvA); + + if (!xTmpPackage.is()) + { + throw deploy::DeploymentException( + OUSTR("Extension Manager: Failed to create temporary XPackage for url: ") + url, + static_cast(this), uno::Any()); + + } + return xTmpPackage; +} +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ + +namespace sdecl = comphelper::service_decl; +sdecl::class_ servicePIP; +extern sdecl::ServiceDecl const serviceDecl( + servicePIP, + // a private one: + "com.sun.star.comp.deployment.ExtensionManager", + "com.sun.star.comp.deployment.ExtensionManager"); + +//------------------------------------------------------------------------------ +bool singleton_entries( + uno::Reference< registry::XRegistryKey > const & xRegistryKey ) +{ + try { + uno::Reference< registry::XRegistryKey > xKey( + xRegistryKey->createKey( + serviceDecl.getImplementationName() + + // xxx todo: use future generated function to get singleton name + OUSTR("/UNO/SINGLETONS/" + "com.sun.star.deployment.ExtensionManager") ) ); + xKey->setStringValue( serviceDecl.getSupportedServiceNames()[0] ); + return true; + } + catch (registry::InvalidRegistryException & exc) { + (void) exc; // avoid warnings + OSL_ENSURE( 0, ::rtl::OUStringToOString( + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + return false; + } +} + +} // namespace dp_manager + + diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx new file mode 100644 index 000000000000..386e2a7ceffd --- /dev/null +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -0,0 +1,287 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#if ! defined INCLUDED_DP_EXTENSIONMANAGER_H +#define INCLUDED_DP_EXTENSIONMANAGER_H + +#include "dp_manager.hrc" +#include "dp_misc.h" +#include "dp_interact.h" +#include "dp_activepackages.hxx" +#include "rtl/ref.hxx" +#include "cppuhelper/compbase1.hxx" +//#include "cppuhelper/implbase2.hxx" +#include "ucbhelper/content.hxx" +#include "com/sun/star/deployment/XPackageRegistry.hpp" +#include "com/sun/star/deployment/XPackageManager.hpp" +//#include +#include "osl/mutex.hxx" +#include + + +namespace css = ::com::sun::star; + +namespace dp_manager { + +typedef ::std::hash_map< + ::rtl::OUString, + ::std::vector >, + ::rtl::OUStringHash > id2extensions; + +class ExtensionManager : + public ::cppu::WeakImplHelper1< css::deployment::XExtensionManager > + +{ +private: + ::osl::Mutex m_mutex; + + 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(this); }; + +// 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 const & xListener ) + // throw (css::uno::RuntimeException); + //virtual void SAL_CALL removeEventListener( + // css::uno::Reference const & xListener ) + // throw (css::uno::RuntimeException); + // + //// XModifyBroadcaster + //virtual void SAL_CALL addModifyListener( + // css::uno::Reference const & xListener ) + // throw (css::uno::RuntimeException); + //virtual void SAL_CALL removeModifyListener( + // css::uno::Reference const & xListener ) + // throw (css::uno::RuntimeException); + + // XPackageManager +// virtual ::rtl::OUString SAL_CALL getContext() +// throw (css::uno::RuntimeException); + virtual css::uno::Sequence< + css::uno::Reference > SAL_CALL + getSupportedPackageTypes(::rtl::OUString const & repository) + throw (css::uno::RuntimeException); + + virtual css::uno::Reference SAL_CALL + createAbortChannel() throw (css::uno::RuntimeException); + + virtual css::uno::Reference SAL_CALL addExtension( + ::rtl::OUString const & url, ::rtl::OUString const & repository, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual void SAL_CALL removeExtension( + ::rtl::OUString const & identifier, + ::rtl::OUString const & filename, + ::rtl::OUString const & repository, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual void SAL_CALL enableExtension( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual void SAL_CALL disableExtension( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual css::uno::Sequence< css::uno::Reference > + SAL_CALL getDeployedExtensions( + ::rtl::OUString const & repository, + css::uno::Reference const &, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual css::uno::Reference< css::deployment::XPackage> + SAL_CALL getDeployedExtension( + ::rtl::OUString const & repository, + ::rtl::OUString const & identifier, + ::rtl::OUString const & filename, + css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) + throw ( + css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual css::uno::Sequence< css::uno::Sequence > > + SAL_CALL getAllExtensions( + css::uno::Reference const &, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + + virtual void SAL_CALL reinstallDeployedExtensions( + ::rtl::OUString const & repository, + css::uno::Reference< css::task::XAbortChannel> const & xAbortChannel, + css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) + throw ( + css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual void SAL_CALL synchronize( + ::rtl::OUString const & repository, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + +private: + + struct ExtensionInfos + { + ::rtl::OUString identifier; + ::rtl::OUString fileName; + ::rtl::OUString displayName; + ::rtl::OUString version; + }; + + css::uno::Reference< css::uno::XComponentContext> m_xContext; + + css::uno::Reference m_userRepository; + css::uno::Reference m_sharedRepository; + css::uno::Reference m_bundledRepository; + css::uno::Reference m_tmpRepository; + + /* contains the names of all repositories (except tmp) in order of there + priority. That is, the first element is "user" follod by "shared" and + then "bundled" + */ + ::std::list< ::rtl::OUString > m_repositoryNames; + + css::uno::Reference getExtensionAndStatus( + ::rtl::OUString const & identifier, + ::rtl::OUString const & fileName, + ::rtl::OUString const & repository, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv, + bool & out_bWasRegistered); + + bool isUserExtensionDisabled( + ::rtl::OUString const & identifier, + ::rtl::OUString const & fileName, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); + + void activateExtension( + ::rtl::OUString const & identifier, + ::rtl::OUString const & fileName, + bool bUserDisabled, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); + + + ::std::list > + getExtensionsWithSameId(::rtl::OUString const & identifier, + ::rtl::OUString const & fileName); + + css::uno::Reference backupExtension( + ::rtl::OUString const & identifier, ::rtl::OUString const & fileName, + css::uno::Reference const & xPackageManager, + css::uno::Reference const & xCmdEnv); + + void checkInstall( + ::rtl::OUString const & displayName, + css::uno::Reference const & cmdEnv); + + void checkUpdate( + ::rtl::OUString const & newVersion, + ::rtl::OUString const & newDisplayName, + css::uno::Reference const & oldExtension, + css::uno::Reference const & xCmdEnv); + + css::uno::Reference getTempExtension( + ::rtl::OUString const & url, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); + + + void addExtensionsToMap( + id2extensions & mapExt, + css::uno::Sequence > const & seqExt, + ::rtl::OUString const & repository); +}; + +} + + + + +#endif + diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 3f13cb021aae..59e9f2049722 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -60,7 +60,12 @@ #include "com/sun/star/task/XInteractionApprove.hpp" #include "com/sun/star/ucb/UnsupportedCommandException.hpp" #include "boost/bind.hpp" +#include "tools/urlobj.hxx" + +#include "osl/file.hxx" #include +#include +#include "dp_descriptioninfoset.hxx" using namespace ::dp_misc; @@ -91,6 +96,58 @@ struct MatchTempDir } }; +struct MatchExtension +{ + const ActivePackages::Data m_data; + MatchExtension(ActivePackages::Data const & data ) : m_data(data) {} + bool operator () ( OUString const & temporaryName ) const; +}; + +bool MatchExtension::operator () (OUString const & temporaryName) const +{ + //case 1: The temporary file and thus the extension folder are already + //removed. + return m_data.temporaryName.equals(temporaryName); +} + +namespace { +OUString getExtensionFolder(OUString const & parentFolder, + Reference const & xCmdEnv) +{ + ::ucbhelper::Content tempFolder( + parentFolder, xCmdEnv ); + Reference xResultSet( + tempFolder.createCursor( + Sequence( &StrTitle::get(), 1 ), + ::ucbhelper::INCLUDE_FOLDERS_ONLY ) ); + + OUString title; + while (xResultSet->next()) + { + title = Reference( + xResultSet, UNO_QUERY_THROW )->getString(1 /* Title */ ) ; + break; + } + return title; +} +/* adds an unencoded segment to the URL. + + Throws an com.sun.star.uno.Exception if this failed. +*/ +OUString appendURLSegement(OUString const & baseURL, OUString const & segment) +{ + OUString url; + INetURLObject inet(baseURL); + if (inet.insertName( + segment, false, INetURLObject::LAST_SEGMENT, true, + INetURLObject::ENCODE_ALL)) + url = inet.GetMainURL(INetURLObject::NO_DECODE); + else + throw Exception( + OUSTR("ExtensionManager: failed to add segment to URL"), 0); + return url; +} +} //______________________________________________________________________________ void PackageManagerImpl::initActivationLayer( Reference const & xCmdEnv ) @@ -151,12 +208,23 @@ void PackageManagerImpl::initActivationLayer( // user|share: OSL_ASSERT( m_activePackages.getLength() > 0 ); m_activePackages_expanded = expandUnoRcUrl( m_activePackages ); - create_folder( 0, m_activePackages_expanded, xCmdEnv, !m_readOnly ); + m_registrationData_expanded = expandUnoRcUrl(m_registrationData); + create_folder( 0, m_activePackages_expanded, xCmdEnv, true); + + OUString dbName; + if (m_context.equals(OUSTR("user"))) + dbName = m_activePackages_expanded + OUSTR(".db"); + else + { + //Create the extension data base in the user installation + create_folder( 0, m_registrationData_expanded, xCmdEnv, true); + dbName = m_registrationData_expanded + OUSTR("/extensions.db"); + } + //The data base can always be written because it it always in the user installation m_activePackagesDB.reset( - new ActivePackages( - m_activePackages_expanded + OUSTR(".db"), m_readOnly ) ); + new ActivePackages( dbName, false ) ); - if (! m_readOnly) + if (! m_readOnly && ! m_context.equals(OUSTR("bundled"))) { // clean up activation layer, scan for zombie temp dirs: ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); @@ -169,11 +237,17 @@ void PackageManagerImpl::initActivationLayer( ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); // get all temp directories: ::std::vector tempEntries; - while (xResultSet->next()) { + while (xResultSet->next()) + { OUString title( Reference( xResultSet, UNO_QUERY_THROW )->getString( 1 /* Title */ ) ); + const char extensionRemoved[] = ".tmpremoved"; + if (title.endsWithAsciiL( + extensionRemoved, sizeof(extensionRemoved) - 1)) + continue; + tempEntries.push_back( ::rtl::Uri::encode( title, rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, @@ -195,6 +269,9 @@ void PackageManagerImpl::initActivationLayer( false /* no throw: ignore errors */ ); erase_path( url, Reference(), false /* no throw: ignore errors */ ); + //delete the xxx.tmpremoved file + erase_path(url + OUSTR("removed"), + Reference(), false); } } } @@ -206,9 +283,9 @@ void PackageManagerImpl::initRegistryBackends() { if (m_registryCache.getLength() > 0) create_folder( 0, m_registryCache, - Reference(), !m_readOnly ); + Reference(), false); m_xRegistry.set( ::dp_registry::create( - m_context, m_registryCache, m_readOnly, + m_context, m_registryCache, false, m_xComponentContext ) ); } @@ -223,12 +300,14 @@ Reference PackageManagerImpl::create( OUString packages, logFile, stampURL; if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("user") )) { - that->m_activePackages = OUSTR("vnd.sun.star.expand:$UNO_" - "USER_PACKAGES_CACHE/uno_packages"); - that->m_registryCache = OUSTR("vnd.sun.star.expand:$UNO_" - "USER_PACKAGES_CACHE/registry"); - logFile = OUSTR("vnd.sun.star.expand:$UNO_" - "USER_PACKAGES_CACHE/log.txt"); + that->m_activePackages = OUSTR( + "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages"); + that->m_registrationData = OUSTR( + "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"); + that->m_registryCache = OUSTR( + "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/registry"); + logFile = OUSTR( + "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/log.txt"); //We use the extension .sys for the file because on Windows Vista a sys //(as well as exe and dll) file //will not be written in the VirtualStore. For example if the process has no @@ -240,25 +319,42 @@ Reference PackageManagerImpl::create( //using virtualization it appears that he/she can. Then a shared extension can //be installed but is only visible for the user (because the extension is in //the virtual store). - stampURL = OUSTR("vnd.sun.star.expand:$UNO_" - "USER_PACKAGES_CACHE/stamp.sys"); + stampURL = OUSTR( + "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/stamp.sys"); } else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") )) { - that->m_activePackages = OUSTR("vnd.sun.star.expand:$UNO_" - "SHARED_PACKAGES_CACHE/uno_packages"); - that->m_registryCache = OUSTR("vnd.sun.star.expand:$UNO_" - "SHARED_PACKAGES_CACHE/registry"); -// The current logging implementation does not work for shared, because it requires -// write access to the logfile. When two users run OOo at the same time on the same machine -// then the -// second will fail because it does not get write access. One cannot write into the -// user's home, because then people may complain that when installing shared extension -// stuff is written in their home. -// logFile = OUSTR("vnd.sun.star.expand:$UNO_" -// "SHARED_PACKAGES_CACHE/log.txt"); - //See description for stampURL for user packages. - stampURL = OUSTR("vnd.sun.star.expand:$UNO_" - "SHARED_PACKAGES_CACHE/stamp.sys"); + that->m_activePackages = OUSTR( + "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages"); + that->m_registrationData = OUSTR( + "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER"); + that->m_registryCache = OUSTR( + "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER/registry"); + logFile = OUSTR( + "vnd.sun.star.expand:$SHARED_EXTENSIONS_USER/log.txt"); + stampURL = OUSTR( + "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/stamp.sys"); + } + else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") )) { + that->m_activePackages = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS"); + that->m_registrationData = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER"); + that->m_registryCache = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER/registry"); + logFile = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_USER/log.txt"); + //No stamp file. We assume that bundled is always readonly. It must not be + //modified from ExtensionManager but only by the installer + } + else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") )) { + that->m_activePackages = OUSTR( + "vnd.sun.star.expand:$TMP_EXTENSIONS/extensions"); + that->m_registrationData = OUSTR( + "vnd.sun.star.expand:$TMP_EXTENSIONS"); + that->m_registryCache = OUSTR( + "vnd.sun.star.expand:$TMP_EXTENSIONS/registry"); + stampURL = OUSTR( + "vnd.sun.star.expand:$TMP_EXTENSIONS/stamp.sys"); } else if (! context.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:/") )) { @@ -270,29 +366,15 @@ Reference PackageManagerImpl::create( Reference xCmdEnv; try { - bool renewal = false; - + //There is no stampURL for the bundled folder if (stampURL.getLength() > 0) { - // currently no automatic renewal possible, because quickstarter - // already hinders from deleting registry directory... - #define CURRENT_STAMP "1" -// renewal = true; -// { -// ::ucbhelper::Content ucbStamp; -// if (create_ucb_content( -// &ucbStamp, stampURL, xCmdEnv, false /* no throw */ )) -// { -// OUString line; -// renewal = !readLine( &line, OUSTR(CURRENT_STAMP), ucbStamp, -// RTL_TEXTENCODING_ASCII_US ); -// } -// } - try { + //The osl file API does not allow to find out if one can write + //into a folder. Therefore we try to write a file. Then we delete + //it, so that it does not hinder uninstallation of OOo // probe writing: - erase_path( stampURL, xCmdEnv ); ::ucbhelper::Content ucbStamp( stampURL, xCmdEnv ); ::rtl::OString stamp( RTL_CONSTASCII_STRINGPARAM(CURRENT_STAMP) ); @@ -302,8 +384,15 @@ Reference PackageManagerImpl::create( reinterpret_cast(stamp.getStr()), stamp.getLength() ) ) ); ucbStamp.writeStream( xData, true /* replace existing */ ); + that->m_readOnly = false; + erase_path( stampURL, xCmdEnv ); } catch (RuntimeException &) { + try { + erase_path( stampURL, xCmdEnv ); + } catch (...) + { + } throw; } catch (Exception &) { @@ -324,12 +413,6 @@ Reference PackageManagerImpl::create( xCmdEnv.set( new CmdEnvWrapperImpl( xCmdEnv, that->m_xLogFile ) ); } - OSL_ENSURE( !that->m_readOnly || !renewal, - "### ought to reinstall all packages, but cannot write!" ); - if (!that->m_readOnly && renewal) // try to reinstall - that->reinstallDeployedPackages( - Reference(), xCmdEnv ); - that->initRegistryBackends(); that->initActivationLayer( xCmdEnv ); @@ -484,7 +567,7 @@ OUString PackageManagerImpl::detectMediaType( try { Reference xPackage( m_xRegistry->bindPackage( - url, OUString(), ucbContent.getCommandEnvironment() ) ); + url, OUString(), false, ucbContent.getCommandEnvironment() ) ); const Reference xPackageType( xPackage->getPackageType() ); OSL_ASSERT( xPackageType.is() ); @@ -564,10 +647,18 @@ OUString PackageManagerImpl::insertToActivationLayer( title, NameClash::OVERWRITE )) throw RuntimeException( OUSTR("UCB transferContent() failed!"), 0 ); + // write to DB: + //bundled extensions should only be added by the synchronizeAddedExtensions + //functions. Moreover, there is no "temporary folder" for bundled extensions. + OSL_ASSERT(!m_context.equals(OUSTR("bundled"))); + DescriptionInfoset info = + dp_misc::getDescriptionInfoset( + appendURLSegement(destFolderContent.getURL(), title)); dbData->temporaryName = tempEntry; dbData->fileName = title; dbData->mediaType = mediaType; + dbData->version = info.getVersion(); return destFolder; } @@ -582,79 +673,35 @@ void PackageManagerImpl::insertToActivationLayerDB( /* The function returns true if there is an extension with the same id already installed which needs to be uninstalled, before the new extension can be installed. */ -bool PackageManagerImpl::checkUpdate( - Reference const & package, - Reference const & origCmdEnv, - Reference const & wrappedCmdEnv ) +bool PackageManagerImpl::isInstalled( + Reference const & package) { OUString id(dp_misc::getIdentifier(package)); OUString fn(package->getName()); - bool removeExisting = false; + bool bInstalled = false; if (m_activePackagesDB->has( id, fn )) { - // package already deployed, interact --force: - Any request( - (deployment::VersionException( - getResourceString( RID_STR_PACKAGE_ALREADY_ADDED ) + id, - static_cast(this), package, - getDeployedPackage_( id, fn, origCmdEnv ) ) ) ); - bool replace = false, abort = false; - if (! interactContinuation( - request, task::XInteractionApprove::static_type(), - wrappedCmdEnv, &replace, &abort )) { - OSL_ASSERT( !replace && !abort ); - throw deployment::DeploymentException( - getResourceString(RID_STR_ERROR_WHILE_ADDING) + id, - static_cast(this), request ); - } - if (abort || !replace) - throw CommandFailedException( - getResourceString(RID_STR_PACKAGE_ALREADY_ADDED) + id, - static_cast(this), request ); - - // remove clashing package before registering new version: - removeExisting = true; + bInstalled = true; } - return removeExisting; + return bInstalled; } + +// XPackageManager //______________________________________________________________________________ -// Notify the user when a new extension is to be installed. This is only the case -//when unopkg gui extension1 is used (used by system integration (double click on .oxt -// file etc.)). In case there is already this extension then the function returns -//true. -//ToDo: Function always returns true or throws an exception -bool PackageManagerImpl::checkInstall( - Reference const & package, - Reference const & cmdEnv) +Reference PackageManagerImpl::importExtension( + Reference const & extension, + Reference const & xAbortChannel, + Reference const & xCmdEnv_ ) + throw (deployment::DeploymentException, CommandFailedException, + CommandAbortedException, lang::IllegalArgumentException, + RuntimeException) { - OUString id(dp_misc::getIdentifier(package)); - if ( ! m_activePackagesDB->has( id, package->getName() )) - { - Any request( - deployment::InstallException( - OUSTR("Extension ") + id + OUSTR(" is about to be installed."), - static_cast(this), package)); - bool approve = false, abort = false; - if (! interactContinuation( - request, task::XInteractionApprove::static_type(), - cmdEnv, &approve, &abort )) - { - OSL_ASSERT( !approve && !abort ); - throw deployment::DeploymentException( - getResourceString(RID_STR_ERROR_WHILE_ADDING) + id, - static_cast(this), request ); - } - if (abort || !approve) - throw CommandFailedException( - getResourceString(RID_STR_ERROR_WHILE_ADDING) + id, - static_cast(this), request ); - - } - return true; + return addPackage(extension->getURL(), OUString(), xAbortChannel, xCmdEnv_); } -// XPackageManager -//______________________________________________________________________________ +/* The function adds an extension but does not register it!!! + It may not do any user interaction. This is done in XExtensionManager::addExtension +*/ Reference PackageManagerImpl::addPackage( OUString const & url, OUString const & mediaType_, Reference const & xAbortChannel, @@ -733,80 +780,39 @@ Reference PackageManagerImpl::addPackage( // bind activation package: - //Because every extension will be unpacked in a folder, which was created with a unique name - //we will always have two different XPackage objects, even if the second extension is the same. + //Because every shared/user extension will be unpacked in a folder, + //which was created with a unique name we will always have two different + //XPackage objects, even if the second extension is the same. //Therefore bindPackage does not need a guard here. xPackage = m_xRegistry->bindPackage( - makeURL( destFolder, title_enc ), mediaType, xCmdEnv ); + makeURL( destFolder, title_enc ), mediaType, false, xCmdEnv ); OSL_ASSERT( xPackage.is() ); if (xPackage.is()) { bool install = false; - OUString id; - try { - id = dp_misc::getIdentifier( xPackage ); - //checkInstall throws an exception if the user denies the installation - checkInstall(xPackage, xCmdEnv); - //checkUpdate throws an exception if the user cancels the interaction. - //For example, he may be asked if he wants to replace the older version - //with the new version. - //checkUpdates must be called before checkPrerequisites - bool bAlreadyInstalled = checkUpdate( - xPackage, xCmdEnv_, xCmdEnv ); - - if (xPackage->checkPrerequisites(xAbortChannel, xCmdEnv, bAlreadyInstalled, m_context)) + OUString const id = dp_misc::getIdentifier( xPackage ); + //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)) { - //This guard is used to prevent that an extension is installed twice. Do not use it in other - //functions. - //Imagine addPackage is called two times by different threads for the same extension quickly - //after each other. - //The second call would calculate "bAlreadyInstalled = false" if the first thread has not yet reached - //insertToActivationLayerDB. - ::osl::MutexGuard g(m_addMutex); - - //Holds the database data of the old extension, in case we need to roll back. - ActivePackages::Data oldDbData; - if (bAlreadyInstalled) - { - // Remove extension which is already installed. It is not removed from disk, only - // the different contents are being unregisterd. We remember the databas information - // in case we need to roll back this operation. - // When the user canceled the operation (CommandAbortedException) than the package is still - // fully functional. - // Do not guard the complete function with the getMutex - removePackage_(id, xPackage->getName(), xAbortChannel, - xCmdEnv, & oldDbData); - } - install = true; - const ::osl::MutexGuard guard( getMutex() ); - try - { - //throws CommandAbortedException if the user cancelled the installation. - xPackage->registerPackage(xAbortChannel, xCmdEnv); - } - catch(CommandAbortedException & ) - { //ToDo: Interaction so that the gui can display an appropriate string. - //See also removePackage_ - //User aborted installation, restore the previous situation. - //Use a private AbortChannel so the user cannot interrupt. - xPackage->revokePackage(new AbortChannel(), xCmdEnv); - if (bAlreadyInstalled) - { - OUString instFolder = makeURL( m_activePackages, oldDbData.temporaryName) - + OUSTR("_"); - Reference xOldPgk = m_xRegistry->bindPackage( - makeURL( instFolder, oldDbData.fileName ), oldDbData.mediaType, xCmdEnv ); - xOldPgk->registerPackage(new AbortChannel(), xCmdEnv); - insertToActivationLayerDB(dp_misc::getIdentifier( xOldPgk ), oldDbData); - } - throw; - } - //access to the database must be guarded. See removePackage_ - insertToActivationLayerDB(id, dbData); + //Do not guard the complete function with the getMutex + removePackage(id, xPackage->getName(), xAbortChannel, + xCmdEnv); } + install = true; + const ::osl::MutexGuard guard( getMutex() ); + //access to the database must be guarded. See removePackage_ + insertToActivationLayerDB(id, dbData); + } catch (...) { @@ -817,6 +823,7 @@ Reference PackageManagerImpl::addPackage( { deletePackageFromCache( xPackage, destFolder ); } + //ToDo: We should notify only if the extension is registered fireModified(); } return xPackage; @@ -860,42 +867,10 @@ void PackageManagerImpl::deletePackageFromCache( false /* no throw: ignore errors */ ); } -//______________________________________________________________________________ -void PackageManagerImpl::removePackage_( - OUString const & id, OUString const & fileName, - Reference const & xAbortChannel, - Reference const & xCmdEnv, - ActivePackages::Data * out_dbData) -{ - Reference xPackage; - { - try { - const ::osl::MutexGuard guard(getMutex()); - xPackage = getDeployedPackage_(id, fileName, xCmdEnv ); - m_activePackagesDB->get(out_dbData, id, fileName); - beans::Optional< beans::Ambiguous > option( - xPackage->isRegistered( Reference(), - xCmdEnv ) ); - if (!option.IsPresent || option.Value.IsAmbiguous || option.Value.Value) - xPackage->revokePackage( xAbortChannel, xCmdEnv ); - m_activePackagesDB->erase( id, fileName ); // to be removed upon next start - } - catch (CommandAbortedException &) - { - //ToDo: interaction, so that gui can show an appropriate string - //reregister the package - //Create our own XAbortChannel, so the user cannot interrupt the registration. - xPackage->registerPackage(new AbortChannel(), xCmdEnv); - throw; - } - } - try_dispose( xPackage ); -} - //______________________________________________________________________________ void PackageManagerImpl::removePackage( OUString const & id, ::rtl::OUString const & fileName, - Reference const & xAbortChannel, + Reference const & /*xAbortChannel*/, Reference const & xCmdEnv_ ) throw (deployment::DeploymentException, CommandFailedException, CommandAbortedException, lang::IllegalArgumentException, @@ -920,7 +895,39 @@ void PackageManagerImpl::removePackage( xCmdEnv.set( xCmdEnv_ ); try { - removePackage_( id, fileName, xAbortChannel, xCmdEnv, NULL); + Reference xPackage; + { + const ::osl::MutexGuard guard(getMutex()); + //Check if this extension exist and throw an IllegalArgumentException + //if it does not + xPackage = getDeployedPackage_(id, fileName, xCmdEnv ); + //Because the extension is only removed the next time the extension + //manager runs after restarting OOo, we need to indicate that a + //shared extension was "deleted". When a user starts OOo, then it + //will check if something changed in the shared repository. Based on + //the flag file it will then recognize, that the extension was + //deleted and can then update the extnesion database of the shared + //extensions in the user installation. + if (m_context.equals(OUSTR("shared"))) + { + ActivePackages::Data val; + m_activePackagesDB->get( & val, id, fileName); + OSL_ASSERT(val.temporaryName.getLength()); + OUString url(makeURL(m_activePackages_expanded, + val.temporaryName + OUSTR("removed"))); + ::ucbhelper::Content contentRemoved(url, xCmdEnv ); + ::rtl::OString stamp("1"); + Reference xData( + ::xmlscript::createInputStream( + ::rtl::ByteSequence( + reinterpret_cast(stamp.getStr()), + stamp.getLength() ) ) ); + contentRemoved.writeStream( xData, true /* replace existing */ ); + } + m_activePackagesDB->erase( id, fileName ); // to be removed upon next start + } + try_dispose( xPackage ); + fireModified(); } catch (RuntimeException &) { @@ -955,10 +962,16 @@ OUString PackageManagerImpl::getDeployPath( ActivePackages::Data const & data ) { ::rtl::OUStringBuffer buf; buf.append( data.temporaryName ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_/") ); - buf.append( ::rtl::Uri::encode( data.fileName, rtl_UriCharClassPchar, + //The bundled extensions are not contained in an additional folder + //with a unique name. data.temporaryName contains already the + //UTF8 encoded folder name. See PackageManagerImpl::synchronize + if (!m_context.equals(OUSTR("bundled"))) + { + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_/") ); + buf.append( ::rtl::Uri::encode( data.fileName, rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ) ); + } return makeURL( m_activePackages, buf.makeStringAndClear() ); } @@ -998,7 +1011,7 @@ Reference PackageManagerImpl::getDeployedPackage_( } } return m_xRegistry->bindPackage( - getDeployPath( data ), data.mediaType, xCmdEnv ); + getDeployPath( data ), data.mediaType, false, xCmdEnv ); } //______________________________________________________________________________ @@ -1124,8 +1137,12 @@ PackageManagerImpl::getDeployedPackages( } //______________________________________________________________________________ + + +//ToDo: the function must not call registerPackage, do this in +//XExtensionManager.reinstallDeployedExtensions void PackageManagerImpl::reinstallDeployedPackages( - Reference const & xAbortChannel, + Reference const & /*xAbortChannel*/, Reference const & xCmdEnv_ ) throw (deployment::DeploymentException, CommandFailedException, CommandAbortedException, @@ -1167,12 +1184,7 @@ void PackageManagerImpl::reinstallDeployedPackages( if (xUpdatable.is()) xUpdatable->update(); - // reregister all: - const ::osl::MutexGuard guard( getMutex() ); - const Sequence< Reference > packages( - getDeployedPackages_( xCmdEnv ) ); - for ( sal_Int32 pos = 0; pos < packages.getLength(); ++pos ) - packages[ pos ]->registerPackage( xAbortChannel, xCmdEnv ); + //registering is done by the ExtensionManager service. } catch (RuntimeException &) { throw; @@ -1205,6 +1217,242 @@ void PackageManagerImpl::reinstallDeployedPackages( { return m_readOnly; } +void PackageManagerImpl::synchronizeRemovedExtensions( + Sequence > & out_removedExtensions, + Reference const & /*xAbortChannel*/, + Reference const & xCmdEnv) +{ + + //find all which are in the extension data base but which + //are removed already. + OSL_ASSERT(!m_context.equals(OUSTR("user"))); + ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); + + //Iterate over the contents of the extension folder and gather the + //temp file names (shared) or the folder names of the bundled extension. + ::ucbhelper::ResultSetInclude includeType = ::ucbhelper::INCLUDE_DOCUMENTS_ONLY; + if (m_context.equals(OUSTR("bundled"))) + includeType = ::ucbhelper::INCLUDE_FOLDERS_ONLY; + ::ucbhelper::Content tempFolder( + m_activePackages_expanded, xCmdEnv ); + Reference xResultSet( + tempFolder.createCursor( + Sequence( &StrTitle::get(), 1 ), includeType) ); + // get all temp directories: + ::std::vector tempEntries; + while (xResultSet->next()) { + OUString title( + Reference( + xResultSet, UNO_QUERY_THROW )->getString( + 1 /* Title */ ) ); + //also add the xxx.tmpremoved files for remove shared extensions + //this does not matter + tempEntries.push_back( ::rtl::Uri::encode( + title, rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ) ); + } + + typedef ActivePackages::Entries::const_iterator ITActive; + bool bShared = m_context.equals(OUSTR("shared")); + ::std::vector > removedExtensions; + for (ITActive i = id2temp.begin(); i != id2temp.end(); i++) + { + //Get the URL to the extensions folder, first make the url for the + //shared repository including the temporary name +// OUString url(m_activePackages_expanded + OUSTR("/") +// + i->second.temporaryName); +// if (bShared) +// url = appendURLSegement(m_activePackages_expanded + OUSTR("/") +// + i->second.temporaryName + OUSTR("_"), +// i->second.fileName); + OUString url = makeURL(m_activePackages, i->second.temporaryName); + if (bShared) + url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName); + + const MatchExtension match(i->second); + bool bRemoved = false; + if (::std::find_if(tempEntries.begin(), tempEntries.end(), match) == + tempEntries.end()) + { + //The the URL from the data base entry does not exist anymore. That is the + //folder was removed. + bRemoved = true; + } + else + { + //The folder is in the extension database, but it can still be deleted. + //look for the xxx.tmpremoved file + if (bShared) + { + ::ucbhelper::Content contentRemoved; + if (create_ucb_content( + &contentRemoved, + m_activePackages_expanded + OUSTR("/") + + i->second.temporaryName + OUSTR("removed"), + Reference(), false)) + { + bRemoved = true; + } + } + if (!bRemoved) + { + //There may be another extensions at the same place + dp_misc::DescriptionInfoset infoset = + dp_misc::getDescriptionInfoset(url); + OSL_ENSURE(infoset.hasDescription(), + "Extension Manager: bundled and shared extensions " + "must have an identifer and a version"); + if ( ! i->first.equals(*(infoset.getIdentifier())) + || ! i->second.version.equals(infoset.getVersion())) + { + bRemoved = true; + } + } + } + if (bRemoved) + { + Reference xPackage = m_xRegistry->bindPackage( + url, i->second.mediaType, true, xCmdEnv ); + OSL_ASSERT(xPackage.is()); //Even if the files are removed, we must get the object. + removedExtensions.push_back(xPackage); + } + } + out_removedExtensions = ::comphelper::containerToSequence(removedExtensions); +} + +void PackageManagerImpl::synchronizeAddedExtensions( + Sequence > & out_addedExtensions, + Reference const & xAbortChannel, + Reference const & xCmdEnv) +{ + // clean up activation layer, scan for zombie temp dirs: + ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); + + ::ucbhelper::Content tempFolder( + m_activePackages_expanded, xCmdEnv ); + Reference xResultSet( + tempFolder.createCursor( + Sequence( &StrTitle::get(), 1 ), + ::ucbhelper::INCLUDE_FOLDERS_ONLY ) ); + + + ::std::vector > addedExtensions; + while (xResultSet->next()) + { + OUString title( + Reference( + xResultSet, UNO_QUERY_THROW )->getString( + 1 /* Title */ ) ); + //The temporary folders of user and shared have an '_' at then end. + //But the name in ActivePackages.temporaryName is saved without. + OUString title2 = title; + bool bNotBundled = !m_context.equals(OUSTR("bundled")); + if (bNotBundled) + { + OSL_ASSERT(title2[title2.getLength() -1] == '_'); + title2 = title2.copy(0, title2.getLength() -1); + } + OUString titleEncoded = ::rtl::Uri::encode( + title2, rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8); + + const MatchTempDir match(titleEncoded); + if (::std::find_if( id2temp.begin(), id2temp.end(), match ) == + id2temp.end()) + { + + // The folder was not found in the data base, so it must be + // an added extension + OUString url(m_activePackages_expanded + OUSTR("/") + titleEncoded); + OUString sExtFolder; + if (bNotBundled) //that is, shared + { + //Check if the extension was not "deleted" already which is indicated + //by a xxx.tmpremoved file + ::ucbhelper::Content contentRemoved; + if (create_ucb_content(&contentRemoved, url + OUSTR("removed"), + Reference(), false)) + continue; + sExtFolder = getExtensionFolder( + m_activePackages_expanded + + OUString(OUSTR("/")) + titleEncoded + OUSTR("_"), xCmdEnv); + url = appendURLSegement(m_activePackages_expanded, title); + url = appendURLSegement(url, sExtFolder); + } + Reference xPackage = m_xRegistry->bindPackage( + url, OUString(), false, xCmdEnv ); + if (xPackage.is()) + { + try + { + //ToDo: We need to prevent that removed shared extensions are + //added again. This can happen if there is still the folder of the + //extension. However, there is the "removed" flag file which indicates + //that the extension was removed. + //Prepare the database entry + ActivePackages::Data dbData; + //There is no temporary folder for bundled extensions. It is therefore + //an empty string. + dbData.temporaryName = titleEncoded; + if (bNotBundled) + dbData.fileName = sExtFolder; + else + dbData.fileName = title; + dbData.mediaType = xPackage->getPackageType()->getMediaType(); + dbData.version = xPackage->getVersion(); + OSL_ENSURE(dbData.version.getLength() > 0, + "Extension Manager: bundled and shared extensions must have " + "an identifier and a version"); + + OUString id = dp_misc::getIdentifier( xPackage ); + sal_Bool bAlreadyInstalled = sal_False; + if (xPackage->checkPrerequisites( + xAbortChannel, xCmdEnv, bAlreadyInstalled, m_context)) + { + const ::osl::MutexGuard guard( getMutex() ); + //access to the database must be guarded. See removePackage_ + insertToActivationLayerDB(id, dbData); + } + else + { + //ToDo: Remember that this failed. For example, the user + //could have declined the license. Then the next time the + //extension folder is investigated we do not want to + //try to install the extension again. + } + addedExtensions.push_back(xPackage); + } + catch (...) + { + } + } + } + } + out_addedExtensions = ::comphelper::containerToSequence(addedExtensions); +} + +void PackageManagerImpl::synchronize( + Sequence > & out_addedExtensions, + Sequence > & out_removedExtensions, + Reference const & xAbortChannel, + Reference const & xCmdEnv) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::uno::RuntimeException) +{ + + check(); + if (m_context.equals(OUSTR("user"))) + return; + synchronizeRemovedExtensions( + out_removedExtensions, xAbortChannel, xCmdEnv); + synchronizeAddedExtensions( + out_addedExtensions, xAbortChannel, xCmdEnv); +} + //############################################################################## diff --git a/desktop/source/deployment/manager/dp_manager.h b/desktop/source/deployment/manager/dp_manager.h index ffa7252d7883..1249fe7e29d4 100644 --- a/desktop/source/deployment/manager/dp_manager.h +++ b/desktop/source/deployment/manager/dp_manager.h @@ -53,6 +53,8 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper { css::uno::Reference m_xComponentContext; ::rtl::OUString m_context; + ::rtl::OUString m_registrationData; + ::rtl::OUString m_registrationData_expanded; ::rtl::OUString m_registryCache; bool m_readOnly; @@ -83,16 +85,20 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper css::uno::Reference const & xPackage, ::rtl::OUString const & destFolder ); - bool checkUpdate( - css::uno::Reference const & package, - css::uno::Reference const & origCmdEnv, - css::uno::Reference const & - wrappedCmdEnv ); + bool isInstalled( + css::uno::Reference const & package); - bool checkInstall( - css::uno::Reference const & package, - css::uno::Reference const & cmdEnv); + void synchronizeRemovedExtensions( + css::uno::Sequence > & + out_removedExtensions, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); + void synchronizeAddedExtensions( + css::uno::Sequence > & + out_AddedExtensions, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv); class CmdEnvWrapperImpl : public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment, @@ -135,7 +141,7 @@ protected: : t_pm_helper( getMutex() ), m_xComponentContext( xComponentContext ), m_context( context ), - m_readOnly( false ) + m_readOnly( true ) {} public: @@ -180,17 +186,15 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); - /* Unregisters the package but does not remove it from disk. - When the operation is canceled by the user, a CommandAbortedException - is thrown. Then the package is still fully functional. - @param out_oldData - can be NULL - */ - void removePackage_( - ::rtl::OUString const & id, ::rtl::OUString const & fileName, + virtual css::uno::Reference SAL_CALL importExtension( + css::uno::Reference const & extension, css::uno::Reference const & xAbortChannel, - css::uno::Reference const & xCmdEnv, - ActivePackages::Data * out_oldData); + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); virtual void SAL_CALL removePackage( ::rtl::OUString const & id, ::rtl::OUString const & fileName, @@ -242,6 +246,17 @@ public: virtual ::sal_Bool SAL_CALL isReadOnly( ) throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL synchronize( + css::uno::Sequence > & out_xAddedExtensions, + css::uno::Sequence > & out_xRemovedExtensions, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::uno::RuntimeException); + }; //______________________________________________________________________________ diff --git a/desktop/source/deployment/manager/dp_managerfac.cxx b/desktop/source/deployment/manager/dp_managerfac.cxx index d4c9df1d57af..f6fde6b07d60 100644 --- a/desktop/source/deployment/manager/dp_managerfac.cxx +++ b/desktop/source/deployment/manager/dp_managerfac.cxx @@ -53,6 +53,7 @@ class PackageManagerFactoryImpl : private MutexHolder, public t_pmfac_helper Reference m_xUserMgr; Reference m_xSharedMgr; + Reference m_xBundledMgr; typedef ::std::hash_map< OUString, WeakReference, ::rtl::OUStringHash > t_string2weakref; @@ -141,6 +142,7 @@ void PackageManagerFactoryImpl::disposing() // the below are already disposed: m_xUserMgr.clear(); m_xSharedMgr.clear(); + m_xBundledMgr.clear(); } // XPackageManagerFactory @@ -172,6 +174,8 @@ PackageManagerFactoryImpl::getPackageManager( OUString const & context ) m_xUserMgr = xRet; else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") )) m_xSharedMgr = xRet; + else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") )) + m_xBundledMgr = xRet; } else { diff --git a/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx b/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx new file mode 100644 index 000000000000..3a4a6f1d2b72 --- /dev/null +++ b/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx @@ -0,0 +1,166 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "com/sun/star/deployment/VersionException.hpp" +#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp" +#include "com/sun/star/deployment/LicenseException.hpp" +#include "com/sun/star/deployment/InstallException.hpp" +#include "com/sun/star/task/XInteractionApprove.hpp" +#include "com/sun/star/task/XInteractionAbort.hpp" +#include "com/sun/star/ucb/XCommandEnvironment.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "dp_tmprepocmdenv.hxx" + +namespace deployment = com::sun::star::deployment; +namespace lang = com::sun::star::lang; +namespace task = com::sun::star::task; +namespace ucb = com::sun::star::ucb; +namespace uno = com::sun::star::uno; +namespace css = com::sun::star; + +#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) + +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +namespace dp_manager { + +TmpRepositoryCommandEnv::TmpRepositoryCommandEnv() +{ +} + +TmpRepositoryCommandEnv::TmpRepositoryCommandEnv( + Reference< css::task::XInteractionHandler> const & handler) + : m_forwardHandler(handler) +{ +} + +TmpRepositoryCommandEnv::~TmpRepositoryCommandEnv() +{ +} +// XCommandEnvironment +//______________________________________________________________________________ +Reference TmpRepositoryCommandEnv::getInteractionHandler() +throw (uno::RuntimeException) +{ + return this; +} + +//______________________________________________________________________________ +Reference TmpRepositoryCommandEnv::getProgressHandler() +throw (uno::RuntimeException) +{ + return this; +} + +// XInteractionHandler +void TmpRepositoryCommandEnv::handle( + Reference< task::XInteractionRequest> const & xRequest ) + throw (uno::RuntimeException) +{ + uno::Any request( xRequest->getRequest() ); + OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); + + deployment::VersionException verExc; + deployment::LicenseException licExc; + deployment::InstallException instExc; + deployment::LicenseIndividualAgreementException licAgreementExc; + + + bool approve = false; + bool abort = false; + + if ((request >>= verExc) + || (request >>= licExc) + || (request >>= instExc) + || (request >>= licAgreementExc)) + { + approve = true; + } + + if (approve == false && abort == false) + { + if (m_forwardHandler.is()) + m_forwardHandler->handle(xRequest); + else + approve = true; + } + else + { + // select: + uno::Sequence< Reference< task::XInteractionContinuation > > conts( + xRequest->getContinuations() ); + Reference< task::XInteractionContinuation > const * pConts = + conts.getConstArray(); + sal_Int32 len = conts.getLength(); + for ( sal_Int32 pos = 0; pos < len; ++pos ) + { + if (approve) { + Reference< task::XInteractionApprove > xInteractionApprove( + pConts[ pos ], uno::UNO_QUERY ); + if (xInteractionApprove.is()) { + xInteractionApprove->select(); + // don't query again for ongoing continuations: + approve = false; + } + } + else if (abort) { + Reference< task::XInteractionAbort > xInteractionAbort( + pConts[ pos ], uno::UNO_QUERY ); + if (xInteractionAbort.is()) { + xInteractionAbort->select(); + // don't query again for ongoing continuations: + abort = false; + } + } + } + } +} + +// XProgressHandler +void TmpRepositoryCommandEnv::push( uno::Any const & /*Status*/ ) +throw (uno::RuntimeException) +{ +} + + +void TmpRepositoryCommandEnv::update( uno::Any const & /*Status */) +throw (uno::RuntimeException) +{ +} + +void TmpRepositoryCommandEnv::pop() throw (uno::RuntimeException) +{ +} + + +} // namespace dp_manager + + diff --git a/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx b/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx new file mode 100644 index 000000000000..22111bc1e081 --- /dev/null +++ b/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_TMPREPOSITORYCOMMANDENVIRONMENT_HXX +#define INCLUDED_DP_TMPREPOSITORYCOMMANDENVIRONMENT_HXX + + +#include "cppuhelper/compbase3.hxx" +//#include "cppuhelper/implbase2.hxx" +#include "ucbhelper/content.hxx" + + + +namespace css = ::com::sun::star; + +namespace dp_manager { + +/** + This command environment is to be used when an extension is temporarily + stored in the "tmp" repository. It prevents all kind of user interaction. + */ +class TmpRepositoryCommandEnv + : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment, + css::task::XInteractionHandler, + css::ucb::XProgressHandler > +{ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler; +public: + virtual ~TmpRepositoryCommandEnv(); + TmpRepositoryCommandEnv(); + TmpRepositoryCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler); + + // XCommandEnvironment + virtual css::uno::Reference SAL_CALL + getInteractionHandler() throw (css::uno::RuntimeException); + virtual css::uno::Reference + SAL_CALL getProgressHandler() throw (css::uno::RuntimeException); + + // XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); + + // XProgressHandler + virtual void SAL_CALL push( css::uno::Any const & Status ) + throw (css::uno::RuntimeException); + virtual void SAL_CALL update( css::uno::Any const & Status ) + throw (css::uno::RuntimeException); + virtual void SAL_CALL pop() throw (css::uno::RuntimeException); +}; + +} + + + + +#endif + diff --git a/desktop/source/deployment/manager/makefile.mk b/desktop/source/deployment/manager/makefile.mk index a9ff47881fc3..cb99325bde52 100644 --- a/desktop/source/deployment/manager/makefile.mk +++ b/desktop/source/deployment/manager/makefile.mk @@ -45,7 +45,9 @@ SLOFILES = \ $(SLO)$/dp_activepackages.obj \ $(SLO)$/dp_manager.obj \ $(SLO)$/dp_managerfac.obj \ - $(SLO)$/dp_informationprovider.obj + $(SLO)$/dp_informationprovider.obj \ + $(SLO)$/dp_extensionmanager.obj \ + $(SLO)$/dp_tmprepocmdenv.obj .INCLUDE : ..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx index 28f45918e9e2..d97b400f4609 100644 --- a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx +++ b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx @@ -35,6 +35,7 @@ #include "comphelper/sequence.hxx" #include "comphelper/makesequence.hxx" +#include "comphelper/processfactory.hxx" #include "boost/optional.hpp" #include "com/sun/star/beans/Optional.hpp" #include "com/sun/star/lang/XMultiComponentFactory.hpp" @@ -47,17 +48,23 @@ #include "com/sun/star/xml/dom/DOMException.hpp" #include "com/sun/star/xml/dom/XNode.hpp" #include "com/sun/star/xml/dom/XNodeList.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" #include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp" #include "cppuhelper/implbase1.hxx" +#include "cppuhelper/implbase2.hxx" #include "cppuhelper/weak.hxx" +#include "cppuhelper/exc_hlp.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" - +#include "ucbhelper/content.hxx" namespace { namespace css = ::com::sun::star; +using css::uno::Reference; +using ::rtl::OUString; class EmptyNodeList: public ::cppu::WeakImplHelper1< css::xml::dom::XNodeList > { @@ -110,10 +117,251 @@ css::uno::Reference< css::xml::dom::XNode > EmptyNodeList::item(::sal_Int32) } } +/**The class uses the UCB to access the description.xml file in an + extension. The UCB must have been initialized already. It also + requires that the extension has already be unzipped to a particular + location. + */ +class ExtensionDescription +{ +public: + /**throws an exception if the description.xml is not + available, cannot be read, does not contain the expected data, + or any other error occured. Therefore it shoult only be used with + new extensions. + + Throws com::sun::star::uno::RuntimeException, + com::sun::star::deployment::DeploymentException, + dp_registry::backend::bundle::NoDescriptionException. + */ + ExtensionDescription( + const css::uno::Reference& xContext, + const ::rtl::OUString& installDir, + const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv); + + ~ExtensionDescription(); + + css::uno::Reference getRootElement() const + { + return m_xRoot; + } + + ::rtl::OUString getExtensionRootUrl() const + { + return m_sExtensionRootUrl; + } + + +private: + css::uno::Reference m_xRoot; + ::rtl::OUString m_sExtensionRootUrl; +}; + +class NoDescriptionException +{ +}; + +class FileDoesNotExistFilter + : public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment, + css::task::XInteractionHandler > + +{ + //css::uno::Reference m_xHandler; + bool m_bExist; + css::uno::Reference< css::ucb::XCommandEnvironment > m_xCommandEnv; + +public: + virtual ~FileDoesNotExistFilter(); + FileDoesNotExistFilter( + const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv); + + bool exist(); + // XCommandEnvironment + virtual css::uno::Reference SAL_CALL + getInteractionHandler() throw (css::uno::RuntimeException); + virtual css::uno::Reference + SAL_CALL getProgressHandler() throw (css::uno::RuntimeException); + + // XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); +}; + +ExtensionDescription::ExtensionDescription( + const Reference& xContext, + const OUString& installDir, + const Reference< css::ucb::XCommandEnvironment >& xCmdEnv) +{ + try { + m_sExtensionRootUrl = installDir; + //may throw ::com::sun::star::ucb::ContentCreationException + //If there is no description.xml then ucb will start an interaction which + //brings up a dialog.We want to prevent this. Therefore we wrap the xCmdEnv + //and filter the respective exception out. + OUString sDescriptionUri(installDir + OUSTR("/description.xml")); + Reference xFilter = + static_cast( + new FileDoesNotExistFilter(xCmdEnv)); + ::ucbhelper::Content descContent(sDescriptionUri, xFilter); + + //throws an com::sun::star::uno::Exception if the file is not available + Reference xIn; + try + { //throws com.sun.star.ucb.InteractiveAugmentedIOException + xIn = descContent.openStream(); + } + catch (css::uno::Exception& ) + { + if ( ! static_cast(xFilter.get())->exist()) + throw NoDescriptionException(); + throw; + } + if (!xIn.is()) + { + throw css::uno::Exception( + OUSTR("Could not get XInputStream for description.xml of extension ") + + sDescriptionUri, 0); + } + + //get root node of description.xml + Reference xDocBuilder( + xContext->getServiceManager()->createInstanceWithContext( + OUSTR("com.sun.star.xml.dom.DocumentBuilder"), + xContext ), css::uno::UNO_QUERY); + if (!xDocBuilder.is()) + throw css::uno::Exception(OUSTR(" Could not create service com.sun.star.xml.dom.DocumentBuilder"), 0); + + if (xDocBuilder->isNamespaceAware() == sal_False) + { + throw css::uno::Exception( + OUSTR("Service com.sun.star.xml.dom.DocumentBuilder is not namespace aware."), 0); + } + + Reference xDoc = xDocBuilder->parse(xIn); + if (!xDoc.is()) + { + throw css::uno::Exception(sDescriptionUri + OUSTR(" contains data which cannot be parsed. "), 0); + } + + //check for proper root element and namespace + Reference xRoot = xDoc->getDocumentElement(); + if (!xRoot.is()) + { + throw css::uno::Exception( + sDescriptionUri + OUSTR(" contains no root element."), 0); + } + + if ( ! xRoot->getTagName().equals(OUSTR("description"))) + { + throw css::uno::Exception( + sDescriptionUri + OUSTR(" does not contain the root element ."), 0); + } + + m_xRoot = Reference( + xRoot, css::uno::UNO_QUERY_THROW); + OUString nsDescription = xRoot->getNamespaceURI(); + + //check if this namespace is supported + if ( ! nsDescription.equals(OUSTR("http://openoffice.org/extensions/description/2006"))) + { + throw css::uno::Exception(sDescriptionUri + OUSTR(" contains a root element with an unsupported namespace. "), 0); + } + } catch (css::uno::RuntimeException &) { + throw; + } catch (css::deployment::DeploymentException &) { + throw; + } catch (css::uno::Exception & e) { + css::uno::Any a(cppu::getCaughtException()); + throw css::deployment::DeploymentException( + e.Message, Reference< css::uno::XInterface >(), a); + } +} + +ExtensionDescription::~ExtensionDescription() +{ +} + +//====================================================================== +FileDoesNotExistFilter::FileDoesNotExistFilter( + const Reference< css::ucb::XCommandEnvironment >& xCmdEnv): + m_bExist(true), m_xCommandEnv(xCmdEnv) +{} + +FileDoesNotExistFilter::~FileDoesNotExistFilter() +{ +}; + +bool FileDoesNotExistFilter::exist() +{ + return m_bExist; +} + // XCommandEnvironment +Reference + FileDoesNotExistFilter::getInteractionHandler() throw (css::uno::RuntimeException) +{ + return static_cast(this); +} + +Reference + FileDoesNotExistFilter::getProgressHandler() throw (css::uno::RuntimeException) +{ + return m_xCommandEnv.is() + ? m_xCommandEnv->getProgressHandler() + : Reference(); +} + +// XInteractionHandler +//If the interaction was caused by a non-existing file which is specified in the ctor +//of FileDoesNotExistFilter, then we do nothing +void FileDoesNotExistFilter::handle( + Reference const & xRequest ) + throw (css::uno::RuntimeException) +{ + css::uno::Any request( xRequest->getRequest() ); + + css::ucb::InteractiveAugmentedIOException ioexc; + if ((request>>= ioexc) && ioexc.Code == css::ucb::IOErrorCode_NOT_EXISTING ) + { + m_bExist = false; + return; + } + Reference xInteraction; + if (m_xCommandEnv.is()) { + xInteraction = m_xCommandEnv->getInteractionHandler(); + } + if (xInteraction.is()) { + xInteraction->handle(xRequest); + } +} + } namespace dp_misc { +DescriptionInfoset getDescriptionInfoset(OUString const & sExtensionFolderURL) +{ + Reference< css::xml::dom::XNode > root; + Reference context = + comphelper_getProcessComponentContext(); + OSL_ASSERT(context.is()); + try { + root = + ExtensionDescription( + context, sExtensionFolderURL, + Reference< css::ucb::XCommandEnvironment >()). + getRootElement(); + } catch (NoDescriptionException &) { + } catch (css::deployment::DeploymentException & e) { + throw css::uno::RuntimeException( + (OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.deployment.DeploymentException: ")) + + e.Message), 0); + } + return DescriptionInfoset(context, root); +} + DescriptionInfoset::DescriptionInfoset( css::uno::Reference< css::uno::XComponentContext > const & context, css::uno::Reference< css::xml::dom::XNode > const & element): diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 3ed2d554b59f..1f1fde7ca7bf 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -197,6 +197,19 @@ OUString makeURL( OUString const & baseURL, OUString const & relPath_ ) return buf.makeStringAndClear(); } +OUString makeURLAppendSysPathSegment( OUString const & baseURL, OUString const & relPath_ ) +{ + OUString segment = relPath_; + OSL_ASSERT(segment.indexOf(static_cast('/')) == -1); + + ::rtl::Uri::encode( + segment, rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8); + return makeURL(baseURL, segment); +} + + + //============================================================================== OUString expandUnoRcTerm( OUString const & term_ ) { @@ -467,4 +480,22 @@ void TRACE(::rtl::OString const & sText) #endif } +bool hasExtensionRepositoryChanged(::rtl::OUString const & repository) +{ + if (repository.equals(OUSTR("shared"))) + { + //get the extensions folder + OUString folder(RTL_CONSTASCII_USTRINGPARAM("BUNDLED_EXTENSIONS")); + ::rtl::Bootstrap::expandMacros(folder); + } + else if (repository.equals(OUSTR("bundled"))) + { + } + else + throw lang::IllegalArgumentException( + OUSTR("Invalid repository name."), 0, 0); + + return false; +} + } diff --git a/desktop/source/deployment/misc/dp_version.cxx b/desktop/source/deployment/misc/dp_version.cxx index 1668ebe4a0b7..c0da0533b54c 100644 --- a/desktop/source/deployment/misc/dp_version.cxx +++ b/desktop/source/deployment/misc/dp_version.cxx @@ -70,11 +70,5 @@ namespace dp_misc { return ::dp_misc::EQUAL; } -::dp_misc::Order comparePackageVersions( - css::uno::Reference< css::deployment::XPackage > const & package1, - css::uno::Reference< css::deployment::XPackage > const & package2) -{ - return compareVersions(package1->getVersion(), package2->getVersion()); -} } diff --git a/desktop/source/deployment/misc/makefile.mk b/desktop/source/deployment/misc/makefile.mk index e191169202fd..9a7f1d62e001 100644 --- a/desktop/source/deployment/misc/makefile.mk +++ b/desktop/source/deployment/misc/makefile.mk @@ -75,7 +75,8 @@ SHL1STDLIBS = \ $(TOOLSLIB) \ $(UCBHELPERLIB) \ $(UNOTOOLSLIB) \ - $(XMLSCRIPTLIB) + $(XMLSCRIPTLIB) \ + $(COMPHELPERLIB) .IF "$(GUI)"=="OS2" SHL1IMPLIB = ideploymentmisc$(DLLPOSTFIX) LIB1TARGET = $(SLB)$/_deplmisc.lib diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx new file mode 100644 index 000000000000..edaf642a2ab1 --- /dev/null +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx @@ -0,0 +1,142 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" + +#include "dp_compbackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + +#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/component-registry/2010" +#define ROOT_ELEMENT_NAME "component-backend-db" + +namespace dp_registry { +namespace backend { +namespace component { + +ComponentBackendDb::ComponentBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +OUString ComponentBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString ComponentBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +{ + try{ + + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + OUString sExpression( + OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + Reference componentElement( + doc->createElement(OUSTR("component"))); + + componentElement->setAttribute(OUSTR("url"), url); + + Reference componentNode( + componentElement, UNO_QUERY_THROW); + + root->appendChild(componentNode); + + Reference javaTypeLibNode( + doc->createElement(OUSTR("java-type-library")), UNO_QUERY_THROW); + + componentNode->appendChild(javaTypeLibNode); + + Reference javaTypeLibValueNode( + doc->createTextNode(OUString::valueOf((sal_Bool) data.javaTypeLibrary)), + UNO_QUERY_THROW); + javaTypeLibNode->appendChild(javaTypeLibValueNode); + + writeSimpleList( + data.implementationNames, + OUSTR("implementation-names"), + OUSTR("name"), + componentNode); + + writeVectorOfPair( + data.singletons, + OUSTR("singletons"), + OUSTR("item"), + OUSTR("key"), + OUSTR("value"), + componentNode); + + save(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +void ComponentBackendDb::removeEntry(::rtl::OUString const & url) +{ + OUString sExpression( + OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + removeElement(sExpression); +} + + + +} // namespace bundle +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx new file mode 100644 index 000000000000..0dde24beed3f --- /dev/null +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_COMPBACKENDDB_HXX +#define INCLUDED_DP_COMPBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "rtl/string.hxx" +#include +#include +#include "dp_backenddb.hxx" + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } + namespace xml { namespace dom { + class XDocument; + class XNode; + }} + namespace xml { namespace xpath { + class XXPathAPI; + }} +}}} + +namespace dp_registry { +namespace backend { +namespace component { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + The format looks like this: + + + + + true + + com.sun.star.comp.extensionoptions.OptionsEventHandler$_OptionsEventHandler + ... + + + + com.sun.star.java.theJavaVirtualMachine + com.sun.star.java.JavaVirtualMachine + + ... + + + + + ... + + */ +class ComponentBackendDb: public dp_registry::backend::BackendDb +{ +public: + struct Data + { + Data(): javaTypeLibrary(false) {}; + + ::std::list< ::rtl::OUString> implementationNames; + /* every singleton has a key and a value + */ + ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString> >singletons; + bool javaTypeLibrary; + }; + +public: + + ComponentBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + + void addEntry(::rtl::OUString const & url, Data const & data); + void removeEntry(::rtl::OUString const & url); + + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getRootElementName(); + + +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index e6781e2a1746..e4e5efff9e81 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -58,7 +58,7 @@ #include #include #include - +#include "dp_compbackenddb.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -74,6 +74,9 @@ namespace { typedef ::std::list t_stringlist; typedef ::std::vector< ::std::pair > t_stringpairvec; +#define IMPLEMENTATION_NAME "com.sun.star.comp.deployment.component.PackageRegistryBackend" +inline OUString makeRcTerm( OUString const & url ); + /** return a vector of bootstrap variables which have been provided as command arguments. */ @@ -153,9 +156,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - OUString const & loader ) + OUString const & loader, bool bUseDb ) : Package( myBackend, url, name, name /* display-name */, - xPackageType ), + xPackageType, bUseDb ), m_loader( loader ), m_registered( REG_UNINIT ) {} @@ -187,9 +190,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - bool jarFile ) + bool jarFile, bool bUseDb ) : Package( myBackend, url, name, name /* display-name */, - xPackageType ), + xPackageType, bUseDb), m_jarFile( jarFile ) {} }; @@ -212,6 +215,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -230,6 +234,12 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend OUString m_commonRDB_RO; OUString m_nativeRDB_RO; + std::auto_ptr m_backendDb; + + void addDataToDb(OUString const & url, ComponentBackendDb::Data const & data); + void deleteDataFromDb(OUString const & url); + + //These rdbs are for writing new service entries. The rdb files are copies //which are created when services are added or removed. Reference m_xCommonRDB; @@ -371,59 +381,59 @@ void BackendImpl::disposing() } } + void BackendImpl::initServiceRdbFiles() { const Reference xCmdEnv; - if (! m_readOnly) + + ::ucbhelper::Content cacheDir( getCachePath(), xCmdEnv ); + ::ucbhelper::Content oldRDB; + // switch common rdb: + if (m_commonRDB_RO.getLength() > 0) { - ::ucbhelper::Content cacheDir( getCachePath(), xCmdEnv ); - ::ucbhelper::Content oldRDB; - // switch common rdb: - if (m_commonRDB_RO.getLength() > 0) - { - create_ucb_content( - &oldRDB, makeURL( getCachePath(), m_commonRDB_RO), - xCmdEnv, false /* no throw */ ); - } - m_commonRDB = m_commonRDB_RO.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM("common.rdb") ) - ? OUSTR("common_.rdb") : OUSTR("common.rdb"); - if (oldRDB.get().is()) - { - if (! cacheDir.transferContent( + create_ucb_content( + &oldRDB, makeURL( getCachePath(), m_commonRDB_RO), + xCmdEnv, false /* no throw */ ); + } + m_commonRDB = m_commonRDB_RO.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("common.rdb") ) + ? OUSTR("common_.rdb") : OUSTR("common.rdb"); + if (oldRDB.get().is()) + { + if (! cacheDir.transferContent( oldRDB, ::ucbhelper::InsertOperation_COPY, m_commonRDB, NameClash::OVERWRITE )) - { - - throw RuntimeException( - OUSTR("UCB transferContent() failed!"), 0 ); - } - oldRDB = ::ucbhelper::Content(); - } - // switch native rdb: - if (m_nativeRDB_RO.getLength() > 0) { - create_ucb_content( - &oldRDB, makeURL(getCachePath(), m_nativeRDB_RO), - xCmdEnv, false /* no throw */ ); + + throw RuntimeException( + OUSTR("UCB transferContent() failed!"), 0 ); } - const OUString plt_rdb( getPlatformString() + OUSTR(".rdb") ); - const OUString plt_rdb_( getPlatformString() + OUSTR("_.rdb") ); - m_nativeRDB = m_nativeRDB_RO.equals( plt_rdb ) ? plt_rdb_ : plt_rdb; - if (oldRDB.get().is()) - { - if (! cacheDir.transferContent( + oldRDB = ::ucbhelper::Content(); + } + // switch native rdb: + if (m_nativeRDB_RO.getLength() > 0) + { + create_ucb_content( + &oldRDB, makeURL(getCachePath(), m_nativeRDB_RO), + xCmdEnv, false /* no throw */ ); + } + const OUString plt_rdb( getPlatformString() + OUSTR(".rdb") ); + const OUString plt_rdb_( getPlatformString() + OUSTR("_.rdb") ); + m_nativeRDB = m_nativeRDB_RO.equals( plt_rdb ) ? plt_rdb_ : plt_rdb; + if (oldRDB.get().is()) + { + if (! cacheDir.transferContent( oldRDB, ::ucbhelper::InsertOperation_COPY, m_nativeRDB, NameClash::OVERWRITE )) - throw RuntimeException( + throw RuntimeException( OUSTR("UCB transferContent() failed!"), 0 ); - } - - // UNO is bootstrapped, flush for next process start: - m_unorc_modified = true; - unorc_flush( Reference() ); } + // UNO is bootstrapped, flush for next process start: + m_unorc_modified = true; + unorc_flush( Reference() ); + + // common rdb for java, native rdb for shared lib components if (m_commonRDB.getLength() > 0) { m_xCommonRDB.set( @@ -433,7 +443,8 @@ void BackendImpl::initServiceRdbFiles() m_xComponentContext ), UNO_QUERY_THROW ); m_xCommonRDB->open( makeURL( expandUnoRcUrl(getCachePath()), m_commonRDB ), - m_readOnly, !m_readOnly ); +// m_readOnly, !m_readOnly ); + false, true); } if (m_nativeRDB.getLength() > 0) { m_xNativeRDB.set( @@ -443,7 +454,8 @@ void BackendImpl::initServiceRdbFiles() m_xComponentContext ), UNO_QUERY_THROW ); m_xNativeRDB->open( makeURL( expandUnoRcUrl(getCachePath()), m_nativeRDB ), - m_readOnly, !m_readOnly ); +// m_readOnly, !m_readOnly ); + false, true); } } @@ -562,9 +574,25 @@ BackendImpl::BackendImpl( initServiceRdbFiles_RO(); + OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml")); + m_backendDb.reset( + new ComponentBackendDb(getComponentContext(), dbFile)); } } +void BackendImpl::addDataToDb( + OUString const & url, ComponentBackendDb::Data const & data) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url, data); +} + +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + // XPackageRegistry //______________________________________________________________________________ Sequence< Reference > @@ -577,6 +605,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { OUString mediaType(mediaType_); @@ -649,17 +678,20 @@ Reference BackendImpl::bindPackage_( if (value.EqualsIgnoreCaseAscii("native")) { return new BackendImpl::ComponentPackageImpl( this, url, name, m_xDynComponentTypeInfo, - OUSTR("com.sun.star.loader.SharedLibrary") ); + OUSTR("com.sun.star.loader.SharedLibrary"), + bNoFileAccess ); } if (value.EqualsIgnoreCaseAscii("Java")) { return new BackendImpl::ComponentPackageImpl( this, url, name, m_xJavaComponentTypeInfo, - OUSTR("com.sun.star.loader.Java2") ); + OUSTR("com.sun.star.loader.Java2"), + bNoFileAccess ); } if (value.EqualsIgnoreCaseAscii("Python")) { return new BackendImpl::ComponentPackageImpl( this, url, name, m_xPythonComponentTypeInfo, - OUSTR("com.sun.star.loader.Python") ); + OUSTR("com.sun.star.loader.Python"), + bNoFileAccess); } } } @@ -675,12 +707,12 @@ Reference BackendImpl::bindPackage_( { return new BackendImpl::TypelibraryPackageImpl( this, url, name, m_xRDBTypelibTypeInfo, - false /* rdb */ ); + false /* rdb */, bNoFileAccess); } if (value.EqualsIgnoreCaseAscii("Java")) { return new BackendImpl::TypelibraryPackageImpl( this, url, name, m_xJavaTypelibTypeInfo, - true /* jar */ ); + true /* jar */, bNoFileAccess); } } } @@ -785,18 +817,11 @@ void BackendImpl::unorc_flush( Reference const & xCmdEnv ) return; ::rtl::OStringBuffer buf; - // UNO_USER_PACKAGES_CACHE, UNO_SHARED_PACKAGES_CACHE have to be resolved - // locally: - if (m_eContext == CONTEXT_USER) { - buf.append( RTL_CONSTASCII_STRINGPARAM( - "UNO_USER_PACKAGES_CACHE=$ORIGIN/../..") ); - } - else if (m_eContext == CONTEXT_SHARED) { - buf.append( RTL_CONSTASCII_STRINGPARAM( - "UNO_SHARED_PACKAGES_CACHE=$ORIGIN/../..") ); - } - else - OSL_ASSERT(0); + + buf.append(RTL_CONSTASCII_STRINGPARAM("ORIGIN=")); + OUString sOrigin = makeRcTerm(m_cachePath); + ::rtl::OString osOrigin = ::rtl::OUStringToOString(sOrigin, RTL_TEXTENCODING_UTF8); + buf.append(osOrigin); buf.append(LF); if (! m_jar_typelibs.empty()) @@ -852,6 +877,9 @@ void BackendImpl::unorc_flush( Reference const & xCmdEnv ) // write native rc: ::rtl::OStringBuffer buf2; + buf2.append(RTL_CONSTASCII_STRINGPARAM("ORIGIN=")); + buf2.append(osOrigin); + buf2.append(LF); buf2.append( RTL_CONSTASCII_STRINGPARAM("UNO_SERVICES=?$ORIGIN/") ); buf2.append( ::rtl::OUStringToOString( sNativeRDB, RTL_TEXTENCODING_ASCII_US ) ); @@ -886,7 +914,7 @@ void BackendImpl::unorc_flush( Reference const & xCmdEnv ) inline OUString makeRcTerm( OUString const & url ) { OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( - "vnd.sun.star.expand:") ) ); + "vnd.sun.star.expand:") ) ); if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) { // cut protocol: OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) ); @@ -1186,6 +1214,8 @@ void BackendImpl::ComponentPackageImpl::processPackage_( bool isJavaTypelib = java && !jarManifestHeaderPresent( url, OUSTR("UNO-Type-Path"), xCmdEnv ); + ComponentBackendDb::Data data; + data.javaTypeLibrary = isJavaTypelib; if (doRegisterPackage) { if (! m_xRemoteContext.is()) { @@ -1210,12 +1240,17 @@ void BackendImpl::ComponentPackageImpl::processPackage_( //only write to unorc if registration was successful. //It may fail if there is no suitable java. if (isJavaTypelib) + { that->addToUnoRc( java, url, xCmdEnv ); + data.javaTypeLibrary = true; + } t_stringlist implNames; t_stringpairvec singletons; - const Reference xLoader( + const Reference xLoader( getComponentInfo( &implNames, &singletons, m_xRemoteContext ) ); + data.implementationNames = implNames; + data.singletons = singletons; // factories live insertion: const Reference xSet( @@ -1280,6 +1315,7 @@ void BackendImpl::ComponentPackageImpl::processPackage_( } m_registered = REG_REGISTERED; + getMyBackend()->addDataToDb(url, data); } else // revokePackage() { @@ -1364,6 +1400,7 @@ void BackendImpl::ComponentPackageImpl::processPackage_( } m_registered = REG_NOT_REGISTERED; + getMyBackend()->deleteDataFromDb(url); } } @@ -1490,7 +1527,7 @@ namespace sdecl = comphelper::service_decl; sdecl::class_ > serviceBI; extern sdecl::ServiceDecl const serviceDecl( serviceBI, - "com.sun.star.comp.deployment.component.PackageRegistryBackend", + IMPLEMENTATION_NAME, BACKEND_SERVICE_NAME ); } // namespace component diff --git a/desktop/source/deployment/registry/component/makefile.mk b/desktop/source/deployment/registry/component/makefile.mk index 4c4016f9bf6c..b7ee5c203cd5 100644 --- a/desktop/source/deployment/registry/component/makefile.mk +++ b/desktop/source/deployment/registry/component/makefile.mk @@ -40,7 +40,8 @@ SRC1FILES = \ INCPRE += ..$/..$/inc SLOFILES = \ - $(SLO)$/dp_component.obj + $(SLO)$/dp_component.obj \ + $(SLO)$/dp_compbackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 460ba5e9fed0..7118e6d1b2d5 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 const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - bool isSchema ) + bool isSchema, bool bUseDb) : Package( myBackend, url, name, name /* display-name */, - xPackageType ), + xPackageType, bUseDb), m_isSchema( isSchema ) {} }; @@ -113,7 +113,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( - OUString const & url, OUString const & mediaType, + OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, Reference const & xCmdEnv ); ::std::auto_ptr m_registeredPackages; @@ -199,7 +199,7 @@ BackendImpl::BackendImpl( m_registeredPackages.reset( new PersistentMap( makeURL( getCachePath(), OUSTR("registered_packages.db") ), - m_readOnly ) ); + false ) ); } } @@ -215,6 +215,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -255,14 +256,14 @@ Reference BackendImpl::bindPackage_( return new PackageImpl( this, url, ucbContent.getPropertyValue( StrTitle::get() ).get(), - m_xConfDataTypeInfo, false /* data file */ ); + m_xConfDataTypeInfo, false /* data file */, bNoFileAccess); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.configuration-schema")) { return new PackageImpl( this, url, ucbContent.getPropertyValue( StrTitle::get() ).get(), - m_xConfSchemaTypeInfo, true /* schema file */ ); + m_xConfSchemaTypeInfo, true /* schema file */, bNoFileAccess); } } } diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index c06b30be1669..31bb30de7315 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -88,6 +88,10 @@ PackageRegistryBackend::PackageRegistryBackend( m_eContext = CONTEXT_USER; else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") )) m_eContext = CONTEXT_SHARED; + else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") )) + m_eContext = CONTEXT_BUNDLED; + else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") )) + m_eContext = CONTEXT_TMP; else if (m_context.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:/") )) m_eContext = CONTEXT_DOCUMENT; @@ -127,24 +131,29 @@ void PackageRegistryBackend::disposing() // XPackageRegistry //______________________________________________________________________________ Reference PackageRegistryBackend::bindPackage( - OUString const & url, OUString const & mediaType, + OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess , Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException) { ::osl::ResettableMutexGuard guard( getMutex() ); check(); - t_string2ref::const_iterator const iFind( m_bound.find( url ) ); - if (iFind != m_bound.end()) { - Reference xPackage( iFind->second ); - if (xPackage.is()) - return xPackage; + if (!bNoFileAccess) + { + //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 xPackage( iFind->second ); + if (xPackage.is()) + return xPackage; + } } guard.clear(); Reference xNewPackage; try { - xNewPackage = bindPackage_( url, mediaType, xCmdEnv ); + xNewPackage = bindPackage_( url, mediaType, bNoFileAccess, xCmdEnv ); } catch (RuntimeException &) { throw; @@ -166,19 +175,23 @@ Reference PackageRegistryBackend::bindPackage( } guard.reset(); - ::std::pair< t_string2ref::iterator, bool > insertion( - m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) ); - if (insertion.second) - { // first insertion - OSL_ASSERT( Reference(insertion.first->second) - == xNewPackage ); - } - else - { // found existing entry - Reference xPackage( insertion.first->second ); - if (xPackage.is()) - return xPackage; - insertion.first->second = xNewPackage; + 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(insertion.first->second) + == xNewPackage ); + } + else + { // found existing entry + Reference xPackage( insertion.first->second ); + if (xPackage.is()) + return xPackage; + insertion.first->second = xNewPackage; + } } guard.clear(); xNewPackage->addEventListener( this ); // listen for disposing events @@ -197,13 +210,15 @@ Package::Package( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, OUString const & displayName, - Reference const & xPackageType ) + Reference const & xPackageType, + bool bUseDb) : t_PackageBase( getMutex() ), m_myBackend( myBackend ), m_url( url ), m_name( name ), m_displayName( displayName ), - m_xPackageType( xPackageType ) + m_xPackageType( xPackageType ), + m_bUseDb(bUseDb) { } @@ -542,7 +557,29 @@ void Package::revokePackage( lang::IllegalArgumentException, RuntimeException) { processPackage_impl( false /* revoke */, xAbortChannel, xCmdEnv ); + +} + +PackageRegistryBackend * Package::getMyBackend() const +{ + PackageRegistryBackend * pBackend = m_myBackend.get(); + if (NULL == pBackend) + { + //May throw a DisposedException + check(); + //We should never get here... + throw RuntimeException( + OUSTR("Failed to get the BackendImpl"), + static_cast(const_cast(this))); + } + return pBackend; } +OUString Package::getRepositoryName() + throw (RuntimeException) +{ + PackageRegistryBackend * backEnd = getMyBackend(); + return backEnd->getContext(); + } //############################################################################## diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx new file mode 100644 index 000000000000..fb0b99c3363c --- /dev/null +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -0,0 +1,332 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/strbuf.hxx" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "osl/file.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "com/sun/star/io/XActiveDataSource.hpp" +#include "com/sun/star/io/XActiveDataControl.hpp" +#include "dp_ucb.h" +#include "dp_misc.h" +#include "ucbhelper/content.hxx" +#include "xmlscript/xml_helper.hxx" +#include "dp_backenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + + +namespace dp_registry { +namespace backend { + +BackendDb::BackendDb( + Reference const & xContext, + ::rtl::OUString const & url): + m_xContext(xContext) +{ + m_urlDb = dp_misc::expandUnoRcUrl(url); +} + +void BackendDb::save() +{ + Reference xDataSource(m_doc,css::uno::UNO_QUERY_THROW); + ::rtl::ByteSequence bytes; + xDataSource->setOutputStream(::xmlscript::createOutputStream(&bytes)); + Reference xDataControl(m_doc,css::uno::UNO_QUERY_THROW); + xDataControl->start(); + + Reference xData( + ::xmlscript::createInputStream(bytes)); + ::ucbhelper::Content ucbDb(m_urlDb, 0); + ucbDb.writeStream(xData, true /*replace existing*/); +} + +css::uno::Reference BackendDb::getDocument() +{ + if (!m_doc.is()) + { + Reference xDocBuilder( + m_xContext->getServiceManager()->createInstanceWithContext( + OUSTR("com.sun.star.xml.dom.DocumentBuilder"), + m_xContext ), css::uno::UNO_QUERY); + if (!xDocBuilder.is()) + throw css::uno::RuntimeException( + OUSTR(" Could not create service com.sun.star.xml.dom.DocumentBuilder"), 0); + + ::osl::DirectoryItem item; + ::osl::File::RC err = ::osl::DirectoryItem::get(m_urlDb, item); + if (err == ::osl::File::E_None) + { + m_doc = xDocBuilder->parseURI(m_urlDb); + } + else if (err == ::osl::File::E_NOENT) + { + //Create a new document and insert some basic stuff + m_doc = xDocBuilder->newDocument(); + Reference rootNode = + m_doc->createElement(getRootElementName()); + rootNode->setAttribute( + OUSTR("xmlns"), getDbNSName()); + m_doc->appendChild(Reference( + rootNode, UNO_QUERY_THROW)); + save(); + } + else + throw css::uno::RuntimeException( + OUSTR("Extension manager could not access database file:" ) + + m_urlDb, 0); + + if (!m_doc.is()) + throw css::uno::RuntimeException( + OUSTR("Extension manager could not get root node of data base file: ") + + m_urlDb, 0); + } + + return m_doc; +} + +Reference BackendDb::getXPathAPI() +{ + if (!m_xpathApi.is()) + { + m_xpathApi = Reference< css::xml::xpath::XXPathAPI >( + m_xContext->getServiceManager()->createInstanceWithContext( + OUSTR("com.sun.star.xml.xpath.XPathAPI"), + m_xContext), css::uno::UNO_QUERY); + + if (!m_xpathApi.is()) + throw css::uno::RuntimeException( + OUSTR(" Could not create service com.sun.star.xml.xpath.XPathAPI"), 0); + + m_xpathApi->registerNS( + OUSTR("reg"), getDbNSName()); + } + + return m_xpathApi; +} + +// OUString BackendDb::getDbNSName() +// { +// return OUString(); +// } + + +// OUString BackendDb::getRootElementName() +// { +// return OUString(); +// } + +void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) +{ + try + { + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sXPathExpression); + OSL_ASSERT(aNode.is()); + if (aNode.is()) + { + root->removeChild(aNode); + save(); + } + +#if OSL_DEBUG_LEVEL > 0 + //There must not be any other entry with the same url + Reference nextNode = + xpathApi->selectSingleNode(root, sXPathExpression); + OSL_ASSERT(! nextNode.is()); +#endif + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } + +} + +void BackendDb::writeVectorOfPair( + ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > const & vecPairs, + OUString const & sVectorTagName, + OUString const & sPairTagName, + OUString const & sFirstTagName, + OUString const & sSecondTagName, + css::uno::Reference const & xParent) +{ + try{ + + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference vectorNode( + doc->createElement(sVectorTagName)); + + xParent->appendChild( + Reference( + vectorNode, css::uno::UNO_QUERY_THROW)); + typedef ::std::vector< ::std::pair< OUString, OUString > >::const_iterator CIT; + for (CIT i = vecPairs.begin(); i != vecPairs.end(); i++) + { + Reference pairNode( + doc->createElement(sPairTagName)); + + vectorNode->appendChild( + Reference( + pairNode, css::uno::UNO_QUERY_THROW)); + + Reference firstNode( + doc->createElement(sFirstTagName)); + + pairNode->appendChild( + Reference( + firstNode, css::uno::UNO_QUERY_THROW)); + + Reference firstTextNode( + doc->createTextNode( i->first)); + + firstNode->appendChild( + Reference( + firstTextNode, css::uno::UNO_QUERY_THROW)); + + Reference secondNode( + doc->createElement(sSecondTagName)); + + pairNode->appendChild( + Reference( + secondNode, css::uno::UNO_QUERY_THROW)); + + Reference secondTextNode( + doc->createTextNode( i->second)); + + secondNode->appendChild( + Reference( + secondTextNode, css::uno::UNO_QUERY_THROW)); + } + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +::std::vector< ::std::pair< OUString, OUString > > +BackendDb::readVectorOfPair( + Reference const & parent, + OUString const & sListTagName, + OUString const & sPairTagName, + OUString const & sFirstTagName, + OUString const & sSecondTagName) +{ + OSL_ASSERT(parent.is()); + Reference xpathApi = getXPathAPI(); + OUString sExprPairs( + sListTagName + OUSTR("/") + sPairTagName); + Reference 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 aPair = listPairs->item(i); + OUString sExprFirst(sFirstTagName + OUSTR("/text()")); + Reference first = + xpathApi->selectSingleNode(aPair, sExprFirst); + + OUString sExprSecond(sSecondTagName + OUSTR("/text()")); + Reference second = + xpathApi->selectSingleNode(aPair, sExprSecond); + OSL_ASSERT(first.is() && second.is()); + + retVector.push_back(::std::make_pair( + first->getNodeValue(), second->getNodeValue())); + } + return retVector; +} + +void BackendDb::writeSimpleList( + ::std::list< ::rtl::OUString> const & list, + OUString const & sListTagName, + OUString const & sMemberTagName, + Reference const & xParent) +{ + try + { + Reference doc = getDocument(); + + Reference listNode( + doc->createElement(sListTagName)); + + xParent->appendChild( + Reference( + listNode, css::uno::UNO_QUERY_THROW)); + + typedef ::std::list::const_iterator ITC_ITEMS; + for (ITC_ITEMS i = list.begin(); i != list.end(); i++) + { + Reference memberNode( + doc->createElement(sMemberTagName), css::uno::UNO_QUERY_THROW); + + listNode->appendChild(memberNode); + + Reference textNode( + doc->createTextNode( *i), css::uno::UNO_QUERY_THROW); + + memberNode->appendChild(textNode); + } + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write 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 c56131a1015c..9ea13ad2c91f 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -126,7 +126,7 @@ public: // XPackageRegistry virtual Reference SAL_CALL bindPackage( - OUString const & url, OUString const & mediaType, + OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException); @@ -361,9 +361,24 @@ Reference PackageRegistryImpl::create( // Always register as last, because we want to add extensions also as folders // and as a default we accept every folder, which was not recognized by the other // backends. - that->insertBackend( + Reference extensionBackend = ::dp_registry::backend::bundle::create( - that, context, cachePath, readOnly, xComponentContext ) ); + that, context, cachePath, readOnly, xComponentContext); + that->insertBackend(extensionBackend); + + Reference xServiceInfo( + extensionBackend, UNO_QUERY_THROW ); + + OSL_ASSERT(xServiceInfo.is()); + OUString registryCachePath( + makeURL( cachePath, + ::rtl::Uri::encode( + xServiceInfo->getImplementationName(), + rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ) ) ); + create_folder( 0, registryCachePath, Reference()); + #if OSL_DEBUG_LEVEL > 1 // dump tables: @@ -443,7 +458,7 @@ void PackageRegistryImpl::update() throw (RuntimeException) // XPackageRegistry //______________________________________________________________________________ Reference PackageRegistryImpl::bindPackage( - OUString const & url, OUString const & mediaType_, + OUString const & url, OUString const & mediaType_, sal_Bool bNoFileAccess, Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException) @@ -482,7 +497,7 @@ Reference PackageRegistryImpl::bindPackage( for ( ; iPos != iEnd; ++iPos ) { try { - return (*iPos)->bindPackage( url, mediaType, xCmdEnv ); + return (*iPos)->bindPackage( url, mediaType, bNoFileAccess, xCmdEnv ); } catch (lang::IllegalArgumentException &) { } @@ -511,7 +526,7 @@ Reference PackageRegistryImpl::bindPackage( getResourceString(RID_STR_UNSUPPORTED_MEDIA_TYPE) + mediaType, static_cast(this), static_cast(-1) ); } - return iFind->second->bindPackage( url, mediaType, xCmdEnv ); + return iFind->second->bindPackage( url, mediaType, bNoFileAccess, xCmdEnv ); } } diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index 8c95d5874b4c..a5fe1b99746f 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -72,9 +72,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend inline ExecutablePackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, - Reference const & xPackageType) + Reference const & xPackageType, bool bUseDb) : Package( myBackend, url, name, name /* display-name */, - xPackageType ) //, + xPackageType, bUseDb) //, {} }; friend class ExecutablePackageImpl; @@ -84,7 +84,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( - OUString const & url, OUString const & mediaType, + OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, Reference const & xCmdEnv ); Reference m_xExecutableTypeInfo; @@ -125,7 +125,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) // PackageRegistryBackend Reference BackendImpl::bindPackage_( - OUString const & url, OUString const & mediaType, + OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { if (mediaType.getLength() == 0) @@ -147,7 +147,7 @@ Reference BackendImpl::bindPackage_( if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.executable")) { return new BackendImpl::ExecutablePackageImpl( - this, url, name, m_xExecutableTypeInfo); + this, url, name, m_xExecutableTypeInfo, bNoFileAccess); } } } diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 2b0d91250e4a..05ff8dda0e01 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -78,8 +78,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend inline PackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, - Reference const & xPackageType ) - : Package( myBackend, url, name, name, xPackageType ) + Reference const & xPackageType, + bool bUseDb) + : Package( myBackend, url, name, name, xPackageType, bUseDb) {} }; friend class PackageImpl; @@ -87,6 +88,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ); void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage ); @@ -138,6 +140,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { // we don't support auto detection: @@ -156,8 +159,10 @@ Reference BackendImpl::bindPackage_( if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.help")) { - return new PackageImpl( this, url, - ucbContent.getPropertyValue( StrTitle::get() ).get(), m_xHelpTypeInfo ); + return new PackageImpl( + this, url, + ucbContent.getPropertyValue( StrTitle::get() ).get(), + m_xHelpTypeInfo, bNoFileAccess); } } } diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index fe52c8ffc7e3..09b25caedc2b 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -62,6 +62,7 @@ typedef ::cppu::WeakComponentImplHelper1< //============================================================================== class Package : protected ::dp_misc::MutexHolder, public t_PackageBase { + PackageRegistryBackend * getMyBackend() const; void processPackage_impl( bool registerPackage, css::uno::Reference const & xAbortChannel, @@ -73,6 +74,7 @@ protected: ::rtl::OUString m_name; ::rtl::OUString m_displayName; const css::uno::Reference m_xPackageType; + const bool m_bUseDb; void check() const; void fireModified(); @@ -101,7 +103,8 @@ protected: ::rtl::OUString const & name, ::rtl::OUString const & displayName, css::uno::Reference const & - xPackageType ); + xPackageType, + bool bUseDb); public: @@ -233,6 +236,9 @@ public: css::uno::Reference const & xCmdEnv ) throw (css::ucb::CommandFailedException, css::ucb::CommandAbortedException, css::uno::RuntimeException); + + virtual ::rtl::OUString SAL_CALL getRepositoryName() + throw (css::uno::RuntimeException); }; typedef ::cppu::WeakComponentImplHelper2< @@ -243,7 +249,6 @@ typedef ::cppu::WeakComponentImplHelper2< class PackageRegistryBackend : protected ::dp_misc::MutexHolder, public t_BackendBase { - ::rtl::OUString m_cachePath; //The map held originally WeakReferences. The map entries are removed in the disposing //function, which is called when the XPackages are destructed or they are //explicitely disposed. The latter happens, for example, when a extension is @@ -257,13 +262,14 @@ class PackageRegistryBackend t_string2ref m_bound; protected: + ::rtl::OUString m_cachePath; css::uno::Reference m_xComponentContext; ::rtl::OUString m_context; // currently only for library containers: enum context { CONTEXT_UNKNOWN, - CONTEXT_USER, CONTEXT_SHARED, + CONTEXT_USER, CONTEXT_SHARED,CONTEXT_BUNDLED, CONTEXT_TMP, CONTEXT_DOCUMENT } m_eContext; bool m_readOnly; @@ -276,6 +282,7 @@ protected: // @@@ to be implemented by specific backend: virtual css::uno::Reference bindPackage_( ::rtl::OUString const & url, ::rtl::OUString const & mediaType, + sal_Bool bNoFileAccess, css::uno::Reference const & xCmdEnv ) = 0; @@ -299,6 +306,8 @@ public: inline ::rtl::OUString const & getCachePath() const { return m_cachePath; } inline bool transientMode() const { return m_cachePath.getLength() == 0; } + inline ::rtl::OUString getContext() const {return m_context; } + // XEventListener virtual void SAL_CALL disposing( css::lang::EventObject const & evt ) throw (css::uno::RuntimeException); @@ -306,6 +315,7 @@ public: // XPackageRegistry virtual css::uno::Reference SAL_CALL bindPackage( ::rtl::OUString const & url, ::rtl::OUString const & mediaType, + sal_Bool bNoFileAccess, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, css::ucb::CommandFailedException, diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx new file mode 100644 index 000000000000..3005ffcafb5b --- /dev/null +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -0,0 +1,121 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_BACKENDDB_HXX +#define INCLUDED_DP_BACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } + namespace xml { namespace dom { + class XDocument; + class XNode; + }} + namespace xml { namespace xpath { + class XXPathAPI; + }} +}}} + +namespace dp_registry { +namespace backend { + +class BackendDb +{ +private: + + css::uno::Reference m_doc; + css::uno::Reference m_xpathApi; + + BackendDb(BackendDb const &); + BackendDb & operator = (BackendDb const &); + +protected: + const css::uno::Reference m_xContext; + ::rtl::OUString m_urlDb; + +protected: + + /* caller must make sure that only one thread accesses the function + */ + css::uno::Reference getDocument(); + + /* the namespace prefix is "reg" (without quotes) + */ + css::uno::Reference getXPathAPI(); + void save(); + void removeElement(::rtl::OUString const & sXPathExpression); + + void writeSimpleList( + ::std::list< ::rtl::OUString> const & list, + ::rtl::OUString const & sListTagName, + ::rtl::OUString const & sMemberTagName, + css::uno::Reference const & xParent); + + void writeVectorOfPair( + ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > const & vecPairs, + ::rtl::OUString const & sVectorTagName, + ::rtl::OUString const & sPairTagName, + ::rtl::OUString const & sFirstTagName, + ::rtl::OUString const & sSecondTagName, + css::uno::Reference const & xParent); + + ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > + readVectorOfPair( + css::uno::Reference const & parent, + ::rtl::OUString const & sListTagName, + ::rtl::OUString const & sPairTagName, + ::rtl::OUString const & sFirstTagName, + ::rtl::OUString const & sSecondTagName); + + + + /* returns the namespace which is to be written as xmlns attribute + into the root element. + */ + virtual ::rtl::OUString getDbNSName()=0; + /* returns the name of the root element without any namespace prefix. + */ + virtual ::rtl::OUString getRootElementName()=0; + + +public: + BackendDb(css::uno::Reference const & xContext, + ::rtl::OUString const & url); + virtual ~BackendDb() {}; + +}; + +} +} +#endif + diff --git a/desktop/source/deployment/registry/makefile.mk b/desktop/source/deployment/registry/makefile.mk index de0e943654d9..e45cec272ca7 100644 --- a/desktop/source/deployment/registry/makefile.mk +++ b/desktop/source/deployment/registry/makefile.mk @@ -41,7 +41,8 @@ INCPRE += inc SLOFILES = \ $(SLO)$/dp_backend.obj \ - $(SLO)$/dp_registry.obj + $(SLO)$/dp_registry.obj \ + $(SLO)$/dp_backenddb.obj .INCLUDE : ..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/package/dp_description.cxx b/desktop/source/deployment/registry/package/dp_description.cxx deleted file mode 100644 index 7c05bfd90a5b..000000000000 --- a/desktop/source/deployment/registry/package/dp_description.cxx +++ /dev/null @@ -1,205 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_desktop.hxx" - -#include "dp_description.hxx" - -#include "cppuhelper/exc_hlp.hxx" -#include "ucbhelper/content.hxx" -#include "com/sun/star/deployment/DeploymentException.hpp" -#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" -#include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/ucb/CommandFailedException.hpp" -#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp" -#include "com/sun/star/ucb/IOErrorCode.hpp" - -#include "com/sun/star/beans/PropertyValue.hpp" - - -#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) - -namespace css = com::sun::star; -namespace cssu = com::sun::star::uno; - -namespace dp_registry { -namespace backend { -namespace bundle { - -ExtensionDescription::ExtensionDescription( - const cssu::Reference& xContext, - const ::rtl::OUString& installDir, - const cssu::Reference< css::ucb::XCommandEnvironment >& xCmdEnv) -{ - try { - m_sExtensionRootUrl = installDir; - //may throw ::com::sun::star::ucb::ContentCreationException - //If there is no description.xml then ucb will start an interaction which - //brings up a dialog.We want to prevent this. Therefore we wrap the xCmdEnv - //and filter the respective exception out. - ::rtl::OUString sDescriptionUri(installDir + OUSTR("/description.xml")); - cssu::Reference xFilter = - static_cast( - new FileDoesNotExistFilter(xCmdEnv)); - ::ucbhelper::Content descContent(sDescriptionUri, xFilter); - - //throws an com::sun::star::uno::Exception if the file is not available - cssu::Reference xIn; - try - { //throws com.sun.star.ucb.InteractiveAugmentedIOException - xIn = descContent.openStream(); - } - catch (cssu::Exception& ) - { - if ( ! static_cast(xFilter.get())->exist()) - throw NoDescriptionException(); - throw; - } - if (!xIn.is()) - { - throw cssu::Exception( - OUSTR("Could not get XInputStream for description.xml of extension ") + - sDescriptionUri, 0); - } - - //get root node of description.xml - cssu::Reference xDocBuilder( - xContext->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.xml.dom.DocumentBuilder"), - xContext ), cssu::UNO_QUERY); - if (!xDocBuilder.is()) - throw css::uno::Exception(OUSTR(" Could not create service com.sun.star.xml.dom.DocumentBuilder"), 0); - - if (xDocBuilder->isNamespaceAware() == sal_False) - { - throw cssu::Exception( - OUSTR("Service com.sun.star.xml.dom.DocumentBuilder is not namespace aware."), 0); - } - - cssu::Reference xDoc = xDocBuilder->parse(xIn); - if (!xDoc.is()) - { - throw cssu::Exception(sDescriptionUri + OUSTR(" contains data which cannot be parsed. "), 0); - } - - //check for proper root element and namespace - cssu::Reference xRoot = xDoc->getDocumentElement(); - if (!xRoot.is()) - { - throw cssu::Exception( - sDescriptionUri + OUSTR(" contains no root element."), 0); - } - - if ( ! xRoot->getTagName().equals(OUSTR("description"))) - { - throw cssu::Exception( - sDescriptionUri + OUSTR(" does not contain the root element ."), 0); - } - - m_xRoot = cssu::Reference( - xRoot, cssu::UNO_QUERY_THROW); - ::rtl::OUString nsDescription = xRoot->getNamespaceURI(); - - //check if this namespace is supported - if ( ! nsDescription.equals(OUSTR("http://openoffice.org/extensions/description/2006"))) - { - throw cssu::Exception(sDescriptionUri + OUSTR(" contains a root element with an unsupported namespace. "), 0); - } - } catch (css::uno::RuntimeException &) { - throw; - } catch (css::deployment::DeploymentException &) { - throw; - } catch (css::uno::Exception & e) { - css::uno::Any a(cppu::getCaughtException()); - throw css::deployment::DeploymentException( - e.Message, css::uno::Reference< css::uno::XInterface >(), a); - } -} - -ExtensionDescription::~ExtensionDescription() -{ -} - -//====================================================================== -FileDoesNotExistFilter::FileDoesNotExistFilter( - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv): - m_bExist(true), m_xCommandEnv(xCmdEnv) -{} - -FileDoesNotExistFilter::~FileDoesNotExistFilter() -{ -}; - -bool FileDoesNotExistFilter::exist() -{ - return m_bExist; -} - // XCommandEnvironment -cssu::Reference - FileDoesNotExistFilter::getInteractionHandler() throw (css::uno::RuntimeException) -{ - return static_cast(this); -} - -cssu::Reference - FileDoesNotExistFilter::getProgressHandler() throw (css::uno::RuntimeException) -{ - return m_xCommandEnv.is() - ? m_xCommandEnv->getProgressHandler() - : cssu::Reference(); -} - -// XInteractionHandler -//If the interaction was caused by a non-existing file which is specified in the ctor -//of FileDoesNotExistFilter, then we do nothing -void FileDoesNotExistFilter::handle( - cssu::Reference const & xRequest ) - throw (css::uno::RuntimeException) -{ - cssu::Any request( xRequest->getRequest() ); - - css::ucb::InteractiveAugmentedIOException ioexc; - if ((request>>= ioexc) && ioexc.Code == css::ucb::IOErrorCode_NOT_EXISTING ) - { - m_bExist = false; - return; - } - css::uno::Reference xInteraction; - if (m_xCommandEnv.is()) { - xInteraction = m_xCommandEnv->getInteractionHandler(); - } - if (xInteraction.is()) { - xInteraction->handle(xRequest); - } -} - - -} // namespace bundle -} // namespace backend -} // namespace dp_registry - diff --git a/desktop/source/deployment/registry/package/dp_description.hxx b/desktop/source/deployment/registry/package/dp_description.hxx deleted file mode 100644 index eb74c454af75..000000000000 --- a/desktop/source/deployment/registry/package/dp_description.hxx +++ /dev/null @@ -1,125 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#if !defined INCLUDED_DESKTOP_EXTENSION_DESCRIPTION_HXX -#define INCLUDED_DESKTOP_EXTENSION_DESCRIPTION_HXX - - - -#include "com/sun/star/uno/Reference.hxx" - -#include "com/sun/star/ucb/XCommandEnvironment.hpp" -#include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/xml/dom/XNode.hpp" -#include "com/sun/star/task/XInteractionHandler.hpp" -#include "cppuhelper/implbase2.hxx" - - -namespace css = ::com::sun::star; - -namespace dp_registry { -namespace backend { -namespace bundle { - -/**The class uses the UCB to access the description.xml file in an - extension. The UCB must have been initialized already. It also - requires that the extension has already be unzipped to a particular - location. - */ -class ExtensionDescription -{ -public: - /**throws an exception if the description.xml is not - available, cannot be read, does not contain the expected data, - or any other error occured. Therefore it shoult only be used with - new extensions. - - Throws com::sun::star::uno::RuntimeException, - com::sun::star::deployment::DeploymentException, - dp_registry::backend::bundle::NoDescriptionException. - */ - ExtensionDescription( - const css::uno::Reference& xContext, - const ::rtl::OUString& installDir, - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv); - - ~ExtensionDescription(); - - css::uno::Reference getRootElement() const - { - return m_xRoot; - } - - ::rtl::OUString getExtensionRootUrl() const - { - return m_sExtensionRootUrl; - } - - -private: - css::uno::Reference m_xRoot; - ::rtl::OUString m_sExtensionRootUrl; -}; - -class NoDescriptionException -{ -}; - -class FileDoesNotExistFilter - : public ::cppu::WeakImplHelper2< css::ucb::XCommandEnvironment, - css::task::XInteractionHandler > - -{ - //css::uno::Reference m_xHandler; - bool m_bExist; - css::uno::Reference< css::ucb::XCommandEnvironment > m_xCommandEnv; - -public: - virtual ~FileDoesNotExistFilter(); - FileDoesNotExistFilter( - const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv); - - bool exist(); - // XCommandEnvironment - virtual css::uno::Reference SAL_CALL - getInteractionHandler() throw (css::uno::RuntimeException); - virtual css::uno::Reference - SAL_CALL getProgressHandler() throw (css::uno::RuntimeException); - - // XInteractionHandler - virtual void SAL_CALL handle( - css::uno::Reference const & xRequest ) - throw (css::uno::RuntimeException); -}; - - -} // namespace bundle -} // namespace backend -} // namespace dp_registry - - -#endif // INCLUDED_DESKTOP_LICENSE_INTERACT_HXX diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx new file mode 100644 index 000000000000..97cfc136049c --- /dev/null +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx @@ -0,0 +1,177 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" + +#include "dp_extbackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +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 { + +ExtensionBackendDb::ExtensionBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +OUString ExtensionBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString ExtensionBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +{ + try{ + + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + OUString sExpression( + OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + // + Reference extensionNode( + doc->createElement(OUSTR("extension"))); + + extensionNode->setAttribute(OUSTR("url"), url); + + Reference extensionNodeNode( + extensionNode, css::uno::UNO_QUERY_THROW); + root->appendChild(extensionNodeNode); + + // ... + Reference identifierNode( + doc->createElement(OUSTR("identifier")), UNO_QUERY_THROW); + extensionNodeNode->appendChild(identifierNode); + + Reference identifierValue( + doc->createTextNode(data.identifier), UNO_QUERY_THROW); + identifierNode->appendChild(identifierValue); + + + writeVectorOfPair( + data.items, + OUSTR("extension-items"), + OUSTR("item"), + OUSTR("url"), + OUSTR("media-type"), + extensionNodeNode); + save(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +void ExtensionBackendDb::removeEntry(::rtl::OUString const & url) +{ + OUString sExpression( + OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + removeElement(sExpression); +} + +ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & url) +{ + ExtensionBackendDb::Data retData; + const OUString sExpression( + OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + OSL_ASSERT(aNode.is()); + + const OUString sExprIdentifier(OUSTR("reg:identifier/text()")); + + Reference 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; +} + +} // namespace bundle +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx new file mode 100644 index 000000000000..156e34155040 --- /dev/null +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#if ! defined INCLUDED_DP_EXTBACKENDDB_HXX +#define INCLUDED_DP_EXTBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "rtl/string.hxx" +#include +#include "dp_backenddb.hxx" + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } + namespace xml { namespace dom { + class XDocument; + class XNode; + }} + namespace xml { namespace xpath { + class XXPathAPI; + }} +}}} + +namespace dp_registry { +namespace backend { +namespace bundle { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + */ +class ExtensionBackendDb: public dp_registry::backend::BackendDb +{ +public: + struct Data + { + ::rtl::OUString identifier; + /* 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; + typedef ::std::vector< + ::std::pair< ::rtl::OUString, ::rtl::OUString> >::const_iterator ITC_ITEMS; + + }; + +public: + + ExtensionBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + + void addEntry(::rtl::OUString const & url, Data const & data); + void removeEntry(::rtl::OUString const & url); + Data getEntry(::rtl::OUString const & url); + + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getRootElementName(); +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index b0b4a918c7a3..8fe7874f247f 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -34,7 +34,6 @@ #include "dp_interact.h" #include "dp_dependencies.hxx" #include "dp_platform.hxx" -#include "dp_description.hxx" #include "dp_descriptioninfoset.hxx" #include "dp_identifier.hxx" #include "rtl/uri.hxx" @@ -74,7 +73,7 @@ #include #include - +#include "dp_extbackenddb.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -106,6 +105,8 @@ class BackendImpl : public ImplBaseT Sequence< Reference > m_bundle; Sequence< Reference > * m_pBundle; + ExtensionBackendDb::Data m_data; + Reference bindBundleItem( OUString const & url, OUString const & mediaType, Reference const & xCmdEnv, @@ -122,20 +123,20 @@ class BackendImpl : public ImplBaseT ::rtl::Reference const & abortChannel, Reference const & xCmdEnv, bool skip_registration = false ); - + ::std::vector > getPackagesFromDb(); bool checkPlatform( css::uno::Reference< css::ucb::XCommandEnvironment > const & environment); bool checkDependencies( css::uno::Reference< css::ucb::XCommandEnvironment > const & environment, - ExtensionDescription const & description); + DescriptionInfoset const & description); // throws css::uno::RuntimeException, // css::deployment::DeploymentException ::sal_Bool checkLicense( css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv, - ExtensionDescription const& description, bool bInstalled, + DescriptionInfoset const & description, bool bInstalled, OUString const & aContextName ) throw (css::deployment::DeploymentException, css::ucb::CommandFailedException, @@ -169,13 +170,8 @@ class BackendImpl : public ImplBaseT OUString const & url, OUString const & name, Reference const & xPackageType, - bool legacyBundle ) - : Package( myBackend, url, name, name /* display-name */, - xPackageType ), - m_url_expanded( expandUnoRcUrl( url ) ), - m_legacyBundle( legacyBundle ), - m_pBundle( 0 ) - {} + bool legacyBundle, + bool useDb); // XPackage virtual sal_Bool SAL_CALL isBundle() throw (RuntimeException); @@ -228,9 +224,16 @@ class BackendImpl : public ImplBaseT const Reference m_xLegacyBundleTypeInfo; Sequence< Reference > m_typeInfos; + std::auto_ptr m_backendDb; + + void addDataToDb(OUString const & url, ExtensionBackendDb::Data const & data); + ExtensionBackendDb::Data readDataFromDb(OUString const & url); + void deleteDataFromDb(OUString const & url); + // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -291,6 +294,14 @@ BackendImpl::BackendImpl( { m_typeInfos[ 0 ] = m_xBundleTypeInfo; m_typeInfos[ 1 ] = m_xLegacyBundleTypeInfo; + + if (!transientMode()) + { + OUString dbFile = makeURL(getCachePath(), getImplementationName()); + dbFile = makeURL(dbFile, OUSTR("backenddb.xml")); + m_backendDb.reset( + new ExtensionBackendDb(getComponentContext(), dbFile)); + } } //______________________________________________________________________________ @@ -333,6 +344,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -381,19 +393,21 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); + ::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 )) + name = ucbContent.getPropertyValue( + StrTitle::get() ).get(); if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.package-bundle")) { return new PackageImpl( - this, url, ucbContent.getPropertyValue( - StrTitle::get() ).get(), - m_xBundleTypeInfo, false ); + this, url, name, m_xBundleTypeInfo, false, bNoFileAccess); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.legacy-package-bundle")) { return new PackageImpl( - this, url, ucbContent.getPropertyValue( - StrTitle::get() ).get(), - m_xLegacyBundleTypeInfo, true ); + this, url, name, m_xLegacyBundleTypeInfo, true, bNoFileAccess); } } } @@ -403,8 +417,48 @@ Reference BackendImpl::bindPackage_( static_cast(-1) ); } +void BackendImpl::addDataToDb( + OUString const & url, ExtensionBackendDb::Data const & data) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url, data); +} + +ExtensionBackendDb::Data BackendImpl::readDataFromDb( + OUString const & url) +{ + ExtensionBackendDb::Data data; + if (m_backendDb.get()) + data = m_backendDb->getEntry(url); + return data; +} + +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + + //############################################################################## +BackendImpl::PackageImpl::PackageImpl( + ::rtl::Reference const & myBackend, + OUString const & url, + OUString const & name, + Reference const & xPackageType, + bool legacyBundle, + bool useDb) + : Package( myBackend, url, name, name /* display-name */, + xPackageType, useDb ), + m_url_expanded( expandUnoRcUrl( url ) ), + m_legacyBundle( legacyBundle ), + m_pBundle( 0 ) +{ + if (useDb) + m_data = getMyBackend()->readDataFromDb(url); +} + BackendImpl * BackendImpl::PackageImpl::getMyBackend() const { BackendImpl * pBackend = static_cast(m_myBackend.get()); @@ -510,23 +564,7 @@ OUString BackendImpl::PackageImpl::getTextFromURL( DescriptionInfoset BackendImpl::PackageImpl::getDescriptionInfoset() { - css::uno::Reference< css::xml::dom::XNode > root; - try { - root = - ExtensionDescription( - getMyBackend()->getComponentContext(), m_url_expanded, - css::uno::Reference< css::ucb::XCommandEnvironment >()). - getRootElement(); - } catch (NoDescriptionException &) { - } catch (css::deployment::DeploymentException & e) { - throw RuntimeException( - (OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.deployment.DeploymentException: ")) + - e.Message), - static_cast< OWeakObject * >(this)); - } - return DescriptionInfoset(getMyBackend()->getComponentContext(), root); + return dp_misc::getDescriptionInfoset(m_url_expanded); } bool BackendImpl::PackageImpl::checkPlatform( @@ -561,14 +599,11 @@ bool BackendImpl::PackageImpl::checkPlatform( bool BackendImpl::PackageImpl::checkDependencies( css::uno::Reference< css::ucb::XCommandEnvironment > const & environment, - ExtensionDescription const & description) + DescriptionInfoset const & description) { css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > - unsatisfied( - dp_misc::Dependencies::check( - DescriptionInfoset( - getMyBackend()->getComponentContext(), - description.getRootElement()))); + unsatisfied(dp_misc::Dependencies::check(description)); + if (unsatisfied.getLength() == 0) { return true; } else { @@ -590,7 +625,7 @@ bool BackendImpl::PackageImpl::checkDependencies( ::sal_Bool BackendImpl::PackageImpl::checkLicense( css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv, - ExtensionDescription const & desc, bool bInstalled, OUString const & aContextName) + DescriptionInfoset const & info, bool bInstalled, OUString const & aContextName) throw (css::deployment::DeploymentException, css::ucb::CommandFailedException, css::ucb::CommandAbortedException, @@ -598,7 +633,6 @@ bool BackendImpl::PackageImpl::checkDependencies( { try { - DescriptionInfoset info = getDescriptionInfoset(); ::boost::optional simplLicAttr = info.getSimpleLicenseAttributes(); if (! simplLicAttr) @@ -610,7 +644,7 @@ bool BackendImpl::PackageImpl::checkDependencies( if (sLic.getLength() == 0) throw css::deployment::DeploymentException( OUSTR("Could not obtain path to license. Possible error in description.xml"), 0, Any()); - OUString sHref = desc.getExtensionRootUrl() + OUSTR("/") + sLic; + OUString sHref = m_url_expanded + OUSTR("/") + sLic; OUString sLicense = getTextFromURL(xCmdEnv, sHref); ////determine who has to agree to the license //check correct value for attribute @@ -693,19 +727,13 @@ bool BackendImpl::PackageImpl::checkDependencies( css::ucb::CommandAbortedException, css::uno::RuntimeException) { - std::auto_ptr spDescription; - try { - spDescription.reset( - new ExtensionDescription( - getMyBackend()->getComponentContext(), - m_url_expanded, - xCmdEnv)); - } catch (NoDescriptionException& ) { + DescriptionInfoset info = getDescriptionInfoset(); + if (!info.hasDescription()) return sal_True; - } + return checkPlatform(xCmdEnv) - && checkDependencies(xCmdEnv, *spDescription) - && checkLicense(xCmdEnv, *spDescription, bInstalled, aContextName); + && checkDependencies(xCmdEnv, info) + && checkLicense(xCmdEnv, info, bInstalled, aContextName); } ::sal_Bool BackendImpl::PackageImpl::checkDependencies( @@ -714,23 +742,25 @@ bool BackendImpl::PackageImpl::checkDependencies( css::ucb::CommandFailedException, css::uno::RuntimeException) { - std::auto_ptr spDescription; - try { - spDescription.reset( - new ExtensionDescription( getMyBackend()->getComponentContext(), m_url_expanded, xCmdEnv )); - } catch (NoDescriptionException& ) { + DescriptionInfoset info = getDescriptionInfoset(); + if (!info.hasDescription()) return sal_True; - } - return checkDependencies(xCmdEnv, *spDescription); + + return checkDependencies(xCmdEnv, info); } beans::Optional BackendImpl::PackageImpl::getIdentifier() throw (RuntimeException) { + OUString identifier; + if (m_bUseDb) + identifier = m_data.identifier; + else + identifier = dp_misc::generateIdentifier( + getDescriptionInfoset().getIdentifier(), m_name); + return beans::Optional( - true, - dp_misc::generateIdentifier( - getDescriptionInfoset().getIdentifier(), m_name)); + true, identifier); } OUString BackendImpl::PackageImpl::getVersion() throw (RuntimeException) @@ -793,6 +823,7 @@ void BackendImpl::PackageImpl::processPackage_( if (doRegisterPackage) { + ExtensionBackendDb::Data data; const sal_Int32 len = bundle.getLength(); for ( sal_Int32 pos = 0; pos < len; ++pos ) { @@ -870,7 +901,12 @@ void BackendImpl::PackageImpl::processPackage_( ::cppu::throwException(exc); } } + data.items.push_back( + ::std::make_pair(xPackage->getURL(), + xPackage->getPackageType()->getMediaType())); } + data.identifier = getIdentifier().Value; + getMyBackend()->addDataToDb(getURL(), data); } else { @@ -914,6 +950,7 @@ void BackendImpl::PackageImpl::processPackage_( // selected } } + getMyBackend()->deleteDataFromDb(getURL()); } } @@ -1139,58 +1176,66 @@ Sequence< Reference > BackendImpl::PackageImpl::getBundle( if (pBundle == 0) { t_packagevec bundle; - try { - if (m_legacyBundle) - { - // .zip legacy packages allow script.xlb, dialog.xlb in bundle - // root folder: - OUString mediaType; - // probe for script.xlb: - if (create_ucb_content( - 0, makeURL( m_url_expanded, OUSTR("script.xlb") ), - xCmdEnv, false /* no throw */ )) { - mediaType = OUSTR("application/vnd.sun.star.basic-library"); + if (m_bUseDb) + { + bundle = getPackagesFromDb(); + } + else + { + try { + if (m_legacyBundle) + { + // .zip legacy packages allow script.xlb, dialog.xlb in bundle + // root folder: + OUString mediaType; + // probe for script.xlb: + if (create_ucb_content( + 0, makeURL( m_url_expanded, OUSTR("script.xlb") ), + xCmdEnv, false /* no throw */ )) { + mediaType = OUSTR("application/vnd.sun.star.basic-library"); + } + // probe for dialog.xlb: + else if (create_ucb_content( + 0, makeURL( m_url_expanded, OUSTR("dialog.xlb") ), + xCmdEnv, false /* no throw */ )) + mediaType = OUSTR("application/vnd.sun.star." + "dialog-library"); + + if (mediaType.getLength() > 0) { + const Reference xPackage( + bindBundleItem( getURL(), mediaType, xCmdEnv ) ); + if (xPackage.is()) + bundle.push_back( xPackage ); + // continue scanning: + } + scanLegacyBundle( bundle, getURL(), + AbortChannel::get(xAbortChannel), xCmdEnv ); } - // probe for dialog.xlb: - else if (create_ucb_content( - 0, makeURL( m_url_expanded, OUSTR("dialog.xlb") ), - xCmdEnv, false /* no throw */ )) - mediaType = OUSTR("application/vnd.sun.star." - "dialog-library"); - - if (mediaType.getLength() > 0) { - const Reference xPackage( - bindBundleItem( getURL(), mediaType, xCmdEnv ) ); - if (xPackage.is()) - bundle.push_back( xPackage ); - // continue scanning: + else + { + // .oxt: + scanBundle( bundle, AbortChannel::get(xAbortChannel), xCmdEnv ); } - scanLegacyBundle( bundle, getURL(), - AbortChannel::get(xAbortChannel), xCmdEnv ); + } - else - { - // .oxt: - scanBundle( bundle, AbortChannel::get(xAbortChannel), xCmdEnv ); + catch (RuntimeException &) { + throw; + } + catch (CommandFailedException &) { + throw; + } + catch (CommandAbortedException &) { + throw; + } + catch (deployment::DeploymentException &) { + throw; + } + catch (Exception &) { + Any exc( ::cppu::getCaughtException() ); + throw deployment::DeploymentException( + OUSTR("error scanning bundle: ") + getURL(), + static_cast(this), exc ); } - } - catch (RuntimeException &) { - throw; - } - catch (CommandFailedException &) { - throw; - } - catch (CommandAbortedException &) { - throw; - } - catch (deployment::DeploymentException &) { - throw; - } - catch (Exception &) { - Any exc( ::cppu::getCaughtException() ); - throw deployment::DeploymentException( - OUSTR("error scanning bundle: ") + getURL(), - static_cast(this), exc ); } // sort: schema before config data, typelibs before components: @@ -1267,7 +1312,7 @@ Reference BackendImpl::PackageImpl::bindBundleItem( ReferencexPackage; try { xPackage.set( getMyBackend()->m_xRootRegistry->bindPackage( - url, mediaType, xCmdEnv ) ); + url, mediaType, false, xCmdEnv ) ); OSL_ASSERT( xPackage.is() ); } catch (RuntimeException &) { @@ -1523,6 +1568,13 @@ OUString BackendImpl::PackageImpl::getDisplayName() throw (RuntimeException) return sName; } +::std::vector > BackendImpl::PackageImpl::getPackagesFromDb() +{ + //get the data base entry for this extension + + return ::std::vector >(); +} + } // anon namespace //============================================================================== diff --git a/desktop/source/deployment/registry/package/makefile.mk b/desktop/source/deployment/registry/package/makefile.mk index ccadc2070301..203ce176d289 100644 --- a/desktop/source/deployment/registry/package/makefile.mk +++ b/desktop/source/deployment/registry/package/makefile.mk @@ -41,7 +41,7 @@ INCPRE += ..$/..$/inc SLOFILES = \ $(SLO)$/dp_package.obj \ - $(SLO)$/dp_description.obj + $(SLO)$/dp_extbackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index 4af0cbb84130..6d503d33d51d 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -88,13 +88,15 @@ class BackendImpl : public t_helper ::rtl::Reference const & myBackend, OUString const & url, Reference const &xCmdEnv, - OUString const & scriptURL, OUString const & dialogURL ); + OUString const & scriptURL, OUString const & dialogURL, + bool bUseDb); }; friend class PackageImpl; // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ); rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); @@ -123,11 +125,11 @@ BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference const & myBackend, OUString const & url, Reference const &xCmdEnv, - OUString const & scriptURL, OUString const & dialogURL ) + OUString const & scriptURL, OUString const & dialogURL, bool bUseDb ) : Package( myBackend.get(), url, OUString(), OUString(), // will be late-initialized scriptURL.getLength() > 0 ? myBackend->m_xBasicLibTypeInfo - : myBackend->m_xDialogLibTypeInfo ), + : myBackend->m_xDialogLibTypeInfo, bUseDb), m_scriptURL( scriptURL ), m_dialogURL( dialogURL ) { @@ -189,6 +191,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -231,13 +234,15 @@ Reference BackendImpl::bindPackage_( } return new PackageImpl( this, url, xCmdEnv, makeURL( url, OUSTR("script.xlb") ), - dialogURL ); + dialogURL, bNoFileAccess); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.dialog-library")) { - return new PackageImpl( this, url, xCmdEnv, - OUString() /* no script lib */, - makeURL( url, OUSTR("dialog.xlb") ) ); + return new PackageImpl( + this, url, xCmdEnv, + OUString() /* no script lib */, + makeURL( url, OUSTR("dialog.xlb") ), + bNoFileAccess); } } } diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx index 52ced6908bd8..47b6430f1a1e 100644 --- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx +++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx @@ -81,8 +81,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference const & xCmdEnv ); public: - PackageImpl( ::rtl::Reference const & myBackend, - OUString const & url, OUString const & libType ); + PackageImpl( + ::rtl::Reference const & myBackend, + OUString const & url, OUString const & libType, bool bUseDb); // XPackage virtual OUString SAL_CALL getDescription() throw (RuntimeException); }; @@ -91,6 +92,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, + sal_Bool bNoFileAccess, Reference const & xCmdEnv ); const Reference m_xTypeInfo; @@ -131,9 +133,9 @@ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) //______________________________________________________________________________ BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference const & myBackend, - OUString const & url, OUString const & libType ) + OUString const & url, OUString const & libType, bool bUseDb) : Package( myBackend.get(), url, OUString(), OUString(), - myBackend->m_xTypeInfo ), + myBackend->m_xTypeInfo, bUseDb ), m_descr(libType) { initPackageHandler(); @@ -217,7 +219,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) // PackageRegistryBackend //______________________________________________________________________________ Reference BackendImpl::bindPackage_( - OUString const & url, OUString const & mediaType_, + OUString const & url, OUString const & mediaType_, sal_Bool bNoFileAccess, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -294,7 +296,7 @@ Reference 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 ); + return new PackageImpl( this, url, sfwkLibType, bNoFileAccess); } } } @@ -322,6 +324,10 @@ void BackendImpl::PackageImpl:: initPackageHandler() { aContext <<= OUSTR("share"); } + else if ( that->m_eContext == CONTEXT_BUNDLED ) + { + aContext <<= OUSTR("bundled"); + } else { OSL_ASSERT( 0 ); diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 2acd4f79a781..807260fe4663 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -41,7 +41,8 @@ #include "cppuhelper/implbase1.hxx" #include "cppuhelper/exc_hlp.hxx" #include "comphelper/anytostring.hxx" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" + #include "com/sun/star/deployment/ui/PackageManagerDialog.hpp" #include "com/sun/star/ui/dialogs/XExecutableDialog.hpp" #include "com/sun/star/lang/DisposedException.hpp" @@ -149,12 +150,13 @@ void DialogClosedListenerImpl::dialogClosed( // installed with OOo 2.2 or later could not normally be found via its file // name. Reference findPackage( - Reference const & manager, + OUString const & repository, + Reference const & manager, Reference const & environment, OUString const & idOrFileName ) { Sequence< Reference > ps( - manager->getDeployedPackages( + manager->getDeployedExtensions(repository, Reference(), environment ) ); for ( sal_Int32 i = 0; i < ps.getLength(); ++i ) if ( dp_misc::getIdentifier( ps[i] ) == idOrFileName ) @@ -214,7 +216,7 @@ extern "C" int unopkg_main() bool subcmd_add = false; bool subcmd_gui = false; OUString logFile; - OUString deploymentContext; + OUString repository; OUString cmdArg; ::std::vector cmdPackages; @@ -279,7 +281,7 @@ extern "C" int unopkg_main() !readOption( &option_force, info_force, &nPos ) && !readOption( &option_bundled, info_bundled, &nPos ) && !readOption( &option_suppressLicense, info_suppressLicense, &nPos ) && - !readArgument( &deploymentContext, info_context, &nPos ) && + !readArgument( &repository, info_context, &nPos ) && !isBootstrapVariable(&nPos)) { osl_getCommandArg( nPos, &cmdArg.pData ); @@ -313,24 +315,30 @@ extern "C" int unopkg_main() } //make sure the bundled option was provided together with shared - if (option_bundled && !option_shared) - { - dp_misc::writeConsoleError( - "\nERROR: option --bundled can only be used together with --shared!"); - return 1; - } +// if (option_bundled && !option_shared) +// { +// dp_misc::writeConsoleError( +// "\nERROR: option --bundled can only be used together with --shared!"); +// return 1; +// } xComponentContext = getUNO( disposeGuard, option_verbose, option_shared, subcmd_gui, xLocalComponentContext ); - if (deploymentContext.getLength() == 0) { - deploymentContext = option_shared ? OUSTR("shared") : OUSTR("user"); + if (repository.getLength() == 0) + { + if (option_shared) + repository = OUSTR("shared"); + else if (option_bundled) + repository = OUSTR("bundled"); + else + repository = OUSTR("user"); } else { - if (deploymentContext.equalsAsciiL( + if (repository.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") )) { option_shared = true; } @@ -343,10 +351,9 @@ extern "C" int unopkg_main() } } - Reference xPackageManagerFactory( - deployment::thePackageManagerFactory::get( xComponentContext ) ); - Reference xPackageManager( - xPackageManagerFactory->getPackageManager( deploymentContext ) ); + + Reference xExtensionManager( + deployment::ExtensionManager::get( xComponentContext ) ); Reference< ::com::sun::star::ucb::XCommandEnvironment > xCmdEnv( createCmdEnv( xComponentContext, logFile, @@ -362,25 +369,23 @@ extern "C" int unopkg_main() OUString const & cmdPackage = cmdPackages[ pos ]; if (subcmd_add) { - Reference xPackage( - xPackageManager->addPackage( - cmdPackage, OUString() /* to be detected */, - Reference(), xCmdEnv ) ); - OSL_ASSERT( xPackage.is() ); + xExtensionManager->addExtension( + cmdPackage, repository, + Reference(), xCmdEnv); } else { try { - xPackageManager->removePackage( - cmdPackage, cmdPackage, + xExtensionManager->removeExtension( + cmdPackage, cmdPackage, repository, Reference(), xCmdEnv ); } catch (lang::IllegalArgumentException &) { Reference p( - findPackage( - xPackageManager, xCmdEnv, cmdPackage ) ); + findPackage(repository, + xExtensionManager, xCmdEnv, cmdPackage ) ); //Todo. temporary preventing exception in bundled case. //In case of a bundled extension, remove would be called as a result of //uninstalling a rpm. Then we do not want to show an error when the @@ -389,8 +394,9 @@ extern "C" int unopkg_main() if ( !p.is() && !option_bundled) throw; else if (p.is()) - xPackageManager->removePackage( + xExtensionManager->removeExtension( ::dp_misc::getIdentifier(p), p->getName(), + repository, Reference(), xCmdEnv ); } } @@ -399,18 +405,18 @@ extern "C" int unopkg_main() else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("reinstall") )) { - xPackageManager->reinstallDeployedPackages( - Reference(), xCmdEnv ); + xExtensionManager->reinstallDeployedExtensions( + repository, Reference(), xCmdEnv); } else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("list") )) { Sequence< Reference > packages; if (cmdPackages.empty()) { - packages = xPackageManager->getDeployedPackages( - Reference(), xCmdEnv ); + packages = xExtensionManager->getDeployedExtensions( + repository, Reference(), xCmdEnv ); dp_misc::writeConsole( - OUSTR("all deployed ") + deploymentContext + OUSTR(" packages:\n")); + OUSTR("all deployed ") + repository + OUSTR(" packages:\n")); } else { @@ -418,13 +424,13 @@ extern "C" int unopkg_main() for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos ) try { - packages[ pos ] = xPackageManager->getDeployedPackage( - cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv ); + packages[ pos ] = xExtensionManager->getDeployedExtension( + repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv ); } catch (lang::IllegalArgumentException &) { - packages[ pos ] = findPackage( - xPackageManager, xCmdEnv, cmdPackages[ pos ] ); + packages[ pos ] = findPackage(repository, + xExtensionManager, xCmdEnv, cmdPackages[ pos ] ); if ( !packages[ pos ].is() ) throw; } diff --git a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx index e4a503d98732..d23dcbf9577d 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx @@ -320,7 +320,7 @@ void CommandEnvironmentImpl::handle( deployment::VersionException nc_exc; if (request >>= nc_exc) { approve = m_option_force_overwrite || - (::dp_misc::comparePackageVersions(nc_exc.New, nc_exc.Deployed) + (::dp_misc::compareVersions(nc_exc.NewVersion, nc_exc.Deployed->getVersion()) == ::dp_misc::GREATER); abort = !approve; } -- cgit From d8411c3281b10eeea679e84697adfcd7c51b1657 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 19 Mar 2010 15:12:00 +0100 Subject: jl152 import 263439 from native0jl: #i77196# fix for XExtensionManager.getAllExtensions --- desktop/source/deployment/manager/dp_extensionmanager.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 469245bef340..1519e1f40596 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -936,7 +936,6 @@ uno::Sequence< uno::Sequence > > lang::IllegalArgumentException, uno::RuntimeException) { - uno::Sequence< uno::Sequence > > seqSeq; try { id2extensions mapExt; @@ -964,10 +963,13 @@ uno::Sequence< uno::Sequence > > ::std::vector< ::std::vector > >::const_iterator citVecVec = vecExtensions.begin(); sal_Int32 j = 0; + uno::Sequence< uno::Sequence > > seqSeq(vecExtensions.size()); for (;citVecVec != vecExtensions.end(); citVecVec++, j++) { seqSeq[j] = comphelper::containerToSequence(*citVecVec); } + return seqSeq; + } catch (deploy::DeploymentException& ) { throw; } catch (ucb::CommandFailedException & ) { @@ -983,9 +985,7 @@ uno::Sequence< uno::Sequence > > throw deploy::DeploymentException( OUSTR("Extension Manager: exception during enableExtension"), static_cast(this), exc); - } - - return seqSeq; + } } void ExtensionManager::reinstallDeployedExtensions( -- cgit From 67c12270ab84ac474cebe3ec4169688fa3120844 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 22 Mar 2010 12:35:33 +0100 Subject: jl152 import 263440 from native0jl: #i77196# removing of bundled/shared extension (except python, script) works now --- .../deployment/manager/dp_extensionmanager.cxx | 50 ++-- desktop/source/deployment/manager/dp_manager.cxx | 55 ++--- .../registry/component/dp_compbackenddb.cxx | 58 +++++ .../registry/component/dp_compbackenddb.hxx | 11 +- .../deployment/registry/component/dp_component.cxx | 132 +++++++---- .../registry/configuration/dp_configuration.cxx | 31 ++- desktop/source/deployment/registry/dp_backend.cxx | 149 ++++++++---- .../source/deployment/registry/dp_backenddb.cxx | 90 ++++++-- desktop/source/deployment/registry/dp_registry.cxx | 10 +- .../registry/executable/dp_executable.cxx | 25 +- .../source/deployment/registry/help/dp_help.cxx | 21 +- .../source/deployment/registry/inc/dp_backend.h | 68 ++++-- .../deployment/registry/inc/dp_backenddb.hxx | 6 + .../registry/package/dp_extbackenddb.cxx | 87 ++++--- .../registry/package/dp_extbackenddb.hxx | 11 +- .../deployment/registry/package/dp_package.cxx | 257 +++++++++++++-------- .../deployment/registry/script/dp_script.cxx | 15 +- .../source/deployment/registry/sfwk/dp_sfwk.cxx | 16 +- 18 files changed, 687 insertions(+), 405 deletions(-) (limited to 'desktop') 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 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 > listExtensions = - getExtensionsWithSameId(identifier, fileName); - ::std::list >::const_iterator - iext = listExtensions.begin(); - bool bCheckOptional = false; - Reference xActive; - for (; iext != listExtensions.end(); iext++) + Reference xExtension; + try + { //will throw an exception if the extension does not exist + xExtension = m_userRepository->getDeployedPackage( + identifier, fileName, Reference()); + } 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 const & xUser = listExtensions.front(); - if (xUser.is() - && xActive.is() - && xUser != xActive) + } + if (xExtension.is()) + { + beans::Optional > 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 xPackage( m_xRegistry->bindPackage( - url, OUString(), false, ucbContent.getCommandEnvironment() ) ); + url, OUString(), false, OUString(), ucbContent.getCommandEnvironment() ) ); const Reference xPackageType( xPackage->getPackageType() ); OSL_ASSERT( xPackageType.is() ); @@ -785,7 +785,7 @@ Reference 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(this), Any() ); - } Reference 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 PackageManagerImpl::getDeployedPackage_( static_cast(-1) ); } } - return m_xRegistry->bindPackage( - getDeployPath( data ), data.mediaType, false, xCmdEnv ); + Reference 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(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 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 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 name( +// doc->createElement(OUSTR("name")), UNO_QUERY_THROW); + +// componentNode->appendChild(name); + +// Reference nameValue( +// doc->createTextNode(data.name), +// UNO_QUERY_THROW); +// name->appendChild(nameValue); + Reference 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 doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + if (aNode.is()) + { +// const OUString sExprName(OUSTR("reg:name/text()")); + +// Reference nameValue = +// xpathApi->selectSingleNode(aNode, sExprName); +// retData.name = nameValue->getNodeValue(); + + const OUString sExprJavaTypeLib(OUSTR("reg:java-type-library/text()")); + + Reference 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 { + FileName true com.sun.star.comp.extensionoptions.OptionsEventHandler$_OptionsEventHandler @@ -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 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 getRDB_RO() const; public: - inline ComponentPackageImpl( + ComponentPackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference 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 const & xCmdEnv ); public: - inline TypelibraryPackageImpl( + TypelibraryPackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference 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 bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bNoFileAccess, OUString const & identifier, Reference 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 const & myBackend, + OUString const & url, OUString const & name, + Reference 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 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 > @@ -605,7 +624,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ) { OUString mediaType(mediaType_); @@ -661,9 +680,14 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); - const OUString name( ucbContent.getPropertyValue( - StrTitle::get() ).get() ); + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); + name = ucbContent.getPropertyValue( + StrTitle::get() ).get(); + } + if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.uno-component")) { // xxx todo: probe and evaluate component xml description @@ -679,19 +703,19 @@ Reference 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 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 xSet( that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW ); @@ -1405,6 +1435,16 @@ void BackendImpl::ComponentPackageImpl::processPackage_( } //############################################################################## +BackendImpl::TypelibraryPackageImpl::TypelibraryPackageImpl( + ::rtl::Reference const & myBackend, + OUString const & url, OUString const & name, + Reference 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 const & myBackend, OUString const & url, OUString const & name, Reference 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 bindPackage_( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ); + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference const & xCmdEnv ); ::std::auto_ptr m_registeredPackages; // for backwards compatibility @@ -215,7 +215,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -250,20 +250,27 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); + name = ucbContent.getPropertyValue( + StrTitle::get() ).get(); + } + ::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(), - 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(), - 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 PackageRegistryBackend::bindPackage( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess , - Reference const & xCmdEnv ) - throw (deployment::DeploymentException, CommandFailedException, + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference 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 xPackage( iFind->second ); + if (xPackage.is()) { - Reference 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(this), 1); + if (xPackage->isRemoved() != bRemoved) + throw deployment::InvalidRemovedParameterException( + OUSTR("XPackageRegistry::bindPackage: bRemoved parameter does not match"), + static_cast(this), xPackage->isRemoved(), xPackage); + return xPackage; } } + guard.clear(); Reference xNewPackage; try { - xNewPackage = bindPackage_( url, mediaType, bNoFileAccess, xCmdEnv ); + xNewPackage = bindPackage_( url, mediaType, bRemoved, identifier, xCmdEnv ); } catch (RuntimeException &) { throw; @@ -175,24 +187,22 @@ Reference 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(insertion.first->second) - == xNewPackage ); - } - else - { // found existing entry - Reference 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(insertion.first->second) + == xNewPackage ); } + else + { // found existing entry + Reference 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 const & myBackend, OUString const & name, OUString const & displayName, Reference 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 Package::getIdentifier() throw (RuntimeException) { + if (m_bRemoved) + return beans::Optional(true, m_identifier); + return beans::Optional(); } //______________________________________________________________________________ -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 Package::getUpdateInformationURLs() throw (RuntimeException) +Sequence Package::getUpdateInformationURLs() throw ( + deployment::ExtensionRemovedException, RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return Sequence(); } //______________________________________________________________________________ -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 Package::getPackageType() void Package::exportTo( OUString const & destFolderURL, OUString const & newTitle, sal_Int32 nameClashAction, Reference 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 const & xAbortChannel, Reference 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 xpathApi = getXPathAPI(); - OUString sExprPairs( - sListTagName + OUSTR("/") + sPairTagName); - Reference 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 aPair = listPairs->item(i); - OUString sExprFirst(sFirstTagName + OUSTR("/text()")); - Reference first = - xpathApi->selectSingleNode(aPair, sExprFirst); - - OUString sExprSecond(sSecondTagName + OUSTR("/text()")); - Reference 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 xpathApi = getXPathAPI(); + OUString sExprPairs( + sListTagName + OUSTR("/") + sPairTagName); + Reference 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 aPair = listPairs->item(i); + OUString sExprFirst(sFirstTagName + OUSTR("/text()")); + Reference first = + xpathApi->selectSingleNode(aPair, sExprFirst); + + OUString sExprSecond(sSecondTagName + OUSTR("/text()")); + Reference 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 const & parent, + OUString const & sListTagName, + OUString const & sMemberTagName) +{ + try + { + OSL_ASSERT(parent.is()); + Reference xpathApi = getXPathAPI(); + OUString sExprList( + sListTagName + OUSTR("/") + sMemberTagName + OUSTR("/text()")); + Reference list = + xpathApi->selectNodeList(parent, sExprList); + + ::std::list retList; + sal_Int32 length = list->getLength(); + for (sal_Int32 i = 0; i < length; i++) + { + Reference 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 SAL_CALL bindPackage( OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ) + OUString const & identifier, Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException); virtual Sequence< Reference > SAL_CALL @@ -458,8 +458,8 @@ void PackageRegistryImpl::update() throw (RuntimeException) // XPackageRegistry //______________________________________________________________________________ Reference PackageRegistryImpl::bindPackage( - OUString const & url, OUString const & mediaType_, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ) + OUString const & url, OUString const & mediaType_, sal_Bool bRemoved, + OUString const & identifier, Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException) { @@ -497,7 +497,7 @@ Reference 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 PackageRegistryImpl::bindPackage( getResourceString(RID_STR_UNSUPPORTED_MEDIA_TYPE) + mediaType, static_cast(this), static_cast(-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 const & myBackend, OUString const & url, OUString const & name, - Reference const & xPackageType, bool bUseDb) + Reference 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 bindPackage_( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ); + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference const & xCmdEnv ); Reference m_xExecutableTypeInfo; @@ -125,8 +126,8 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) // PackageRegistryBackend Reference BackendImpl::bindPackage_( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ) + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, + OUString const & identifier, Reference const & xCmdEnv ) { if (mediaType.getLength() == 0) { @@ -141,13 +142,17 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { - ::ucbhelper::Content ucbContent( url, xCmdEnv ); - const OUString name( ucbContent.getPropertyValue( - dp_misc::StrTitle::get() ).get() ); + OUString name; + if (!bRemoved) + { + ::ucbhelper::Content ucbContent( url, xCmdEnv ); + name = ucbContent.getPropertyValue( + dp_misc::StrTitle::get() ).get(); + } 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 const & myBackend, OUString const & url, OUString const & name, Reference 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 bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage ); @@ -140,7 +140,7 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ) { // we don't support auto detection: @@ -155,14 +155,19 @@ Reference 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(); + } + if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.help")) { return new PackageImpl( - this, url, - ucbContent.getPropertyValue( StrTitle::get() ).get(), - 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 #include #include "dp_registry.hrc" @@ -74,7 +75,9 @@ protected: ::rtl::OUString m_name; ::rtl::OUString m_displayName; const css::uno::Reference 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 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 const & xAbortChannel, css::uno::Reference 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 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 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 bindPackage_( ::rtl::OUString const & url, ::rtl::OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, ::rtl::OUString const & identifier, css::uno::Reference const & xCmdEnv ) = 0; @@ -315,14 +335,12 @@ public: // XPackageRegistry virtual css::uno::Reference SAL_CALL bindPackage( ::rtl::OUString const & url, ::rtl::OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, ::rtl::OUString const & identifier, css::uno::Reference 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 > 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 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); // ... - Reference identifierNode( - doc->createElement(OUSTR("identifier")), UNO_QUERY_THROW); - extensionNodeNode->appendChild(identifierNode); +// Reference identifierNode( +// doc->createElement(OUSTR("identifier")), UNO_QUERY_THROW); +// extensionNodeNode->appendChild(identifierNode); - Reference identifierValue( - doc->createTextNode(data.identifier), UNO_QUERY_THROW); - identifierNode->appendChild(identifierValue); +// Reference 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 doc = getDocument(); - Reference root = doc->getFirstChild(); - - Reference xpathApi = getXPathAPI(); - //find the extension element that is to be removed - Reference aNode = - xpathApi->selectSingleNode(root, sExpression); - OSL_ASSERT(aNode.is()); - - const OUString sExprIdentifier(OUSTR("reg:identifier/text()")); - - Reference 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 doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + if (aNode.is()) + { +// const OUString sExprIdentifier(OUSTR("reg:identifier/text()")); + +// Reference 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 > m_bundle; Sequence< Reference > * m_pBundle; - ExtensionBackendDb::Data m_data; + ExtensionBackendDb::Data m_dbData; Reference bindBundleItem( OUString const & url, OUString const & mediaType, - Reference const & xCmdEnv, + sal_Bool bRemoved, //that is, useing data base information + OUString const & identifier, + Reference const & xCmdEnv, bool notifyDetectionError = true ); typedef ::std::vector< Reference > t_packagevec; void scanBundle( t_packagevec & bundle, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv ); + Reference const & xCmdEnv ); void scanLegacyBundle( t_packagevec & bundle, OUString const & url, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv, + Reference const & xCmdEnv, bool skip_registration = false ); - ::std::vector > getPackagesFromDb(); + ::std::vector > getPackagesFromDb( + Reference const & xCmdEnv); bool checkPlatform( - css::uno::Reference< css::ucb::XCommandEnvironment > const & environment); + Reference const & environment); bool checkDependencies( - css::uno::Reference< css::ucb::XCommandEnvironment > const & + Reference 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 > isRegistered_( ::osl::ResettableMutexGuard & guard, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv ); + Reference const & xCmdEnv ); virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv ); + Reference const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -171,51 +174,66 @@ class BackendImpl : public ImplBaseT OUString const & name, Reference const & xPackageType, bool legacyBundle, - bool useDb); + bool bRemoved, + OUString const & identifier); // XPackage virtual sal_Bool SAL_CALL isBundle() throw (RuntimeException); + virtual Sequence< Reference > SAL_CALL getBundle( Reference const & xAbortChannel, - Reference const & xCmdEnv ) + Reference 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 const & xCmdEnv ) - throw (CommandFailedException, CommandAbortedException, + Reference 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 SAL_CALL getIdentifier() throw (RuntimeException); - virtual OUString SAL_CALL getVersion() throw (RuntimeException); + virtual OUString SAL_CALL getVersion() + throw (deployment::ExtensionRemovedException, RuntimeException); virtual Sequence 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 bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, - Reference const & xCmdEnv ); + sal_Bool bRemoved, OUString const & identifier, + Reference const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -344,8 +362,8 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) //______________________________________________________________________________ Reference BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, - Reference const & xCmdEnv ) + sal_Bool bRemoved, OUString const & identifier, + Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); if (mediaType.getLength() == 0) @@ -393,21 +411,24 @@ Reference 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(); + } 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 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 > BackendImpl::PackageImpl::isRegistered_( ::osl::ResettableMutexGuard &, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv ) + Reference 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 > 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 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 BackendImpl::PackageImpl::getIdentifier() OUString BackendImpl::PackageImpl::getVersion() throw (RuntimeException) { + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); return getDescriptionInfoset().getVersion(); } Sequence 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 const & abortChannel, - Reference const & xCmdEnv ) + Reference const & xCmdEnv ) { const Sequence< Reference > 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 const & xCmdEnv ) - throw (CommandFailedException, CommandAbortedException, RuntimeException) + sal_Int32 nameClashAction, Reference 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(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(this), Any() ); } @@ -1033,11 +1081,11 @@ void BackendImpl::PackageImpl::exportTo( while (xResultSet->next()) { ::ucbhelper::Content subContent( - Reference( + Reference( 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(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(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 > BackendImpl::PackageImpl::getBundle( Reference const & xAbortChannel, - Reference const & xCmdEnv ) + Reference const & xCmdEnv ) throw (deployment::DeploymentException, - CommandFailedException, CommandAbortedException, + ucb::CommandFailedException, ucb::CommandAbortedException, lang::IllegalArgumentException, RuntimeException) { Sequence< Reference > * 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 > BackendImpl::PackageImpl::getBundle( if (mediaType.getLength() > 0) { const Reference 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 > 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 BackendImpl::PackageImpl::bindBundleItem( OUString const & url, OUString const & mediaType, - Reference const & xCmdEnv, + sal_Bool bRemoved, OUString const & identifier, + Reference const & xCmdEnv, bool notifyDetectionError ) { // ignore any nested bundles: @@ -1312,13 +1362,13 @@ Reference BackendImpl::PackageImpl::bindBundleItem( ReferencexPackage; 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 BackendImpl::PackageImpl::bindBundleItem( void BackendImpl::PackageImpl::scanBundle( t_packagevec & bundle, ::rtl::Reference const & abortChannel, - Reference const & xCmdEnv ) + Reference 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 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 const & abortChannel, - Reference const & xCmdEnv, + Reference const & xCmdEnv, bool skip_registration ) { ::ucbhelper::Content ucbContent( url, xCmdEnv ); @@ -1523,8 +1573,8 @@ void BackendImpl::PackageImpl::scanLegacyBundle( OUString mediaType; const Reference 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 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 > BackendImpl::PackageImpl::getPackagesFromDb() +::std::vector > +BackendImpl::PackageImpl::getPackagesFromDb( + Reference const & xCmdEnv) { - //get the data base entry for this extension + ::std::vector > retVector; + + typedef ::std::vector< ::std::pair >::const_iterator ITC; + for (ITC i = m_dbData.items.begin(); i != m_dbData.items.end(); i++) + { + Reference xExtension = + bindBundleItem(i->first, i->second, true, m_identifier, xCmdEnv); + OSL_ASSERT(xExtension.is()); + retVector.push_back(xExtension); + } - return ::std::vector >(); + 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 const &xCmdEnv, OUString const & scriptURL, OUString const & dialogURL, - bool bUseDb); + bool bRemoved, OUString const & identifier); }; friend class PackageImpl; // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); @@ -125,11 +125,12 @@ BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference const & myBackend, OUString const & url, Reference 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 BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType_, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); @@ -234,7 +235,7 @@ Reference 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 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 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 bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); const Reference m_xTypeInfo; @@ -133,9 +134,10 @@ OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) //______________________________________________________________________________ BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference 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 BackendImpl::bindPackage_( - OUString const & url, OUString const & mediaType_, sal_Bool bNoFileAccess, - Reference const & xCmdEnv ) + OUString const & url, OUString const & mediaType_, sal_Bool bRemoved, + OUString const & identifier, Reference const & xCmdEnv ) { OUString mediaType( mediaType_ ); if (mediaType.getLength() == 0) @@ -296,7 +298,7 @@ Reference 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); } } } -- cgit From a13b1c857a8bc6657a14eb46e7e9663ff2bc9fa4 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 25 Mar 2010 10:32:07 +0100 Subject: jl152 import 263441 from native0jl:#i77196# add and remove in the same process now works, help backend creates a unique folder for every extension --- desktop/source/deployment/manager/dp_manager.cxx | 74 +++- .../registry/component/dp_compbackenddb.cxx | 61 ++- .../registry/component/dp_compbackenddb.hxx | 2 +- desktop/source/deployment/registry/dp_backend.cxx | 86 ++++ .../source/deployment/registry/dp_backenddb.cxx | 36 +- desktop/source/deployment/registry/dp_registry.cxx | 2 +- .../source/deployment/registry/help/dp_help.cxx | 463 ++++++++++++--------- .../deployment/registry/help/dp_helpbackenddb.cxx | 224 ++++++++++ .../deployment/registry/help/dp_helpbackenddb.hxx | 101 +++++ .../source/deployment/registry/help/makefile.mk | 3 +- .../source/deployment/registry/inc/dp_backend.h | 18 + .../deployment/registry/inc/dp_backenddb.hxx | 5 + .../registry/package/dp_extbackenddb.cxx | 48 +-- .../registry/package/dp_extbackenddb.hxx | 2 +- 14 files changed, 836 insertions(+), 289 deletions(-) create mode 100644 desktop/source/deployment/registry/help/dp_helpbackenddb.cxx create mode 100644 desktop/source/deployment/registry/help/dp_helpbackenddb.hxx (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 9b4f51ea89dd..e2580e7b955b 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -39,6 +39,7 @@ #include "rtl/bootstrap.hxx" #include "osl/diagnose.h" #include "osl/file.hxx" +#include "osl/security.hxx" #include "cppuhelper/weakref.hxx" #include "cppuhelper/exc_hlp.hxx" #include "cppuhelper/implbase1.hxx" @@ -237,23 +238,37 @@ void PackageManagerImpl::initActivationLayer( ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); // get all temp directories: ::std::vector tempEntries; + ::std::vector removedEntries; while (xResultSet->next()) { OUString title( Reference( xResultSet, UNO_QUERY_THROW )->getString( 1 /* Title */ ) ); - const char extensionRemoved[] = ".tmpremoved"; + + const char extensionRemoved[] = "removed"; if (title.endsWithAsciiL( extensionRemoved, sizeof(extensionRemoved) - 1)) - continue; - - tempEntries.push_back( ::rtl::Uri::encode( - title, rtl_UriCharClassPchar, - rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_UTF8 ) ); + { + //save the file name withouth the "removed" part + sal_Int32 index = title.lastIndexOfAsciiL( + extensionRemoved, sizeof(extensionRemoved) - 1); + OUString remFile = title.copy(0, index); + removedEntries.push_back(::rtl::Uri::encode( + remFile, rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ) ); + } + else + { + tempEntries.push_back( ::rtl::Uri::encode( + title, rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ) ); + } } + bool bShared = m_context.equals(OUSTR("shared")) ? true : false; for ( ::std::size_t pos = 0; pos < tempEntries.size(); ++pos ) { OUString const & tempEntry = tempEntries[ pos ]; @@ -261,9 +276,44 @@ void PackageManagerImpl::initActivationLayer( if (::std::find_if( id2temp.begin(), id2temp.end(), match ) == id2temp.end()) { + const OUString url( + makeURL(m_activePackages_expanded, tempEntry ) ); + + //In case of shared extensions, new entries are regarded as + //added extensions if there is no xxx.tmpremoved file. + if (bShared) + { + if (::std::find(removedEntries.begin(), removedEntries.end(), tempEntry) == + removedEntries.end()) + { + continue; + } + else + { + //Make sure only the same user removes the extension, who + //previously unregistered it. This is avoid races if multiple instances + //of OOo are running which all have write access to the shared installation. + //For example, user a uses extension a, removes the extension, but keeps OOo + //running. Parts of the extension may still be loaded and used by OOo. + //Therefore the extension is only deleted the next time the extension manager is + //run after restarting OOo. While OOo is still running, another user starts OOo + //which would deleted the extension files. If the same user starts another + //instance of OOo then the lock file will prevent this. + OUString aUserName; + ::osl::Security aSecurity; + aSecurity.getUserName( aUserName ); + ucbhelper::Content remFileContent( + url + OUSTR("removed"), Reference()); + ::rtl::ByteSequence data = dp_misc::readFile(remFileContent); + ::rtl::OString osData(reinterpret_cast(data.getConstArray()), + data.getLength()); + OUString sData = ::rtl::OStringToOUString( + osData, RTL_TEXTENCODING_UTF8); + if (!sData.equals(aUserName)) + continue; + } + } // temp entry not needed anymore: - const OUString url( makeURL( m_activePackages_expanded, - tempEntry ) ); erase_path( url + OUSTR("_"), Reference(), false /* no throw: ignore errors */ ); @@ -911,7 +961,11 @@ void PackageManagerImpl::removePackage( OUString url(makeURL(m_activePackages_expanded, val.temporaryName + OUSTR("removed"))); ::ucbhelper::Content contentRemoved(url, xCmdEnv ); - ::rtl::OString stamp("1"); + OUString aUserName; + ::osl::Security aSecurity; + aSecurity.getUserName( aUserName ); + + ::rtl::OString stamp = ::rtl::OUStringToOString(aUserName, RTL_TEXTENCODING_UTF8); Reference xData( ::xmlscript::createInputStream( ::rtl::ByteSequence( diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx index a942b81a7e32..568ecca08138 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx @@ -44,6 +44,7 @@ using namespace ::com::sun::star::uno; using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/component-registry/2010" +#define NS_PREFIX "comp" #define ROOT_ELEMENT_NAME "component-backend-db" namespace dp_registry { @@ -62,6 +63,11 @@ OUString ComponentBackendDb::getDbNSName() return OUSTR(EXTENSION_REG_NS); } +OUString ComponentBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + OUString ComponentBackendDb::getRootElementName() { return OUSTR(ROOT_ELEMENT_NAME); @@ -70,20 +76,21 @@ OUString ComponentBackendDb::getRootElementName() void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); Reference doc = getDocument(); Reference root = doc->getFirstChild(); #if OSL_DEBUG_LEVEL > 0 //There must not be yet an entry with the same url OUString sExpression( - OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + sPrefix + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); Reference _extensionNode = getXPathAPI()->selectSingleNode(root, sExpression); OSL_ASSERT(! _extensionNode.is()); #endif Reference componentElement( - doc->createElement(OUSTR("component"))); + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":component"))); componentElement->setAttribute(OUSTR("url"), url); @@ -92,18 +99,8 @@ void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data root->appendChild(componentNode); -// Reference name( -// doc->createElement(OUSTR("name")), UNO_QUERY_THROW); - -// componentNode->appendChild(name); - -// Reference nameValue( -// doc->createTextNode(data.name), -// UNO_QUERY_THROW); -// name->appendChild(nameValue); - Reference javaTypeLibNode( - doc->createElement(OUSTR("java-type-library")), UNO_QUERY_THROW); + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":java-type-library")), UNO_QUERY_THROW); componentNode->appendChild(javaTypeLibNode); @@ -114,16 +111,16 @@ void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data writeSimpleList( data.implementationNames, - OUSTR("implementation-names"), - OUSTR("name"), + sPrefix + OUSTR(":implementation-names"), + sPrefix + OUSTR(":name"), componentNode); writeVectorOfPair( data.singletons, - OUSTR("singletons"), - OUSTR("item"), - OUSTR("key"), - OUSTR("value"), + sPrefix + OUSTR(":singletons"), + sPrefix + OUSTR(":item"), + sPrefix + OUSTR(":key"), + sPrefix + OUSTR(":value"), componentNode); save(); @@ -140,7 +137,7 @@ void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data void ComponentBackendDb::removeEntry(::rtl::OUString const & url) { OUString sExpression( - OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + OUSTR(NS_PREFIX) + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); removeElement(sExpression); } @@ -148,9 +145,10 @@ ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & ur { try { + const OUString sPrefix = getNSPrefix(); ComponentBackendDb::Data retData; const OUString sExpression( - OUSTR("reg:component[@url = \"") + url + OUSTR("\"]")); + sPrefix + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); Reference doc = getDocument(); Reference root = doc->getFirstChild(); @@ -160,13 +158,7 @@ ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & ur xpathApi->selectSingleNode(root, sExpression); if (aNode.is()) { -// const OUString sExprName(OUSTR("reg:name/text()")); - -// Reference nameValue = -// xpathApi->selectSingleNode(aNode, sExprName); -// retData.name = nameValue->getNodeValue(); - - const OUString sExprJavaTypeLib(OUSTR("reg:java-type-library/text()")); + const OUString sExprJavaTypeLib(sPrefix + OUSTR(":java-type-library/text()")); Reference idValueNode = xpathApi->selectSingleNode(aNode, sExprJavaTypeLib); @@ -175,12 +167,17 @@ ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & ur retData.implementationNames = readList( - aNode, OUSTR("reg:implementation-names"), OUSTR("reg:name")); + aNode, + sPrefix + OUSTR(":implementation-names"), + sPrefix + OUSTR(":name")); retData.singletons = readVectorOfPair( - aNode, OUSTR("reg:singletons"), OUSTR("item"), OUSTR("key"), - OUSTR("value")); + aNode, + sPrefix + OUSTR(":singletons"), + sPrefix + OUSTR(":item"), + sPrefix + OUSTR(":key"), + sPrefix + OUSTR(":value")); } return retData; } diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx index 29ac4e50fe88..90ff41f2a4b8 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx @@ -83,7 +83,7 @@ class ComponentBackendDb: public dp_registry::backend::BackendDb { protected: virtual ::rtl::OUString getDbNSName(); - + virtual ::rtl::OUString getNSPrefix(); virtual ::rtl::OUString getRootElementName(); public: diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index 7ee49fc46734..dcfc2c6b3d2f 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -31,13 +31,18 @@ #include "dp_backend.h" #include "dp_ucb.h" #include "rtl/uri.hxx" +#include "osl/file.hxx" #include "cppuhelper/exc_hlp.hxx" #include "comphelper/servicedecl.hxx" #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/ucb/InteractiveAugmentedIOException.hpp" +#include "com/sun/star/ucb/IOErrorCode.hpp" #include "com/sun/star/beans/StringPair.hpp" +#include "com/sun/star/sdbc/XResultSet.hpp" +#include "com/sun/star/sdbc/XRow.hpp" using namespace ::dp_misc; @@ -208,6 +213,87 @@ Reference PackageRegistryBackend::bindPackage( return xNewPackage; } +OUString PackageRegistryBackend::createFolder( + OUString const & relUrl, + Reference const & xCmdEnv) +{ + OUString sDataFolder = makeURL(getCachePath(), relUrl); + //make sure the folder exist + ucbhelper::Content dataContent; + ::dp_misc::create_folder(&dataContent, sDataFolder, xCmdEnv); + + OUString sDataFolderURL = dp_misc::expandUnoRcUrl(sDataFolder); + + OUString tempEntry; + if (::osl::File::createTempFile( + &sDataFolderURL, 0, &tempEntry ) != ::osl::File::E_None) + throw RuntimeException( + OUSTR("::osl::File::createTempFile() failed!"), 0 ); + tempEntry = tempEntry.copy( tempEntry.lastIndexOf( '/' ) + 1 ); + OUString destFolder= makeURL(sDataFolder, tempEntry) + OUSTR("_"); + ::ucbhelper::Content destFolderContent; + dp_misc::create_folder( &destFolderContent, destFolder, xCmdEnv ); + + return destFolder; +} + +void PackageRegistryBackend::deleteUnusedFolders( + OUString const & relUrl, + ::std::list< OUString> const & usedFolders) +{ + try + { + const OUString sDataFolder = makeURL(getCachePath(), relUrl); + ::ucbhelper::Content tempFolder( + sDataFolder, Reference()); + Reference xResultSet( + tempFolder.createCursor( + Sequence( &StrTitle::get(), 1 ), + ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); + // get all temp directories: + ::std::vector tempEntries; + + char tmp[] = ".tmp"; + + while (xResultSet->next()) + { + OUString title( + Reference( + xResultSet, UNO_QUERY_THROW )->getString( + 1 /* Title */ ) ); + + if (title.endsWithAsciiL(tmp, sizeof(tmp) - 1)) + tempEntries.push_back( + makeURLAppendSysPathSegment(sDataFolder, title)); + } + + for ( ::std::size_t pos = 0; pos < tempEntries.size(); ++pos ) + { + //usedFolders contains the urls to the folders which have + //a trailing underscore + const OUString tempFile = tempEntries[ pos ]; + const OUString tempFolder = tempFile + OUSTR("_"); + + if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolder ) == + usedFolders.end()) + { + erase_path( tempFolder, Reference(), + false /* no throw: ignore errors */ ); + erase_path( tempFile, Reference(), + false /* no throw: ignore errors */ ); + } + } + } + catch (ucb::InteractiveAugmentedIOException& e) + { + //In case the folder containing all the data folder does not + //exist yet, we ignore the exception + if (e.Code != ucb::IOErrorCode_NOT_EXISTING) + throw e; + } + +} + //############################################################################## //______________________________________________________________________________ diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 339236126796..1c0451c77cd6 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -98,9 +98,10 @@ css::uno::Reference BackendDb::getDocument() //Create a new document and insert some basic stuff m_doc = xDocBuilder->newDocument(); Reference rootNode = - m_doc->createElement(getRootElementName()); - rootNode->setAttribute( - OUSTR("xmlns"), getDbNSName()); + m_doc->createElementNS(getDbNSName(), getNSPrefix() + + OUSTR(":") + getRootElementName()); +// rootNode->setAttribute( +// OUSTR("xmlns"), getDbNSName()); m_doc->appendChild(Reference( rootNode, UNO_QUERY_THROW)); save(); @@ -133,23 +134,12 @@ Reference BackendDb::getXPathAPI() OUSTR(" Could not create service com.sun.star.xml.xpath.XPathAPI"), 0); m_xpathApi->registerNS( - OUSTR("reg"), getDbNSName()); + getNSPrefix(), getDbNSName()); } return m_xpathApi; } -// OUString BackendDb::getDbNSName() -// { -// return OUString(); -// } - - -// OUString BackendDb::getRootElementName() -// { -// return OUString(); -// } - void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) { try @@ -193,12 +183,13 @@ void BackendDb::writeVectorOfPair( css::uno::Reference const & xParent) { try{ - + const OUString sNameSpace = getDbNSName(); + OSL_ASSERT(sNameSpace.getLength()); Reference doc = getDocument(); Reference root = doc->getFirstChild(); Reference vectorNode( - doc->createElement(sVectorTagName)); + doc->createElementNS(sNameSpace, sVectorTagName)); xParent->appendChild( Reference( @@ -207,14 +198,14 @@ void BackendDb::writeVectorOfPair( for (CIT i = vecPairs.begin(); i != vecPairs.end(); i++) { Reference pairNode( - doc->createElement(sPairTagName)); + doc->createElementNS(sNameSpace, sPairTagName)); vectorNode->appendChild( Reference( pairNode, css::uno::UNO_QUERY_THROW)); Reference firstNode( - doc->createElement(sFirstTagName)); + doc->createElementNS(sNameSpace, sFirstTagName)); pairNode->appendChild( Reference( @@ -228,7 +219,7 @@ void BackendDb::writeVectorOfPair( firstTextNode, css::uno::UNO_QUERY_THROW)); Reference secondNode( - doc->createElement(sSecondTagName)); + doc->createElementNS(sNameSpace, sSecondTagName)); pairNode->appendChild( Reference( @@ -304,10 +295,11 @@ void BackendDb::writeSimpleList( { try { + const OUString sNameSpace = getDbNSName(); Reference doc = getDocument(); Reference listNode( - doc->createElement(sListTagName)); + doc->createElementNS(sNameSpace, sListTagName)); xParent->appendChild( Reference( @@ -317,7 +309,7 @@ void BackendDb::writeSimpleList( for (ITC_ITEMS i = list.begin(); i != list.end(); i++) { Reference memberNode( - doc->createElement(sMemberTagName), css::uno::UNO_QUERY_THROW); + doc->createElementNS(sNameSpace, sMemberTagName), css::uno::UNO_QUERY_THROW); listNode->appendChild(memberNode); diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index 0b3b9e80a7d7..e35b37bdeb07 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -115,6 +115,7 @@ protected: virtual ~PackageRegistryImpl(); PackageRegistryImpl() : t_helper( getMutex() ) {} + public: static Reference create( OUString const & context, @@ -536,7 +537,6 @@ PackageRegistryImpl::getSupportedPackageTypes() throw (RuntimeException) { return comphelper::containerToSequence(m_typesInfos); } - } // anon namespace //============================================================================== diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 9fd9e7ae79fc..b594f9395ceb 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -30,9 +30,11 @@ #include "dp_help.hrc" #include "dp_backend.h" +#include "dp_helpbackenddb.hxx" #include "dp_ucb.h" #include "rtl/uri.hxx" #include "osl/file.hxx" +#include "rtl/bootstrap.hxx" #include "ucbhelper/content.hxx" #include "comphelper/servicedecl.hxx" #include "svl/inettype.hxx" @@ -45,6 +47,7 @@ #include #include + using namespace ::dp_misc; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -63,6 +66,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend { BackendImpl * getMyBackend() const; + HelpBackendDb::Data m_dbData; + // Package virtual beans::Optional< beans::Ambiguous > isRegistered_( ::osl::ResettableMutexGuard & guard, @@ -79,9 +84,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - bool bRemoved, OUString const & identifier) - : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) - {} + bool bRemoved, OUString const & identifier); }; friend class PackageImpl; @@ -91,18 +94,25 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); - void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage ); + void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage, + Reference const & xCmdEnv); void implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ); rtl::OUString getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ); rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); rtl::OUString getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ); rtl::OUString expandURL( const rtl::OUString& aURL ); + + void addDataToDb(OUString const & url, HelpBackendDb::Data const & data); + HelpBackendDb::Data readDataFromDb(OUString const & url); + void deleteDataFromDb(OUString const & url); + Reference< ucb::XSimpleFileAccess > getFileAccess( void ); Reference< ucb::XSimpleFileAccess > m_xSFA; const Reference m_xHelpTypeInfo; Sequence< Reference > m_typeInfos; + std::auto_ptr m_backendDb; public: BackendImpl( Sequence const & args, @@ -126,6 +136,20 @@ BackendImpl::BackendImpl( m_typeInfos( 1 ) { m_typeInfos[ 0 ] = m_xHelpTypeInfo; + if (!transientMode()) + { + OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml")); + m_backendDb.reset( + new HelpBackendDb(getComponentContext(), dbFile)); + + //clean up data folders which are no longer used. + //This must not be done in the same process where the help files + //are still registers. Only after revoking and restarting OOo the folders + //can be removed. This works now, because the extension manager is a singleton + //and the backends are only create once per process. + ::std::list folders = m_backendDb->getAllDataUrls(); + deleteUnusedFolders(OUString(), folders); + } } // XPackageRegistry @@ -177,8 +201,39 @@ Reference BackendImpl::bindPackage_( static_cast(-1) ); } +void BackendImpl::addDataToDb( + OUString const & url, HelpBackendDb::Data const & data) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url, data); +} + +HelpBackendDb::Data BackendImpl::readDataFromDb( + OUString const & url) +{ + HelpBackendDb::Data data; + if (m_backendDb.get()) + data = m_backendDb->getEntry(url); + return data; +} + +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} //############################################################################## +BackendImpl::PackageImpl::PackageImpl( + ::rtl::Reference const & myBackend, + OUString const & url, OUString const & name, + Reference const & xPackageType, + bool bRemoved, OUString const & identifier) + : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) +{ + if (bRemoved) + m_dbData = getMyBackend()->readDataFromDb(url); +} // Package BackendImpl * BackendImpl::PackageImpl::getMyBackend() const @@ -226,7 +281,14 @@ void BackendImpl::PackageImpl::processPackage_( BackendImpl* that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); - that->implProcessHelp( xThisPackage, doRegisterPackage ); + that->implProcessHelp( xThisPackage, doRegisterPackage, xCmdEnv); + +// HelpBackendDb::Data data; +// getMyBackend()->addDataToDb(getURL(), data); + +// } +// else +// getMyBackend()->deleteDataFromDb(getURL()); } //############################################################################## @@ -234,235 +296,246 @@ void BackendImpl::PackageImpl::processPackage_( static rtl::OUString aSlash( rtl::OUString::createFromAscii( "/" ) ); static rtl::OUString aHelpStr( rtl::OUString::createFromAscii( "help" ) ); + void BackendImpl::implProcessHelp - ( Reference< deployment::XPackage > xPackage, bool doRegisterPackage ) +( Reference< deployment::XPackage > xPackage, bool doRegisterPackage, + Reference const & xCmdEnv) { - if( !xPackage.is() ) - return; - - Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess(); - - rtl::OUString aRegisteredFlagFile = getRegisteredFlagFileURL( xPackage ); - if( !doRegisterPackage ) + OSL_ASSERT(xPackage.is()); + if (doRegisterPackage) { - if( xSFA->exists( aRegisteredFlagFile ) ) - xSFA->kill( aRegisteredFlagFile ); - return; - } + HelpBackendDb::Data data; + Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess(); - bool bCompile = true; - rtl::OUString aCompiledFlagFile = getCompiledFlagFileURL( xPackage ); - if( xSFA->exists( aCompiledFlagFile ) ) - bCompile = false; - - if( bCompile ) - { - rtl::OUString aHelpURL = xPackage->getURL(); - rtl::OUString aExpandedHelpURL = expandURL( aHelpURL ); - rtl::OUString aName = xPackage->getName(); - if( !xSFA->isFolder( aExpandedHelpURL ) ) + rtl::OUString aRegisteredFlagFile = getRegisteredFlagFileURL( xPackage ); + if( !doRegisterPackage ) { - rtl::OUString aErrStr = getResourceString( RID_STR_HELPPROCESSING_GENERAL_ERROR ); - aErrStr += rtl::OUString::createFromAscii( "No help folder" ); - OWeakObject* oWeakThis = static_cast(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + if( xSFA->exists( aRegisteredFlagFile ) ) + xSFA->kill( aRegisteredFlagFile ); + return; } - Reference const & xContext = getComponentContext(); - Reference< script::XInvocation > xInvocation; - if( xContext.is() ) + bool bCompile = true; + rtl::OUString aCompiledFlagFile = getCompiledFlagFileURL( xPackage ); + if( xSFA->exists( aCompiledFlagFile ) ) + bCompile = false; + + if( bCompile ) { - try + OUString sHelpFolder = createFolder(OUString(), xCmdEnv); + data.dataUrl = sHelpFolder; + rtl::OUString aHelpURL = xPackage->getURL(); + rtl::OUString aExpandedHelpURL = expandURL( aHelpURL ); + rtl::OUString aName = xPackage->getName(); + if( !xSFA->isFolder( aExpandedHelpURL ) ) { - xInvocation = Reference< script::XInvocation >( - xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( - "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY ); + rtl::OUString aErrStr = getResourceString( RID_STR_HELPPROCESSING_GENERAL_ERROR ); + aErrStr += rtl::OUString::createFromAscii( "No help folder" ); + OWeakObject* oWeakThis = static_cast(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); } - catch (Exception &) + + Reference const & xContext = getComponentContext(); + Reference< script::XInvocation > xInvocation; + if( xContext.is() ) { - // i98680: Survive missing lucene + try + { + xInvocation = Reference< script::XInvocation >( + xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( + "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY ); + } + catch (Exception &) + { + // i98680: Survive missing lucene + } } - } - // Scan languages - Sequence< rtl::OUString > aLanguageFolderSeq = xSFA->getFolderContents( aExpandedHelpURL, true ); - sal_Int32 nLangCount = aLanguageFolderSeq.getLength(); - const rtl::OUString* pSeq = aLanguageFolderSeq.getConstArray(); - for( sal_Int32 iLang = 0 ; iLang < nLangCount ; ++iLang ) - { - rtl::OUString aLangURL = pSeq[iLang]; - if( xSFA->isFolder( aLangURL ) ) + // Scan languages + Sequence< rtl::OUString > aLanguageFolderSeq = xSFA->getFolderContents( aExpandedHelpURL, true ); + sal_Int32 nLangCount = aLanguageFolderSeq.getLength(); + const rtl::OUString* pSeq = aLanguageFolderSeq.getConstArray(); + for( sal_Int32 iLang = 0 ; iLang < nLangCount ; ++iLang ) { - std::vector< rtl::OUString > aXhpFileVector; - - // Delete (old) files in any case to allow compiler to be started every time - rtl::OUString aLangWithPureNameURL( aLangURL ); - aLangWithPureNameURL += aSlash; - aLangWithPureNameURL += aHelpStr; - rtl::OUString aDbFile( aLangWithPureNameURL ); - aDbFile += rtl::OUString::createFromAscii( ".db" ); - if( xSFA->exists( aDbFile ) ) - xSFA->kill( aDbFile ); - rtl::OUString aHtFile( aLangWithPureNameURL ); - aHtFile += rtl::OUString::createFromAscii( ".ht" ); - if( xSFA->exists( aHtFile ) ) - xSFA->kill( aHtFile ); - rtl::OUString aKeyFile( aLangWithPureNameURL ); - aKeyFile += rtl::OUString::createFromAscii( ".key" ); - if( xSFA->exists( aKeyFile ) ) - xSFA->kill( aKeyFile ); - - // calculate jar file URL - rtl::OUString aJarFile( aLangURL ); - aJarFile += aSlash; - aJarFile += aHelpStr; - aJarFile += rtl::OUString::createFromAscii( ".jar" ); - // remove in any case to clean up - if( xSFA->exists( aJarFile ) ) - xSFA->kill( aJarFile ); - - rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( aJarFile, - rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ); - rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.pkg://" ); - aDestBasePath += aEncodedJarFilePath; - aDestBasePath += rtl::OUString::createFromAscii( "/" ); - - sal_Int32 nLenLangFolderURL = aLangURL.getLength() + 1; - - Sequence< rtl::OUString > aSubLangSeq = xSFA->getFolderContents( aLangURL, true ); - sal_Int32 nSubLangCount = aSubLangSeq.getLength(); - const rtl::OUString* pSubLangSeq = aSubLangSeq.getConstArray(); - for( sal_Int32 iSubLang = 0 ; iSubLang < nSubLangCount ; ++iSubLang ) + rtl::OUString aLangURL = pSeq[iLang]; + if( xSFA->isFolder( aLangURL ) ) { - rtl::OUString aSubFolderURL = pSubLangSeq[iSubLang]; - if( !xSFA->isFolder( aSubFolderURL ) ) - continue; + std::vector< rtl::OUString > aXhpFileVector; + + // Delete (old) files in any case to allow compiler to be started every time + rtl::OUString aLangWithPureNameURL( aLangURL ); + aLangWithPureNameURL += aSlash; + aLangWithPureNameURL += aHelpStr; + rtl::OUString aDbFile( aLangWithPureNameURL ); + aDbFile += rtl::OUString::createFromAscii( ".db" ); + if( xSFA->exists( aDbFile ) ) + xSFA->kill( aDbFile ); + rtl::OUString aHtFile( aLangWithPureNameURL ); + aHtFile += rtl::OUString::createFromAscii( ".ht" ); + if( xSFA->exists( aHtFile ) ) + xSFA->kill( aHtFile ); + rtl::OUString aKeyFile( aLangWithPureNameURL ); + aKeyFile += rtl::OUString::createFromAscii( ".key" ); + if( xSFA->exists( aKeyFile ) ) + xSFA->kill( aKeyFile ); + + // calculate jar file URL + rtl::OUString aJarFile( aLangURL ); + aJarFile += aSlash; + aJarFile += aHelpStr; + aJarFile += rtl::OUString::createFromAscii( ".jar" ); + // remove in any case to clean up + if( xSFA->exists( aJarFile ) ) + xSFA->kill( aJarFile ); + + rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( aJarFile, + rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ); + rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.pkg://" ); + aDestBasePath += aEncodedJarFilePath; + aDestBasePath += rtl::OUString::createFromAscii( "/" ); + + sal_Int32 nLenLangFolderURL = aLangURL.getLength() + 1; + + Sequence< rtl::OUString > aSubLangSeq = xSFA->getFolderContents( aLangURL, true ); + sal_Int32 nSubLangCount = aSubLangSeq.getLength(); + const rtl::OUString* pSubLangSeq = aSubLangSeq.getConstArray(); + for( sal_Int32 iSubLang = 0 ; iSubLang < nSubLangCount ; ++iSubLang ) + { + rtl::OUString aSubFolderURL = pSubLangSeq[iSubLang]; + if( !xSFA->isFolder( aSubFolderURL ) ) + continue; - implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); + implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); - // Copy to package (later: move?) - rtl::OUString aDestPath = aDestBasePath; - rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); - aDestPath += aPureFolderName; - xSFA->copy( aSubFolderURL, aDestPath ); - } + // Copy to package (later: move?) + rtl::OUString aDestPath = aDestBasePath; + rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); + aDestPath += aPureFolderName; + xSFA->copy( aSubFolderURL, aDestPath ); + } - // Call compiler - sal_Int32 nXhpFileCount = aXhpFileVector.size(); - rtl::OUString* pXhpFiles = new rtl::OUString[nXhpFileCount]; - for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) - { - rtl::OUString aXhpFile = aXhpFileVector[iXhp]; - rtl::OUString aXhpRelFile = aXhpFile.copy( nLenLangFolderURL ); - pXhpFiles[iXhp] = aXhpRelFile; - } + // Call compiler + sal_Int32 nXhpFileCount = aXhpFileVector.size(); + rtl::OUString* pXhpFiles = new rtl::OUString[nXhpFileCount]; + for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) + { + rtl::OUString aXhpFile = aXhpFileVector[iXhp]; + rtl::OUString aXhpRelFile = aXhpFile.copy( nLenLangFolderURL ); + pXhpFiles[iXhp] = aXhpRelFile; + } - rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); - rtl::OUString aOfficeHelpPathFileURL; - ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); + rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); + rtl::OUString aOfficeHelpPathFileURL; + ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); - HelpProcessingErrorInfo aErrorInfo; - bool bSuccess = compileExtensionHelp( aOfficeHelpPathFileURL, aHelpStr, aLangURL, - nXhpFileCount, pXhpFiles, aErrorInfo ); + HelpProcessingErrorInfo aErrorInfo; + bool bSuccess = compileExtensionHelp( aOfficeHelpPathFileURL, aHelpStr, aLangURL, + nXhpFileCount, pXhpFiles, aErrorInfo ); - if( bSuccess && xInvocation.is() ) - { - Sequence aParamsSeq( 6 ); - - aParamsSeq[0] = uno::makeAny( rtl::OUString::createFromAscii( "-lang" ) ); - - rtl::OUString aLang; - sal_Int32 nLastSlash = aLangURL.lastIndexOf( '/' ); - if( nLastSlash != -1 ) - aLang = aLangURL.copy( nLastSlash + 1 ); - else - aLang = rtl::OUString::createFromAscii( "en" ); - aParamsSeq[1] = uno::makeAny( aLang ); - - aParamsSeq[2] = uno::makeAny( rtl::OUString::createFromAscii( "-mod" ) ); - aParamsSeq[3] = uno::makeAny( rtl::OUString::createFromAscii( "help" ) ); - - aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); - rtl::OUString aSystemPath; - osl::FileBase::getSystemPathFromFileURL( aLangURL, aSystemPath ); - aParamsSeq[5] = uno::makeAny( aSystemPath ); - - Sequence< sal_Int16 > aOutParamIndex; - Sequence< uno::Any > aOutParam; - uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "createIndex" ), - aParamsSeq, aOutParamIndex, aOutParam ); - } + if( bSuccess && xInvocation.is() ) + { + Sequence aParamsSeq( 6 ); + + aParamsSeq[0] = uno::makeAny( rtl::OUString::createFromAscii( "-lang" ) ); + + rtl::OUString aLang; + sal_Int32 nLastSlash = aLangURL.lastIndexOf( '/' ); + if( nLastSlash != -1 ) + aLang = aLangURL.copy( nLastSlash + 1 ); + else + aLang = rtl::OUString::createFromAscii( "en" ); + aParamsSeq[1] = uno::makeAny( aLang ); + + aParamsSeq[2] = uno::makeAny( rtl::OUString::createFromAscii( "-mod" ) ); + aParamsSeq[3] = uno::makeAny( rtl::OUString::createFromAscii( "help" ) ); + + aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); + rtl::OUString aSystemPath; + osl::FileBase::getSystemPathFromFileURL( aLangURL, aSystemPath ); + aParamsSeq[5] = uno::makeAny( aSystemPath ); + + Sequence< sal_Int16 > aOutParamIndex; + Sequence< uno::Any > aOutParam; + uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "createIndex" ), + aParamsSeq, aOutParamIndex, aOutParam ); + } - if( !bSuccess ) - { - USHORT nErrStrId = 0; - switch( aErrorInfo.m_eErrorClass ) + if( !bSuccess ) { + USHORT nErrStrId = 0; + switch( aErrorInfo.m_eErrorClass ) + { case HELPPROCESSING_GENERAL_ERROR: case HELPPROCESSING_INTERNAL_ERROR: nErrStrId = RID_STR_HELPPROCESSING_GENERAL_ERROR; break; case HELPPROCESSING_XMLPARSING_ERROR: nErrStrId = RID_STR_HELPPROCESSING_XMLPARSING_ERROR; break; default: ; - }; + }; - rtl::OUString aErrStr; - if( nErrStrId != 0 ) - { - aErrStr = getResourceString( nErrStrId ); - - // Remoce CR/LF - rtl::OUString aErrMsg( aErrorInfo.m_aErrorMsg ); - sal_Unicode nCR = 13, nLF = 10; - sal_Int32 nSearchCR = aErrMsg.indexOf( nCR ); - sal_Int32 nSearchLF = aErrMsg.indexOf( nLF ); - sal_Int32 nCopy; - if( nSearchCR != -1 || nSearchLF != -1 ) + rtl::OUString aErrStr; + if( nErrStrId != 0 ) { - if( nSearchCR == -1 ) - nCopy = nSearchLF; - else if( nSearchLF == -1 ) - nCopy = nSearchCR; - else - nCopy = ( nSearchCR < nSearchLF ) ? nSearchCR : nSearchLF; - - aErrMsg = aErrMsg.copy( 0, nCopy ); - } - aErrStr += aErrMsg; - if( nErrStrId == RID_STR_HELPPROCESSING_XMLPARSING_ERROR && aErrorInfo.m_aXMLParsingFile.getLength() ) - { - aErrStr += rtl::OUString::createFromAscii( " in " ); - - rtl::OUString aDecodedFile = rtl::Uri::decode( aErrorInfo.m_aXMLParsingFile, - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - aErrStr += aDecodedFile; - if( aErrorInfo.m_nXMLParsingLine != -1 ) + aErrStr = getResourceString( nErrStrId ); + + // Remoce CR/LF + rtl::OUString aErrMsg( aErrorInfo.m_aErrorMsg ); + sal_Unicode nCR = 13, nLF = 10; + sal_Int32 nSearchCR = aErrMsg.indexOf( nCR ); + sal_Int32 nSearchLF = aErrMsg.indexOf( nLF ); + sal_Int32 nCopy; + if( nSearchCR != -1 || nSearchLF != -1 ) { - aErrStr += rtl::OUString::createFromAscii( ", line " ); - aErrStr += ::rtl::OUString::valueOf( aErrorInfo.m_nXMLParsingLine ); + if( nSearchCR == -1 ) + nCopy = nSearchLF; + else if( nSearchLF == -1 ) + nCopy = nSearchCR; + else + nCopy = ( nSearchCR < nSearchLF ) ? nSearchCR : nSearchLF; + + aErrMsg = aErrMsg.copy( 0, nCopy ); + } + aErrStr += aErrMsg; + if( nErrStrId == RID_STR_HELPPROCESSING_XMLPARSING_ERROR && aErrorInfo.m_aXMLParsingFile.getLength() ) + { + aErrStr += rtl::OUString::createFromAscii( " in " ); + + rtl::OUString aDecodedFile = rtl::Uri::decode( aErrorInfo.m_aXMLParsingFile, + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); + aErrStr += aDecodedFile; + if( aErrorInfo.m_nXMLParsingLine != -1 ) + { + aErrStr += rtl::OUString::createFromAscii( ", line " ); + aErrStr += ::rtl::OUString::valueOf( aErrorInfo.m_nXMLParsingLine ); + } } } - } - OWeakObject* oWeakThis = static_cast(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + OWeakObject* oWeakThis = static_cast(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + } } } - } - // Write compiled flag file (this code is only reached in case of success) - Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aCompiledFlagFile ); - if( xOutputStream.is() ) - xOutputStream->closeOutput(); + // Write compiled flag file (this code is only reached in case of success) + Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aCompiledFlagFile ); + if( xOutputStream.is() ) + xOutputStream->closeOutput(); - } // if( bCompile ) + } // if( bCompile ) - // Write registered flag file (this code is only reached in case of success) - if( !xSFA->exists( aRegisteredFlagFile ) ) + // Write registered flag file (this code is only reached in case of success) + if( !xSFA->exists( aRegisteredFlagFile ) ) + { + Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aRegisteredFlagFile ); + if( xOutputStream.is() ) + xOutputStream->closeOutput(); + } + addDataToDb(xPackage->getURL(), data); + } + else { - Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aRegisteredFlagFile ); - if( xOutputStream.is() ) - xOutputStream->closeOutput(); + deleteDataFromDb(xPackage->getURL()); } } diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx new file mode 100644 index 000000000000..6f7e1d2844ac --- /dev/null +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -0,0 +1,224 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_package.cxx,v $ + * $Revision: 1.34.16.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" + +#include "dp_helpbackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + +#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/help-registry/2010" +#define NS_PREFIX "help" +#define ROOT_ELEMENT_NAME "help-backend-db" + +namespace dp_registry { +namespace backend { +namespace help { + +HelpBackendDb::HelpBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +OUString HelpBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString HelpBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + +OUString HelpBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +{ + try{ + + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + OUString sExpression( + sPrefix + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); + Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + Reference helpElement( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":help"))); + + helpElement->setAttribute(OUSTR("url"), url); + + Reference helpNode( + helpElement, UNO_QUERY_THROW); + root->appendChild(helpNode); + + Reference dataNode( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":data-url")), + UNO_QUERY_THROW); + helpNode->appendChild(dataNode); + + Reference dataValue( + doc->createTextNode(data.dataUrl), UNO_QUERY_THROW); + dataNode->appendChild(dataValue); + +// writeSimpleList( +// data.implementationNames, +// OUSTR("implementation-names"), +// OUSTR("name"), +// componentNode); + +// writeVectorOfPair( +// data.singletons, +// OUSTR("singletons"), +// OUSTR("item"), +// OUSTR("key"), +// OUSTR("value"), +// componentNode); + + save(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +void HelpBackendDb::removeEntry(::rtl::OUString const & url) +{ + OUString sExpression( + OUSTR(NS_PREFIX) + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); + removeElement(sExpression); +} + +HelpBackendDb::Data HelpBackendDb::getEntry(::rtl::OUString const & url) +{ + try + { + const OUString sPrefix = getNSPrefix(); + HelpBackendDb::Data retData; + const OUString sExpression( + sPrefix + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + if (aNode.is()) + { + const OUString sExprDataUrl(sPrefix + OUSTR(":data-url/text()")); + + Reference dataUrlVal = + xpathApi->selectSingleNode(aNode, sExprDataUrl); + retData.dataUrl = dataUrlVal->getNodeValue(); + +// 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); + } +} + +::std::list HelpBackendDb::getAllDataUrls() +{ + try + { + ::std::list listRet; + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + const OUString sPrefix = getNSPrefix(); + OUString sExpression( + sPrefix + OUSTR(":help/") + sPrefix + OUSTR(":data-url/text()")); + Reference nodes = + xpathApi->selectNodeList(root, sExpression); + if (nodes.is()) + { + sal_Int32 length = nodes->getLength(); + for (sal_Int32 i = 0; i < length; i++) + listRet.push_back(nodes->item(i)->getNodeValue()); + } + return listRet; + } + 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 help +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx new file mode 100644 index 000000000000..e80a24f85ab1 --- /dev/null +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_backend.h,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_HELPBACKENDDB_HXX +#define INCLUDED_DP_HELPBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "rtl/string.hxx" +#include +#include +#include "dp_backenddb.hxx" + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } + namespace xml { namespace dom { + class XDocument; + class XNode; + }} + namespace xml { namespace xpath { + class XXPathAPI; + }} +}}} + +namespace dp_registry { +namespace backend { +namespace help { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + The format looks like this: + + + */ +class HelpBackendDb: public dp_registry::backend::BackendDb +{ +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getNSPrefix(); + + virtual ::rtl::OUString getRootElementName(); + +public: + struct Data + { + /* the URL to the folder containing the compiled help files, etc. + */ + ::rtl::OUString dataUrl; + + }; + +public: + + HelpBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + + void addEntry(::rtl::OUString const & url, Data const & data); + void removeEntry(::rtl::OUString const & url); + Data getEntry(::rtl::OUString const & url); + ::std::list< ::rtl::OUString> getAllDataUrls(); + +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/help/makefile.mk b/desktop/source/deployment/registry/help/makefile.mk index ba904bb7f28a..d4934f71a46f 100644 --- a/desktop/source/deployment/registry/help/makefile.mk +++ b/desktop/source/deployment/registry/help/makefile.mk @@ -44,7 +44,8 @@ SRC1FILES = \ dp_help.src SLOFILES = \ - $(SLO)$/dp_help.obj + $(SLO)$/dp_help.obj \ + $(SLO)$/dp_helpbackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 371faf579caf..24c6e4914fe1 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -43,6 +43,7 @@ #include "com/sun/star/deployment/InvalidRemovedParameterException.hpp" #include #include +#include #include "dp_registry.hrc" namespace dp_registry @@ -314,6 +315,23 @@ protected: css::uno::Sequence const & args, css::uno::Reference const & xContext ); + /* creates a folder with a unique name. + If url is empty then it is created in the the backend folder, otherwise + at a location relative to that folder specified by url. + */ + ::rtl::OUString createFolder( + ::rtl::OUString const & relUrl, + css::uno::Reference const & xCmdEnv); + /* deletes folders and files. + + All folder all files which end with ".tmp" or ".tmp_" and which are + not used are deleted. + */ + void deleteUnusedFolders( + ::rtl::OUString const & relUrl, + ::std::list< ::rtl::OUString> const & usedFolders); + + public: struct StrRegisteringPackage : public ::dp_misc::StaticResourceString< StrRegisteringPackage, RID_STR_REGISTERING_PACKAGE> {}; diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index dbac54e10c6d..ca28f28ac390 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -109,6 +109,11 @@ protected: into the root element. */ virtual ::rtl::OUString getDbNSName()=0; + /* return the namespace prefix which is to be registered with the XPath API. + + The prefix can then be used in XPath expressions. + */ + virtual ::rtl::OUString getNSPrefix()=0; /* returns the name of the root element without any namespace prefix. */ virtual ::rtl::OUString getRootElementName()=0; diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx index 93aa62174e0f..99aa2178b421 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx @@ -44,6 +44,7 @@ using namespace ::com::sun::star::uno; using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/extension-registry/2010" +#define NS_PREFIX "ext" #define ROOT_ELEMENT_NAME "extension-backend-db" namespace dp_registry { @@ -62,6 +63,11 @@ OUString ExtensionBackendDb::getDbNSName() return OUSTR(EXTENSION_REG_NS); } +OUString ExtensionBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + OUString ExtensionBackendDb::getRootElementName() { return OUSTR(ROOT_ELEMENT_NAME); @@ -71,20 +77,23 @@ void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data { try{ + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); Reference doc = getDocument(); Reference root = doc->getFirstChild(); #if OSL_DEBUG_LEVEL > 0 //There must not be yet an entry with the same url OUString sExpression( - OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + sPrefix + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); Reference _extensionNode = getXPathAPI()->selectSingleNode(root, sExpression); OSL_ASSERT(! _extensionNode.is()); #endif // Reference extensionNode( - doc->createElement(OUSTR("extension"))); + doc->createElementNS(sNameSpace, + sPrefix + OUSTR(":extension"))); extensionNode->setAttribute(OUSTR("url"), url); @@ -92,22 +101,12 @@ void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data extensionNode, css::uno::UNO_QUERY_THROW); root->appendChild(extensionNodeNode); - // ... -// Reference identifierNode( -// doc->createElement(OUSTR("identifier")), UNO_QUERY_THROW); -// extensionNodeNode->appendChild(identifierNode); - -// Reference identifierValue( -// doc->createTextNode(data.identifier), UNO_QUERY_THROW); -// identifierNode->appendChild(identifierValue); - - writeVectorOfPair( data.items, - OUSTR("extension-items"), - OUSTR("item"), - OUSTR("url"), - OUSTR("media-type"), + sPrefix + OUSTR(":extension-items"), + sPrefix + OUSTR(":item"), + sPrefix + OUSTR(":url"), + sPrefix + OUSTR(":media-type"), extensionNodeNode); save(); } @@ -123,7 +122,7 @@ void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data void ExtensionBackendDb::removeEntry(::rtl::OUString const & url) { OUString sExpression( - OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + OUSTR(NS_PREFIX) + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); removeElement(sExpression); } @@ -131,9 +130,10 @@ ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & ur { try { + const OUString sPrefix = getNSPrefix(); ExtensionBackendDb::Data retData; const OUString sExpression( - OUSTR("reg:extension[@url = \"") + url + OUSTR("\"]")); + sPrefix + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); Reference doc = getDocument(); Reference root = doc->getFirstChild(); @@ -143,17 +143,13 @@ ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & ur xpathApi->selectSingleNode(root, sExpression); if (aNode.is()) { -// const OUString sExprIdentifier(OUSTR("reg:identifier/text()")); - -// Reference 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")); + sPrefix + OUSTR(":extension-items"), + sPrefix + OUSTR(":item"), + sPrefix + OUSTR(":url"), + sPrefix + OUSTR(":media-type")); } return retData; } diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx index 4afe6f1a5577..e46c67b166de 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx @@ -60,7 +60,7 @@ class ExtensionBackendDb: public dp_registry::backend::BackendDb { protected: virtual ::rtl::OUString getDbNSName(); - + virtual ::rtl::OUString getNSPrefix(); virtual ::rtl::OUString getRootElementName(); public: -- cgit From e955e6941dcf5784f44d64ec753041a4dc6cf37e Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Wed, 24 Mar 2010 08:27:52 +0100 Subject: jl152 import 263442 from native0jl:#i77196# new add, remove and update are now supported from extension manager --- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 17 +++-- .../source/deployment/gui/dp_gui_extlistbox.cxx | 4 +- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 85 ++++++++++++++++------ desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 4 + 4 files changed, 82 insertions(+), 28 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 89a5ae1e22c8..a617e07758c7 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -946,11 +946,12 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv try { - uno::Reference< deployment::XPackage > xPackage( xPackageManager->addPackage( - rPackageURL, OUString() /* detect media-type */, - xAbortChannel, rCmdEnv.get() ) ); + OUString sPackageManager = xPackageManager->getContext(); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< deployment::XPackage > xPackage( xExtMgr->addExtension( rPackageURL, sPackageManager, + xAbortChannel, rCmdEnv.get() ) ); OSL_ASSERT( xPackage.is() ); - } + } catch ( ucb::CommandFailedException & ) { // When the extension is already installed we'll get a dialog asking if we want to overwrite. If we then press @@ -976,8 +977,14 @@ void ExtensionCmdQueue::Thread::_removeExtension( ::rtl::Reference< ProgressCmdE OUString id( dp_misc::getIdentifier( xPackage ) ); try { - xPackageManager->removePackage( id, xPackage->getName(), xAbortChannel, rCmdEnv.get() ); + OUString sPackageManager = xPackageManager->getContext(); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + xExtMgr->removeExtension( id, xPackage->getName(), sPackageManager, xAbortChannel, rCmdEnv.get() ); } + catch ( deployment::DeploymentException & ) + {} + catch ( ucb::CommandFailedException & ) + {} catch ( ucb::CommandAbortedException & ) {} diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 2e02a90f59fd..6793b6e1e0ab 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -951,7 +951,7 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & if ( m_vEntries.empty() ) { pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - pEntry->m_bShared = ( m_pManager->getSharedPkgMgr() == xPackageManager ); + pEntry->m_bShared = ( m_pManager->getUserPkgMgr() != xPackageManager ); pEntry->m_bNew = m_bInCheckMode; m_vEntries.push_back( pEntry ); } @@ -960,7 +960,7 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & if ( !FindEntryPos( pEntry, 0, m_vEntries.size()-1, nPos ) ) { pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - pEntry->m_bShared = ( m_pManager->getSharedPkgMgr() == xPackageManager ); + pEntry->m_bShared = ( m_pManager->getUserPkgMgr() != xPackageManager ); pEntry->m_bNew = m_bInCheckMode; m_vEntries.insert( m_vEntries.begin()+nPos, pEntry ); } diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 796918202a52..7519ab8a1dc8 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -47,6 +47,10 @@ #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) +#define USER_PACKAGE_MANAGER OUSTR("user") +#define SHARED_PACKAGE_MANAGER OUSTR("shared") +#define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") + using namespace ::com::sun::star; using ::rtl::OUString; @@ -67,15 +71,18 @@ TheExtensionManager::TheExtensionManager( Window *pParent, m_pExtMgrDialog( NULL ), m_pUpdReqDialog( NULL ) { - m_sPackageManagers.realloc(2); - m_sPackageManagers[0] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( OUSTR("user") ); - m_sPackageManagers[1] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( OUSTR("shared") );; + m_sPackageManagers.realloc(3); + m_sPackageManagers[0] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( USER_PACKAGE_MANAGER ); + m_sPackageManagers[1] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( SHARED_PACKAGE_MANAGER ); + m_sPackageManagers[2] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( BUNDLED_PACKAGE_MANAGER ); for ( sal_Int32 i = 0; i < m_sPackageManagers.getLength(); ++i ) { m_sPackageManagers[i]->addModifyListener( this ); } + m_xExtensionManager = deployment::ExtensionManager::get( xContext ); + uno::Reference< lang::XMultiServiceFactory > xConfig( xContext->getServiceManager()->createInstanceWithContext( OUSTR("com.sun.star.configuration.ConfigurationProvider"), xContext ), uno::UNO_QUERY_THROW); @@ -206,26 +213,34 @@ bool TheExtensionManager::isVisible() bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bParentVisible*/ ) { std::vector< TUpdateListEntry > vEntries; + uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; - for ( sal_Int32 i = 0; i < m_sPackageManagers.getLength(); ++i ) + try { + xAllPackages = m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(), + uno::Reference< ucb::XCommandEnvironment >() ); + } catch ( deployment::DeploymentException & ) { + return false; + } catch ( ucb::CommandFailedException & ) { + return false; + } catch ( ucb::CommandAbortedException & ) { + return false; + } catch ( lang::IllegalArgumentException & e ) { + throw uno::RuntimeException( e.Message, e.Context ); + } + + for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) { - uno::Sequence< uno::Reference< deployment::XPackage > > xPackages; - try { - xPackages = m_sPackageManagers[i]->getDeployedPackages( uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment >() ); - for ( sal_Int32 k = 0; k < xPackages.getLength(); ++k ) + uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; + + for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j ) + { + uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; + if ( xPackage.is() ) { - TUpdateListEntry pEntry( new UpdateListEntry( xPackages[k], m_sPackageManagers[i] ) ); + TUpdateListEntry pEntry( new UpdateListEntry( xPackage, m_sPackageManagers[j] ) ); vEntries.push_back( pEntry ); + break; } - } catch ( deployment::DeploymentException & ) { - continue; - } catch ( ucb::CommandFailedException & ) { - continue; - } catch ( ucb::CommandAbortedException & ) { - return true; - } catch ( lang::IllegalArgumentException & e ) { - throw uno::RuntimeException( e.Message, e.Context ); } } @@ -342,10 +357,38 @@ bool TheExtensionManager::createPackageList( const uno::Reference< deployment::X //------------------------------------------------------------------------------ void TheExtensionManager::createPackageList() { - for ( sal_Int32 i = 0; i < m_sPackageManagers.getLength(); ++i ) + uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; + + try { + xAllPackages = m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(), + uno::Reference< ucb::XCommandEnvironment >() ); + } catch ( deployment::DeploymentException & ) { + return; + } catch ( ucb::CommandFailedException & ) { + return; + } catch ( ucb::CommandAbortedException & ) { + return; + } catch ( lang::IllegalArgumentException & e ) { + throw uno::RuntimeException( e.Message, e.Context ); + } + + for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) { - if ( ! createPackageList( m_sPackageManagers[i] ) ) - break; + uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; + + for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j ) + { + uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; + if ( xPackage.is() ) + { + PackageState eState = getPackageState( xPackage ); + getDialogHelper()->addPackageToList( xPackage, m_sPackageManagers[j] ); + // When the package is enabled, we can stop here, otherwise we have to look for + // another version of this package + if ( ( eState == REGISTERED ) || ( eState == NOT_AVAILABLE ) ) + break; + } + } } } diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx index 1cdd1851d59e..f794f8aa432d 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -34,6 +34,8 @@ #include "com/sun/star/container/XNameAccess.hpp" #include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/XExtensionManager.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/frame/XDesktop.hpp" #include "com/sun/star/frame/XTerminateListener.hpp" #include "com/sun/star/uno/XComponentContext.hpp" @@ -57,6 +59,7 @@ class TheExtensionManager : private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > m_xDesktop; + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> > m_sPackageManagers; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xNameAccessNodes; @@ -111,6 +114,7 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext; } ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > getUserPkgMgr() const { return m_sPackageManagers[0]; } ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > getSharedPkgMgr() const { return m_sPackageManagers[1]; } + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > getExtensionManager() const { return m_xExtensionManager; } //----------------- static ::rtl::Reference get( -- cgit From 72506215f8419786691277f2936b9298ddadd925 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 25 Mar 2010 10:45:08 +0100 Subject: jl152 import 263443 from native0jl:#i77196# merging --- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 32 ++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 7519ab8a1dc8..a45affcb2c08 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -34,7 +34,6 @@ #include "vos/mutex.hxx" #include "toolkit/helper/vclunohelper.hxx" - #include "com/sun/star/beans/XPropertySet.hpp" #include "com/sun/star/deployment/XPackageManagerFactory.hpp" #include "com/sun/star/deployment/thePackageManagerFactory.hpp" @@ -51,6 +50,10 @@ #define SHARED_PACKAGE_MANAGER OUSTR("shared") #define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") +#define USER_PACKAGE_MANAGER OUSTR("user") +#define SHARED_PACKAGE_MANAGER OUSTR("shared") +#define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") + using namespace ::com::sun::star; using ::rtl::OUString; @@ -329,16 +332,14 @@ void TheExtensionManager::terminateDialog() //------------------------------------------------------------------------------ bool TheExtensionManager::createPackageList( const uno::Reference< deployment::XPackageManager > &xPackageManager ) { - uno::Sequence< uno::Reference< deployment::XPackage > > packages; + uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; try { - packages = xPackageManager->getDeployedPackages( uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment >() ); + xAllPackages = m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(), + uno::Reference< ucb::XCommandEnvironment >() ); } catch ( deployment::DeploymentException & ) { - //handleGeneralError(e.Cause); return true; } catch ( ucb::CommandFailedException & ) { - //handleGeneralError(e.Reason); return true; } catch ( ucb::CommandAbortedException & ) { return false; @@ -346,9 +347,24 @@ bool TheExtensionManager::createPackageList( const uno::Reference< deployment::X throw uno::RuntimeException( e.Message, e.Context ); } - for ( sal_Int32 j = 0; j < packages.getLength(); ++j ) + for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) { - getDialogHelper()->addPackageToList( packages[j], xPackageManager ); + uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; + + for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j ) + { + uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; + if ( xPackage.is() ) + { + PackageState eState = getPackageState( xPackage ); + getDialogHelper()->addPackageToList( xPackage, m_sPackageManagers[j] ); + // When the package is enabled, we can stop here, otherwise we have to look for + // another version of this package + if ( ( eState == REGISTERED ) || ( eState == NOT_AVAILABLE ) ) + break; + } + } + } return true; -- cgit From ada29520025252056fc0b9a156103b17bc770b0f Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Thu, 25 Mar 2010 11:57:04 +0100 Subject: jl152 import 263444 from native0jl:#i77196# disable now supported new from extension manager --- desktop/source/deployment/gui/dp_gui.hrc | 2 + desktop/source/deployment/gui/dp_gui_dialog2.cxx | 25 +++++++---- desktop/source/deployment/gui/dp_gui_dialog2.hxx | 6 +-- desktop/source/deployment/gui/dp_gui_dialog2.src | 12 +++++- .../source/deployment/gui/dp_gui_extlistbox.cxx | 46 +++++++++++++-------- .../source/deployment/gui/dp_gui_extlistbox.hxx | 20 +++++---- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 48 ++-------------------- desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 1 - 8 files changed, 78 insertions(+), 82 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui.hrc b/desktop/source/deployment/gui/dp_gui.hrc index 8da4db5ca74f..1d2f4869cc7f 100644 --- a/desktop/source/deployment/gui/dp_gui.hrc +++ b/desktop/source/deployment/gui/dp_gui.hrc @@ -138,6 +138,8 @@ #define RID_IMG_LOCKED_HC (RID_DEPLOYMENT_GUI_START+59) #define RID_IMG_EXTENSION (RID_DEPLOYMENT_GUI_START+60) #define RID_IMG_EXTENSION_HC (RID_DEPLOYMENT_GUI_START+61) +#define RID_IMG_SHARED (RID_DEPLOYMENT_GUI_START+62) +#define RID_IMG_SHARED_HC (RID_DEPLOYMENT_GUI_START+63) #define RID_STR_ADD_PACKAGES (RID_DEPLOYMENT_GUI_START+70) diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 2d0733dfbae3..5f0cf3d91012 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -291,6 +291,7 @@ void ExtBoxWithBtns_Impl::SetButtonPos( const Rectangle& rRect ) // ----------------------------------------------------------------------- void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) { + pEntry->m_bHasButtons = false; if ( ( pEntry->m_eState == REGISTERED ) || ( pEntry->m_eState == NOT_AVAILABLE ) ) { m_pEnableBtn->SetText( DialogHelper::getResourceString( RID_CTX_ITEM_DISABLE ) ); @@ -302,24 +303,32 @@ void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_ENABLE ); } - if ( ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps ) + if ( !pEntry->m_bUser || ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps ) m_pEnableBtn->Hide(); else { m_pEnableBtn->Enable( !pEntry->m_bLocked ); m_pEnableBtn->Show(); + pEntry->m_bHasButtons = true; } if ( pEntry->m_bHasOptions ) { m_pOptionsBtn->Enable( pEntry->m_bHasOptions ); m_pOptionsBtn->Show(); + pEntry->m_bHasButtons = true; } else m_pOptionsBtn->Hide(); - m_pRemoveBtn->Show(); - m_pRemoveBtn->Enable( !pEntry->m_bLocked ); + if ( pEntry->m_bUser || pEntry->m_bShared ) + { + m_pRemoveBtn->Enable( !pEntry->m_bLocked ); + m_pRemoveBtn->Show(); + pEntry->m_bHasButtons = true; + } + else + m_pRemoveBtn->Hide(); } // ----------------------------------------------------------------------- @@ -778,10 +787,9 @@ long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage } //------------------------------------------------------------------------------ -void ExtMgrDialog::prepareChecking( const uno::Reference< deployment::XPackageManager > &xPackageManager ) +void ExtMgrDialog::prepareChecking() { - if ( xPackageManager.is() ) - m_pExtensionBox->prepareChecking( xPackageManager ); + m_pExtensionBox->prepareChecking(); } //------------------------------------------------------------------------------ @@ -1323,10 +1331,9 @@ long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::X } //------------------------------------------------------------------------------ -void UpdateRequiredDialog::prepareChecking( const uno::Reference< deployment::XPackageManager > &xPackageManager ) +void UpdateRequiredDialog::prepareChecking() { - if ( xPackageManager.is() ) - m_pExtensionBox->prepareChecking( xPackageManager ); + m_pExtensionBox->prepareChecking(); } //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx index d5e939ace8a9..cadc127446ea 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -85,7 +85,7 @@ public: virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > & ) = 0; - virtual void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ) = 0; + virtual void prepareChecking() = 0; virtual void checkEntries() = 0; static ResId getResId( USHORT nId ); @@ -169,7 +169,7 @@ public: bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); - virtual void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + virtual void prepareChecking(); virtual void checkEntries(); ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); @@ -242,7 +242,7 @@ public: bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); - virtual void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + virtual void prepareChecking(); virtual void checkEntries(); ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.src b/desktop/source/deployment/gui/dp_gui_dialog2.src index d55421d50d75..7c47365999a0 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.src +++ b/desktop/source/deployment/gui/dp_gui_dialog2.src @@ -165,10 +165,20 @@ Image RID_IMG_WARNING_HC Image RID_IMG_LOCKED { - ImageBitmap = Bitmap { File = "shared_16.png"; }; + ImageBitmap = Bitmap { File = "lock_16.png"; }; }; Image RID_IMG_LOCKED_HC +{ + ImageBitmap = Bitmap { File = "lock_16_h.png"; }; +}; + +Image RID_IMG_SHARED +{ + ImageBitmap = Bitmap { File = "shared_16.png"; }; +}; + +Image RID_IMG_SHARED_HC { ImageBitmap = Bitmap { File = "shared_16_h.png"; }; }; diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 6793b6e1e0ab..7d616b103c21 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -58,9 +58,11 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, m_bLocked( false ), m_bHasOptions( false ), m_bShared( false ), + m_bUser( false ), m_bNew( false ), m_bChecked( false ), m_bMissingDeps( false ), + m_bHasButtons( false ), m_eState( eState ), m_pPublisher( NULL ), m_xPackage( xPackage ), @@ -177,6 +179,8 @@ ExtensionBox_Impl::ExtensionBox_Impl( Dialog* pParent, TheExtensionManager *pMan m_nTopIndex( 0 ), m_nActiveHeight( 0 ), m_nExtraHeight( 2 ), + m_aSharedImage( DialogHelper::getResId( RID_IMG_SHARED ) ), + m_aSharedImageHC( DialogHelper::getResId( RID_IMG_SHARED_HC ) ), m_aLockedImage( DialogHelper::getResId( RID_IMG_LOCKED ) ), m_aLockedImageHC( DialogHelper::getResId( RID_IMG_LOCKED_HC ) ), m_aWarningImage( DialogHelper::getResId( RID_IMG_WARNING ) ), @@ -380,7 +384,10 @@ void ExtensionBox_Impl::CalcActiveHeight( const long nPos ) if ( aTextHeight < m_nStdHeight ) aTextHeight = m_nStdHeight; - m_nActiveHeight = aTextHeight + m_nExtraHeight; + if ( m_vEntries[ nPos ]->m_bHasButtons ) + m_nActiveHeight = aTextHeight + m_nExtraHeight; + else + m_nActiveHeight = aTextHeight + 2; } //------------------------------------------------------------------------------ @@ -469,13 +476,15 @@ void ExtensionBox_Impl::selectEntry( const long nPos ) if ( IsReallyVisible() ) { - m_bNeedsRecalc = true; m_bAdjustActive = true; } } if ( IsReallyVisible() ) + { + m_bNeedsRecalc = true; Invalidate(); + } guard.clear(); } @@ -595,7 +604,12 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr aPos.Y() += aTextHeight; if ( pEntry->m_bActive ) { - DrawText( Rectangle( aPos.X(), aPos.Y(), rRect.Right(), rRect.Bottom() - m_nExtraHeight ), + long nExtraHeight = 0; + + if ( pEntry->m_bHasButtons ) + nExtraHeight = m_nExtraHeight; + + DrawText( Rectangle( aPos.X(), aPos.Y(), rRect.Right(), rRect.Bottom() - nExtraHeight ), sDescription, TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK ); } else @@ -615,10 +629,13 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr } // Draw status icons - if ( pEntry->m_bShared ) + if ( !pEntry->m_bUser ) { aPos = rRect.TopRight() + Point( -(RIGHT_ICON_OFFSET + SMALL_ICON_SIZE), TOP_OFFSET ); - DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aLockedImageHC : m_aLockedImage ); + if ( pEntry->m_bLocked ) + DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aLockedImageHC : m_aLockedImage ); + else + DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aSharedImageHC : m_aSharedImage ); } if ( ( pEntry->m_eState == AMBIGUOUS ) || pEntry->m_bMissingDeps ) { @@ -950,18 +967,12 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & ::osl::ClearableMutexGuard guard(m_entriesMutex); if ( m_vEntries.empty() ) { - pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - pEntry->m_bShared = ( m_pManager->getUserPkgMgr() != xPackageManager ); - pEntry->m_bNew = m_bInCheckMode; m_vEntries.push_back( pEntry ); } else { if ( !FindEntryPos( pEntry, 0, m_vEntries.size()-1, nPos ) ) { - pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - pEntry->m_bShared = ( m_pManager->getUserPkgMgr() != xPackageManager ); - pEntry->m_bNew = m_bInCheckMode; m_vEntries.insert( m_vEntries.begin()+nPos, pEntry ); } else if ( !m_bInCheckMode ) @@ -969,6 +980,12 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & OSL_ENSURE( 0, "ExtensionBox_Impl::addEntry(): Will not add duplicate entries" ); } } + + pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); + pEntry->m_bUser = ( m_pManager->getUserPkgMgr() == xPackageManager ); + pEntry->m_bShared = !pEntry->m_bUser && ( m_pManager->getSharedPkgMgr() == xPackageManager ); + pEntry->m_bNew = m_bInCheckMode; + //access to m_nActive must be guarded if ( !m_bInCheckMode && m_bHasActive && ( m_nActive >= nPos ) ) m_nActive += 1; @@ -1084,16 +1101,13 @@ void ExtensionBox_Impl::RemoveUnlocked() } //------------------------------------------------------------------------------ -void ExtensionBox_Impl::prepareChecking( const uno::Reference< deployment::XPackageManager > &xPackageMgr ) +void ExtensionBox_Impl::prepareChecking() { m_bInCheckMode = true; typedef std::vector< TEntry_Impl >::iterator ITER; for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex ) { - if ( (*iIndex)->m_xPackageManager == xPackageMgr ) - (*iIndex)->m_bChecked = false; - else - (*iIndex)->m_bChecked = true; + (*iIndex)->m_bChecked = false; (*iIndex)->m_bNew = false; } } diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx index ad62bfd1a2d8..1ea3d0d72fcc 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx @@ -65,13 +65,15 @@ typedef ::boost::shared_ptr< Entry_Impl > TEntry_Impl; struct Entry_Impl { - bool m_bActive; - bool m_bLocked; - bool m_bHasOptions; - bool m_bShared; - bool m_bNew; - bool m_bChecked; - bool m_bMissingDeps; + bool m_bActive :1; + bool m_bLocked :1; + bool m_bHasOptions :1; + bool m_bUser :1; + bool m_bShared :1; + bool m_bNew :1; + bool m_bChecked :1; + bool m_bMissingDeps :1; + bool m_bHasButtons :1; PackageState m_eState; String m_sTitle; String m_sVersion; @@ -135,6 +137,8 @@ class ExtensionBox_Impl : public ::svt::IExtensionListBox long m_nActiveHeight; long m_nExtraHeight; Size m_aOutputSize; + Image m_aSharedImage; + Image m_aSharedImageHC; Image m_aLockedImage; Image m_aLockedImageHC; Image m_aWarningImage; @@ -209,7 +213,7 @@ public: void updateEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void removeEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); - void prepareChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageMgr ); + void prepareChecking(); void checkEntries(); TheExtensionManager* getExtensionManager() const { return m_pManager; } diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index a45affcb2c08..fef6d36c7165 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -235,7 +235,8 @@ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bPare { uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; - for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j ) + // we don't want update notifications for bundled packages + for ( sal_Int32 j = 0; ( j < 2 ) && ( j < xPackageList.getLength() ); ++j ) { uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; if ( xPackage.is() ) @@ -329,47 +330,6 @@ void TheExtensionManager::terminateDialog() } } -//------------------------------------------------------------------------------ -bool TheExtensionManager::createPackageList( const uno::Reference< deployment::XPackageManager > &xPackageManager ) -{ - uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; - - try { - xAllPackages = m_xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment >() ); - } catch ( deployment::DeploymentException & ) { - return true; - } catch ( ucb::CommandFailedException & ) { - return true; - } catch ( ucb::CommandAbortedException & ) { - return false; - } catch ( lang::IllegalArgumentException & e ) { - throw uno::RuntimeException( e.Message, e.Context ); - } - - for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) - { - uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; - - for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j ) - { - uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; - if ( xPackage.is() ) - { - PackageState eState = getPackageState( xPackage ); - getDialogHelper()->addPackageToList( xPackage, m_sPackageManagers[j] ); - // When the package is enabled, we can stop here, otherwise we have to look for - // another version of this package - if ( ( eState == REGISTERED ) || ( eState == NOT_AVAILABLE ) ) - break; - } - } - - } - - return true; -} - //------------------------------------------------------------------------------ void TheExtensionManager::createPackageList() { @@ -553,8 +513,8 @@ void TheExtensionManager::modified( ::lang::EventObject const & rEvt ) uno::Reference< deployment::XPackageManager > xPackageManager( rEvt.Source, uno::UNO_QUERY ); if ( xPackageManager.is() ) { - getDialogHelper()->prepareChecking( xPackageManager ); - createPackageList( xPackageManager ); + getDialogHelper()->prepareChecking(); + createPackageList(); getDialogHelper()->checkEntries(); } } diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx index f794f8aa432d..2b8f86de9955 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -74,7 +74,6 @@ private: // liste der packages ( xpackage?, mit parent manager, ... ) void createPackageList(); - bool createPackageList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); public: static ::rtl::Reference s_ExtMgr; -- cgit From fb70a4cd3b77e0ea6bb5820b47bfd7ea39fa3228 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 6 Apr 2010 17:15:01 +0200 Subject: jl152 import 263445 from native0jl:#i77196# supporting extension help --- desktop/source/deployment/registry/dp_backend.cxx | 9 + .../source/deployment/registry/help/dp_help.cxx | 583 +++++++++++---------- .../deployment/registry/help/dp_helpbackenddb.cxx | 10 +- .../deployment/registry/help/dp_helpbackenddb.hxx | 3 +- .../source/deployment/registry/inc/dp_backend.h | 3 + 5 files changed, 325 insertions(+), 283 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index dcfc2c6b3d2f..be752bcf0733 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -716,6 +716,15 @@ OUString Package::getRepositoryName() return backEnd->getContext(); } +beans::Optional< OUString > Package::getRegistrationDataURL() + throw (deployment::ExtensionRemovedException, + css::uno::RuntimeException) +{ + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + return beans::Optional(); +} + sal_Bool Package::isRemoved() throw (RuntimeException) { diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index b594f9395ceb..aeeec94981e6 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -46,7 +46,7 @@ #include #include #include - +#include "boost/optional.hpp" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -80,11 +80,15 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference const & xCmdEnv ); public: - inline PackageImpl( + PackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, bool bRemoved, OUString const & identifier); + + //XPackage + virtual css::beans::Optional< ::rtl::OUString > SAL_CALL getRegistrationDataURL() + throw (deployment::ExtensionRemovedException, css::uno::RuntimeException); }; friend class PackageImpl; @@ -98,13 +102,13 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference const & xCmdEnv); void implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ); - rtl::OUString getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ); - rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); - rtl::OUString getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ); - rtl::OUString expandURL( const rtl::OUString& aURL ); +// rtl::OUString getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ); +// rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); +// rtl::OUString getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ); +// rtl::OUString expandURL( const rtl::OUString& aURL ); void addDataToDb(OUString const & url, HelpBackendDb::Data const & data); - HelpBackendDb::Data readDataFromDb(OUString const & url); + ::boost::optional readDataFromDb(OUString const & url); void deleteDataFromDb(OUString const & url); Reference< ucb::XSimpleFileAccess > getFileAccess( void ); @@ -208,10 +212,10 @@ void BackendImpl::addDataToDb( m_backendDb->addEntry(url, data); } -HelpBackendDb::Data BackendImpl::readDataFromDb( +::boost::optional BackendImpl::readDataFromDb( OUString const & url) { - HelpBackendDb::Data data; + ::boost::optional data; if (m_backendDb.get()) data = m_backendDb->getEntry(url); return data; @@ -232,7 +236,12 @@ BackendImpl::PackageImpl::PackageImpl( : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) { if (bRemoved) - m_dbData = getMyBackend()->readDataFromDb(url); + { + ::boost::optional opt = + getMyBackend()->readDataFromDb(url); + if (opt) + m_dbData = *opt; + } } // Package @@ -259,11 +268,10 @@ BackendImpl::PackageImpl::isRegistered_( Reference const & ) { BackendImpl * that = getMyBackend(); - Reference< deployment::XPackage > xThisPackage( this ); - rtl::OUString aRegisteredFlagFile = that->getRegisteredFlagFileURL( xThisPackage ); - Reference< ucb::XSimpleFileAccess > xSFA = that->getFileAccess(); - bool bReg = xSFA->exists( aRegisteredFlagFile ); + bool bReg = false; + if (that->readDataFromDb(getURL())) + bReg = true; return beans::Optional< beans::Ambiguous >( true, beans::Ambiguous( bReg, false ) ); } @@ -291,6 +299,23 @@ void BackendImpl::PackageImpl::processPackage_( // getMyBackend()->deleteDataFromDb(getURL()); } +beans::Optional< OUString > BackendImpl::PackageImpl::getRegistrationDataURL() + throw (deployment::ExtensionRemovedException, + css::uno::RuntimeException) +{ + if (m_bRemoved) + throw deployment::ExtensionRemovedException(); + + ::boost::optional data = + getMyBackend()->readDataFromDb(getURL()); + + if (data) + return beans::Optional(true, data->dataUrl); + + return beans::Optional(true, OUString()); +} + + //############################################################################## static rtl::OUString aSlash( rtl::OUString::createFromAscii( "/" ) ); @@ -305,232 +330,230 @@ void BackendImpl::implProcessHelp if (doRegisterPackage) { HelpBackendDb::Data data; - Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess(); + const OUString sHelpFolder = createFolder(OUString(), xCmdEnv); + data.dataUrl = sHelpFolder; - rtl::OUString aRegisteredFlagFile = getRegisteredFlagFileURL( xPackage ); - if( !doRegisterPackage ) + Reference< ucb::XSimpleFileAccess > xSFA = getFileAccess(); + rtl::OUString aHelpURL = xPackage->getURL(); + rtl::OUString aExpandedHelpURL = dp_misc::expandUnoRcUrl( aHelpURL ); + rtl::OUString aName = xPackage->getName(); + if( !xSFA->isFolder( aExpandedHelpURL ) ) { - if( xSFA->exists( aRegisteredFlagFile ) ) - xSFA->kill( aRegisteredFlagFile ); - return; + rtl::OUString aErrStr = getResourceString( RID_STR_HELPPROCESSING_GENERAL_ERROR ); + aErrStr += rtl::OUString::createFromAscii( "No help folder" ); + OWeakObject* oWeakThis = static_cast(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); } - bool bCompile = true; - rtl::OUString aCompiledFlagFile = getCompiledFlagFileURL( xPackage ); - if( xSFA->exists( aCompiledFlagFile ) ) - bCompile = false; - - if( bCompile ) + Reference const & xContext = getComponentContext(); + Reference< script::XInvocation > xInvocation; + if( xContext.is() ) { - OUString sHelpFolder = createFolder(OUString(), xCmdEnv); - data.dataUrl = sHelpFolder; - rtl::OUString aHelpURL = xPackage->getURL(); - rtl::OUString aExpandedHelpURL = expandURL( aHelpURL ); - rtl::OUString aName = xPackage->getName(); - if( !xSFA->isFolder( aExpandedHelpURL ) ) + try { - rtl::OUString aErrStr = getResourceString( RID_STR_HELPPROCESSING_GENERAL_ERROR ); - aErrStr += rtl::OUString::createFromAscii( "No help folder" ); - OWeakObject* oWeakThis = static_cast(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + xInvocation = Reference< script::XInvocation >( + xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( + "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY ); } - - Reference const & xContext = getComponentContext(); - Reference< script::XInvocation > xInvocation; - if( xContext.is() ) + catch (Exception &) { - try - { - xInvocation = Reference< script::XInvocation >( - xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( - "com.sun.star.help.HelpIndexer" ), xContext ) , UNO_QUERY ); - } - catch (Exception &) - { - // i98680: Survive missing lucene - } + // i98680: Survive missing lucene } + } - // Scan languages - Sequence< rtl::OUString > aLanguageFolderSeq = xSFA->getFolderContents( aExpandedHelpURL, true ); - sal_Int32 nLangCount = aLanguageFolderSeq.getLength(); - const rtl::OUString* pSeq = aLanguageFolderSeq.getConstArray(); - for( sal_Int32 iLang = 0 ; iLang < nLangCount ; ++iLang ) + // Scan languages + Sequence< rtl::OUString > aLanguageFolderSeq = xSFA->getFolderContents( aExpandedHelpURL, true ); + sal_Int32 nLangCount = aLanguageFolderSeq.getLength(); + const rtl::OUString* pSeq = aLanguageFolderSeq.getConstArray(); + for( sal_Int32 iLang = 0 ; iLang < nLangCount ; ++iLang ) + { + rtl::OUString aLangURL = pSeq[iLang]; + if( xSFA->isFolder( aLangURL ) ) { - rtl::OUString aLangURL = pSeq[iLang]; - if( xSFA->isFolder( aLangURL ) ) + std::vector< rtl::OUString > aXhpFileVector; + + // Delete (old) files in any case to allow compiler to be started every time +// rtl::OUString aLangWithPureNameURL( aLangURL ); +// aLangWithPureNameURL += aSlash; +// aLangWithPureNameURL += aHelpStr; +// rtl::OUString aDbFile( aLangWithPureNameURL ); +// aDbFile += rtl::OUString::createFromAscii( ".db" ); +// if( xSFA->exists( aDbFile ) ) +// xSFA->kill( aDbFile ); +// rtl::OUString aHtFile( aLangWithPureNameURL ); +// aHtFile += rtl::OUString::createFromAscii( ".ht" ); +// if( xSFA->exists( aHtFile ) ) +// xSFA->kill( aHtFile ); +// rtl::OUString aKeyFile( aLangWithPureNameURL ); +// aKeyFile += rtl::OUString::createFromAscii( ".key" ); +// if( xSFA->exists( aKeyFile ) ) +// xSFA->kill( aKeyFile ); + + // calculate jar file URL + sal_Int32 indexStartSegment = aLangURL.lastIndexOf('/'); + // for example "/en" + OUString langFolderURLSegment( + aLangURL.copy( + indexStartSegment + 1, aLangURL.getLength() - indexStartSegment - 1)); + + //create the folder in the "temporary folder" + ::ucbhelper::Content langFolderContent; + const OUString langFolderDest = makeURL(sHelpFolder, langFolderURLSegment); + const OUString langFolderDestExpanded = ::dp_misc::expandUnoRcUrl(langFolderDest); + ::dp_misc::create_folder( + &langFolderContent, + langFolderDest, xCmdEnv); + + rtl::OUString aJarFile( + makeURL(sHelpFolder, langFolderURLSegment + aSlash + aHelpStr + + OUSTR(".jar"))); +// aJarFile += aSlash; +// aJarFile += aHelpStr; +// aJarFile += rtl::OUString::createFromAscii( ".jar" ); + // remove in any case to clean up +// if( xSFA->exists( aJarFile ) ) +// xSFA->kill( aJarFile ); + aJarFile = ::dp_misc::expandUnoRcUrl(aJarFile); + + rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( + aJarFile, rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ); + rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.pkg://" ); + aDestBasePath += aEncodedJarFilePath; + aDestBasePath += rtl::OUString::createFromAscii( "/" ); + + sal_Int32 nLenLangFolderURL = aLangURL.getLength() + 1; + + Sequence< rtl::OUString > aSubLangSeq = xSFA->getFolderContents( aLangURL, true ); + sal_Int32 nSubLangCount = aSubLangSeq.getLength(); + const rtl::OUString* pSubLangSeq = aSubLangSeq.getConstArray(); + for( sal_Int32 iSubLang = 0 ; iSubLang < nSubLangCount ; ++iSubLang ) { - std::vector< rtl::OUString > aXhpFileVector; - - // Delete (old) files in any case to allow compiler to be started every time - rtl::OUString aLangWithPureNameURL( aLangURL ); - aLangWithPureNameURL += aSlash; - aLangWithPureNameURL += aHelpStr; - rtl::OUString aDbFile( aLangWithPureNameURL ); - aDbFile += rtl::OUString::createFromAscii( ".db" ); - if( xSFA->exists( aDbFile ) ) - xSFA->kill( aDbFile ); - rtl::OUString aHtFile( aLangWithPureNameURL ); - aHtFile += rtl::OUString::createFromAscii( ".ht" ); - if( xSFA->exists( aHtFile ) ) - xSFA->kill( aHtFile ); - rtl::OUString aKeyFile( aLangWithPureNameURL ); - aKeyFile += rtl::OUString::createFromAscii( ".key" ); - if( xSFA->exists( aKeyFile ) ) - xSFA->kill( aKeyFile ); - - // calculate jar file URL - rtl::OUString aJarFile( aLangURL ); - aJarFile += aSlash; - aJarFile += aHelpStr; - aJarFile += rtl::OUString::createFromAscii( ".jar" ); - // remove in any case to clean up - if( xSFA->exists( aJarFile ) ) - xSFA->kill( aJarFile ); - - rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( aJarFile, - rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ); - rtl::OUString aDestBasePath = rtl::OUString::createFromAscii( "vnd.sun.star.pkg://" ); - aDestBasePath += aEncodedJarFilePath; - aDestBasePath += rtl::OUString::createFromAscii( "/" ); - - sal_Int32 nLenLangFolderURL = aLangURL.getLength() + 1; - - Sequence< rtl::OUString > aSubLangSeq = xSFA->getFolderContents( aLangURL, true ); - sal_Int32 nSubLangCount = aSubLangSeq.getLength(); - const rtl::OUString* pSubLangSeq = aSubLangSeq.getConstArray(); - for( sal_Int32 iSubLang = 0 ; iSubLang < nSubLangCount ; ++iSubLang ) - { - rtl::OUString aSubFolderURL = pSubLangSeq[iSubLang]; - if( !xSFA->isFolder( aSubFolderURL ) ) - continue; + rtl::OUString aSubFolderURL = pSubLangSeq[iSubLang]; + if( !xSFA->isFolder( aSubFolderURL ) ) + continue; - implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); + implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); - // Copy to package (later: move?) - rtl::OUString aDestPath = aDestBasePath; - rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); - aDestPath += aPureFolderName; - xSFA->copy( aSubFolderURL, aDestPath ); - } + // Copy to package (later: move?) + rtl::OUString aDestPath = aDestBasePath; + rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); + aDestPath += aPureFolderName; + xSFA->copy( aSubFolderURL, aDestPath ); + } + //Copy help.tree to the temp folder in the help backend folder +// xSFA->copy(aLangURL + OUSTR("/help.tree"), langFolderDestExpanded + OUSTR("/help.tree")); - // Call compiler - sal_Int32 nXhpFileCount = aXhpFileVector.size(); - rtl::OUString* pXhpFiles = new rtl::OUString[nXhpFileCount]; - for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) - { - rtl::OUString aXhpFile = aXhpFileVector[iXhp]; - rtl::OUString aXhpRelFile = aXhpFile.copy( nLenLangFolderURL ); - pXhpFiles[iXhp] = aXhpRelFile; - } + // Call compiler + sal_Int32 nXhpFileCount = aXhpFileVector.size(); + rtl::OUString* pXhpFiles = new rtl::OUString[nXhpFileCount]; + for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) + { + rtl::OUString aXhpFile = aXhpFileVector[iXhp]; + rtl::OUString aXhpRelFile = aXhpFile.copy( nLenLangFolderURL ); + pXhpFiles[iXhp] = aXhpRelFile; + } - rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); - rtl::OUString aOfficeHelpPathFileURL; - ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); + rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); + rtl::OUString aOfficeHelpPathFileURL; + ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); - HelpProcessingErrorInfo aErrorInfo; - bool bSuccess = compileExtensionHelp( aOfficeHelpPathFileURL, aHelpStr, aLangURL, - nXhpFileCount, pXhpFiles, aErrorInfo ); + HelpProcessingErrorInfo aErrorInfo; + bool bSuccess = compileExtensionHelp( + aOfficeHelpPathFileURL, aHelpStr, aLangURL, + nXhpFileCount, pXhpFiles, + langFolderDestExpanded, aErrorInfo ); - if( bSuccess && xInvocation.is() ) - { - Sequence aParamsSeq( 6 ); - - aParamsSeq[0] = uno::makeAny( rtl::OUString::createFromAscii( "-lang" ) ); - - rtl::OUString aLang; - sal_Int32 nLastSlash = aLangURL.lastIndexOf( '/' ); - if( nLastSlash != -1 ) - aLang = aLangURL.copy( nLastSlash + 1 ); - else - aLang = rtl::OUString::createFromAscii( "en" ); - aParamsSeq[1] = uno::makeAny( aLang ); - - aParamsSeq[2] = uno::makeAny( rtl::OUString::createFromAscii( "-mod" ) ); - aParamsSeq[3] = uno::makeAny( rtl::OUString::createFromAscii( "help" ) ); - - aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); - rtl::OUString aSystemPath; - osl::FileBase::getSystemPathFromFileURL( aLangURL, aSystemPath ); - aParamsSeq[5] = uno::makeAny( aSystemPath ); - - Sequence< sal_Int16 > aOutParamIndex; - Sequence< uno::Any > aOutParam; - uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "createIndex" ), - aParamsSeq, aOutParamIndex, aOutParam ); - } + if( bSuccess && xInvocation.is() ) + { + Sequence aParamsSeq( 6 ); + + aParamsSeq[0] = uno::makeAny( rtl::OUString::createFromAscii( "-lang" ) ); + + rtl::OUString aLang; + sal_Int32 nLastSlash = aLangURL.lastIndexOf( '/' ); + if( nLastSlash != -1 ) + aLang = aLangURL.copy( nLastSlash + 1 ); + else + aLang = rtl::OUString::createFromAscii( "en" ); + aParamsSeq[1] = uno::makeAny( aLang ); + + aParamsSeq[2] = uno::makeAny( rtl::OUString::createFromAscii( "-mod" ) ); + aParamsSeq[3] = uno::makeAny( rtl::OUString::createFromAscii( "help" ) ); + + aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); + rtl::OUString aSystemPath; +// osl::FileBase::getSystemPathFromFileURL( aLangURL, aSystemPath ); + osl::FileBase::getSystemPathFromFileURL( + langFolderDestExpanded, aSystemPath ); + aParamsSeq[5] = uno::makeAny( aSystemPath ); + + Sequence< sal_Int16 > aOutParamIndex; + Sequence< uno::Any > aOutParam; + uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "createIndex" ), + aParamsSeq, aOutParamIndex, aOutParam ); + } - if( !bSuccess ) + if( !bSuccess ) + { + USHORT nErrStrId = 0; + switch( aErrorInfo.m_eErrorClass ) + { + case HELPPROCESSING_GENERAL_ERROR: + case HELPPROCESSING_INTERNAL_ERROR: nErrStrId = RID_STR_HELPPROCESSING_GENERAL_ERROR; break; + case HELPPROCESSING_XMLPARSING_ERROR: nErrStrId = RID_STR_HELPPROCESSING_XMLPARSING_ERROR; break; + default: ; + }; + + rtl::OUString aErrStr; + if( nErrStrId != 0 ) { - USHORT nErrStrId = 0; - switch( aErrorInfo.m_eErrorClass ) + aErrStr = getResourceString( nErrStrId ); + + // Remoce CR/LF + rtl::OUString aErrMsg( aErrorInfo.m_aErrorMsg ); + sal_Unicode nCR = 13, nLF = 10; + sal_Int32 nSearchCR = aErrMsg.indexOf( nCR ); + sal_Int32 nSearchLF = aErrMsg.indexOf( nLF ); + sal_Int32 nCopy; + if( nSearchCR != -1 || nSearchLF != -1 ) { - case HELPPROCESSING_GENERAL_ERROR: - case HELPPROCESSING_INTERNAL_ERROR: nErrStrId = RID_STR_HELPPROCESSING_GENERAL_ERROR; break; - case HELPPROCESSING_XMLPARSING_ERROR: nErrStrId = RID_STR_HELPPROCESSING_XMLPARSING_ERROR; break; - default: ; - }; - - rtl::OUString aErrStr; - if( nErrStrId != 0 ) + if( nSearchCR == -1 ) + nCopy = nSearchLF; + else if( nSearchLF == -1 ) + nCopy = nSearchCR; + else + nCopy = ( nSearchCR < nSearchLF ) ? nSearchCR : nSearchLF; + + aErrMsg = aErrMsg.copy( 0, nCopy ); + } + aErrStr += aErrMsg; + if( nErrStrId == RID_STR_HELPPROCESSING_XMLPARSING_ERROR && aErrorInfo.m_aXMLParsingFile.getLength() ) { - aErrStr = getResourceString( nErrStrId ); - - // Remoce CR/LF - rtl::OUString aErrMsg( aErrorInfo.m_aErrorMsg ); - sal_Unicode nCR = 13, nLF = 10; - sal_Int32 nSearchCR = aErrMsg.indexOf( nCR ); - sal_Int32 nSearchLF = aErrMsg.indexOf( nLF ); - sal_Int32 nCopy; - if( nSearchCR != -1 || nSearchLF != -1 ) - { - if( nSearchCR == -1 ) - nCopy = nSearchLF; - else if( nSearchLF == -1 ) - nCopy = nSearchCR; - else - nCopy = ( nSearchCR < nSearchLF ) ? nSearchCR : nSearchLF; - - aErrMsg = aErrMsg.copy( 0, nCopy ); - } - aErrStr += aErrMsg; - if( nErrStrId == RID_STR_HELPPROCESSING_XMLPARSING_ERROR && aErrorInfo.m_aXMLParsingFile.getLength() ) + aErrStr += rtl::OUString::createFromAscii( " in " ); + + rtl::OUString aDecodedFile = rtl::Uri::decode( aErrorInfo.m_aXMLParsingFile, + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); + aErrStr += aDecodedFile; + if( aErrorInfo.m_nXMLParsingLine != -1 ) { - aErrStr += rtl::OUString::createFromAscii( " in " ); - - rtl::OUString aDecodedFile = rtl::Uri::decode( aErrorInfo.m_aXMLParsingFile, - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - aErrStr += aDecodedFile; - if( aErrorInfo.m_nXMLParsingLine != -1 ) - { - aErrStr += rtl::OUString::createFromAscii( ", line " ); - aErrStr += ::rtl::OUString::valueOf( aErrorInfo.m_nXMLParsingLine ); - } + aErrStr += rtl::OUString::createFromAscii( ", line " ); + aErrStr += ::rtl::OUString::valueOf( aErrorInfo.m_nXMLParsingLine ); } } - - OWeakObject* oWeakThis = static_cast(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); } + + OWeakObject* oWeakThis = static_cast(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); } } - - // Write compiled flag file (this code is only reached in case of success) - Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aCompiledFlagFile ); - if( xOutputStream.is() ) - xOutputStream->closeOutput(); - - } // if( bCompile ) - - // Write registered flag file (this code is only reached in case of success) - if( !xSFA->exists( aRegisteredFlagFile ) ) - { - Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aRegisteredFlagFile ); - if( xOutputStream.is() ) - xOutputStream->closeOutput(); } + + //Writing the data entry replaces writing the flag file. If we got to this + //point the registration was successful. addDataToDb(xPackage->getURL(), data); } else @@ -539,75 +562,75 @@ void BackendImpl::implProcessHelp } } -rtl::OUString BackendImpl::getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ) -{ - rtl::OUString aRetURL; - if( !xPackage.is() ) - return aRetURL; - rtl::OUString aHelpURL = xPackage->getURL(); - aRetURL = expandURL( aHelpURL ); - aRetURL += rtl::OUString::createFromAscii( pFlagStr ); - return aRetURL; -} - -rtl::OUString BackendImpl::getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ) -{ - return getFlagFileURL( xPackage, "/RegisteredFlag" ); -} - -rtl::OUString BackendImpl::getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ) -{ - return getFlagFileURL( xPackage, "/CompiledFlag" ); -} - -rtl::OUString BackendImpl::expandURL( const rtl::OUString& aURL ) -{ - static Reference< util::XMacroExpander > xMacroExpander; - static Reference< uri::XUriReferenceFactory > xFac; - - if( !xMacroExpander.is() || !xFac.is() ) - { - Reference const & xContext = getComponentContext(); - if( xContext.is() ) - { - xFac = Reference< uri::XUriReferenceFactory >( - xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( - "com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY ); - } - if( !xFac.is() ) - { - throw RuntimeException( - ::rtl::OUString::createFromAscii( - "dp_registry::backend::help::BackendImpl::expandURL(), " - "could not instatiate UriReferenceFactory." ), - Reference< XInterface >() ); - } - - xMacroExpander = Reference< util::XMacroExpander >( - xContext->getValueByName( - ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ), - UNO_QUERY_THROW ); - } - - rtl::OUString aRetURL = aURL; - if( xMacroExpander.is() ) - { - Reference< uri::XUriReference > uriRef; - for (;;) - { - uriRef = Reference< uri::XUriReference >( xFac->parse( aRetURL ), UNO_QUERY ); - if ( uriRef.is() ) - { - Reference < uri::XVndSunStarExpandUrl > sxUri( uriRef, UNO_QUERY ); - if( !sxUri.is() ) - break; - - aRetURL = sxUri->expand( xMacroExpander ); - } - } - } - return aRetURL; -} +// rtl::OUString BackendImpl::getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ) +// { +// rtl::OUString aRetURL; +// if( !xPackage.is() ) +// return aRetURL; +// rtl::OUString aHelpURL = xPackage->getURL(); +// aRetURL = expandURL( aHelpURL ); +// aRetURL += rtl::OUString::createFromAscii( pFlagStr ); +// return aRetURL; +// } + +// rtl::OUString BackendImpl::getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ) +// { +// return getFlagFileURL( xPackage, "/RegisteredFlag" ); +// } + +// rtl::OUString BackendImpl::getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ) +// { +// return getFlagFileURL( xPackage, "/CompiledFlag" ); +// } + +// rtl::OUString BackendImpl::expandURL( const rtl::OUString& aURL ) +// { +// static Reference< util::XMacroExpander > xMacroExpander; +// static Reference< uri::XUriReferenceFactory > xFac; + +// if( !xMacroExpander.is() || !xFac.is() ) +// { +// Reference const & xContext = getComponentContext(); +// if( xContext.is() ) +// { +// xFac = Reference< uri::XUriReferenceFactory >( +// xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( +// "com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY ); +// } +// if( !xFac.is() ) +// { +// throw RuntimeException( +// ::rtl::OUString::createFromAscii( +// "dp_registry::backend::help::BackendImpl::expandURL(), " +// "could not instatiate UriReferenceFactory." ), +// Reference< XInterface >() ); +// } + +// xMacroExpander = Reference< util::XMacroExpander >( +// xContext->getValueByName( +// ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ), +// UNO_QUERY_THROW ); +// } + +// rtl::OUString aRetURL = aURL; +// if( xMacroExpander.is() ) +// { +// Reference< uri::XUriReference > uriRef; +// for (;;) +// { +// uriRef = Reference< uri::XUriReference >( xFac->parse( aRetURL ), UNO_QUERY ); +// if ( uriRef.is() ) +// { +// Reference < uri::XVndSunStarExpandUrl > sxUri( uriRef, UNO_QUERY ); +// if( !sxUri.is() ) +// break; + +// aRetURL = sxUri->expand( xMacroExpander ); +// } +// } +// } +// return aRetURL; +// } void BackendImpl::implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ) diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx index 6f7e1d2844ac..f36eb6d7b8cb 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -143,7 +143,8 @@ void HelpBackendDb::removeEntry(::rtl::OUString const & url) removeElement(sExpression); } -HelpBackendDb::Data HelpBackendDb::getEntry(::rtl::OUString const & url) +::boost::optional +HelpBackendDb::getEntry(::rtl::OUString const & url) { try { @@ -174,8 +175,13 @@ HelpBackendDb::Data HelpBackendDb::getEntry(::rtl::OUString const & url) // readVectorOfPair( // aNode, OUSTR("reg:singletons"), OUSTR("item"), OUSTR("key"), // OUSTR("value")); + + } + else + { + return ::boost::optional(); } - return retData; + return ::boost::optional(retData); } catch(css::uno::Exception &) { diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx index e80a24f85ab1..bf812ad96511 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx @@ -35,6 +35,7 @@ #include "rtl/string.hxx" #include #include +#include "boost/optional.hpp" #include "dp_backenddb.hxx" namespace css = ::com::sun::star; @@ -87,7 +88,7 @@ public: void addEntry(::rtl::OUString const & url, Data const & data); void removeEntry(::rtl::OUString const & url); - Data getEntry(::rtl::OUString const & url); + ::boost::optional getEntry(::rtl::OUString const & url); ::std::list< ::rtl::OUString> getAllDataUrls(); }; diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 24c6e4914fe1..179420b16ef6 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -257,6 +257,9 @@ public: css::ucb::CommandAbortedException, css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getRepositoryName() throw (css::uno::RuntimeException); + virtual css::beans::Optional< ::rtl::OUString > SAL_CALL getRegistrationDataURL() + throw (css::deployment::ExtensionRemovedException, + css::uno::RuntimeException); virtual sal_Bool SAL_CALL isRemoved() throw (css::uno::RuntimeException); -- cgit From 3c289e248a4f7c6940bb7429ee70d17a6196016c Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 19 Apr 2010 11:33:33 +0200 Subject: jl152 import 263446 from native0jl:#i77196# supporting licenses, suppress license switch, subsequent accepting of licenses for bundled/shared extensions --- desktop/inc/deployment.hrc | 1 - desktop/source/app/check_ext_deps.cxx | 135 +------ desktop/source/app/makefile.mk | 14 + desktop/source/deployment/gui/dp_gui.hrc | 1 - desktop/source/deployment/gui/dp_gui_dialog.src | 10 +- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 23 +- .../deployment/gui/dp_gui_updateinstalldialog.cxx | 4 +- desktop/source/deployment/gui/license_dialog.cxx | 11 +- desktop/source/deployment/gui/license_dialog.hxx | 1 + desktop/source/deployment/inc/dp_misc.h | 7 +- desktop/source/deployment/inc/dp_ucb.h | 7 + .../deployment/manager/dp_activepackages.cxx | 8 +- .../deployment/manager/dp_activepackages.hxx | 9 + .../deployment/manager/dp_commandenvironments.cxx | 255 ++++++++++++ .../deployment/manager/dp_commandenvironments.hxx | 146 +++++++ .../deployment/manager/dp_extensionmanager.cxx | 333 ++++++++-------- .../deployment/manager/dp_extensionmanager.hxx | 37 +- desktop/source/deployment/manager/dp_manager.cxx | 439 ++++++++++++--------- desktop/source/deployment/manager/dp_manager.h | 28 +- .../source/deployment/manager/dp_properties.cxx | 147 +++++++ .../source/deployment/manager/dp_properties.hxx | 76 ++++ .../source/deployment/manager/dp_tmprepocmdenv.cxx | 166 -------- .../source/deployment/manager/dp_tmprepocmdenv.hxx | 84 ---- desktop/source/deployment/manager/makefile.mk | 3 +- .../source/deployment/migration/dp_migration.cxx | 2 +- desktop/source/deployment/misc/dp_misc.cxx | 142 ++++++- desktop/source/deployment/misc/dp_ucb.cxx | 46 +++ .../deployment/registry/component/dp_component.cxx | 11 +- .../registry/configuration/dp_configuration.cxx | 3 +- desktop/source/deployment/registry/dp_backend.cxx | 20 +- desktop/source/deployment/registry/dp_registry.cxx | 8 +- .../registry/executable/dp_executable.cxx | 3 +- .../source/deployment/registry/help/dp_help.cxx | 112 +----- .../source/deployment/registry/inc/dp_backend.h | 4 +- .../deployment/registry/package/dp_package.cxx | 69 ++-- .../deployment/registry/script/dp_script.cxx | 6 +- desktop/source/deployment/unopkg/unopkg.src | 7 +- .../migration/services/oo3extensionmigration.cxx | 4 +- desktop/source/pkgchk/unopkg/unopkg_app.cxx | 161 ++++++-- desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx | 55 +-- desktop/source/pkgchk/unopkg/unopkg_misc.cxx | 42 +- desktop/source/pkgchk/unopkg/unopkg_shared.h | 10 +- 42 files changed, 1612 insertions(+), 1038 deletions(-) create mode 100644 desktop/source/deployment/manager/dp_commandenvironments.cxx create mode 100644 desktop/source/deployment/manager/dp_commandenvironments.hxx create mode 100644 desktop/source/deployment/manager/dp_properties.cxx create mode 100644 desktop/source/deployment/manager/dp_properties.hxx delete mode 100644 desktop/source/deployment/manager/dp_tmprepocmdenv.cxx delete mode 100644 desktop/source/deployment/manager/dp_tmprepocmdenv.hxx (limited to 'desktop') diff --git a/desktop/inc/deployment.hrc b/desktop/inc/deployment.hrc index 7e4c21d3c5a4..370996c710ae 100644 --- a/desktop/inc/deployment.hrc +++ b/desktop/inc/deployment.hrc @@ -63,7 +63,6 @@ #define RID_IMG_JAVA_TYPELIB_HC (RID_DEPLOYMENT_COMPONENT_START+7) #define RID_DEPLOYMENT_UNOPKG_START (RID_DEPLOYMENT_START+4000) -#define RID_STR_UNOPKG_NO_SHARED_ALLOWED RID_DEPLOYMENT_UNOPKG_START #define RID_STR_UNOPKG_ACCEPT_LIC_1 (RID_DEPLOYMENT_UNOPKG_START+1) #define RID_STR_UNOPKG_ACCEPT_LIC_2 (RID_DEPLOYMENT_UNOPKG_START+2) #define RID_STR_UNOPKG_ACCEPT_LIC_3 (RID_DEPLOYMENT_UNOPKG_START+3) diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 17dc20e1a129..f487e0dfc96f 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -53,6 +53,8 @@ #include "app.hxx" +#include "../deployment/inc/dp_misc.h" + using rtl::OUString; using namespace desktop; using namespace com::sun::star; @@ -342,101 +344,6 @@ sal_Bool Desktop::CheckExtensionDependencies() return bAbort; } -//Returns true if the Folder was more recently modified then -//the lastsynchronized file. That is the repository needs to -//be synchronized. -static bool compareExtensionFolderWithLastSynchronizedFile( - OUString const & folderURL, OUString const & fileURL) -{ - bool bNeedsSync = false; - ::osl::DirectoryItem itemExtFolder; - ::osl::File::RC err1 = - ::osl::DirectoryItem::get(folderURL, itemExtFolder); - //If it does not exist, then there is nothing to be done - if (err1 == ::osl::File::E_NOENT) - { - return false; - } - else if (err1 != ::osl::File::E_None) - { - OSL_ENSURE(0, "Cannot access extension folder"); - return true; //sync just in case - } - - //If last synchronized does not exist, then OOo is started for the first time - ::osl::DirectoryItem itemFile; - ::osl::File::RC err2 = ::osl::DirectoryItem::get(fileURL, itemFile); - if (err2 == ::osl::File::E_NOENT) - { - return true; - - } - else if (err2 != ::osl::File::E_None) - { - OSL_ENSURE(0, "Cannot access file lastsynchronized"); - return true; //sync just in case - } - - //compare the modification time of the extension folder and the last - //modified file - ::osl::FileStatus statFolder(FileStatusMask_ModifyTime); - ::osl::FileStatus statFile(FileStatusMask_ModifyTime); - if (itemExtFolder.getFileStatus(statFolder) == ::osl::File::E_None) - { - if (itemFile.getFileStatus(statFile) == ::osl::File::E_None) - { - TimeValue timeFolder = statFolder.getModifyTime(); - TimeValue timeFile = statFile.getModifyTime(); - - if (timeFile.Seconds < timeFolder.Seconds) - bNeedsSync = true; - } - else - { - OSL_ASSERT(0); - bNeedsSync = true; - } - } - else - { - OSL_ASSERT(0); - bNeedsSync = true; - } - return bNeedsSync; -} - -static bool needToSyncRepostitory(OUString const & name) -{ - OUString folder; - OUString file; - if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("bundled")))) - { - folder = OUString( - RTL_CONSTASCII_USTRINGPARAM("$BUNDLED_EXTENSIONS")); - file = OUString ( - RTL_CONSTASCII_USTRINGPARAM( - "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); - } - else if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("shared")))) - { - folder = OUString( - RTL_CONSTASCII_USTRINGPARAM( - "$UNO_SHARED_PACKAGES_CACHE/uno_packages")); - file = OUString ( - RTL_CONSTASCII_USTRINGPARAM( - "$SHARED_EXTENSIONS_USER/lastsynchronized")); - } - else - { - OSL_ASSERT(0); - return true; - } - ::rtl::Bootstrap::expandMacros(folder); - ::rtl::Bootstrap::expandMacros(file); - return compareExtensionFolderWithLastSynchronizedFile( - folder, file); -} - void Desktop::SynchronizeExtensionRepositories() { RTL_LOGFILE_CONTEXT(aLog,"desktop (jl97489) ::Desktop::SynchronizeExtensionRepositories"); @@ -447,41 +354,5 @@ void Desktop::SynchronizeExtensionRepositories() OUString(RTL_CONSTASCII_USTRINGPARAM(""))); if (sDisable.getLength() > 0) return; - Reference xExtensionManager; - //synchronize shared before bundled otherewise there are - //more revoke and registration calls. - OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); - if (needToSyncRepostitory(sShared)) - { - xExtensionManager = - deployment::ExtensionManager::get( - comphelper_getProcessComponentContext()); - if (xExtensionManager.is()) - { - Reference cmdEnv( - new SilentCommandEnv()); - xExtensionManager->synchronize( - sShared, Reference(), cmdEnv); - } - - } - - OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); - if (needToSyncRepostitory( sBundled)) - { - if (!xExtensionManager.is()) - { - xExtensionManager = - deployment::ExtensionManager::get( - comphelper_getProcessComponentContext()); - } - if (xExtensionManager.is()) - { - Reference cmdEnv( - new SilentCommandEnv()); - xExtensionManager->synchronize( - sBundled, Reference(), cmdEnv); - - } - } + dp_misc::syncRepositories(new SilentCommandEnv()); } diff --git a/desktop/source/app/makefile.mk b/desktop/source/app/makefile.mk index d9db7c163481..085d8520e7ad 100644 --- a/desktop/source/app/makefile.mk +++ b/desktop/source/app/makefile.mk @@ -35,11 +35,24 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.INCLUDE : ../deployment/inc/dp_misc.mk .IF "$(ENABLE_GNOMEVFS)"=="TRUE" CFLAGS+=-DGNOME_VFS_ENABLED .ENDIF +# .IF "$(OS)" == "WNT" +# .IF "$(COM)" == "GCC" +# DEPLOYMENTMISCLIB = -ldeploymentmisc$(DLLPOSTFIX) +# .ELSE +# DEPLOYMENTMISCLIB = ideploymentmisc$(DLLPOSTFIX).lib +# .ENDIF +# .ELIF "$(OS)" == "OS2" +# DEPLOYMENTMISCLIB = ideploymentmisc$(DLLPOSTFIX).lib +# .ELSE +# DEPLOYMENTMISCLIB = -ldeploymentmisc$(DLLPOSTFIX) +# .ENDIF + SHL1TARGET = sofficeapp SHL1OBJS = \ $(SLO)$/app.obj \ @@ -67,6 +80,7 @@ SHL1STDLIBS = \ $(COMPHELPERLIB) \ $(CPPUHELPERLIB) \ $(CPPULIB) \ + $(DEPLOYMENTMISCLIB) \ $(I18NISOLANGLIB) \ $(SALLIB) \ $(SFXLIB) \ diff --git a/desktop/source/deployment/gui/dp_gui.hrc b/desktop/source/deployment/gui/dp_gui.hrc index 1d2f4869cc7f..022141976f55 100644 --- a/desktop/source/deployment/gui/dp_gui.hrc +++ b/desktop/source/deployment/gui/dp_gui.hrc @@ -172,7 +172,6 @@ #define RID_WARNINGBOX_DISABLE_SHARED_EXTENSION (RID_DEPLOYMENT_GUI_START+106) #define RID_DLG_LICENSE RID_DEPLOYMENT_LICENSE_START -#define WARNINGBOX_NOSHAREDALLOWED (RID_DEPLOYMENT_LICENSE_START+1) diff --git a/desktop/source/deployment/gui/dp_gui_dialog.src b/desktop/source/deployment/gui/dp_gui_dialog.src index 79c0c5172030..f9d9c0e011c6 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog.src +++ b/desktop/source/deployment/gui/dp_gui_dialog.src @@ -131,7 +131,7 @@ String RID_STR_ERROR_MISSING_DEPENDENCIES #define ROW1_Y RSC_SP_DLG_INNERBORDER_TOP #define ROW1_HEIGHT 16*RSC_CD_FIXEDTEXT_HEIGHT #define ROW2_Y ROW1_Y+ROW1_HEIGHT+RSC_SP_CTRL_GROUP_Y -#define ROW2_HEIGHT 2*RSC_CD_FIXEDTEXT_HEIGHT +#define ROW2_HEIGHT 3*RSC_CD_FIXEDTEXT_HEIGHT #define ROW3_Y ROW2_Y+ROW2_HEIGHT+RSC_SP_CTRL_GROUP_Y #define ROW3_HEIGHT 3*RSC_CD_FIXEDTEXT_HEIGHT #define ROW4_Y ROW3_Y+ROW3_HEIGHT+RSC_SP_CTRL_GROUP_Y @@ -282,14 +282,6 @@ ModalDialog RID_DLG_LICENSE -WarningBox WARNINGBOX_NOSHAREDALLOWED -{ - Buttons = WB_OK ; - DefButton = WB_DEF_OK; - Message[ en-US ] ="The extension \'%NAME\' cannot be installed under \"%PRODUCTNAME Extensions\", because " - "every user has to agree to the license agreement of the extension. The extension will not be installed."; -}; - WarningBox RID_WARNINGBOX_INSTALL_EXTENSION { Buttons = WB_OK_CANCEL; DefButton = WB_DEF_OK; diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index a617e07758c7..4b55a93d3f84 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -36,10 +36,10 @@ #include #include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/beans/NamedValue.hpp" #include "com/sun/star/deployment/DependencyException.hpp" #include "com/sun/star/deployment/LicenseException.hpp" -#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp" #include "com/sun/star/deployment/VersionException.hpp" #include "com/sun/star/deployment/InstallException.hpp" #include "com/sun/star/deployment/PlatformException.hpp" @@ -379,7 +379,6 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & lang::WrappedTargetException wtExc; deployment::DependencyException depExc; deployment::LicenseException licExc; - deployment::LicenseIndividualAgreementException licAgreementExc; deployment::VersionException verExc; deployment::InstallException instExc; deployment::PlatformException platExc; @@ -441,23 +440,12 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & || (n == RET_CANCEL && !Application::IsDialogCancelEnabled()); } } - else if (request >>= licAgreementExc) - { - vos::OGuard aSolarGuard( Application::GetSolarMutex() ); - ResId warnId(WARNINGBOX_NOSHAREDALLOWED, *DeploymentGuiResMgr::get()); - WarningBox warn( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL, warnId); - String msgText = warn.GetMessText(); - msgText.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() ); - msgText.SearchAndReplaceAllAscii("%NAME", licAgreementExc.ExtensionName); - warn.SetMessText(msgText); - warn.Execute(); - abort = true; - } else if (request >>= licExc) { uno::Reference< ui::dialogs::XExecutableDialog > xDialog( deployment::ui::LicenseDialog::create( - m_xContext, VCLUnoHelper::GetInterface( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL ), licExc.Text ) ); + m_xContext, VCLUnoHelper::GetInterface( m_pDialogHelper? m_pDialogHelper->getWindow() : NULL ), + licExc.ExtensionName, licExc.Text ) ); sal_Int16 res = xDialog->execute(); if ( res == ui::dialogs::ExecutableDialogResults::CANCEL ) abort = true; @@ -948,8 +936,9 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv { OUString sPackageManager = xPackageManager->getContext(); uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); - uno::Reference< deployment::XPackage > xPackage( xExtMgr->addExtension( rPackageURL, sPackageManager, - xAbortChannel, rCmdEnv.get() ) ); + uno::Reference< deployment::XPackage > xPackage( + xExtMgr->addExtension(rPackageURL, uno::Sequence(), + sPackageManager, xAbortChannel, rCmdEnv.get() ) ); OSL_ASSERT( xPackage.is() ); } catch ( ucb::CommandFailedException & ) diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx index 113e6d2069ac..f607713118f0 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx @@ -46,6 +46,7 @@ #include "cppuhelper/implbase3.hxx" #include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/beans/NamedValue.hpp" #include "com/sun/star/xml/dom/XElement.hpp" #include "com/sun/star/xml/dom/XNode.hpp" #include "com/sun/star/xml/dom/XNodeList.hpp" @@ -504,7 +505,8 @@ void UpdateInstallDialog::Thread::installExtensions() m_abort = xAbortChannel; } xPackage = curData.aPackageManager->addPackage( - curData.sLocalURL, OUString(), xAbortChannel, m_updateCmdEnv.get()); + curData.sLocalURL, css::uno::Sequence(), + OUString(), xAbortChannel, m_updateCmdEnv.get()); } catch (css::deployment::DeploymentException & de) { diff --git a/desktop/source/deployment/gui/license_dialog.cxx b/desktop/source/deployment/gui/license_dialog.cxx index 50992eb07a97..9698e257b953 100644 --- a/desktop/source/deployment/gui/license_dialog.cxx +++ b/desktop/source/deployment/gui/license_dialog.cxx @@ -116,6 +116,7 @@ struct LicenseDialogImpl : public ModalDialog LicenseDialogImpl( Window * pParent, css::uno::Reference< css::uno::XComponentContext > const & xContext, + const ::rtl::OUString & sExtensionName, const ::rtl::OUString & sLicenseText); virtual void Activate(); @@ -193,6 +194,7 @@ void LicenseView::Notify( SfxBroadcaster&, const SfxHint& rHint ) LicenseDialogImpl::LicenseDialogImpl( Window * pParent, cssu::Reference< cssu::XComponentContext > const & xContext, + const ::rtl::OUString & sExtensionName, const ::rtl::OUString & sLicenseText): ModalDialog(pParent, DpGuiResId(RID_DLG_LICENSE)) ,m_xComponentContext(xContext) @@ -225,6 +227,7 @@ LicenseDialogImpl::LicenseDialogImpl( m_fiArrow1.Show(true); m_fiArrow2.Show(false); m_mlLicense.SetText(sLicenseText); + m_ftHead.SetText(m_ftHead.GetText() + OUString('\n') + sExtensionName); m_mlLicense.SetEndReachedHdl( LINK(this, LicenseDialogImpl, EndReachedHdl) ); m_mlLicense.SetScrolledHdl( LINK(this, LicenseDialogImpl, ScrolledHdl) ); @@ -296,7 +299,7 @@ LicenseDialog::LicenseDialog( Sequence const& args, Reference const& xComponentContext) : m_xComponentContext(xComponentContext) { - comphelper::unwrapArgs( args, m_parent, m_sLicenseText ); + comphelper::unwrapArgs( args, m_parent, m_sExtensionName, m_sLicenseText ); } // XExecutableDialog @@ -315,8 +318,10 @@ sal_Int16 LicenseDialog::execute() throw (RuntimeException) sal_Int16 LicenseDialog::solar_execute() { - std::auto_ptr dlg(new LicenseDialogImpl( - VCLUnoHelper::GetWindow(m_parent), m_xComponentContext, m_sLicenseText)); + std::auto_ptr dlg( + new LicenseDialogImpl( + VCLUnoHelper::GetWindow(m_parent), + m_xComponentContext, m_sExtensionName, m_sLicenseText)); return dlg->Execute(); } diff --git a/desktop/source/deployment/gui/license_dialog.hxx b/desktop/source/deployment/gui/license_dialog.hxx index 4733922dc607..bb4a6b6646c8 100644 --- a/desktop/source/deployment/gui/license_dialog.hxx +++ b/desktop/source/deployment/gui/license_dialog.hxx @@ -48,6 +48,7 @@ class LicenseDialog { Reference const m_xComponentContext; Reference /* const */ m_parent; + OUString m_sExtensionName; OUString /* const */ m_sLicenseText; OUString m_initialTitle; diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h index ee5867a655d3..3283d20718be 100644 --- a/desktop/source/deployment/inc/dp_misc.h +++ b/desktop/source/deployment/inc/dp_misc.h @@ -36,6 +36,7 @@ #include "com/sun/star/lang/XComponent.hpp" #include "com/sun/star/lang/DisposedException.hpp" #include "com/sun/star/deployment/XPackageRegistry.hpp" +#include "com/sun/star/ucb/XCommandEnvironment.hpp" #include "com/sun/star/awt/XWindow.hpp" #include "dp_misc_api.hxx" @@ -168,8 +169,12 @@ void TRACE(::rtl::OUString const & sText); DESKTOP_DEPLOYMENTMISC_DLLPUBLIC void TRACE(::rtl::OString const & sText); +/** registers or revokes shared or bundled extensions which have been + recently added or removed. +*/ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC -bool hasExtensionRepositoryChanged(::rtl::OUString const & repository); +void syncRepositories(::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv); } diff --git a/desktop/source/deployment/inc/dp_ucb.h b/desktop/source/deployment/inc/dp_ucb.h index 6f9127504860..03144388e8a8 100644 --- a/desktop/source/deployment/inc/dp_ucb.h +++ b/desktop/source/deployment/inc/dp_ucb.h @@ -28,6 +28,7 @@ #if ! defined INCLUDED_DP_UCB_H #define INCLUDED_DP_UCB_H +#include #include "rtl/byteseq.hxx" #include "rtl/instance.hxx" #include "com/sun/star/ucb/XCommandEnvironment.hpp" @@ -79,6 +80,12 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool readLine( ::rtl::OUString * res, ::rtl::OUString const & startingWith, ::ucbhelper::Content & ucb_content, rtl_TextEncoding textenc ); +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +bool readProperties( ::std::list< ::std::pair< ::rtl::OUString, ::rtl::OUString> > & out_result, + ::ucbhelper::Content & ucb_content); + + + } #endif diff --git a/desktop/source/deployment/manager/dp_activepackages.cxx b/desktop/source/deployment/manager/dp_activepackages.cxx index bf9071682b2e..8f6b6b82c0b7 100644 --- a/desktop/source/deployment/manager/dp_activepackages.cxx +++ b/desktop/source/deployment/manager/dp_activepackages.cxx @@ -107,10 +107,14 @@ static char const legacyPrefix[] = "org.openoffice.legacy."; } else { + sal_Int32 i4 = value.indexOf(separator, i3 + 1); d.mediaType = ::rtl::OUString( value.getStr() + i2 + 1, i3 - i2 -1, RTL_TEXTENCODING_UTF8); d.version = ::rtl::OUString( - value.getStr() + i3 + 1, value.getLength() - i3 - 1, + value.getStr() + i3 + 1, i4 - i3 - 1, + RTL_TEXTENCODING_UTF8); + d.failedPrerequisites = ::rtl::OUString( + value.getStr() + i4 + 1, value.getLength() - i4 - 1, RTL_TEXTENCODING_UTF8); } return d; @@ -188,6 +192,8 @@ void ActivePackages::put(::rtl::OUString const & id, Data const & data) { b.append(::rtl::OUStringToOString(data.mediaType, RTL_TEXTENCODING_UTF8)); b.append(separator); b.append(::rtl::OUStringToOString(data.version, RTL_TEXTENCODING_UTF8)); + b.append(separator); + b.append(::rtl::OUStringToOString(data.failedPrerequisites, RTL_TEXTENCODING_UTF8)); m_map.put(newKey(id), b.makeStringAndClear()); } diff --git a/desktop/source/deployment/manager/dp_activepackages.hxx b/desktop/source/deployment/manager/dp_activepackages.hxx index 36060d26bd02..7d9c7e32cfb4 100644 --- a/desktop/source/deployment/manager/dp_activepackages.hxx +++ b/desktop/source/deployment/manager/dp_activepackages.hxx @@ -42,6 +42,8 @@ namespace dp_manager { class ActivePackages { public: struct Data { + Data(): failedPrerequisites(::rtl::OUString::valueOf((sal_Int32)0)) + {} /* name of the temporary file (shared, user extension) or the name of the folder of the bundled extension. It does not contain the trailing '_' of the folder. @@ -55,6 +57,13 @@ public: ::rtl::OUString fileName; ::rtl::OUString mediaType; ::rtl::OUString version; + /* If this string contains the value according to + com::sun::star::deployment::Prerequisites or "0". That is, if + the value is > 0 then + the call to XPackage::checkPrerequisites failed. + In this case the extension must not be registered. + */ + ::rtl::OUString failedPrerequisites; }; typedef ::std::vector< ::std::pair< ::rtl::OUString, Data > > Entries; diff --git a/desktop/source/deployment/manager/dp_commandenvironments.cxx b/desktop/source/deployment/manager/dp_commandenvironments.cxx new file mode 100644 index 000000000000..814dc818b2a6 --- /dev/null +++ b/desktop/source/deployment/manager/dp_commandenvironments.cxx @@ -0,0 +1,255 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "com/sun/star/deployment/VersionException.hpp" +#include "com/sun/star/deployment/LicenseException.hpp" +#include "com/sun/star/deployment/InstallException.hpp" +#include "com/sun/star/task/XInteractionApprove.hpp" +#include "com/sun/star/task/XInteractionAbort.hpp" +#include "com/sun/star/task/XInteractionHandler.hpp" +#include "com/sun/star/ucb/XCommandEnvironment.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "dp_commandenvironments.hxx" + +namespace deployment = com::sun::star::deployment; +namespace lang = com::sun::star::lang; +namespace task = com::sun::star::task; +namespace ucb = com::sun::star::ucb; +namespace uno = com::sun::star::uno; +namespace css = com::sun::star; + +#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) + +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +namespace dp_manager { + +BaseCommandEnv::BaseCommandEnv() +{ +} + +BaseCommandEnv::BaseCommandEnv( + Reference< task::XInteractionHandler> const & handler) + : m_forwardHandler(handler) +{ +} + +BaseCommandEnv::~BaseCommandEnv() +{ +} +// XCommandEnvironment +//______________________________________________________________________________ +Reference BaseCommandEnv::getInteractionHandler() +throw (uno::RuntimeException) +{ + return this; +} + +//______________________________________________________________________________ +Reference BaseCommandEnv::getProgressHandler() +throw (uno::RuntimeException) +{ + return this; +} + +void BaseCommandEnv::handle( + Reference< task::XInteractionRequest> const & /*xRequest*/ ) + throw (uno::RuntimeException) +{ +} + +void BaseCommandEnv::handle_(bool approve, bool abort, + Reference< task::XInteractionRequest> const & xRequest ) +{ + if (approve == false && abort == false) + { + //not handled so far -> forwarding + if (m_forwardHandler.is()) + m_forwardHandler->handle(xRequest); + else + return; //cannot handle + } + else + { + // select: + uno::Sequence< Reference< task::XInteractionContinuation > > conts( + xRequest->getContinuations() ); + Reference< task::XInteractionContinuation > const * pConts = + conts.getConstArray(); + sal_Int32 len = conts.getLength(); + for ( sal_Int32 pos = 0; pos < len; ++pos ) + { + if (approve) { + Reference< task::XInteractionApprove > xInteractionApprove( + pConts[ pos ], uno::UNO_QUERY ); + if (xInteractionApprove.is()) { + xInteractionApprove->select(); + // don't query again for ongoing continuations: + approve = false; + } + } + else if (abort) { + Reference< task::XInteractionAbort > xInteractionAbort( + pConts[ pos ], uno::UNO_QUERY ); + if (xInteractionAbort.is()) { + xInteractionAbort->select(); + // don't query again for ongoing continuations: + abort = false; + } + } + } + } + +} + +// XProgressHandler +void BaseCommandEnv::push( uno::Any const & /*Status*/ ) +throw (uno::RuntimeException) +{ +} + + +void BaseCommandEnv::update( uno::Any const & /*Status */) +throw (uno::RuntimeException) +{ +} + +void BaseCommandEnv::pop() throw (uno::RuntimeException) +{ +} +//============================================================================== + +TmpRepositoryCommandEnv::TmpRepositoryCommandEnv() +{ +} + +TmpRepositoryCommandEnv::TmpRepositoryCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler): + BaseCommandEnv(handler) +{ +} +// XInteractionHandler +void TmpRepositoryCommandEnv::handle( + Reference< task::XInteractionRequest> const & xRequest ) + throw (uno::RuntimeException) +{ + uno::Any request( xRequest->getRequest() ); + OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); + + deployment::VersionException verExc; + deployment::LicenseException licExc; + deployment::InstallException instExc; + + bool approve = false; + bool abort = false; + + if ((request >>= verExc) + || (request >>= licExc) + || (request >>= instExc)) + { + approve = true; + } + + handle_(approve, abort, xRequest); +} +//================================================================================ + +LicenseCommandEnv::LicenseCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler, + bool bSuppressLicense, + OUString const & repository): + BaseCommandEnv(handler), m_repository(repository), + m_bSuppressLicense(bSuppressLicense) +{ +} +// XInteractionHandler +void LicenseCommandEnv::handle( + Reference< task::XInteractionRequest> const & xRequest ) + throw (uno::RuntimeException) +{ + uno::Any request( xRequest->getRequest() ); + OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); + + + deployment::LicenseException licExc; + + bool approve = false; + bool abort = false; + + if (request >>= licExc) + { + if (m_bSuppressLicense + || m_repository.equals(OUSTR("bundled")) + || licExc.AcceptBy.equals(OUSTR("admin"))) + { + //always approve in bundled case, because we do not support + //showing licenses anyway. + //The "admin" already accepted the license when installing the + // shared extension + approve = true; + } + } + + handle_(approve, abort, xRequest); +} + +//================================================================================ +//================================================================================ + +NoLicenseCommandEnv::NoLicenseCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler): + BaseCommandEnv(handler) +{ +} +// XInteractionHandler +void NoLicenseCommandEnv::handle( + Reference< task::XInteractionRequest> const & xRequest ) + throw (uno::RuntimeException) +{ + uno::Any request( xRequest->getRequest() ); + OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); + + + deployment::LicenseException licExc; + + bool approve = false; + bool abort = false; + + if (request >>= licExc) + { + approve = true; + } + handle_(approve, abort, xRequest); +} + +} // namespace dp_manager + + diff --git a/desktop/source/deployment/manager/dp_commandenvironments.hxx b/desktop/source/deployment/manager/dp_commandenvironments.hxx new file mode 100644 index 000000000000..ad47fd2af549 --- /dev/null +++ b/desktop/source/deployment/manager/dp_commandenvironments.hxx @@ -0,0 +1,146 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_COMMANDENVIRONMENTS_HXX +#define INCLUDED_DP_COMMANDENVIRONMENTS_HXX + + +#include "cppuhelper/compbase3.hxx" +//#include "cppuhelper/implbase2.hxx" +#include "ucbhelper/content.hxx" + + + +namespace css = ::com::sun::star; + +namespace dp_manager { + + + +/** + This command environment is to be used when an extension is temporarily + stored in the "tmp" repository. It prevents all kind of user interaction. + */ +class BaseCommandEnv + : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment, + css::task::XInteractionHandler, + css::ucb::XProgressHandler > +{ +protected: + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler; + + void handle_(bool approve, bool abort, + css::uno::Reference< css::task::XInteractionRequest> const & xRequest ); +public: + virtual ~BaseCommandEnv(); + BaseCommandEnv(); + BaseCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler); + + // XCommandEnvironment + virtual css::uno::Reference SAL_CALL + getInteractionHandler() throw (css::uno::RuntimeException); + virtual css::uno::Reference + SAL_CALL getProgressHandler() throw (css::uno::RuntimeException); + + // XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); + + // XProgressHandler + virtual void SAL_CALL push( css::uno::Any const & Status ) + throw (css::uno::RuntimeException); + virtual void SAL_CALL update( css::uno::Any const & Status ) + throw (css::uno::RuntimeException); + virtual void SAL_CALL pop() throw (css::uno::RuntimeException); +}; + +class TmpRepositoryCommandEnv : public BaseCommandEnv +{ +public: + TmpRepositoryCommandEnv::TmpRepositoryCommandEnv(); + TmpRepositoryCommandEnv::TmpRepositoryCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler); + +// XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); + +}; + +/** this class is for use in XPackageManager::synchronize. + + It handles particular license cases. + */ +class LicenseCommandEnv : public BaseCommandEnv +{ +private: + ::rtl::OUString m_repository; + bool m_bSuppressLicense; +public: + LicenseCommandEnv::LicenseCommandEnv(){}; + LicenseCommandEnv::LicenseCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler, + bool bSuppressLicense, + ::rtl::OUString const & repository); + +// XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); + +}; + +/** this class is for use in XPackageManager::checkPrerequisites + + It always prohibits a license interaction + */ +class NoLicenseCommandEnv : public BaseCommandEnv +{ + +public: + NoLicenseCommandEnv::NoLicenseCommandEnv(){}; + NoLicenseCommandEnv::NoLicenseCommandEnv( + css::uno::Reference< css::task::XInteractionHandler> const & handler); + +// XInteractionHandler + virtual void SAL_CALL handle( + css::uno::Reference const & xRequest ) + throw (css::uno::RuntimeException); + +}; + +} + + + + +#endif + diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 6e76cfb574bd..15bd9a581611 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -56,9 +56,10 @@ #include "dp_resource.h" #include "dp_ucb.h" #include "dp_identifier.hxx" - +#include "dp_descriptioninfoset.hxx" #include "dp_extensionmanager.hxx" -#include "dp_tmprepocmdenv.hxx" +#include "dp_commandenvironments.hxx" +#include "dp_properties.hxx" #include #include #include @@ -146,6 +147,25 @@ Reference ExtensionManager::createAbortChannel() return new dp_misc::AbortChannel; } +css::uno::Reference +ExtensionManager::getPackageManager(::rtl::OUString const & repository) + throw (css::lang::IllegalArgumentException) +{ + Reference xPackageManager; + if (repository.equals(OUSTR("user"))) + xPackageManager = m_userRepository; + else if (repository.equals(OUSTR("shared"))) + xPackageManager = m_sharedRepository; + else if (repository.equals(OUSTR("bundled"))) + xPackageManager = m_bundledRepository; + else + throw lang::IllegalArgumentException( + OUSTR("No valid repository name provided."), + static_cast(this), 0); + return xPackageManager; +} + + /* Enters the XPackage objects into a map. They must be all from the same repository. The value type of the map is a vector, where each vector @@ -278,37 +298,6 @@ Reference ExtensionManager::getExtensionAndStatus( return theExtension; } -/* - Determines if the user extension was disabled by the user. Currently a user - cannot disable extensions from other repositories. If an extension does not - 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. - */ -bool ExtensionManager::isUserExtensionDisabled( - OUString const & identifier, OUString const & fileName, - css::uno::Reference const & xAbortChannel, - css::uno::Reference const & xCmdEnv ) - -{ - bool bDisabled = false; - Reference xExtension; - try - { //will throw an exception if the extension does not exist - xExtension = m_userRepository->getDeployedPackage( - identifier, fileName, Reference()); - } catch(lang::IllegalArgumentException &) - { - } - if (xExtension.is()) - { - beans::Optional > reg = - xExtension->isRegistered(xAbortChannel, xCmdEnv); - if (reg.IsPresent && ! reg.Value.Value) - bDisabled = true; - } - return bDisabled; -} /* This method determines the active extension (XPackage.registerPackage) with a particular identifier. @@ -326,36 +315,50 @@ bool ExtensionManager::isUserExtensionDisabled( */ void ExtensionManager::activateExtension( OUString const & identifier, OUString const & fileName, - bool bUserDisabled, Reference const & xAbortChannel, Reference const & xCmdEnv ) { ::std::list > listExtensions = getExtensionsWithSameId(identifier, fileName); OSL_ASSERT(listExtensions.size() == 3); - ::std::list >::const_iterator - iext = listExtensions.begin(); - //skip disabled user extension - if (listExtensions.front().is() && bUserDisabled) - iext++; + + activateExtension( + ::comphelper::containerToSequence< + Reference, + ::std::list > + > (listExtensions), + xAbortChannel, xCmdEnv); +} + +void ExtensionManager::activateExtension( + uno::Sequence > const & seqExt, + Reference const & xAbortChannel, + Reference const & xCmdEnv ) +{ bool bActive = false; - for (; iext != listExtensions.end(); iext++) + sal_Int32 len = seqExt.getLength(); + for (sal_Int32 i = 0; i < len; i++) { - if (iext->is()) + Reference const & aExt = seqExt[i]; + if (aExt.is()) { //get the registration value of the current iteration beans::Optional > optReg = - (*iext)->isRegistered(xAbortChannel, xCmdEnv); + aExt->isRegistered(xAbortChannel, xCmdEnv); //If nothing can be registered then break if (!optReg.IsPresent) break; + //Check if this is a disabled user extension, if so then skip + if (!optReg.Value.Value && i == 0) //e.g. not registered + continue; + //If we have already determined an active extension then we must //make sure to unregister all extensions with the same id in //repositories with a lower priority if (bActive) { - (*iext)->revokePackage(xAbortChannel, xCmdEnv); + aExt->revokePackage(xAbortChannel, xCmdEnv); } else { @@ -365,7 +368,7 @@ void ExtensionManager::activateExtension( //Register if not already done. //reregister if the value is ambiguous, which indicates that //something went wrong during last registration. - (*iext)->registerPackage(xAbortChannel, xCmdEnv); + aExt->registerPackage(xAbortChannel, xCmdEnv); } } } @@ -386,8 +389,8 @@ Reference ExtensionManager::backupExtension( if (xOldExtension.is()) { xBackup = m_tmpRepository->addPackage( - xOldExtension->getURL(), OUString(), - Reference(), tmpCmdEnv); + xOldExtension->getURL(), uno::Sequence(), + OUString(), Reference(), tmpCmdEnv); OSL_ENSURE(xBackup.is(), "Failed to backup extension"); } @@ -408,7 +411,8 @@ ExtensionManager::getSupportedPackageTypes(OUString const & repository) // Only add to shared and user repository Reference ExtensionManager::addExtension( - OUString const & url, OUString const & repository, + OUString const & url, uno::Sequence const & properties, + OUString const & repository, Reference const & xAbortChannel, Reference const & xCmdEnv ) throw (deploy::DeploymentException, @@ -436,9 +440,11 @@ Reference ExtensionManager::addExtension( const OUString sFileName = xTmpExtension->getName(); const OUString sDisplayName = xTmpExtension->getDisplayName(); const OUString sVersion = xTmpExtension->getVersion(); + dp_misc::DescriptionInfoset info(dp_misc::getDescriptionInfoset(xTmpExtension->getURL())); + const ::boost::optional licenseAttributes = + info.getSimpleLicenseAttributes(); Reference xOldExtension; - bool bUserDisabled = false; Reference xExtensionBackup; uno::Any excOccurred1; @@ -450,10 +456,6 @@ Reference ExtensionManager::addExtension( //disabled by a user, then the newly installed one is enabled. If we //add to another repository then the user extension remains //disabled. - if (! repository.equals(OUSTR("user"))) - bUserDisabled = isUserExtensionDisabled( - sIdentifier, sFileName, xAbortChannel, xCmdEnv); - bool bWasRegistered = false; xOldExtension = getExtensionAndStatus( sIdentifier, sFileName, repository, xAbortChannel, @@ -474,8 +476,15 @@ Reference ExtensionManager::addExtension( checkInstall(sDisplayName, xCmdEnv); } + //Prevent showing the license if requested. + Reference _xCmdEnv(xCmdEnv); + ExtensionProperties props(OUString(), properties, Reference()); + if (licenseAttributes && licenseAttributes->suppressIfRequired + && props.isSuppressedLicense()) + _xCmdEnv = Reference(new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler())); + bCanInstall = xTmpExtension->checkPrerequisites( - xAbortChannel, xCmdEnv, xOldExtension.is(), repository); + xAbortChannel, _xCmdEnv, xOldExtension.is()) == 0 ? true : false; } catch (deploy::DeploymentException& ) { excOccurred1 = ::cppu::getCaughtException(); @@ -516,11 +525,10 @@ Reference ExtensionManager::addExtension( } xNewExtension = xPackageManager->addPackage( - url, OUString(), xAbortChannel, xCmdEnv); + url, properties, OUString(), xAbortChannel, xCmdEnv); activateExtension( dp_misc::getIdentifier(xNewExtension), - xNewExtension->getName(), bUserDisabled, - xAbortChannel, xCmdEnv); + xNewExtension->getName(), xAbortChannel, xCmdEnv); } } catch (deploy::DeploymentException& ) { @@ -560,7 +568,7 @@ Reference ExtensionManager::addExtension( tmpCmdEnv); } activateExtension( - sIdentifier, sFileName, bUserDisabled, + sIdentifier, sFileName, Reference(), tmpCmdEnv); if (xTmpExtension.is() || xExtensionBackup.is()) m_tmpRepository->removePackage( @@ -595,7 +603,7 @@ void ExtensionManager::removeExtension( uno::Any excOccurred1; Reference xExtensionBackup; Reference xPackageManager; - bool bUserDisabled = false; + try { //Determine the repository to use @@ -610,10 +618,6 @@ void ExtensionManager::removeExtension( ::osl::MutexGuard guard(m_mutex); //Backup the extension, in case the user cancels the action - - bUserDisabled = isUserExtensionDisabled( - identifier, fileName, xAbortChannel, xCmdEnv); - //Backup the extension, in case the user cancels the action xExtensionBackup = backupExtension( identifier, fileName, xPackageManager, xCmdEnv); @@ -625,8 +629,7 @@ void ExtensionManager::removeExtension( xPackageManager->removePackage( identifier, fileName, xAbortChannel, xCmdEnv); - activateExtension(identifier, fileName, bUserDisabled, - xAbortChannel, xCmdEnv); + activateExtension(identifier, fileName, xAbortChannel, xCmdEnv); } catch (deploy::DeploymentException& ) { excOccurred1 = ::cppu::getCaughtException(); @@ -661,7 +664,7 @@ void ExtensionManager::removeExtension( xExtensionBackup, Reference(), tmpCmdEnv); activateExtension( - identifier, fileName, bUserDisabled, Reference(), + identifier, fileName, Reference(), tmpCmdEnv); m_tmpRepository->removePackage( @@ -735,7 +738,7 @@ void ExtensionManager::enableExtension( { activateExtension(dp_misc::getIdentifier(extension), extension->getName(), - false, xAbortChannel, xCmdEnv); + xAbortChannel, xCmdEnv); } catch (deploy::DeploymentException& ) { excOccurred = ::cppu::getCaughtException(); @@ -762,7 +765,7 @@ void ExtensionManager::enableExtension( extension->revokePackage(Reference(), xCmdEnv); activateExtension(dp_misc::getIdentifier(extension), extension->getName(), - true, xAbortChannel, xCmdEnv); + xAbortChannel, xCmdEnv); } catch (...) { @@ -771,6 +774,56 @@ void ExtensionManager::enableExtension( } } +/** + */ +long ExtensionManager::checkPrerequisitesAndEnable( + Reference const & extension, + Reference const & xAbortChannel, + Reference const & xCmdEnv) + throw (deploy::DeploymentException, + ucb::CommandFailedException, + ucb::CommandAbortedException, + lang::IllegalArgumentException, + uno::RuntimeException) +{ + try + { + if (!extension.is()) + return 0; + ::osl::MutexGuard guard(m_mutex); + sal_Int32 ret = 0; + Reference mgr = + getPackageManager(extension->getRepositoryName()); + ret = mgr->checkPrerequisites(extension, xAbortChannel, xCmdEnv); + if (ret) + { + //There are some unfulfilled prerequisites, try to revoke + extension->revokePackage(xAbortChannel, xCmdEnv); + } + activateExtension(dp_misc::getIdentifier(extension), + extension->getName(), xAbortChannel, xCmdEnv); + return ret; + } + catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any excOccurred = ::cppu::getCaughtException(); + deploy::DeploymentException exc( + OUSTR("Extension Manager: exception during disableExtension"), + static_cast(this), excOccurred); + throw exc; + } +} + + void ExtensionManager::disableExtension( Reference const & extension, Reference const & xAbortChannel, @@ -806,7 +859,7 @@ void ExtensionManager::disableExtension( extension->revokePackage(xAbortChannel, xCmdEnv); activateExtension(dp_misc::getIdentifier(extension), extension->getName(), - true, xAbortChannel, xCmdEnv); + xAbortChannel, xCmdEnv); } catch (deploy::DeploymentException& ) { excOccurred = ::cppu::getCaughtException(); @@ -832,7 +885,7 @@ void ExtensionManager::disableExtension( { activateExtension(dp_misc::getIdentifier(extension), extension->getName(), - false, xAbortChannel, xCmdEnv); + xAbortChannel, xCmdEnv); } catch (...) { @@ -852,26 +905,8 @@ uno::Sequence< Reference > lang::IllegalArgumentException, uno::RuntimeException) { - if (repository.equals(OUSTR("user"))) - { - return m_userRepository->getDeployedPackages( - xAbort, xCmdEnv); - } - else if (repository.equals(OUSTR("shared"))) - { - return m_sharedRepository->getDeployedPackages( - xAbort, xCmdEnv); - } - else if (repository.equals(OUSTR("bundled"))) - { - return m_bundledRepository->getDeployedPackages( - xAbort, xCmdEnv); - } - else - throw lang::IllegalArgumentException( - OUSTR("No valid repository name provided."), - static_cast(this), 0); - + return getPackageManager(repository)->getDeployedPackages( + xAbort, xCmdEnv); } Reference @@ -885,25 +920,8 @@ Reference lang::IllegalArgumentException, uno::RuntimeException) { - if (repository.equals(OUSTR("user"))) - { - return m_userRepository->getDeployedPackage( - identifier, filename, xCmdEnv); - } - else if (repository.equals(OUSTR("shared"))) - { - return m_sharedRepository->getDeployedPackage( - identifier, filename, xCmdEnv); - } - else if (repository.equals(OUSTR("bundled"))) - { - return m_bundledRepository->getDeployedPackage( - identifier, filename, xCmdEnv); - } - else - throw lang::IllegalArgumentException( - OUSTR("No valid repository name provided."), - static_cast(this), 0); + return getPackageManager(repository)->getDeployedPackage( + identifier, filename, xCmdEnv); } uno::Sequence< uno::Sequence > > @@ -978,17 +996,8 @@ void ExtensionManager::reinstallDeployedExtensions( { try { - Reference xPackageManager; - if (repository.equals(OUSTR("user"))) - xPackageManager = m_userRepository; - else if (repository.equals(OUSTR("shared"))) - xPackageManager = m_sharedRepository; - else if (repository.equals(OUSTR("bundled"))) - xPackageManager = m_bundledRepository; - else - throw lang::IllegalArgumentException( - OUSTR("No valid repository name provided."), - static_cast(this), 0); + Reference + xPackageManager = getPackageManager(repository); ::osl::MutexGuard guard(m_mutex); xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv); @@ -1002,10 +1011,7 @@ void ExtensionManager::reinstallDeployedExtensions( const OUString id = dp_misc::getIdentifier(extensions[ pos ]); const OUString fileName = extensions[ pos ]->getName(); OSL_ASSERT(id.getLength()); - activateExtension( - id, fileName, - isUserExtensionDisabled(id, fileName, xAbortChannel, xCmdEnv), - xAbortChannel, xCmdEnv ); + activateExtension(id, fileName, xAbortChannel, xCmdEnv ); } catch (lang::DisposedException &) { @@ -1067,57 +1073,34 @@ void ExtensionManager::synchronize( static_cast(this), 0); ::osl::MutexGuard guard(m_mutex); - uno::Sequence > seqAddedExtensions; - uno::Sequence > seqRemovedExtensions; - xPackageManager->synchronize(seqAddedExtensions, seqRemovedExtensions, - xAbortChannel, xCmdEnv); - - //ToDo: optimize, only call activateExtension once per id. - //Determine which of the extensions was disabled by the user - //iterate of both sequences and add the ids of the user disabled - //to a map - for (sal_Int32 i = 0; i < seqRemovedExtensions.getLength(); i++) + + dp_misc::ProgressLevel progress( + xCmdEnv, OUSTR("Synchronizing ") + repository + OUSTR(" repository\n")); + xPackageManager->synchronize(xAbortChannel, xCmdEnv); + + + try { - try - { - Reference const & xExtension = seqRemovedExtensions[i]; - OSL_ASSERT(xExtension.is()); - const OUString id = dp_misc::getIdentifier(xExtension); - const OUString fileName = xExtension->getName(); - - bool bUserDisabled = isUserExtensionDisabled( - id, xExtension->getName(), xAbortChannel, xCmdEnv); - xExtension->revokePackage(xAbortChannel, xCmdEnv); - xPackageManager->removePackage( - id, fileName, xAbortChannel, xCmdEnv); - activateExtension( - id, fileName, /*bUserDisabled*/ false, xAbortChannel, xCmdEnv); - } - catch (...) + const uno::Sequence > > + seqSeqExt = getAllExtensions(xAbortChannel, xCmdEnv); + for (sal_Int32 i = 0; i < seqSeqExt.getLength(); i++) { - OSL_ENSURE(0, "Extensions Manager: synchronize"); + uno::Sequence > const & seqExt = + seqSeqExt[i]; + + activateExtension(seqExt, xAbortChannel, xCmdEnv); } } - - for (sal_Int32 i = 0; i < seqAddedExtensions.getLength(); i++) + catch (...) { - try - { - Reference const & xExtension = seqAddedExtensions[i]; - OSL_ASSERT(xExtension.is()); - const OUString id = dp_misc::getIdentifier(xExtension); - const OUString fileName = xExtension->getName(); - bool bUserDisabled = isUserExtensionDisabled( - id, fileName, xAbortChannel, xCmdEnv); - activateExtension( - id, fileName, bUserDisabled, xAbortChannel, xCmdEnv); - } - catch (...) - { - OSL_ENSURE(0, "Extensions Manager: synchronize"); - } + //We catch the exception, so we can write the lastmodified file + //so we will no repeat this everytime OOo starts. + OSL_ENSURE(0, "Extensions Manager: synchronize"); } + + progress.update(OUSTR("\n\n")); + //Write the lastmodified file try { ::rtl::Bootstrap::expandMacros(file); @@ -1231,7 +1214,7 @@ Reference ExtensionManager::getTempExtension( { Reference tmpCmdEnvA(new TmpRepositoryCommandEnv()); Reference xTmpPackage = m_tmpRepository->addPackage( - url, OUString(), xAbortChannel, tmpCmdEnvA); + url, uno::Sequence(),OUString(), xAbortChannel, tmpCmdEnvA); if (!xTmpPackage.is()) { @@ -1242,6 +1225,20 @@ Reference ExtensionManager::getTempExtension( } return xTmpPackage; } + +uno::Sequence > SAL_CALL +ExtensionManager::getExtensionsWithUnacceptedLicenses( + OUString const & repository, + Reference const & xCmdEnv) + throw (deploy::DeploymentException, + uno::RuntimeException) +{ + Reference + xPackageManager = getPackageManager(repository); + ::osl::MutexGuard guard(m_mutex); + return xPackageManager->getExtensionsWithUnacceptedLicenses(xCmdEnv); +} + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 386e2a7ceffd..bafa97c24944 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -106,7 +106,9 @@ public: createAbortChannel() throw (css::uno::RuntimeException); virtual css::uno::Reference SAL_CALL addExtension( - ::rtl::OUString const & url, ::rtl::OUString const & repository, + ::rtl::OUString const & url, + css::uno::Sequence const & properties, + ::rtl::OUString const & repository, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, @@ -147,6 +149,18 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); + + virtual long SAL_CALL checkPrerequisitesAndEnable( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + + virtual css::uno::Sequence< css::uno::Reference > SAL_CALL getDeployedExtensions( ::rtl::OUString const & repository, @@ -202,6 +216,13 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); + virtual css::uno::Sequence > SAL_CALL + getExtensionsWithUnacceptedLicenses( + ::rtl::OUString const & repository, + css::uno::Reference const & xCmdEnv) + throw (css::deployment::DeploymentException, + css::uno::RuntimeException); + private: struct ExtensionInfos @@ -233,18 +254,16 @@ private: css::uno::Reference const & xCmdEnv, bool & out_bWasRegistered); - bool isUserExtensionDisabled( + void activateExtension( ::rtl::OUString const & identifier, ::rtl::OUString const & fileName, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); void activateExtension( - ::rtl::OUString const & identifier, - ::rtl::OUString const & fileName, - bool bUserDisabled, - css::uno::Reference const & xAbortChannel, - css::uno::Reference const & xCmdEnv); + css::uno::Sequence > const & seqExt, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ); ::std::list > @@ -276,6 +295,10 @@ private: id2extensions & mapExt, css::uno::Sequence > const & seqExt, ::rtl::OUString const & repository); + + css::uno::Reference + getPackageManager(::rtl::OUString const & repository) + throw (css::lang::IllegalArgumentException); }; } diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index e2580e7b955b..0464d0de62d5 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -58,6 +58,7 @@ #include "com/sun/star/ucb/NameClash.hpp" #include "com/sun/star/deployment/VersionException.hpp" #include "com/sun/star/deployment/InstallException.hpp" +#include "com/sun/star/deployment/Prerequisites.hpp" #include "com/sun/star/task/XInteractionApprove.hpp" #include "com/sun/star/ucb/UnsupportedCommandException.hpp" #include "boost/bind.hpp" @@ -67,7 +68,8 @@ #include #include #include "dp_descriptioninfoset.hxx" - +#include "dp_commandenvironments.hxx" +#include "dp_properties.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -97,19 +99,6 @@ struct MatchTempDir } }; -struct MatchExtension -{ - const ActivePackages::Data m_data; - MatchExtension(ActivePackages::Data const & data ) : m_data(data) {} - bool operator () ( OUString const & temporaryName ) const; -}; - -bool MatchExtension::operator () (OUString const & temporaryName) const -{ - //case 1: The temporary file and thus the extension folder are already - //removed. - return m_data.temporaryName.equals(temporaryName); -} namespace { OUString getExtensionFolder(OUString const & parentFolder, @@ -131,23 +120,6 @@ OUString getExtensionFolder(OUString const & parentFolder, } return title; } -/* adds an unencoded segment to the URL. - - Throws an com.sun.star.uno.Exception if this failed. -*/ -OUString appendURLSegement(OUString const & baseURL, OUString const & segment) -{ - OUString url; - INetURLObject inet(baseURL); - if (inet.insertName( - segment, false, INetURLObject::LAST_SEGMENT, true, - INetURLObject::ENCODE_ALL)) - url = inet.GetMainURL(INetURLObject::NO_DECODE); - else - throw Exception( - OUSTR("ExtensionManager: failed to add segment to URL"), 0); - return url; -} } //______________________________________________________________________________ void PackageManagerImpl::initActivationLayer( @@ -193,7 +165,8 @@ void PackageManagerImpl::initActivationLayer( { ActivePackages::Data dbData; insertToActivationLayer( - mediaType, sourceContent, title, &dbData ); + Sequence(),mediaType, sourceContent, + title, &dbData ); insertToActivationLayerDB( title, dbData ); //TODO #i73136#: insertToActivationLayerDB needs id not @@ -293,7 +266,7 @@ void PackageManagerImpl::initActivationLayer( //Make sure only the same user removes the extension, who //previously unregistered it. This is avoid races if multiple instances //of OOo are running which all have write access to the shared installation. - //For example, user a uses extension a, removes the extension, but keeps OOo + //For example, a user removes the extension, but keeps OOo //running. Parts of the extension may still be loaded and used by OOo. //Therefore the extension is only deleted the next time the extension manager is //run after restarting OOo. While OOo is still running, another user starts OOo @@ -637,6 +610,7 @@ OUString PackageManagerImpl::detectMediaType( //______________________________________________________________________________ OUString PackageManagerImpl::insertToActivationLayer( + Sequence const & properties, OUString const & mediaType, ::ucbhelper::Content const & sourceContent_, OUString const & title, ActivePackages::Data * dbData ) { @@ -702,13 +676,17 @@ OUString PackageManagerImpl::insertToActivationLayer( //bundled extensions should only be added by the synchronizeAddedExtensions //functions. Moreover, there is no "temporary folder" for bundled extensions. OSL_ASSERT(!m_context.equals(OUSTR("bundled"))); + OUString sFolderUrl = makeURLAppendSysPathSegment(destFolderContent.getURL(), title); DescriptionInfoset info = - dp_misc::getDescriptionInfoset( - appendURLSegement(destFolderContent.getURL(), title)); + dp_misc::getDescriptionInfoset(sFolderUrl); dbData->temporaryName = tempEntry; dbData->fileName = title; dbData->mediaType = mediaType; dbData->version = info.getVersion(); + + //No write the properties file next to the extension + ExtensionProperties props(sFolderUrl, properties, xCmdEnv); + props.write(); return destFolder; } @@ -716,6 +694,8 @@ OUString PackageManagerImpl::insertToActivationLayer( void PackageManagerImpl::insertToActivationLayerDB( OUString const & id, ActivePackages::Data const & dbData ) { + //access to the database must be guarded. See removePackage + const ::osl::MutexGuard guard( getMutex() ); m_activePackagesDB->put( id, dbData ); } @@ -746,14 +726,17 @@ Reference PackageManagerImpl::importExtension( CommandAbortedException, lang::IllegalArgumentException, RuntimeException) { - return addPackage(extension->getURL(), OUString(), xAbortChannel, xCmdEnv_); + return addPackage(extension->getURL(), Sequence(), + OUString(), xAbortChannel, xCmdEnv_); } /* The function adds an extension but does not register it!!! It may not do any user interaction. This is done in XExtensionManager::addExtension */ Reference PackageManagerImpl::addPackage( - OUString const & url, OUString const & mediaType_, + OUString const & url, + css::uno::Sequence const & properties, + OUString const & mediaType_, Reference const & xAbortChannel, Reference const & xCmdEnv_ ) throw (deployment::DeploymentException, CommandFailedException, @@ -826,7 +809,7 @@ Reference PackageManagerImpl::addPackage( } ActivePackages::Data dbData; destFolder = insertToActivationLayer( - mediaType, sourceContent, title, &dbData ); + properties, mediaType, sourceContent, title, &dbData ); // bind activation package: @@ -859,10 +842,7 @@ Reference PackageManagerImpl::addPackage( xCmdEnv); } install = true; - const ::osl::MutexGuard guard( getMutex() ); - //access to the database must be guarded. See removePackage_ insertToActivationLayerDB(id, dbData); - } catch (...) { @@ -1062,8 +1042,13 @@ Reference PackageManagerImpl::getDeployedPackage_( Reference xExtension; try { - xExtension = m_xRegistry->bindPackage( - getDeployPath( data ), data.mediaType, false, OUString(), xCmdEnv ); + //Ignore extensions where XPackage::checkPrerequisites failed. + //They must not be usable for this user. + if (data.failedPrerequisites.equals(OUSTR("0"))) + { + xExtension = m_xRegistry->bindPackage( + getDeployPath( data ), data.mediaType, false, OUString(), xCmdEnv ); + } } catch (deployment::InvalidRemovedParameterException& e) { @@ -1083,6 +1068,8 @@ PackageManagerImpl::getDeployedPackages_( ActivePackages::Entries::const_iterator const iEnd( id2temp.end() ); for ( ; iPos != iEnd; ++iPos ) { + if (! iPos->second.failedPrerequisites.equals(OUSTR("0"))) + continue; try { packages.push_back( getDeployedPackage_( @@ -1265,8 +1252,7 @@ void PackageManagerImpl::reinstallDeployedPackages( return m_readOnly; } void PackageManagerImpl::synchronizeRemovedExtensions( - Sequence > & out_removedExtensions, - Reference const & /*xAbortChannel*/, + Reference const & xAbortChannel, Reference const & xCmdEnv) { @@ -1275,64 +1261,38 @@ void PackageManagerImpl::synchronizeRemovedExtensions( OSL_ASSERT(!m_context.equals(OUSTR("user"))); ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); - //Iterate over the contents of the extension folder and gather the - //temp file names (shared) or the folder names of the bundled extension. - ::ucbhelper::ResultSetInclude includeType = ::ucbhelper::INCLUDE_DOCUMENTS_ONLY; - if (m_context.equals(OUSTR("bundled"))) - includeType = ::ucbhelper::INCLUDE_FOLDERS_ONLY; - ::ucbhelper::Content tempFolder( - m_activePackages_expanded, xCmdEnv ); - Reference xResultSet( - tempFolder.createCursor( - Sequence( &StrTitle::get(), 1 ), includeType) ); - // get all temp directories: - ::std::vector tempEntries; - while (xResultSet->next()) { - OUString title( - Reference( - xResultSet, UNO_QUERY_THROW )->getString( - 1 /* Title */ ) ); - //also add the xxx.tmpremoved files for remove shared extensions - //this does not matter - tempEntries.push_back( ::rtl::Uri::encode( - title, rtl_UriCharClassPchar, - rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_UTF8 ) ); - } - typedef ActivePackages::Entries::const_iterator ITActive; bool bShared = m_context.equals(OUSTR("shared")); - ::std::vector > removedExtensions; + for (ITActive i = id2temp.begin(); i != id2temp.end(); i++) { - //Get the URL to the extensions folder, first make the url for the - //shared repository including the temporary name -// OUString url(m_activePackages_expanded + OUSTR("/") -// + i->second.temporaryName); -// if (bShared) -// url = appendURLSegement(m_activePackages_expanded + OUSTR("/") -// + i->second.temporaryName + OUSTR("_"), -// i->second.fileName); - OUString url = makeURL(m_activePackages, i->second.temporaryName); - if (bShared) - url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName); - - const MatchExtension match(i->second); - bool bRemoved = false; - if (::std::find_if(tempEntries.begin(), tempEntries.end(), match) == - tempEntries.end()) - { - //The the URL from the data base entry does not exist anymore. That is the - //folder was removed. - bRemoved = true; - } - else + try { + //Get the URL to the extensions folder, first make the url for the + //shared repository including the temporary name + OUString url = makeURL(m_activePackages, i->second.temporaryName); + if (bShared) + url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName); + + bool bRemoved = false; + //Check if the URL to the extension is still the same + ::ucbhelper::Content contentExtension; + + if (!create_ucb_content( + &contentExtension, url, + Reference(), false)) + { + bRemoved = true; + } + //The folder is in the extension database, but it can still be deleted. //look for the xxx.tmpremoved file - if (bShared) + //There can also be the case that a different extension was installed + //in a "temp" folder with name that is already used. + if (!bRemoved && bShared) { ::ucbhelper::Content contentRemoved; + if (create_ucb_content( &contentRemoved, m_activePackages_expanded + OUSTR("/") + @@ -1342,6 +1302,7 @@ void PackageManagerImpl::synchronizeRemovedExtensions( bRemoved = true; } } + if (!bRemoved) { //There may be another extensions at the same place @@ -1353,26 +1314,32 @@ void PackageManagerImpl::synchronizeRemovedExtensions( if (infoset.hasDescription() && infoset.getIdentifier() && (! i->first.equals(*(infoset.getIdentifier())) - || ! i->second.version.equals(infoset.getVersion()))) + || ! i->second.version.equals(infoset.getVersion()))) { bRemoved = true; } + + } + if (bRemoved) + { + Reference xPackage = m_xRegistry->bindPackage( + url, i->second.mediaType, true, i->first, xCmdEnv ); + OSL_ASSERT(xPackage.is()); //Even if the files are removed, we must get the object. + xPackage->revokePackage(xAbortChannel, xCmdEnv); + removePackage(xPackage->getIdentifier().Value, xPackage->getName(), + xAbortChannel, xCmdEnv); } } - if (bRemoved) + catch( uno::Exception & ) { - Reference xPackage = m_xRegistry->bindPackage( - url, i->second.mediaType, true, i->first, xCmdEnv ); - OSL_ASSERT(xPackage.is()); //Even if the files are removed, we must get the object. - removedExtensions.push_back(xPackage); + OSL_ASSERT(0); } } - out_removedExtensions = ::comphelper::containerToSequence(removedExtensions); } + void PackageManagerImpl::synchronizeAddedExtensions( - Sequence > & out_addedExtensions, - Reference const & xAbortChannel, + Reference const & xAbortChannel, Reference const & xCmdEnv) { // clean up activation layer, scan for zombie temp dirs: @@ -1385,65 +1352,58 @@ void PackageManagerImpl::synchronizeAddedExtensions( Sequence( &StrTitle::get(), 1 ), ::ucbhelper::INCLUDE_FOLDERS_ONLY ) ); - - ::std::vector > addedExtensions; while (xResultSet->next()) { - OUString title( - Reference( - xResultSet, UNO_QUERY_THROW )->getString( - 1 /* Title */ ) ); - //The temporary folders of user and shared have an '_' at then end. - //But the name in ActivePackages.temporaryName is saved without. - OUString title2 = title; - bool bNotBundled = !m_context.equals(OUSTR("bundled")); - if (bNotBundled) + try { - OSL_ASSERT(title2[title2.getLength() -1] == '_'); - title2 = title2.copy(0, title2.getLength() -1); - } - OUString titleEncoded = ::rtl::Uri::encode( + OUString title( + Reference( + xResultSet, UNO_QUERY_THROW )->getString( + 1 /* Title */ ) ); + //The temporary folders of user and shared have an '_' at then end. + //But the name in ActivePackages.temporaryName is saved without. + OUString title2 = title; + bool bNotBundled = !m_context.equals(OUSTR("bundled")); + if (bNotBundled) + { + OSL_ASSERT(title2[title2.getLength() -1] == '_'); + title2 = title2.copy(0, title2.getLength() -1); + } + OUString titleEncoded = ::rtl::Uri::encode( title2, rtl_UriCharClassPchar, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8); - const MatchTempDir match(titleEncoded); - if (::std::find_if( id2temp.begin(), id2temp.end(), match ) == - id2temp.end()) - { - - // The folder was not found in the data base, so it must be - // an added extension - OUString url(m_activePackages_expanded + OUSTR("/") + titleEncoded); - OUString sExtFolder; - if (bNotBundled) //that is, shared + const MatchTempDir match(titleEncoded); + if (::std::find_if( id2temp.begin(), id2temp.end(), match ) == + id2temp.end()) { - //Check if the extension was not "deleted" already which is indicated - //by a xxx.tmpremoved file - ::ucbhelper::Content contentRemoved; - if (create_ucb_content(&contentRemoved, url + OUSTR("removed"), - Reference(), false)) - continue; - sExtFolder = getExtensionFolder( - m_activePackages_expanded + + + // The folder was not found in the data base, so it must be + // an added extension + OUString url(m_activePackages_expanded + OUSTR("/") + titleEncoded); + OUString sExtFolder; + if (bNotBundled) //that is, shared + { + //Check if the extension was not "deleted" already which is indicated + //by a xxx.tmpremoved file + ::ucbhelper::Content contentRemoved; + if (create_ucb_content(&contentRemoved, url + OUSTR("removed"), + Reference(), false)) + continue; + sExtFolder = getExtensionFolder( + m_activePackages_expanded + OUString(OUSTR("/")) + titleEncoded + OUSTR("_"), xCmdEnv); - url = appendURLSegement(m_activePackages_expanded, title); - url = appendURLSegement(url, sExtFolder); - } - Reference xPackage = m_xRegistry->bindPackage( - url, OUString(), false, OUString(), xCmdEnv ); - if (xPackage.is()) - { - try + url = makeURLAppendSysPathSegment(m_activePackages_expanded, title); + url = makeURLAppendSysPathSegment(url, sExtFolder); + } + Reference xPackage = m_xRegistry->bindPackage( + url, OUString(), false, OUString(), xCmdEnv ); + if (xPackage.is()) { - //ToDo: We need to prevent that removed shared extensions are - //added again. This can happen if there is still the folder of the - //extension. However, there is the "removed" flag file which indicates - //that the extension was removed. //Prepare the database entry ActivePackages::Data dbData; - //There is no temporary folder for bundled extensions. It is therefore - //an empty string. + dbData.temporaryName = titleEncoded; if (bNotBundled) dbData.fileName = sExtFolder; @@ -1456,35 +1416,45 @@ void PackageManagerImpl::synchronizeAddedExtensions( "an identifier and a version"); OUString id = dp_misc::getIdentifier( xPackage ); - sal_Bool bAlreadyInstalled = sal_False; - if (xPackage->checkPrerequisites( - xAbortChannel, xCmdEnv, bAlreadyInstalled, m_context)) - { - const ::osl::MutexGuard guard( getMutex() ); - //access to the database must be guarded. See removePackage_ - insertToActivationLayerDB(id, dbData); - } - else - { - //ToDo: Remember that this failed. For example, the user - //could have declined the license. Then the next time the - //extension folder is investigated we do not want to - //try to install the extension again. - } - addedExtensions.push_back(xPackage); - } - catch (...) - { + + //We provide a special command environment that will prevent + //showing a license if simple-licens/@accept-by = "admin" + //It will also prevent showing the license for bundled extensions + //which is not supported. + OSL_ASSERT(!m_context.equals(OUSTR("user"))); + + // shall the license be suppressed? + DescriptionInfoset info = + dp_misc::getDescriptionInfoset(url); + ::boost::optional + attr = info.getSimpleLicenseAttributes(); + ExtensionProperties props(url,xCmdEnv); + bool bNoLicense = false; + if (attr && attr->suppressIfRequired && props.isSuppressedLicense()) + bNoLicense = true; + + Reference licCmdEnv( + new LicenseCommandEnv(xCmdEnv->getInteractionHandler(), + bNoLicense, m_context)); + sal_Int32 failedPrereq = xPackage->checkPrerequisites( + xAbortChannel, licCmdEnv, false); + //Remember that this failed. For example, the user + //could have declined the license. Then the next time the + //extension folder is investigated we do not want to + //try to install the extension again. + dbData.failedPrerequisites = OUString::valueOf(failedPrereq); + insertToActivationLayerDB(id, dbData); } } } + catch (uno::Exception &) + { + OSL_ASSERT(0); + } } - out_addedExtensions = ::comphelper::containerToSequence(addedExtensions); } void PackageManagerImpl::synchronize( - Sequence > & out_addedExtensions, - Sequence > & out_removedExtensions, Reference const & xAbortChannel, Reference const & xCmdEnv) throw (css::deployment::DeploymentException, @@ -1496,12 +1466,129 @@ void PackageManagerImpl::synchronize( check(); if (m_context.equals(OUSTR("user"))) return; - synchronizeRemovedExtensions( - out_removedExtensions, xAbortChannel, xCmdEnv); - synchronizeAddedExtensions( - out_addedExtensions, xAbortChannel, xCmdEnv); + synchronizeRemovedExtensions(xAbortChannel, xCmdEnv); + synchronizeAddedExtensions(xAbortChannel, xCmdEnv); +} + +Sequence< Reference > PackageManagerImpl::getExtensionsWithUnacceptedLicenses( + Reference const & xCmdEnv) + throw (deployment::DeploymentException, RuntimeException) +{ + try + { + const ::osl::MutexGuard guard( getMutex() ); + // clean up activation layer, scan for zombie temp dirs: + ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); + + ActivePackages::Entries::const_iterator i = id2temp.begin(); + bool bShared = m_context.equals(OUSTR("shared")); + ::std::vector > vec; + + + for (; i != id2temp.end(); i++ ) + { + //Get the database entry + ActivePackages::Data const & dbData = i->second; + sal_Int32 failedPrereq = dbData.failedPrerequisites.toInt32(); + //If the installation failed for other reason then the license then we + //ignore it. + if (failedPrereq ^= deployment::Prerequisites::LICENSE) + continue; + + //Prepare the URL to the extension + OUString url = makeURL(m_activePackages, i->second.temporaryName); + if (bShared) + url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName); + + Reference p = m_xRegistry->bindPackage( + url, OUString(), false, OUString(), xCmdEnv ); + + if (p.is()) + vec.push_back(p); + + } + return ::comphelper::containerToSequence(vec); + } + catch (deployment::DeploymentException &) + { + throw; + } + catch (RuntimeException&) + { + throw; + } + catch (...) + { + Any exc = ::cppu::getCaughtException(); + deployment::DeploymentException de( + OUSTR("PackageManagerImpl::getExtensionsWithUnacceptedLicenses"), + static_cast(this), exc); + exc <<= de; + ::cppu::throwException(exc); + } } +sal_Int32 PackageManagerImpl::checkPrerequisites( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException) +{ + try + { + if (!extension.is()) + return 0; + if (!m_context.equals(extension->getRepositoryName())) + throw lang::IllegalArgumentException( + OUSTR("PackageManagerImpl::checkPrerequisites: extension is not" + " from this repository."), 0, 0); + + ActivePackages::Data dbData; + OUString id = dp_misc::getIdentifier(extension); + if (m_activePackagesDB->get( &dbData, id, OUString())) + { + //If the license was already displayed, then do not show it again + Reference _xCmdEnv = xCmdEnv; + sal_Int32 prereq = dbData.failedPrerequisites.toInt32(); + if ( !(prereq & deployment::Prerequisites::LICENSE)) + _xCmdEnv = new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler()); + + sal_Int32 failedPrereq = extension->checkPrerequisites( + xAbortChannel, _xCmdEnv, false); + dbData.failedPrerequisites = OUString::valueOf(failedPrereq); + insertToActivationLayerDB(id, dbData); + } + else + { + throw lang::IllegalArgumentException( + OUSTR("PackageManagerImpl::checkPrerequisites: unknown extension"), + 0, 0); + + } + return 0; + } + catch (deployment::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any excOccurred = ::cppu::getCaughtException(); + deployment::DeploymentException exc( + OUSTR("PackageManagerImpl::checkPrerequisites: exception "), + static_cast(this), excOccurred); + throw exc; + } +} //############################################################################## diff --git a/desktop/source/deployment/manager/dp_manager.h b/desktop/source/deployment/manager/dp_manager.h index 1249fe7e29d4..2e13c56ae968 100644 --- a/desktop/source/deployment/manager/dp_manager.h +++ b/desktop/source/deployment/manager/dp_manager.h @@ -75,6 +75,7 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper ::rtl::OUString detectMediaType( ::ucbhelper::Content const & ucbContent, bool throw_exc = true ); ::rtl::OUString insertToActivationLayer( + css::uno::Sequence const & properties, ::rtl::OUString const & mediaType, ::ucbhelper::Content const & sourceContent, ::rtl::OUString const & title, ActivePackages::Data * dbData ); @@ -89,14 +90,10 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper css::uno::Reference const & package); void synchronizeRemovedExtensions( - css::uno::Sequence > & - out_removedExtensions, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); void synchronizeAddedExtensions( - css::uno::Sequence > & - out_AddedExtensions, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); @@ -177,7 +174,9 @@ public: createAbortChannel() throw (css::uno::RuntimeException); virtual css::uno::Reference SAL_CALL addPackage( - ::rtl::OUString const & url, ::rtl::OUString const & mediaType, + ::rtl::OUString const & url, + css::uno::Sequence const & properties, + ::rtl::OUString const & mediaType, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, @@ -248,8 +247,6 @@ public: throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL synchronize( - css::uno::Sequence > & out_xAddedExtensions, - css::uno::Sequence > & out_xRemovedExtensions, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, @@ -257,7 +254,22 @@ public: css::ucb::CommandAbortedException, css::uno::RuntimeException); -}; + virtual css::uno::Sequence > SAL_CALL + getExtensionsWithUnacceptedLicenses( + css::uno::Reference const & xCmdEnv) + throw (css::deployment::DeploymentException, + css::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL checkPrerequisites( + css::uno::Reference const & extension, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::ucb::CommandAbortedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + }; //______________________________________________________________________________ inline void PackageManagerImpl::check() diff --git a/desktop/source/deployment/manager/dp_properties.cxx b/desktop/source/deployment/manager/dp_properties.cxx new file mode 100644 index 000000000000..b04e8131ee15 --- /dev/null +++ b/desktop/source/deployment/manager/dp_properties.cxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "com/sun/star/ucb/XCommandEnvironment.hpp" +#include "com/sun/star/lang/IllegalArgumentException.hpp" +#include "xmlscript/xml_helper.hxx" +#include "ucbhelper/content.hxx" +#include + +#include "dp_ucb.h" +#include "rtl/ustrbuf.hxx" +#include "dp_properties.hxx" + +namespace lang = com::sun::star::lang; +namespace task = com::sun::star::task; +namespace ucb = com::sun::star::ucb; +namespace uno = com::sun::star::uno; +namespace css = com::sun::star; + +#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) + +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +#define PROP_SUPPRESS_LICENSE "SUPPRESS_LICENSE" +namespace dp_manager { + +//Reading the file +ExtensionProperties::ExtensionProperties( + OUString const & urlExtension, + Reference const & xCmdEnv) : + m_xCmdEnv(xCmdEnv) +{ + m_propFileUrl = urlExtension + OUSTR("properties"); + + ::std::list< ::std::pair< OUString, OUString> > props; + if (! dp_misc::create_ucb_content(NULL, m_propFileUrl, 0, false)) + return; + + ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv); + dp_misc::readProperties(props, contentProps); + + typedef ::std::list< ::std::pair< OUString, OUString> >::const_iterator CI; + for (CI i = props.begin(); i != props.end(); i++) + { + if (i->first.equals(OUSTR(PROP_SUPPRESS_LICENSE))) + m_prop_suppress_license = i->second; + } +} + +//Writing the file +ExtensionProperties::ExtensionProperties( + OUString const & urlExtension, + uno::Sequence const & properties, + Reference const & xCmdEnv) : + m_xCmdEnv(xCmdEnv) +{ + m_propFileUrl = urlExtension + OUSTR("properties"); + + for (sal_Int32 i = 0; i < properties.getLength(); i++) + { + css::beans::NamedValue const & v = properties[i]; + if (v.Name.equals(OUSTR(PROP_SUPPRESS_LICENSE))) + { + OUString value; + if (v.Value >>= value) + { + if (value.equals(OUSTR("1"))) + m_prop_suppress_license = OUSTR("1"); + } + else + { + throw lang::IllegalArgumentException( + OUSTR("Extension Manager: wrong property value"), 0, -1); + } + } + else + { + throw lang::IllegalArgumentException( + OUSTR("Extension Manager: unknown property"), 0, -1); + } + } +} + +void ExtensionProperties::write() +{ + ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv); + ::rtl::OUStringBuffer buf; + + if (m_prop_suppress_license) + { + buf.append(OUSTR(PROP_SUPPRESS_LICENSE)); + buf.append(OUSTR("=")); + buf.append(*m_prop_suppress_license); + } + + ::rtl::OString stamp = ::rtl::OUStringToOString( + buf.makeStringAndClear(), RTL_TEXTENCODING_UTF8); + Reference xData( + ::xmlscript::createInputStream( + ::rtl::ByteSequence( + reinterpret_cast(stamp.getStr()), + stamp.getLength() ) ) ); + contentProps.writeStream( xData, true /* replace existing */ ); +} + +bool ExtensionProperties::isSuppressedLicense() +{ + bool ret = false; + if (m_prop_suppress_license) + { + if (m_prop_suppress_license->equals(OUSTR("1"))) + ret = true; + } + return ret; +} + +} // namespace dp_manager + + diff --git a/desktop/source/deployment/manager/dp_properties.hxx b/desktop/source/deployment/manager/dp_properties.hxx new file mode 100644 index 000000000000..197155653de1 --- /dev/null +++ b/desktop/source/deployment/manager/dp_properties.hxx @@ -0,0 +1,76 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_manager.h,v $ + * $Revision: 1.17 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_PROPERTIES_HXX +#define INCLUDED_DP_PROPERTIES_HXX + + + +#include "com/sun/star/beans/NamedValue.hpp" +#include "com/sun/star/ucb/XCommandEnvironment.hpp" +#include "boost/optional.hpp" + + +namespace css = ::com::sun::star; + +namespace dp_manager { + + + +/** + + */ +class ExtensionProperties +{ +protected: + ::rtl::OUString m_propFileUrl; + const css::uno::Reference m_xCmdEnv; + ::boost::optional< ::rtl::OUString> m_prop_suppress_license; +public: + + virtual ~ExtensionProperties() {}; + ExtensionProperties(::rtl::OUString const & urlExtension, + css::uno::Reference const & xCmdEnv); + + ExtensionProperties(::rtl::OUString const & urlExtension, + css::uno::Sequence const & properties, + css::uno::Reference const & xCmdEnv); + + void write(); + + bool isSuppressedLicense(); +}; +} + + + + +#endif + diff --git a/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx b/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx deleted file mode 100644 index 3a4a6f1d2b72..000000000000 --- a/desktop/source/deployment/manager/dp_tmprepocmdenv.cxx +++ /dev/null @@ -1,166 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_desktop.hxx" - -#include "com/sun/star/deployment/VersionException.hpp" -#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp" -#include "com/sun/star/deployment/LicenseException.hpp" -#include "com/sun/star/deployment/InstallException.hpp" -#include "com/sun/star/task/XInteractionApprove.hpp" -#include "com/sun/star/task/XInteractionAbort.hpp" -#include "com/sun/star/ucb/XCommandEnvironment.hpp" -#include "com/sun/star/uno/XComponentContext.hpp" -#include "dp_tmprepocmdenv.hxx" - -namespace deployment = com::sun::star::deployment; -namespace lang = com::sun::star::lang; -namespace task = com::sun::star::task; -namespace ucb = com::sun::star::ucb; -namespace uno = com::sun::star::uno; -namespace css = com::sun::star; - -#define OUSTR(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) - -using ::com::sun::star::uno::Reference; -using ::rtl::OUString; - -namespace dp_manager { - -TmpRepositoryCommandEnv::TmpRepositoryCommandEnv() -{ -} - -TmpRepositoryCommandEnv::TmpRepositoryCommandEnv( - Reference< css::task::XInteractionHandler> const & handler) - : m_forwardHandler(handler) -{ -} - -TmpRepositoryCommandEnv::~TmpRepositoryCommandEnv() -{ -} -// XCommandEnvironment -//______________________________________________________________________________ -Reference TmpRepositoryCommandEnv::getInteractionHandler() -throw (uno::RuntimeException) -{ - return this; -} - -//______________________________________________________________________________ -Reference TmpRepositoryCommandEnv::getProgressHandler() -throw (uno::RuntimeException) -{ - return this; -} - -// XInteractionHandler -void TmpRepositoryCommandEnv::handle( - Reference< task::XInteractionRequest> const & xRequest ) - throw (uno::RuntimeException) -{ - uno::Any request( xRequest->getRequest() ); - OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); - - deployment::VersionException verExc; - deployment::LicenseException licExc; - deployment::InstallException instExc; - deployment::LicenseIndividualAgreementException licAgreementExc; - - - bool approve = false; - bool abort = false; - - if ((request >>= verExc) - || (request >>= licExc) - || (request >>= instExc) - || (request >>= licAgreementExc)) - { - approve = true; - } - - if (approve == false && abort == false) - { - if (m_forwardHandler.is()) - m_forwardHandler->handle(xRequest); - else - approve = true; - } - else - { - // select: - uno::Sequence< Reference< task::XInteractionContinuation > > conts( - xRequest->getContinuations() ); - Reference< task::XInteractionContinuation > const * pConts = - conts.getConstArray(); - sal_Int32 len = conts.getLength(); - for ( sal_Int32 pos = 0; pos < len; ++pos ) - { - if (approve) { - Reference< task::XInteractionApprove > xInteractionApprove( - pConts[ pos ], uno::UNO_QUERY ); - if (xInteractionApprove.is()) { - xInteractionApprove->select(); - // don't query again for ongoing continuations: - approve = false; - } - } - else if (abort) { - Reference< task::XInteractionAbort > xInteractionAbort( - pConts[ pos ], uno::UNO_QUERY ); - if (xInteractionAbort.is()) { - xInteractionAbort->select(); - // don't query again for ongoing continuations: - abort = false; - } - } - } - } -} - -// XProgressHandler -void TmpRepositoryCommandEnv::push( uno::Any const & /*Status*/ ) -throw (uno::RuntimeException) -{ -} - - -void TmpRepositoryCommandEnv::update( uno::Any const & /*Status */) -throw (uno::RuntimeException) -{ -} - -void TmpRepositoryCommandEnv::pop() throw (uno::RuntimeException) -{ -} - - -} // namespace dp_manager - - diff --git a/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx b/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx deleted file mode 100644 index 22111bc1e081..000000000000 --- a/desktop/source/deployment/manager/dp_tmprepocmdenv.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#if ! defined INCLUDED_DP_TMPREPOSITORYCOMMANDENVIRONMENT_HXX -#define INCLUDED_DP_TMPREPOSITORYCOMMANDENVIRONMENT_HXX - - -#include "cppuhelper/compbase3.hxx" -//#include "cppuhelper/implbase2.hxx" -#include "ucbhelper/content.hxx" - - - -namespace css = ::com::sun::star; - -namespace dp_manager { - -/** - This command environment is to be used when an extension is temporarily - stored in the "tmp" repository. It prevents all kind of user interaction. - */ -class TmpRepositoryCommandEnv - : public ::cppu::WeakImplHelper3< css::ucb::XCommandEnvironment, - css::task::XInteractionHandler, - css::ucb::XProgressHandler > -{ - css::uno::Reference< css::uno::XComponentContext > m_xContext; - css::uno::Reference< css::task::XInteractionHandler> m_forwardHandler; -public: - virtual ~TmpRepositoryCommandEnv(); - TmpRepositoryCommandEnv(); - TmpRepositoryCommandEnv( - css::uno::Reference< css::task::XInteractionHandler> const & handler); - - // XCommandEnvironment - virtual css::uno::Reference SAL_CALL - getInteractionHandler() throw (css::uno::RuntimeException); - virtual css::uno::Reference - SAL_CALL getProgressHandler() throw (css::uno::RuntimeException); - - // XInteractionHandler - virtual void SAL_CALL handle( - css::uno::Reference const & xRequest ) - throw (css::uno::RuntimeException); - - // XProgressHandler - virtual void SAL_CALL push( css::uno::Any const & Status ) - throw (css::uno::RuntimeException); - virtual void SAL_CALL update( css::uno::Any const & Status ) - throw (css::uno::RuntimeException); - virtual void SAL_CALL pop() throw (css::uno::RuntimeException); -}; - -} - - - - -#endif - diff --git a/desktop/source/deployment/manager/makefile.mk b/desktop/source/deployment/manager/makefile.mk index cb99325bde52..4dc6405e34bf 100644 --- a/desktop/source/deployment/manager/makefile.mk +++ b/desktop/source/deployment/manager/makefile.mk @@ -47,7 +47,8 @@ SLOFILES = \ $(SLO)$/dp_managerfac.obj \ $(SLO)$/dp_informationprovider.obj \ $(SLO)$/dp_extensionmanager.obj \ - $(SLO)$/dp_tmprepocmdenv.obj + $(SLO)$/dp_commandenvironments.obj \ + $(SLO)$/dp_properties.obj .INCLUDE : ..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/migration/dp_migration.cxx b/desktop/source/deployment/migration/dp_migration.cxx index 49362f7e2f5f..c2d0b0dc6bb8 100644 --- a/desktop/source/deployment/migration/dp_migration.cxx +++ b/desktop/source/deployment/migration/dp_migration.cxx @@ -136,7 +136,7 @@ Any MigrationImpl::execute( Sequence const & ) ->queryContentIdentifierString() ); try { xManager->addPackage( - sourceURL, OUString() /* detect media-type */, + sourceURL, uno::Sequence(),OUString() /* detect media-type */, Reference(), xCmdEnv ); } catch (RuntimeException &) { diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 1f1fde7ca7bf..919f134b3fb9 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -44,8 +44,10 @@ #include "com/sun/star/ucb/CommandAbortedException.hpp" #include "com/sun/star/bridge/UnoUrlResolver.hpp" #include "com/sun/star/bridge/XUnoUrlResolver.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include "boost/scoped_array.hpp" #include "boost/shared_ptr.hpp" +#include #ifdef WNT //#include "tools/prewin.h" @@ -138,6 +140,103 @@ bool existsOfficePipe() return pipe.is(); } + +//Returns true if the Folder was more recently modified then +//the lastsynchronized file. That is the repository needs to +//be synchronized. +bool compareExtensionFolderWithLastSynchronizedFile( + OUString const & folderURL, OUString const & fileURL) +{ + bool bNeedsSync = false; + ::osl::DirectoryItem itemExtFolder; + ::osl::File::RC err1 = + ::osl::DirectoryItem::get(folderURL, itemExtFolder); + //If it does not exist, then there is nothing to be done + if (err1 == ::osl::File::E_NOENT) + { + return false; + } + else if (err1 != ::osl::File::E_None) + { + OSL_ENSURE(0, "Cannot access extension folder"); + return true; //sync just in case + } + + //If last synchronized does not exist, then OOo is started for the first time + ::osl::DirectoryItem itemFile; + ::osl::File::RC err2 = ::osl::DirectoryItem::get(fileURL, itemFile); + if (err2 == ::osl::File::E_NOENT) + { + return true; + + } + else if (err2 != ::osl::File::E_None) + { + OSL_ENSURE(0, "Cannot access file lastsynchronized"); + return true; //sync just in case + } + + //compare the modification time of the extension folder and the last + //modified file + ::osl::FileStatus statFolder(FileStatusMask_ModifyTime); + ::osl::FileStatus statFile(FileStatusMask_ModifyTime); + if (itemExtFolder.getFileStatus(statFolder) == ::osl::File::E_None) + { + if (itemFile.getFileStatus(statFile) == ::osl::File::E_None) + { + TimeValue timeFolder = statFolder.getModifyTime(); + TimeValue timeFile = statFile.getModifyTime(); + + if (timeFile.Seconds < timeFolder.Seconds) + bNeedsSync = true; + } + else + { + OSL_ASSERT(0); + bNeedsSync = true; + } + } + else + { + OSL_ASSERT(0); + bNeedsSync = true; + } + return bNeedsSync; +} + +bool needToSyncRepostitory(OUString const & name) +{ + OUString folder; + OUString file; + if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("bundled")))) + { + folder = OUString( + RTL_CONSTASCII_USTRINGPARAM("$BUNDLED_EXTENSIONS")); + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); + } + else if (name.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("shared")))) + { + folder = OUString( + RTL_CONSTASCII_USTRINGPARAM( + "$UNO_SHARED_PACKAGES_CACHE/uno_packages")); + file = OUString ( + RTL_CONSTASCII_USTRINGPARAM( + "$SHARED_EXTENSIONS_USER/lastsynchronized")); + } + else + { + OSL_ASSERT(0); + return true; + } + ::rtl::Bootstrap::expandMacros(folder); + ::rtl::Bootstrap::expandMacros(file); + return compareExtensionFolderWithLastSynchronizedFile( + folder, file); +} + + } // anon namespace //============================================================================== @@ -480,22 +579,43 @@ void TRACE(::rtl::OString const & sText) #endif } -bool hasExtensionRepositoryChanged(::rtl::OUString const & repository) +void syncRepositories(Reference const & xCmdEnv) { - if (repository.equals(OUSTR("shared"))) + Reference xExtensionManager; + //synchronize shared before bundled otherewise there are + //more revoke and registration calls. + OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); + if (needToSyncRepostitory(sShared)) { - //get the extensions folder - OUString folder(RTL_CONSTASCII_USTRINGPARAM("BUNDLED_EXTENSIONS")); - ::rtl::Bootstrap::expandMacros(folder); + xExtensionManager = + deployment::ExtensionManager::get( + comphelper_getProcessComponentContext()); + + if (xExtensionManager.is()) + { + xExtensionManager->synchronize( + sShared, Reference(), xCmdEnv); + } } - else if (repository.equals(OUSTR("bundled"))) + + OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); + if (needToSyncRepostitory( sBundled)) { - } - else - throw lang::IllegalArgumentException( - OUSTR("Invalid repository name."), 0, 0); + if (!xExtensionManager.is()) + { + xExtensionManager = + deployment::ExtensionManager::get( + comphelper_getProcessComponentContext()); + } + if (xExtensionManager.is()) + { + xExtensionManager->synchronize( + sBundled, Reference(), xCmdEnv); - return false; + } + } } + + } diff --git a/desktop/source/deployment/misc/dp_ucb.cxx b/desktop/source/deployment/misc/dp_ucb.cxx index 571aef9c1b95..795a492aa0d5 100644 --- a/desktop/source/deployment/misc/dp_ucb.cxx +++ b/desktop/source/deployment/misc/dp_ucb.cxx @@ -271,4 +271,50 @@ bool readLine( OUString * res, OUString const & startingWith, return false; } +bool readProperties( ::std::list< ::std::pair< ::rtl::OUString, ::rtl::OUString> > & out_result, + ::ucbhelper::Content & ucb_content ) +{ + // read whole file: + ::rtl::ByteSequence bytes( readFile( ucb_content ) ); + OUString file( reinterpret_cast(bytes.getConstArray()), + bytes.getLength(), RTL_TEXTENCODING_UTF8); + sal_Int32 pos = 0; + + for (;;) + { + + ::rtl::OUStringBuffer buf; + sal_Int32 start = pos; + + bool bEOF = false; + pos = file.indexOf( LF, pos ); + if (pos < 0) { // EOF + buf.append( file.copy( start ) ); + bEOF = true; + } + else + { + if (pos > 0 && file[ pos - 1 ] == CR) + // consume extra CR + buf.append( file.copy( start, pos - start - 1 ) ); + else + buf.append( file.copy( start, pos - start ) ); + pos++; + } + OUString aLine = buf.makeStringAndClear(); + + sal_Int32 posEqual = aLine.indexOf('='); + if (posEqual > 0 && (posEqual + 1) < aLine.getLength()) + { + OUString name = aLine.copy(0, posEqual); + OUString value = aLine.copy(posEqual + 1); + out_result.push_back(::std::make_pair(name, value)); + } + + if (bEOF) + break; + } + return false; +} + } diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index 667f1588e247..17444eb0828e 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -157,7 +157,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - OUString const & loader, bool bRemoved, OUString const & identifier); + OUString const & loader, bool bRemoved, + OUString const & identifier); }; friend class ComponentPackageImpl; @@ -186,7 +187,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - bool jarFile, bool bRemoved, OUString const & identifier); + bool jarFile, bool bRemoved, + OUString const & identifier); }; friend class TypelibraryPackageImpl; @@ -207,7 +209,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, - sal_Bool bNoFileAccess, OUString const & identifier, + sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); virtual void SAL_CALL disposing(); @@ -283,7 +285,8 @@ BackendImpl::ComponentPackageImpl::ComponentPackageImpl( ::rtl::Reference const & myBackend, OUString const & url, OUString const & name, Reference const & xPackageType, - OUString const & loader, bool bRemoved, OUString const & identifier) + OUString const & loader, bool bRemoved, + OUString const & identifier) : Package( myBackend, url, name, name /* display-name */, xPackageType, bRemoved, identifier), m_loader( loader ), diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 354676fd56ff..fefa6794342a 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -114,7 +114,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend // PackageRegistryBackend virtual Reference bindPackage_( OUString const & url, OUString const & mediaType, sal_Bool bRemoved, - OUString const & identifier, Reference const & xCmdEnv ); + OUString const & identifier, + Reference const & xCmdEnv ); ::std::auto_ptr m_registeredPackages; // for backwards compatibility diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index be752bcf0733..1cebd20c297a 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -31,6 +31,7 @@ #include "dp_backend.h" #include "dp_ucb.h" #include "rtl/uri.hxx" +#include "rtl/bootstrap.hxx" #include "osl/file.hxx" #include "cppuhelper/exc_hlp.hxx" #include "comphelper/servicedecl.hxx" @@ -170,7 +171,8 @@ Reference PackageRegistryBackend::bindPackage( Reference xNewPackage; try { - xNewPackage = bindPackage_( url, mediaType, bRemoved, identifier, xCmdEnv ); + xNewPackage = bindPackage_( url, mediaType, bRemoved, + identifier, xCmdEnv ); } catch (RuntimeException &) { throw; @@ -318,6 +320,16 @@ Package::Package( ::rtl::Reference const & myBackend, m_bRemoved(bRemoved), m_identifier(identifier) { + if (m_bRemoved) + { + //We use the last segment of the URL + OSL_ASSERT(m_name.getLength() == 0); + OUString name = m_url; + rtl::Bootstrap::expandMacros(name); + sal_Int32 index = name.lastIndexOf('/'); + if (index != -1 && index < name.getLength()) + m_name = name.copy(index + 1); + } } //______________________________________________________________________________ @@ -407,10 +419,10 @@ sal_Bool Package::isBundle() throw (RuntimeException) } //______________________________________________________________________________ -::sal_Bool Package::checkPrerequisites( +::sal_Int32 Package::checkPrerequisites( const css::uno::Reference< css::task::XAbortChannel >&, const css::uno::Reference< css::ucb::XCommandEnvironment >&, - sal_Bool, ::rtl::OUString const &) + sal_Bool) throw (css::deployment::DeploymentException, css::deployment::ExtensionRemovedException, css::ucb::CommandFailedException, @@ -419,7 +431,7 @@ sal_Bool Package::isBundle() throw (RuntimeException) { if (m_bRemoved) throw deployment::ExtensionRemovedException(); - return true; + return 0; } //______________________________________________________________________________ diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index e35b37bdeb07..c5e440a2a825 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 SAL_CALL bindPackage( - OUString const & url, OUString const & mediaType, sal_Bool bNoFileAccess, + OUString const & url, OUString const & mediaType, sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ) throw (deployment::DeploymentException, CommandFailedException, lang::IllegalArgumentException, RuntimeException); @@ -498,7 +498,8 @@ Reference PackageRegistryImpl::bindPackage( for ( ; iPos != iEnd; ++iPos ) { try { - return (*iPos)->bindPackage( url, mediaType, bRemoved, identifier, xCmdEnv ); + return (*iPos)->bindPackage( url, mediaType, bRemoved, + identifier, xCmdEnv ); } catch (lang::IllegalArgumentException &) { } @@ -527,7 +528,8 @@ Reference PackageRegistryImpl::bindPackage( getResourceString(RID_STR_UNSUPPORTED_MEDIA_TYPE) + mediaType, static_cast(this), static_cast(-1) ); } - return iFind->second->bindPackage( url, mediaType, bRemoved, identifier, 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 39fd3cdc892e..1dc4cdde64ea 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -152,7 +152,8 @@ Reference BackendImpl::bindPackage_( if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.executable")) { return new BackendImpl::ExecutablePackageImpl( - this, url, name, m_xExecutableTypeInfo, bRemoved, identifier); + 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 aeeec94981e6..a523a1aa20a5 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -102,10 +102,6 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference const & xCmdEnv); void implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ); -// rtl::OUString getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ); -// rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); -// rtl::OUString getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ); -// rtl::OUString expandURL( const rtl::OUString& aURL ); void addDataToDb(OUString const & url, HelpBackendDb::Data const & data); ::boost::optional readDataFromDb(OUString const & url); @@ -195,7 +191,8 @@ Reference BackendImpl::bindPackage_( "vnd.sun.star.help")) { return new PackageImpl( - this, url, name, m_xHelpTypeInfo, bRemoved, identifier); + this, url, name, m_xHelpTypeInfo, bRemoved, + identifier); } } } @@ -233,7 +230,8 @@ BackendImpl::PackageImpl::PackageImpl( OUString const & url, OUString const & name, Reference const & xPackageType, bool bRemoved, OUString const & identifier) - : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) + : Package( myBackend, url, name, name, xPackageType, bRemoved, + identifier) { if (bRemoved) { @@ -290,13 +288,6 @@ void BackendImpl::PackageImpl::processPackage_( BackendImpl* that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); that->implProcessHelp( xThisPackage, doRegisterPackage, xCmdEnv); - -// HelpBackendDb::Data data; -// getMyBackend()->addDataToDb(getURL(), data); - -// } -// else -// getMyBackend()->deleteDataFromDb(getURL()); } beans::Optional< OUString > BackendImpl::PackageImpl::getRegistrationDataURL() @@ -373,23 +364,6 @@ void BackendImpl::implProcessHelp { std::vector< rtl::OUString > aXhpFileVector; - // Delete (old) files in any case to allow compiler to be started every time -// rtl::OUString aLangWithPureNameURL( aLangURL ); -// aLangWithPureNameURL += aSlash; -// aLangWithPureNameURL += aHelpStr; -// rtl::OUString aDbFile( aLangWithPureNameURL ); -// aDbFile += rtl::OUString::createFromAscii( ".db" ); -// if( xSFA->exists( aDbFile ) ) -// xSFA->kill( aDbFile ); -// rtl::OUString aHtFile( aLangWithPureNameURL ); -// aHtFile += rtl::OUString::createFromAscii( ".ht" ); -// if( xSFA->exists( aHtFile ) ) -// xSFA->kill( aHtFile ); -// rtl::OUString aKeyFile( aLangWithPureNameURL ); -// aKeyFile += rtl::OUString::createFromAscii( ".key" ); -// if( xSFA->exists( aKeyFile ) ) -// xSFA->kill( aKeyFile ); - // calculate jar file URL sal_Int32 indexStartSegment = aLangURL.lastIndexOf('/'); // for example "/en" @@ -408,12 +382,6 @@ void BackendImpl::implProcessHelp rtl::OUString aJarFile( makeURL(sHelpFolder, langFolderURLSegment + aSlash + aHelpStr + OUSTR(".jar"))); -// aJarFile += aSlash; -// aJarFile += aHelpStr; -// aJarFile += rtl::OUString::createFromAscii( ".jar" ); - // remove in any case to clean up -// if( xSFA->exists( aJarFile ) ) -// xSFA->kill( aJarFile ); aJarFile = ::dp_misc::expandUnoRcUrl(aJarFile); rtl::OUString aEncodedJarFilePath = rtl::Uri::encode( @@ -443,8 +411,6 @@ void BackendImpl::implProcessHelp aDestPath += aPureFolderName; xSFA->copy( aSubFolderURL, aDestPath ); } - //Copy help.tree to the temp folder in the help backend folder -// xSFA->copy(aLangURL + OUSTR("/help.tree"), langFolderDestExpanded + OUSTR("/help.tree")); // Call compiler sal_Int32 nXhpFileCount = aXhpFileVector.size(); @@ -485,7 +451,6 @@ void BackendImpl::implProcessHelp aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-zipdir" ) ); rtl::OUString aSystemPath; -// osl::FileBase::getSystemPathFromFileURL( aLangURL, aSystemPath ); osl::FileBase::getSystemPathFromFileURL( langFolderDestExpanded, aSystemPath ); aParamsSeq[5] = uno::makeAny( aSystemPath ); @@ -562,75 +527,6 @@ void BackendImpl::implProcessHelp } } -// rtl::OUString BackendImpl::getFlagFileURL( Reference< deployment::XPackage > xPackage, const char* pFlagStr ) -// { -// rtl::OUString aRetURL; -// if( !xPackage.is() ) -// return aRetURL; -// rtl::OUString aHelpURL = xPackage->getURL(); -// aRetURL = expandURL( aHelpURL ); -// aRetURL += rtl::OUString::createFromAscii( pFlagStr ); -// return aRetURL; -// } - -// rtl::OUString BackendImpl::getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ) -// { -// return getFlagFileURL( xPackage, "/RegisteredFlag" ); -// } - -// rtl::OUString BackendImpl::getCompiledFlagFileURL( Reference< deployment::XPackage > xPackage ) -// { -// return getFlagFileURL( xPackage, "/CompiledFlag" ); -// } - -// rtl::OUString BackendImpl::expandURL( const rtl::OUString& aURL ) -// { -// static Reference< util::XMacroExpander > xMacroExpander; -// static Reference< uri::XUriReferenceFactory > xFac; - -// if( !xMacroExpander.is() || !xFac.is() ) -// { -// Reference const & xContext = getComponentContext(); -// if( xContext.is() ) -// { -// xFac = Reference< uri::XUriReferenceFactory >( -// xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( -// "com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY ); -// } -// if( !xFac.is() ) -// { -// throw RuntimeException( -// ::rtl::OUString::createFromAscii( -// "dp_registry::backend::help::BackendImpl::expandURL(), " -// "could not instatiate UriReferenceFactory." ), -// Reference< XInterface >() ); -// } - -// xMacroExpander = Reference< util::XMacroExpander >( -// xContext->getValueByName( -// ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ), -// UNO_QUERY_THROW ); -// } - -// rtl::OUString aRetURL = aURL; -// if( xMacroExpander.is() ) -// { -// Reference< uri::XUriReference > uriRef; -// for (;;) -// { -// uriRef = Reference< uri::XUriReference >( xFac->parse( aRetURL ), UNO_QUERY ); -// if ( uriRef.is() ) -// { -// Reference < uri::XVndSunStarExpandUrl > sxUri( uriRef, UNO_QUERY ); -// if( !sxUri.is() ) -// break; - -// aRetURL = sxUri->expand( xMacroExpander ); -// } -// } -// } -// return aRetURL; -// } void BackendImpl::implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ) diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 179420b16ef6..7ad55d29ba2f 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -175,10 +175,10 @@ public: css::ucb::CommandAbortedException, css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL checkPrerequisites( + virtual ::sal_Int32 SAL_CALL checkPrerequisites( const css::uno::Reference< css::task::XAbortChannel >& xAbortChannel, const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, - sal_Bool bInstalled, ::rtl::OUString const & aContextName) + sal_Bool noLicenseChecking) throw (css::deployment::DeploymentException, css::deployment::ExtensionRemovedException, css::ucb::CommandFailedException, diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 467ff5ca89fa..822e744b8fc2 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -64,8 +64,8 @@ #include "com/sun/star/packages/manifest/XManifestWriter.hpp" #include "com/sun/star/deployment/DependencyException.hpp" #include "com/sun/star/deployment/LicenseException.hpp" -#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp" #include "com/sun/star/deployment/PlatformException.hpp" +#include "com/sun/star/deployment/Prerequisites.hpp" #include "com/sun/star/xml/dom/XDocumentBuilder.hpp" #include "com/sun/star/xml/xpath/XXPathAPI.hpp" #include "com/sun/star/deployment/XPackageManager.hpp" @@ -139,8 +139,7 @@ class BackendImpl : public ImplBaseT ::sal_Bool checkLicense( Reference< ucb::XCommandEnvironment > const & xCmdEnv, - DescriptionInfoset const & description, bool bInstalled, - OUString const & aContextName ) + DescriptionInfoset const & description, bool bNoLicenseChecking) throw (deployment::DeploymentException, ucb::CommandFailedException, ucb::CommandAbortedException, @@ -199,10 +198,10 @@ class BackendImpl : public ImplBaseT ucb::CommandAbortedException, RuntimeException); - virtual ::sal_Bool SAL_CALL checkPrerequisites( + virtual ::sal_Int32 SAL_CALL checkPrerequisites( const Reference< task::XAbortChannel >& xAbortChannel, const Reference< ucb::XCommandEnvironment >& xCmdEnv, - ::sal_Bool bInstalled, OUString const & aContextName) + ::sal_Bool noLicenseChecking) throw (deployment::ExtensionRemovedException, deployment::DeploymentException, ucb::CommandFailedException, @@ -423,12 +422,14 @@ Reference BackendImpl::bindPackage_( } if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.package-bundle")) { return new PackageImpl( - this, url, name, m_xBundleTypeInfo, false, bRemoved, identifier); + 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, bRemoved, identifier); + this, url, name, m_xLegacyBundleTypeInfo, true, bRemoved, + identifier); } } } @@ -652,7 +653,7 @@ bool BackendImpl::PackageImpl::checkDependencies( ::sal_Bool BackendImpl::PackageImpl::checkLicense( css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv, - DescriptionInfoset const & info, bool bInstalled, OUString const & aContextName) + DescriptionInfoset const & info, bool alreadyInstalled) throw (css::deployment::DeploymentException, css::ucb::CommandFailedException, css::ucb::CommandAbortedException, @@ -679,41 +680,21 @@ bool BackendImpl::PackageImpl::checkDependencies( throw css::deployment::DeploymentException( OUSTR("Could not obtain attribute simple-lincense@accept-by or it has no valid value"), 0, Any()); - //If if @accept-by="user" then every user needs to accept the license before it can be installed. - //Therefore we must prevent the installation as shared extension unless suppress-if-required="true" - OSL_ASSERT(aContextName.getLength()); - if (simplLicAttr->acceptBy.equals(OUSTR("user")) && aContextName.equals(OUSTR("shared"))) - { - css::deployment::LicenseIndividualAgreementException - exc = css::deployment::LicenseIndividualAgreementException( - OUString(), 0, m_name, simplLicAttr->suppressIfRequired); - - bool approve = false; - bool abort = false; - if (! interactContinuation( - Any(exc), task::XInteractionApprove::static_type(), xCmdEnv, &approve, &abort )) - throw css::deployment::DeploymentException( - OUSTR("Could not interact with user."), 0, Any()); - if (abort == true) - return false; - - //If the unopkg --suppress-license was used and simplLicAttr->suppressIfRequired == true, - //then the user implicitely accepts the license - } //Only use interaction if there is no version of this extension already installed //and the suppress-on-update flag is not set for the new extension - // bInstalled | bSuppressOnUpdate | show license + // alreadyInstalled | bSuppressOnUpdate | show license //---------------------------------------- // 0 | 0 | 1 // 0 | 1 | 1 // 1 | 0 | 1 // 1 | 1 | 0 - if ( !(bInstalled && simplLicAttr->suppressOnUpdate)) + if ( !(alreadyInstalled && simplLicAttr->suppressOnUpdate)) { css::deployment::LicenseException licExc( - OUString(), 0, m_name, sLicense, simplLicAttr->suppressIfRequired); + OUString(), 0, getDisplayName(), sLicense, + simplLicAttr->acceptBy); bool approve = false; bool abort = false; if (! interactContinuation( @@ -745,10 +726,10 @@ bool BackendImpl::PackageImpl::checkDependencies( } } -::sal_Bool BackendImpl::PackageImpl::checkPrerequisites( +::sal_Int32 BackendImpl::PackageImpl::checkPrerequisites( const css::uno::Reference< css::task::XAbortChannel >&, const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv, - sal_Bool bInstalled, OUString const & aContextName) + sal_Bool alreadyInstalled) throw (css::deployment::DeploymentException, css::deployment::ExtensionRemovedException, css::ucb::CommandFailedException, @@ -759,11 +740,21 @@ bool BackendImpl::PackageImpl::checkDependencies( throw deployment::ExtensionRemovedException(); DescriptionInfoset info = getDescriptionInfoset(); if (!info.hasDescription()) - return sal_True; - - return checkPlatform(xCmdEnv) - && checkDependencies(xCmdEnv, info) - && checkLicense(xCmdEnv, info, bInstalled, aContextName); + return 0; + + //always return LICENSE as long as the user did not accept the license + //so that XExtensonManager::checkPrerequisitesAndEnable will again + //check the license + if (!checkPlatform(xCmdEnv)) + return deployment::Prerequisites::PLATFORM | + deployment::Prerequisites::LICENSE; + else if(!checkDependencies(xCmdEnv, info)) + return deployment::Prerequisites::DEPENDENCIES | + deployment::Prerequisites::LICENSE; + else if(!checkLicense(xCmdEnv, info, alreadyInstalled)) + return deployment::Prerequisites::LICENSE; + else + return 0; } ::sal_Bool BackendImpl::PackageImpl::checkDependencies( diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index b645c9b2af7a..5023a501c67e 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -233,9 +233,9 @@ Reference BackendImpl::bindPackage_( 0, dialogURL, xCmdEnv, false /* no throw */ )) { dialogURL = OUString(); } - return new PackageImpl( this, url, xCmdEnv, - makeURL( url, OUSTR("script.xlb") ), - dialogURL, bRemoved, identifier); + return new PackageImpl( + this, url, xCmdEnv, makeURL( url, OUSTR("script.xlb") ), + dialogURL, bRemoved, identifier); } else if (subType.EqualsIgnoreCaseAscii( "vnd.sun.star.dialog-library")) { diff --git a/desktop/source/deployment/unopkg/unopkg.src b/desktop/source/deployment/unopkg/unopkg.src index 79c578628676..dc204e265ec6 100644 --- a/desktop/source/deployment/unopkg/unopkg.src +++ b/desktop/source/deployment/unopkg/unopkg.src @@ -27,15 +27,10 @@ #include "deployment.hrc" -String RID_STR_UNOPKG_NO_SHARED_ALLOWED -{ - Text [ en-US ] = "The option \"--shared\" cannot be used to install the extension \'%NAME\', " - "because every user has to agree to the license agreement of the extension. The extension will not be installed."; -}; String RID_STR_UNOPKG_ACCEPT_LIC_1 { - Text [ en-US ] = "Extension License Agreement:"; + Text [ en-US ] = "Extension Software License Agreement of $NAME:"; }; String RID_STR_UNOPKG_ACCEPT_LIC_2 diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index 11bf8129cc04..a077eaddb911 100755 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -52,6 +52,7 @@ #include #include #include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -363,7 +364,8 @@ bool OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir static_cast< cppu::OWeakObject* >( pCmdEnv ), uno::UNO_QUERY ); uno::Reference< task::XAbortChannel > xAbortChannel; uno::Reference< deployment::XPackage > xPackage = - m_xPackageManager->addPackage( sSourceDir, ::rtl::OUString(), xAbortChannel, xCmdEnv ); + m_xPackageManager->addPackage( + sSourceDir, uno::Sequence(),::rtl::OUString(), xAbortChannel, xCmdEnv ); if ( xPackage.is() ) return true; diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 807260fe4663..ba8cd56085f8 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -41,6 +41,7 @@ #include "cppuhelper/implbase1.hxx" #include "cppuhelper/exc_hlp.hxx" #include "comphelper/anytostring.hxx" +#include "comphelper/sequence.hxx" #include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/deployment/ui/PackageManagerDialog.hpp" @@ -60,10 +61,24 @@ using ::rtl::OUString; namespace css = ::com::sun::star; namespace { +struct ExtensionName +{ + OUString m_str; + ExtensionName( OUString const & str ) : m_str( str ) {} + bool operator () ( Reference const & e ) const + { + if (m_str.equals(dp_misc::getIdentifier(e)) + || m_str.equals(e->getName())) + return true; + return false; + } +}; + //------------------------------------------------------------------------------ const char s_usingText [] = "\n" "using: " APP_NAME " add extension-path...\n" +" " APP_NAME " validate extension-identifier...\n" " " APP_NAME " remove extension-identifier...\n" " " APP_NAME " list extension-identifier...\n" " " APP_NAME " reinstall \n" @@ -73,6 +88,8 @@ const char s_usingText [] = "\n" "sub-commands:\n" " add add extension\n" +" validate checks the prerequisites of an installed extension and" +" registers it if possible\n" " remove remove extensions by identifier\n" " reinstall expert feature: reinstall all deployed extensions\n" " list list information about deployed extensions\n" @@ -252,7 +269,7 @@ extern "C" int unopkg_main() return 0; } else if (isOption( info_version, &nPos )) { - dp_misc::writeConsole("\n"APP_NAME" Version 3.0\n"); + dp_misc::writeConsole("\n"APP_NAME" Version 3.3\n"); return 0; } //consume all bootstrap variables which may occur before the subcommannd @@ -314,15 +331,6 @@ extern "C" int unopkg_main() } } - //make sure the bundled option was provided together with shared -// if (option_bundled && !option_shared) -// { -// dp_misc::writeConsoleError( -// "\nERROR: option --bundled can only be used together with --shared!"); -// return 1; -// } - - xComponentContext = getUNO( disposeGuard, option_verbose, option_shared, subcmd_gui, xLocalComponentContext ); @@ -357,8 +365,11 @@ extern "C" int unopkg_main() Reference< ::com::sun::star::ucb::XCommandEnvironment > xCmdEnv( createCmdEnv( xComponentContext, logFile, - option_force, option_verbose, option_bundled, - option_suppressLicense) ); + option_force, option_verbose) ); + + //synchronize bundled/shared extensions + if (!subcmd_gui && ! dp_misc::office_is_running()) + dp_misc::syncRepositories(xCmdEnv); if (subcmd_add || subCommand.equalsAsciiL( @@ -369,9 +380,12 @@ extern "C" int unopkg_main() OUString const & cmdPackage = cmdPackages[ pos ]; if (subcmd_add) { + beans::NamedValue nvSuppress( + OUSTR("SUPPRESS_LICENSE"), option_suppressLicense ? + makeAny(OUSTR("1")):makeAny(OUSTR("0"))); xExtensionManager->addExtension( - cmdPackage, repository, - Reference(), xCmdEnv); + cmdPackage, Sequence(&nvSuppress, 1), + repository, Reference(), xCmdEnv); } else { @@ -410,32 +424,131 @@ extern "C" int unopkg_main() } else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("list") )) { - Sequence< Reference > packages; + ::std::vector > vecExtUnaccepted; + ::comphelper::sequenceToContainer(vecExtUnaccepted, + xExtensionManager->getExtensionsWithUnacceptedLicenses( + repository, xCmdEnv)); + + //This vector tells what XPackage in allExtensions has an + //unaccepted license. + std::vector vecUnaccepted; + std::vector > allExtensions; if (cmdPackages.empty()) { - packages = xExtensionManager->getDeployedExtensions( - repository, Reference(), xCmdEnv ); + Sequence< Reference > + packages = xExtensionManager->getDeployedExtensions( + repository, Reference(), xCmdEnv ); + + ::std::vector > vec_packages; + ::comphelper::sequenceToContainer(vec_packages, packages); + + //First copy the extensions with the unaccepted license + //to vector allExtensions. + allExtensions.resize(vecExtUnaccepted.size() + vec_packages.size()); + + ::std::vector >::iterator i_all_ext = + ::std::copy(vecExtUnaccepted.begin(), vecExtUnaccepted.end(), + allExtensions.begin()); + //Now copy those we got from getDeployedExtensions + ::std::copy(vec_packages.begin(), vec_packages.end(), i_all_ext); + + //Now prepare the vector which tells what extension has an + //unaccepted license + vecUnaccepted.resize(vecExtUnaccepted.size() + vec_packages.size()); + ::std::vector::iterator i_unaccepted = + ::std::fill_n(vecUnaccepted.begin(), + vecExtUnaccepted.size(), true); + ::std::fill_n(i_unaccepted, vec_packages.size(), false); + dp_misc::writeConsole( - OUSTR("all deployed ") + repository + OUSTR(" packages:\n")); + OUSTR("All deployed ") + repository + OUSTR(" extensions:\n\n")); } else { - packages.realloc( cmdPackages.size() ); + //The user provided the names (ids or file names) of the extensions + //which shall be listed for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos ) + { + Reference extension; try { - packages[ pos ] = xExtensionManager->getDeployedExtension( + extension = xExtensionManager->getDeployedExtension( repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv ); } catch (lang::IllegalArgumentException &) { - packages[ pos ] = findPackage(repository, + extension = findPackage(repository, xExtensionManager, xCmdEnv, cmdPackages[ pos ] ); - if ( !packages[ pos ].is() ) - throw; } + + //Now look if the requested extension has an unaccepted license + bool bUnacceptedLic = false; + if (!extension.is()) + { + ::std::vector >::const_iterator + i = ::std::find_if( + vecExtUnaccepted.begin(), + vecExtUnaccepted.end(), ExtensionName(cmdPackages[pos])); + if (i != vecExtUnaccepted.end()) + { + extension = *i; + bUnacceptedLic = true; + } + } + + if (extension.is()) + { + allExtensions.push_back(extension); + vecUnaccepted.push_back(bUnacceptedLic); + } + + else + throw lang::IllegalArgumentException( + OUSTR("There is no such extension deployed: ") + + cmdPackages[pos],0,-1); + } + + } + + printf_packages(allExtensions, vecUnaccepted, xCmdEnv ); + } + else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("validate") )) + { + ::std::vector > vecExtUnaccepted; + ::comphelper::sequenceToContainer( + vecExtUnaccepted, xExtensionManager->getExtensionsWithUnacceptedLicenses( + repository, xCmdEnv)); + + for ( ::std::size_t pos = 0; pos < cmdPackages.size(); ++pos ) + { + Reference extension; + try + { + extension = xExtensionManager->getDeployedExtension( + repository, cmdPackages[ pos ], cmdPackages[ pos ], xCmdEnv ); + } + catch (lang::IllegalArgumentException &) + { + extension = findPackage( + repository, xExtensionManager, xCmdEnv, cmdPackages[ pos ] ); + } + + if (!extension.is()) + { + ::std::vector >::const_iterator + i = ::std::find_if( + vecExtUnaccepted.begin(), + vecExtUnaccepted.end(), ExtensionName(cmdPackages[pos])); + if (i != vecExtUnaccepted.end()) + { + extension = *i; + } + } + + if (extension.is()) + xExtensionManager->checkPrerequisitesAndEnable( + extension, Reference(), xCmdEnv); } - printf_packages( packages, xCmdEnv ); } else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("gui") )) { diff --git a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx index d23dcbf9577d..69a973b90a42 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx @@ -49,7 +49,7 @@ #include "com/sun/star/deployment/PlatformException.hpp" #include "com/sun/star/i18n/XCollator.hpp" #include "com/sun/star/i18n/CollatorOptions.hpp" -#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp" + #include #include "deployment.hrc" #include "dp_version.hxx" @@ -85,13 +85,12 @@ class CommandEnvironmentImpl sal_Int32 m_logLevel; bool m_option_force_overwrite; bool m_option_verbose; - bool m_option_bundled; - bool m_option_suppressLicense; Reference< XComponentContext > m_xComponentContext; Reference< XProgressHandler > m_xLogFile; void update_( Any const & Status ) throw (RuntimeException); - void printLicense(const OUString& sLicense, bool & accept, bool & decline); + void printLicense(const OUString & sName,const OUString& sLicense, + bool & accept, bool & decline); public: virtual ~CommandEnvironmentImpl(); @@ -99,9 +98,7 @@ public: Reference const & xComponentContext, OUString const & log_file, bool option_force_overwrite, - bool option_verbose, - bool option_bundled, - bool option_suppressLicense); + bool option_verbose); // XCommandEnvironment virtual Reference< task::XInteractionHandler > SAL_CALL @@ -120,19 +117,16 @@ public: virtual void SAL_CALL pop() throw (RuntimeException); }; + //______________________________________________________________________________ CommandEnvironmentImpl::CommandEnvironmentImpl( Reference const & xComponentContext, OUString const & log_file, bool option_force_overwrite, - bool option_verbose, - bool option_bundled, - bool option_suppressLicense) + bool option_verbose) : m_logLevel(0), m_option_force_overwrite( option_force_overwrite ), m_option_verbose( option_verbose ), - m_option_bundled( option_bundled), - m_option_suppressLicense( option_suppressLicense), m_xComponentContext(xComponentContext) { if (log_file.getLength() > 0) { @@ -162,10 +156,13 @@ CommandEnvironmentImpl::~CommandEnvironmentImpl() } //May throw exceptions -void CommandEnvironmentImpl::printLicense(const OUString& sLicense, bool & accept, bool &decline) +void CommandEnvironmentImpl::printLicense( + const OUString & sName, const OUString& sLicense, bool & accept, bool &decline) { ResMgr * pResMgr = DeploymentResMgr::get(); - OUString s1 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_1, *pResMgr)); + String s1tmp(ResId(RID_STR_UNOPKG_ACCEPT_LIC_1, *pResMgr)); + s1tmp.SearchAndReplaceAllAscii( "$NAME", sName ); + OUString s1(s1tmp); OUString s2 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_2, *pResMgr)); OUString s3 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_3, *pResMgr)); OUString s4 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_4, *pResMgr)); @@ -246,7 +243,6 @@ void CommandEnvironmentImpl::handle( lang::WrappedTargetException wtExc; deployment::LicenseException licExc; deployment::InstallException instExc; - deployment::LicenseIndividualAgreementException licAgreementExc; deployment::PlatformException platExc; deployment::VersionException verExc; @@ -281,27 +277,9 @@ void CommandEnvironmentImpl::handle( update_( wtExc.TargetException ); } } - else if (request >>= licAgreementExc) - { - if (m_option_suppressLicense && licAgreementExc.SuppressIfRequired) - { - approve = true; - } - else - { - String sResMsg( ResId( RID_STR_UNOPKG_NO_SHARED_ALLOWED, *DeploymentResMgr::get() ) ); - sResMsg.SearchAndReplaceAllAscii( "%NAME", licAgreementExc.ExtensionName ); - dp_misc::writeConsole(OUSTR("\n") + sResMsg + OUSTR("\n\n")); - abort = true; - } - } else if (request >>= licExc) { - bLicenseException = true; - if (m_option_suppressLicense && licExc.SuppressIfRequired) - approve = true; - else - printLicense(licExc.Text, approve, abort); + printLicense(licExc.ExtensionName, licExc.Text, approve, abort); } else if (request >>= instExc) { @@ -436,6 +414,7 @@ void CommandEnvironmentImpl::pop() throw (RuntimeException) m_xLogFile->pop(); } + } // anon namespace namespace unopkg { @@ -445,14 +424,10 @@ Reference< XCommandEnvironment > createCmdEnv( Reference< XComponentContext > const & xContext, OUString const & logFile, bool option_force_overwrite, - bool option_verbose, - bool option_bundled, - bool option_suppressLicense) + bool option_verbose) { return new CommandEnvironmentImpl( - xContext, logFile, option_force_overwrite, option_verbose, option_bundled, - option_suppressLicense); + xContext, logFile, option_force_overwrite, option_verbose); } - } // unopkg diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx index b25176e1dcee..3272810afee2 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx @@ -48,6 +48,7 @@ #include "unotools/configmgr.hxx" #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "cppuhelper/bootstrap.hxx" +#include "comphelper/sequence.hxx" #include using ::rtl::OUString; @@ -317,7 +318,10 @@ void printf_package( xPackage->getBundle( Reference(), xCmdEnv ) ); printf_space( level + 1 ); dp_misc::writeConsole("bundled Packages: {\n"); - printf_packages( seq, xCmdEnv, level + 2 ); + ::std::vector >vec_bundle; + ::comphelper::sequenceToContainer(vec_bundle, seq); + printf_packages( vec_bundle, ::std::vector(vec_bundle.size()), + xCmdEnv, level + 2 ); printf_space( level + 1 ); dp_misc::writeConsole("}\n"); } @@ -325,23 +329,45 @@ void printf_package( } // anon namespace +void printf_unaccepted_licenses( + Reference const & ext) +{ + OUString id( + dp_misc::getIdentifier(ext) ); + printf_line( OUSTR("Identifier"), id, 0 ); + printf_space(1); + dp_misc::writeConsole(OUSTR("License not accepted\n\n")); +} + //============================================================================== void printf_packages( - Sequence< Reference > const & seq, + ::std::vector< Reference > const & allExtensions, + ::std::vector const & vecUnaccepted, Reference const & xCmdEnv, sal_Int32 level ) { - sal_Int32 len = seq.getLength(); - Reference< deployment::XPackage > const * p = seq.getConstArray(); - if (len == 0) { + OSL_ASSERT(allExtensions.size() == vecUnaccepted.size()); + + if (allExtensions.size() == 0) + { printf_space( level ); dp_misc::writeConsole("\n"); } - else { - for ( sal_Int32 pos = 0; pos < len; ++pos ) - printf_package( p[ pos ], xCmdEnv, level ); + else + { + typedef ::std::vector< Reference >::const_iterator I_EXT; + int index = 0; + for (I_EXT i = allExtensions.begin(); i != allExtensions.end(); i++, index++) + { + if (vecUnaccepted[index]) + printf_unaccepted_licenses(*i); + else + printf_package( *i, xCmdEnv, level ); + dp_misc::writeConsole(OUSTR("\n")); + } } } + //############################################################################## namespace { diff --git a/desktop/source/pkgchk/unopkg/unopkg_shared.h b/desktop/source/pkgchk/unopkg/unopkg_shared.h index 6e9d30cf0d42..43f77513b10c 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_shared.h +++ b/desktop/source/pkgchk/unopkg/unopkg_shared.h @@ -162,14 +162,12 @@ css::uno::Reference createCmdEnv( css::uno::Reference const & xContext, ::rtl::OUString const & logFile, bool option_force_overwrite, - bool option_verbose, - bool option_bundled, - bool option_suppressLicense); - + bool option_verbose); //============================================================================== void printf_packages( - css::uno::Sequence< - css::uno::Reference > const & seq, + ::std::vector< + css::uno::Reference > const & allExtensions, + ::std::vector const & vecUnaccepted, css::uno::Reference const & xCmdEnv, sal_Int32 level = 0 ); -- cgit From 85c93f5779b0382769cf9dfb5a6306a018c17edd Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Tue, 20 Apr 2010 07:59:05 +0200 Subject: jl152 import 263447 from native0jl:#i77196# Show progress on startup --- desktop/inc/app.hxx | 6 +- desktop/source/app/app.cxx | 16 +- desktop/source/app/check_ext_deps.cxx | 205 +++++++++++++-------- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 1 - desktop/source/splash/splash.cxx | 27 +-- desktop/source/splash/splash.hxx | 1 + 6 files changed, 161 insertions(+), 95 deletions(-) (limited to 'desktop') diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 4f5a3b176be3..486d280311d9 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -132,7 +132,10 @@ class Desktop : public Application static sal_Bool LicenseNeedsAcceptance(); static sal_Bool IsFirstStartWizardNeeded(); static sal_Bool CheckExtensionDependencies(); - static void SynchronizeExtensionRepositories(); + + void SynchronizeExtensionRepositories(); + void SetSplashScreenText( const ::rtl::OUString& rText ); + void SetSplashScreenProgress( sal_Int32 ); private: // Bootstrap methods @@ -165,7 +168,6 @@ class Desktop : public Application Reference m_rSplashScreen; void OpenSplashScreen(); - void SetSplashScreenProgress(sal_Int32); void CloseSplashScreen(); void EnableOleAutomation(); diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index b82915871566..8e610fb0e141 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1392,12 +1392,14 @@ void Desktop::Main() tools::InitTestToolLib(); RTL_LOGFILE_CONTEXT_TRACE( aLog, "} tools::InitTestToolLib" ); + // Check if bundled or shared extensions were added /removed + // and process those extensions (has to be done before checking + // the extension dependencies! + SynchronizeExtensionRepositories(); + bool bAbort = CheckExtensionDependencies(); if ( bAbort ) return; - //Check if bundled or shared extensions were added /removed - //and process those extensions - SynchronizeExtensionRepositories(); // First Start Wizard allowed ? if ( ! pCmdLineArgs->IsNoFirstStartWizard()) @@ -2919,6 +2921,14 @@ void Desktop::SetSplashScreenProgress(sal_Int32 iProgress) } } +void Desktop::SetSplashScreenText( const ::rtl::OUString& rText ) +{ + if( m_rSplashScreen.is() ) + { + m_rSplashScreen->setText( rText ); + } +} + void Desktop::CloseSplashScreen() { if(m_rSplashScreen.is()) diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index f487e0dfc96f..6a9beae58ccd 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -27,12 +27,17 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_desktop.hxx" -#include +#include "osl/file.hxx" +#include "osl/mutex.hxx" + #include #include #include #include "cppuhelper/compbase3.hxx" +#include "vcl/wrkwin.hxx" +#include "vcl/timer.hxx" + #include #include @@ -59,7 +64,7 @@ using rtl::OUString; using namespace desktop; using namespace com::sun::star; -#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) +#define UNISTRING(s) OUString(RTL_CONSTASCII_USTRINGPARAM(s)) namespace { @@ -69,9 +74,13 @@ class SilentCommandEnv task::XInteractionHandler, ucb::XProgressHandler > { + Desktop *mpDesktop; + sal_Int32 mnLevel; + sal_Int32 mnProgress; + public: - virtual ~SilentCommandEnv(){}; - SilentCommandEnv(){}; + SilentCommandEnv( Desktop* pDesktop ); + virtual ~SilentCommandEnv(); // XCommandEnvironment virtual uno::Reference SAL_CALL @@ -91,21 +100,38 @@ public: throw (uno::RuntimeException); virtual void SAL_CALL pop() throw (uno::RuntimeException); }; + +//----------------------------------------------------------------------------- +SilentCommandEnv::SilentCommandEnv( Desktop* pDesktop ) +{ + mpDesktop = pDesktop; + mnLevel = 0; + mnProgress = 25; +} + +//----------------------------------------------------------------------------- +SilentCommandEnv::~SilentCommandEnv() +{ + mpDesktop->SetSplashScreenText( OUString() ); +} + +//----------------------------------------------------------------------------- Reference SilentCommandEnv::getInteractionHandler() -throw (uno::RuntimeException) + throw (uno::RuntimeException) { return this; } +//----------------------------------------------------------------------------- Reference SilentCommandEnv::getProgressHandler() -throw (uno::RuntimeException) + throw (uno::RuntimeException) { return this; } +//----------------------------------------------------------------------------- // XInteractionHandler -void SilentCommandEnv::handle( - Reference< task::XInteractionRequest> const & xRequest ) +void SilentCommandEnv::handle( Reference< task::XInteractionRequest> const & xRequest ) throw (uno::RuntimeException) { uno::Any request( xRequest->getRequest() ); @@ -127,23 +153,45 @@ void SilentCommandEnv::handle( } } +//----------------------------------------------------------------------------- // XProgressHandler -void SilentCommandEnv::push( uno::Any const & /*Status*/ ) -throw (uno::RuntimeException) +void SilentCommandEnv::push( uno::Any const & rStatus ) + throw (uno::RuntimeException) { -} + OUString sText; + mnLevel += 1; + if ( rStatus.hasValue() && ( rStatus >>= sText) ) + { + if ( mnLevel == 1 ) + mpDesktop->SetSplashScreenText( sText ); + else + mpDesktop->SetSplashScreenProgress( ++mnProgress ); + } +} -void SilentCommandEnv::update( uno::Any const & /*Status */) -throw (uno::RuntimeException) +//----------------------------------------------------------------------------- +void SilentCommandEnv::update( uno::Any const & rStatus ) + throw (uno::RuntimeException) { + OUString sText; + if ( rStatus.hasValue() && ( rStatus >>= sText) ) + { + mpDesktop->SetSplashScreenText( sText ); + } } +//----------------------------------------------------------------------------- void SilentCommandEnv::pop() throw (uno::RuntimeException) { + mnLevel -= 1; } } // end namespace + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- static const OUString sConfigSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); static const OUString sAccessSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ); //------------------------------------------------------------------------------ @@ -169,55 +217,75 @@ static sal_Int16 impl_showExtensionDialog( uno::Reference< uno::XComponentContex //------------------------------------------------------------------------------ // Check dependencies of all packages //------------------------------------------------------------------------------ -static bool impl_checkDependencies( const uno::Reference< deployment::XPackageManager > &xPackageManager ) +static bool impl_checkDependencies( const uno::Reference< uno::XComponentContext > &xContext ) { - uno::Sequence< uno::Reference< deployment::XPackage > > packages; + uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; + uno::Reference< deployment::XExtensionManager > xExtensionManager = deployment::ExtensionManager::get( xContext ); + + if ( !xExtensionManager.is() ) + { + OSL_ENSURE( 0, "Could not get the Extension Manager!" ); + return true; + } try { - packages = xPackageManager->getDeployedPackages( uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment >() ); + xAllPackages = xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(), + uno::Reference< ucb::XCommandEnvironment >() ); } - catch ( deployment::DeploymentException & ) { /* handleGeneralError(e.Cause);*/ } - catch ( ucb::CommandFailedException & ) { /* handleGeneralError(e.Reason);*/ } - catch ( ucb::CommandAbortedException & ) {} + catch ( deployment::DeploymentException & ) { return true; } + catch ( ucb::CommandFailedException & ) { return true; } + catch ( ucb::CommandAbortedException & ) { return true; } catch ( lang::IllegalArgumentException & e ) { throw uno::RuntimeException( e.Message, e.Context ); } - for ( sal_Int32 i = 0; i < packages.getLength(); ++i ) + sal_Int32 nMax = 2; +#ifdef DEBUG + nMax = 3; +#endif + + for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) { - bool bRegistered = false; - try { - beans::Optional< beans::Ambiguous< sal_Bool > > option( packages[i]->isRegistered( uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment >() ) ); - if ( option.IsPresent ) - { - ::beans::Ambiguous< sal_Bool > const & reg = option.Value; - if ( reg.IsAmbiguous ) - bRegistered = false; - else - bRegistered = reg.Value ? true : false; - } - else - bRegistered = false; - } - catch ( uno::RuntimeException & ) { throw; } - catch ( uno::Exception & exc) { - (void) exc; - OSL_ENSURE( 0, ::rtl::OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); - bRegistered = false; - } + uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; - if ( bRegistered ) + for ( sal_Int32 j = 0; (jcheckDependencies( uno::Reference< ucb::XCommandEnvironment >() ); - } - catch ( deployment::DeploymentException & ) {} - if ( ! bDependenciesValid ) + uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; + if ( xPackage.is() ) { - return false; + bool bRegistered = false; + try { + beans::Optional< beans::Ambiguous< sal_Bool > > option( xPackage->isRegistered( uno::Reference< task::XAbortChannel >(), + uno::Reference< ucb::XCommandEnvironment >() ) ); + if ( option.IsPresent ) + { + ::beans::Ambiguous< sal_Bool > const & reg = option.Value; + if ( reg.IsAmbiguous ) + bRegistered = false; + else + bRegistered = reg.Value ? true : false; + } + else + bRegistered = false; + } + catch ( uno::RuntimeException & ) { throw; } + catch ( uno::Exception & exc) { + (void) exc; + OSL_ENSURE( 0, ::rtl::OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + } + + if ( bRegistered ) + { + bool bDependenciesValid = false; + try { + bDependenciesValid = xPackage->checkDependencies( uno::Reference< ucb::XCommandEnvironment >() ); + } + catch ( deployment::DeploymentException & ) {} + if ( ! bDependenciesValid ) + { + return false; + } + } } } } @@ -254,31 +322,11 @@ static void impl_setNeedsCompatCheck() static bool impl_check() { uno::Reference< uno::XComponentContext > xContext = comphelper_getProcessComponentContext(); - uno::Reference< deployment::XPackageManager > xManager; - bool bDependenciesValid = true; - try { - xManager = deployment::thePackageManagerFactory::get( xContext )->getPackageManager( UNISTRING("user") ); - } - catch ( ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} - - if ( xManager.is() ) - bDependenciesValid = impl_checkDependencies( xManager ); - - if ( bDependenciesValid ) - { - try { - xManager = deployment::thePackageManagerFactory::get( xContext )->getPackageManager( UNISTRING("shared") ); - } - catch ( ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} - - if ( xManager.is() ) - bDependenciesValid = impl_checkDependencies( xManager ); - } + bool bDependenciesValid = impl_checkDependencies( xContext ); short nRet = 0; + if ( !bDependenciesValid ) nRet = impl_showExtensionDialog( xContext ); @@ -292,7 +340,7 @@ static bool impl_check() } //------------------------------------------------------------------------------ -// to check, if we need checking the dependencies of the extensions again, we compare +// to check if we need checking the dependencies of the extensions again, we compare // the build id of the office with the one of the last check //------------------------------------------------------------------------------ static bool impl_needsCompatCheck() @@ -325,6 +373,9 @@ static bool impl_needsCompatCheck() pset->setPropertyValue( OUString::createFromAscii("LastCompatibilityCheckID"), result ); Reference< util::XChangesBatch >( pset, UNO_QUERY_THROW )->commitChanges(); } +#ifdef DEBUG + bNeedsCheck = true; +#endif } catch (const Exception&) {} @@ -348,11 +399,9 @@ void Desktop::SynchronizeExtensionRepositories() { RTL_LOGFILE_CONTEXT(aLog,"desktop (jl97489) ::Desktop::SynchronizeExtensionRepositories"); OUString sDisable; - ::rtl::Bootstrap::get( - OUString(RTL_CONSTASCII_USTRINGPARAM("DISABLE_SYNC_EXTENSIONS")), - sDisable, - OUString(RTL_CONSTASCII_USTRINGPARAM(""))); + ::rtl::Bootstrap::get( UNISTRING( "DISABLE_SYNC_EXTENSIONS" ), sDisable, OUString() ); if (sDisable.getLength() > 0) return; - dp_misc::syncRepositories(new SilentCommandEnv()); + + dp_misc::syncRepositories( new SilentCommandEnv( this ) ); } diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index fef6d36c7165..cd37f07729bb 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -243,7 +243,6 @@ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bPare { TUpdateListEntry pEntry( new UpdateListEntry( xPackage, m_sPackageManagers[j] ) ); vEntries.push_back( pEntry ); - break; } } } diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index 5fee3028b4f6..381a98ce008f 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -135,14 +135,21 @@ void SAL_CALL SplashScreen::reset() } } -void SAL_CALL SplashScreen::setText(const OUString&) +void SAL_CALL SplashScreen::setText(const OUString& rText) throw (RuntimeException) { - if (_bVisible && !_bProgressEnd) { - if ( _eBitmapMode == BM_FULLSCREEN ) - ShowFullScreenMode( TRUE ); - Show(); - Flush(); + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + if ( _sProgressText != rText ) + { + _sProgressText = rText; + + if (_bVisible && !_bProgressEnd) + { + if ( _eBitmapMode == BM_FULLSCREEN ) + ShowFullScreenMode( TRUE ); + Show(); + updateStatus(); + } } } @@ -647,7 +654,7 @@ void SplashScreen::Paint( const Rectangle&) } if( (bNativeOK = DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aControlRegion, - CTRL_STATE_ENABLED, aValue, rtl::OUString() )) != FALSE ) + CTRL_STATE_ENABLED, aValue, _sProgressText )) != FALSE ) { return; } @@ -668,10 +675,8 @@ void SplashScreen::Paint( const Rectangle&) _vdev.DrawRect(Rectangle(_tlx, _tly, _tlx+_barwidth, _tly+_barheight)); _vdev.SetFillColor( _cProgressBarColor ); _vdev.SetLineColor(); - Rectangle aRect(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace); - _vdev.DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, - _tlx+_barspace+length, _tly+_barheight-_barspace)); - + _vdev.DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace)); + _vdev.DrawText( Rectangle(_tlx, _tly+_barheight+5, _tlx+_barwidth, _tly+_barheight+5+20), _sProgressText, TEXT_DRAW_CENTER ); } Size aSize = GetOutputSizePixel(); Size bSize = _vdev.GetOutputSizePixel(); diff --git a/desktop/source/splash/splash.hxx b/desktop/source/splash/splash.hxx index 99677aa107f1..8480ed3df9ae 100644 --- a/desktop/source/splash/splash.hxx +++ b/desktop/source/splash/splash.hxx @@ -91,6 +91,7 @@ private: Color _cProgressBarColor; bool _bNativeProgress; OUString _sAppName; + OUString _sProgressText; std::vector< FullScreenProgressRatioValue > _sFullScreenProgressRatioValues; sal_Int32 _iMax; -- cgit From e1703d7ac3e485fb7b94787ecdf04a7910bb20c5 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 20 Apr 2010 10:04:52 +0200 Subject: jl152 import 263448 from native0jl:#i77196# XExtensionManager supports XModifyBroadcaster --- .../deployment/manager/dp_extensionmanager.cxx | 66 +++++++++++++++++++--- .../deployment/manager/dp_extensionmanager.hxx | 51 +++++------------ desktop/source/deployment/manager/dp_manager.cxx | 8 +-- 3 files changed, 74 insertions(+), 51 deletions(-) (limited to 'desktop') 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 #include #include @@ -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 xPackageManagerFactory( @@ -433,7 +439,7 @@ Reference ExtensionManager::addExtension( OUSTR("No valid repository name provided."), static_cast(this), 0); - ::osl::MutexGuard guard(m_mutex); + ::osl::MutexGuard guard(getMutex()); Reference xTmpExtension = getTempExtension(url, xAbortChannel, xCmdEnv); const OUString sIdentifier = dp_misc::getIdentifier(xTmpExtension); @@ -529,6 +535,7 @@ Reference ExtensionManager::addExtension( activateExtension( dp_misc::getIdentifier(xNewExtension), xNewExtension->getName(), xAbortChannel, xCmdEnv); + fireModified(); } } catch (deploy::DeploymentException& ) { @@ -573,6 +580,7 @@ Reference 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(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(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 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 xPackageManager = getPackageManager(repository); - ::osl::MutexGuard guard(m_mutex); + ::osl::MutexGuard guard(getMutex()); xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv); const uno::Sequence< Reference > extensions( xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv)); @@ -1072,7 +1082,7 @@ void ExtensionManager::synchronize( OUSTR("No valid repository name provided."), static_cast(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 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 const & xListener ) + throw (uno::RuntimeException) +{ + check(); + rBHelper.addListener( ::getCppuType( &xListener ), xListener ); +} + +//______________________________________________________________________________ +void ExtensionManager::removeModifyListener( + Reference 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(this) ); + } +} + +void ExtensionManager::fireModified() +{ + ::cppu::OInterfaceContainerHelper * pContainer = rBHelper.getContainer( + util::XModifyListener::static_type() ); + if (pContainer != 0) { + pContainer->forEach( + boost::bind(&util::XModifyListener::modified, _1, + lang::EventObject(static_cast(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 #include "osl/mutex.hxx" #include @@ -53,50 +51,31 @@ typedef ::std::hash_map< ::std::vector >, ::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(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 const & xListener ) - // throw (css::uno::RuntimeException); - //virtual void SAL_CALL removeEventListener( - // css::uno::Reference const & xListener ) - // throw (css::uno::RuntimeException); - // - //// XModifyBroadcaster - //virtual void SAL_CALL addModifyListener( - // css::uno::Reference const & xListener ) - // throw (css::uno::RuntimeException); - //virtual void SAL_CALL removeModifyListener( - // css::uno::Reference 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 const & xListener ) + throw (css::uno::RuntimeException); + virtual void SAL_CALL removeModifyListener( + css::uno::Reference const & xListener ) + throw (css::uno::RuntimeException); + +//XExtensionManager virtual css::uno::Sequence< css::uno::Reference > 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 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)) { -- cgit From c2d9d80b487dd0d7353b22eee44bee3b84fc7838 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Wed, 21 Apr 2010 16:04:34 +0200 Subject: jl152 import 263449 from native0jl:#i77196# no registration of components in uno.exe at startup, fixed extension activation, basic, etc. --- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 2 +- .../deployment/manager/dp_extensionmanager.cxx | 207 +++++++++------------ .../deployment/manager/dp_extensionmanager.hxx | 21 ++- desktop/source/deployment/manager/dp_manager.hrc | 2 +- desktop/source/deployment/manager/dp_manager.src | 4 + .../deployment/registry/component/dp_component.cxx | 39 ++-- .../registry/configuration/dp_configuration.cxx | 2 + desktop/source/deployment/registry/dp_backend.cxx | 7 +- .../registry/executable/dp_executable.cxx | 2 + .../source/deployment/registry/help/dp_help.cxx | 2 + .../source/deployment/registry/inc/dp_backend.h | 3 + .../deployment/registry/package/dp_package.cxx | 4 +- .../deployment/registry/script/dp_script.cxx | 2 + .../source/deployment/registry/sfwk/dp_sfwk.cxx | 2 + .../migration/services/extensionmigration.cxx | 6 +- .../migration/services/oo3extensionmigration.cxx | 2 +- desktop/source/pkgchk/unopkg/unopkg_app.cxx | 7 +- 17 files changed, 158 insertions(+), 156 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 4b55a93d3f84..647c46b754c8 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -1048,7 +1048,7 @@ void ExtensionCmdQueue::Thread::_enableExtension( ::rtl::Reference< ProgressCmdE try { - xPackage->registerPackage( xAbortChannel, rCmdEnv.get() ); + xPackage->registerPackage(false, xAbortChannel, rCmdEnv.get() ); if ( m_pDialogHelper ) m_pDialogHelper->updatePackageInfo( xPackage ); } diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index c4581556749f..bbe476e57fba 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -260,48 +260,38 @@ void ExtensionManager::addExtensionsToMap( } -/* -*/ -Reference ExtensionManager::getExtensionAndStatus( - ::rtl::OUString const & identifier, - ::rtl::OUString const & fileName, - ::rtl::OUString const & repository, - Reference const & xAbortChannel, - Reference const & xCmdEnv, - bool & out_bWasRegistered) +bool ExtensionManager::isUserDisabled( + OUString const & identifier, OUString const & fileName) { - Reference theExtension; ::std::list > listExtensions = - getExtensionsWithSameId(identifier, fileName); - OSL_ASSERT(listExtensions.size() == m_repositoryNames.size()); - Reference xActiveExtension; - ::std::list::const_iterator - inames = m_repositoryNames.begin(); - ::std::list >::const_iterator - iext = listExtensions.begin(); - for (; inames != m_repositoryNames.end(); inames++, iext++) + getExtensionsWithSameId(identifier, fileName); + OSL_ASSERT(listExtensions.size() == 3); + + return isUserDisabled( ::comphelper::containerToSequence< + Reference, + ::std::list > + > (listExtensions)); +} + +bool ExtensionManager::isUserDisabled( + uno::Sequence > const & seqExtSameId) +{ + OSL_ASSERT(seqExtSameId.getLength() == 3); + Reference const & userExtension = seqExtSameId[0]; + if (userExtension.is()) { - if (repository.equals(*inames)) - { - theExtension = *iext; - if (iext->is()) - { - beans::Optional > optRegistered = - (*iext)->isRegistered(xAbortChannel, xCmdEnv); - OSL_ENSURE(! optRegistered.Value.IsAmbiguous, - "Extension is not properly registered"); - //IsAmbiguous = true: only partly registered, but we assume - //that this is the active extension, and something went wrong when registering it - //previously. - if (optRegistered.IsPresent - && (optRegistered.Value.Value || optRegistered.Value.IsAmbiguous)) - out_bWasRegistered = true; - } - break; - } + beans::Optional > reg = + userExtension->isRegistered(Reference(), + Reference()); + //If the value is ambiguous is than we assume that the extension + //is enabled, but something went wrong during enabling. We do not + //automatically disable user extensions. + if (reg.IsPresent && + ! reg.Value.IsAmbiguous && ! reg.Value.Value) + return true; } - return theExtension; + return false; } /* @@ -321,6 +311,8 @@ Reference ExtensionManager::getExtensionAndStatus( */ void ExtensionManager::activateExtension( OUString const & identifier, OUString const & fileName, + bool bUserDisabled, + bool bStartup, Reference const & xAbortChannel, Reference const & xCmdEnv ) { @@ -333,11 +325,13 @@ void ExtensionManager::activateExtension( Reference, ::std::list > > (listExtensions), - xAbortChannel, xCmdEnv); + bUserDisabled, bStartup, xAbortChannel, xCmdEnv); } void ExtensionManager::activateExtension( uno::Sequence > const & seqExt, + bool bUserDisabled, + bool bStartup, Reference const & xAbortChannel, Reference const & xCmdEnv ) { @@ -355,9 +349,12 @@ void ExtensionManager::activateExtension( if (!optReg.IsPresent) break; - //Check if this is a disabled user extension, if so then skip - if (!optReg.Value.Value && i == 0) //e.g. not registered - continue; + //Check if this is a disabled user extension, + if (i == 0 && bUserDisabled) + { + aExt->revokePackage(xAbortChannel, xCmdEnv); + continue; + } //If we have already determined an active extension then we must //make sure to unregister all extensions with the same id in @@ -374,7 +371,7 @@ void ExtensionManager::activateExtension( //Register if not already done. //reregister if the value is ambiguous, which indicates that //something went wrong during last registration. - aExt->registerPackage(xAbortChannel, xCmdEnv); + aExt->registerPackage(bStartup, xAbortChannel, xCmdEnv); } } } @@ -455,17 +452,18 @@ Reference ExtensionManager::addExtension( uno::Any excOccurred1; uno::Any excOccurred2; - + bool bUserDisabled = false; try { - //If we add a user extension and there is already one which was - //disabled by a user, then the newly installed one is enabled. If we - //add to another repository then the user extension remains - //disabled. - bool bWasRegistered = false; - xOldExtension = getExtensionAndStatus( - sIdentifier, sFileName, repository, xAbortChannel, - xCmdEnv, bWasRegistered); + bUserDisabled = isUserDisabled(sIdentifier, sFileName); + try + { + xOldExtension = xPackageManager->getDeployedPackage( + sIdentifier, sFileName, xCmdEnv); + } + catch (lang::IllegalArgumentException &) + { + } bool bCanInstall = false; try { @@ -514,8 +512,7 @@ Reference ExtensionManager::addExtension( { if (xOldExtension.is()) { - if (bWasRegistered) - xOldExtension->revokePackage(xAbortChannel, xCmdEnv); + xOldExtension->revokePackage(xAbortChannel, xCmdEnv); //save the old user extension in case the user aborts //store the extension in the tmp repository, this will overwrite //xTmpPackage (same identifier). Do not let the user abort or @@ -532,9 +529,17 @@ Reference ExtensionManager::addExtension( xNewExtension = xPackageManager->addPackage( url, properties, OUString(), xAbortChannel, xCmdEnv); + + //If we add a user extension and there is already one which was + //disabled by a user, then the newly installed one is enabled. If we + //add to another repository then the user extension remains + //disabled. + bool bUserDisabled2 = bUserDisabled; + if (repository.equals(OUSTR("user"))) + bUserDisabled2 = false; activateExtension( dp_misc::getIdentifier(xNewExtension), - xNewExtension->getName(), xAbortChannel, xCmdEnv); + xNewExtension->getName(), bUserDisabled2, false, xAbortChannel, xCmdEnv); fireModified(); } } @@ -575,7 +580,7 @@ Reference ExtensionManager::addExtension( tmpCmdEnv); } activateExtension( - sIdentifier, sFileName, + sIdentifier, sFileName, bUserDisabled, false, Reference(), tmpCmdEnv); if (xTmpExtension.is() || xExtensionBackup.is()) m_tmpRepository->removePackage( @@ -611,7 +616,8 @@ void ExtensionManager::removeExtension( uno::Any excOccurred1; Reference xExtensionBackup; Reference xPackageManager; - + bool bUserDisabled = false; + ::osl::MutexGuard guard(getMutex()); try { //Determine the repository to use @@ -624,7 +630,7 @@ void ExtensionManager::removeExtension( OUSTR("No valid repository name provided."), static_cast(this), 0); - ::osl::MutexGuard guard(getMutex()); + bUserDisabled = isUserDisabled(identifier, fileName); //Backup the extension, in case the user cancels the action xExtensionBackup = backupExtension( identifier, fileName, xPackageManager, xCmdEnv); @@ -637,7 +643,8 @@ void ExtensionManager::removeExtension( xPackageManager->removePackage( identifier, fileName, xAbortChannel, xCmdEnv); - activateExtension(identifier, fileName, xAbortChannel, xCmdEnv); + activateExtension(identifier, fileName, bUserDisabled, false, + xAbortChannel, xCmdEnv); fireModified(); } catch (deploy::DeploymentException& ) { @@ -673,7 +680,8 @@ void ExtensionManager::removeExtension( xExtensionBackup, Reference(), tmpCmdEnv); activateExtension( - identifier, fileName, Reference(), + identifier, fileName, bUserDisabled, false, + Reference(), tmpCmdEnv); m_tmpRepository->removePackage( @@ -705,49 +713,24 @@ void ExtensionManager::enableExtension( lang::IllegalArgumentException, uno::RuntimeException) { + ::osl::MutexGuard guard(getMutex()); + bool bUserDisabled = false; + uno::Any excOccurred; try { if (!extension.is()) return; - OUString repository = extension->getRepositoryName(); if (!repository.equals(OUSTR("user"))) throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), static_cast(this), 0); - ::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 - //then there is nothing to do here - beans::Optional > reg = - extension->isRegistered(xAbortChannel, xCmdEnv); - if (!reg.IsPresent - || (!reg.Value.IsAmbiguous && reg.Value.Value)) - return; - } - catch (deploy::DeploymentException& ) { - throw; - } catch (ucb::CommandFailedException & ) { - throw; - } catch (ucb::CommandAbortedException & ) { - throw; - } catch (lang::IllegalArgumentException &) { - throw; - } catch (uno::RuntimeException &) { - throw; - } catch (...) { - uno::Any exc = ::cppu::getCaughtException(); - throw deploy::DeploymentException( - OUSTR("Extension Manager: exception during enableExtension"), - static_cast(this), exc); - } + bUserDisabled = isUserDisabled(dp_misc::getIdentifier(extension), + extension->getName()); - uno::Any excOccurred; - try - { activateExtension(dp_misc::getIdentifier(extension), - extension->getName(), + extension->getName(), false, false, xAbortChannel, xCmdEnv); } catch (deploy::DeploymentException& ) { @@ -772,9 +755,8 @@ void ExtensionManager::enableExtension( { try { - extension->revokePackage(Reference(), xCmdEnv); activateExtension(dp_misc::getIdentifier(extension), - extension->getName(), + extension->getName(), bUserDisabled, false, xAbortChannel, xCmdEnv); } catch (...) @@ -810,8 +792,10 @@ long ExtensionManager::checkPrerequisitesAndEnable( //There are some unfulfilled prerequisites, try to revoke extension->revokePackage(xAbortChannel, xCmdEnv); } - activateExtension(dp_misc::getIdentifier(extension), - extension->getName(), xAbortChannel, xCmdEnv); + const OUString id(dp_misc::getIdentifier(extension)); + activateExtension(id, extension->getName(), + isUserDisabled(id, extension->getName()), false, + xAbortChannel, xCmdEnv); return ret; } catch (deploy::DeploymentException& ) { @@ -844,31 +828,23 @@ void ExtensionManager::disableExtension( lang::IllegalArgumentException, uno::RuntimeException) { + ::osl::MutexGuard guard(getMutex()); uno::Any excOccurred; + bool bUserDisabled = false; try { if (!extension.is()) return; - - ::osl::MutexGuard guard(getMutex()); - OUString repository = extension->getRepositoryName(); + const OUString repository( extension->getRepositoryName()); if (!repository.equals(OUSTR("user"))) throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), static_cast(this), 0); - //if it is already registered or if it cannot be registered - //because it does not contain any files which need to be processed - //then there is nothing to do here - beans::Optional > reg = - extension->isRegistered(xAbortChannel, xCmdEnv); - if (!reg.IsPresent - || (!reg.Value.IsAmbiguous && !reg.Value.Value)) - return; + const OUString id(dp_misc::getIdentifier(extension)); + bUserDisabled = isUserDisabled(id, extension->getName()); - extension->revokePackage(xAbortChannel, xCmdEnv); - activateExtension(dp_misc::getIdentifier(extension), - extension->getName(), + activateExtension(id, extension->getName(), true, false, xAbortChannel, xCmdEnv); } catch (deploy::DeploymentException& ) { @@ -894,7 +870,7 @@ void ExtensionManager::disableExtension( try { activateExtension(dp_misc::getIdentifier(extension), - extension->getName(), + extension->getName(), bUserDisabled, false, xAbortChannel, xCmdEnv); } catch (...) @@ -1021,7 +997,7 @@ void ExtensionManager::reinstallDeployedExtensions( const OUString id = dp_misc::getIdentifier(extensions[ pos ]); const OUString fileName = extensions[ pos ]->getName(); OSL_ASSERT(id.getLength()); - activateExtension(id, fileName, xAbortChannel, xCmdEnv ); + activateExtension(id, fileName, false, false, xAbortChannel, xCmdEnv ); } catch (lang::DisposedException &) { @@ -1083,12 +1059,11 @@ void ExtensionManager::synchronize( static_cast(this), 0); ::osl::MutexGuard guard(getMutex()); + String sSynchronizing(StrSyncRepository::get()); + sSynchronizing.SearchAndReplaceAllAscii( "%NAME", repository ); + dp_misc::ProgressLevel progress(xCmdEnv, sSynchronizing); - dp_misc::ProgressLevel progress( - xCmdEnv, OUSTR("Synchronizing ") + repository + OUSTR(" repository\n")); xPackageManager->synchronize(xAbortChannel, xCmdEnv); - - try { const uno::Sequence > > @@ -1097,8 +1072,8 @@ void ExtensionManager::synchronize( { uno::Sequence > const & seqExt = seqSeqExt[i]; - - activateExtension(seqExt, xAbortChannel, xCmdEnv); + activateExtension(seqExt, isUserDisabled(seqExt), true, + xAbortChannel, xCmdEnv); } } catch (...) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index b11a2c64f546..10bf3713c410 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -204,6 +204,9 @@ public: private: + struct StrSyncRepository : public ::dp_misc::StaticResourceString< + StrSyncRepository, RID_STR_SYNCHRONIZING_REPOSITORY> {}; + struct ExtensionInfos { ::rtl::OUString identifier; @@ -225,24 +228,24 @@ private: */ ::std::list< ::rtl::OUString > m_repositoryNames; - css::uno::Reference getExtensionAndStatus( - ::rtl::OUString const & identifier, - ::rtl::OUString const & fileName, - ::rtl::OUString const & repository, - css::uno::Reference const & xAbortChannel, - css::uno::Reference const & xCmdEnv, - bool & out_bWasRegistered); + bool isUserDisabled(::rtl::OUString const & identifier, + ::rtl::OUString const & filename); + + bool ExtensionManager::isUserDisabled( + css::uno::Sequence > const & seqExtSameId); void activateExtension( ::rtl::OUString const & identifier, ::rtl::OUString const & fileName, + bool bUserDisabled, bool bStartup, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); void activateExtension( css::uno::Sequence > const & seqExt, - css::uno::Reference const & xAbortChannel, - css::uno::Reference const & xCmdEnv ); + bool bUserDisabled, bool bStartup, + css::uno::Reference const & xAbortChannel, + css::uno::Reference const & xCmdEnv ); ::std::list > diff --git a/desktop/source/deployment/manager/dp_manager.hrc b/desktop/source/deployment/manager/dp_manager.hrc index bdbfc079cda6..6131cc381abf 100644 --- a/desktop/source/deployment/manager/dp_manager.hrc +++ b/desktop/source/deployment/manager/dp_manager.hrc @@ -35,5 +35,5 @@ #define RID_STR_PACKAGE_ALREADY_ADDED (RID_DEPLOYMENT_MANAGER_START+2) #define RID_STR_COPYING_PACKAGE (RID_DEPLOYMENT_MANAGER_START+3) #define RID_STR_NO_SUCH_PACKAGE (RID_DEPLOYMENT_MANAGER_START+4) - +#define RID_STR_SYNCHRONIZING_REPOSITORY (RID_DEPLOYMENT_MANAGER_START+5) #endif diff --git a/desktop/source/deployment/manager/dp_manager.src b/desktop/source/deployment/manager/dp_manager.src index 95ede4aa6227..7d38b880c37a 100644 --- a/desktop/source/deployment/manager/dp_manager.src +++ b/desktop/source/deployment/manager/dp_manager.src @@ -53,3 +53,7 @@ String RID_STR_NO_SUCH_PACKAGE Text [ en-US ] = "There is no such extension deployed: "; }; +String RID_STR_SYNCHRONIZING_REPOSITORY +{ + Text [ en-US ] = "Synchronizing repository for %NAME extensions"; +}; diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index 17444eb0828e..b3b8a8249994 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -122,7 +122,6 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend BackendImpl * getMyBackend() const; const OUString m_loader; - Reference m_xRemoteContext; ComponentBackendDb::Data m_registeredComponentsDb; enum reg { @@ -143,6 +142,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -179,6 +179,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -356,7 +357,7 @@ BackendImpl * BackendImpl::ComponentPackageImpl::getMyBackend() const //______________________________________________________________________________ void BackendImpl::ComponentPackageImpl::disposing() { - m_xRemoteContext.clear(); +// m_xRemoteContext.clear(); Package::disposing(); } @@ -1224,6 +1225,7 @@ BackendImpl::ComponentPackageImpl::isRegistered_( void BackendImpl::ComponentPackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ) { @@ -1244,11 +1246,14 @@ void BackendImpl::ComponentPackageImpl::processPackage_( data.javaTypeLibrary = isJavaTypelib; if (doRegisterPackage) { - if (! m_xRemoteContext.is()) { - m_xRemoteContext.set( + Reference context(that->getComponentContext()); + if (! startup) + { + context.set( that->getObject( url ), UNO_QUERY ); - if (! m_xRemoteContext.is()) { - m_xRemoteContext.set( + + if (! context.is()) { + context.set( that->insertObject( url, raise_uno_process( that->getComponentContext(), abortChannel ) ), @@ -1258,9 +1263,9 @@ void BackendImpl::ComponentPackageImpl::processPackage_( const Reference xServicesRDB( getRDB() ); const Reference xImplReg( - m_xRemoteContext->getServiceManager()->createInstanceWithContext( + context->getServiceManager()->createInstanceWithContext( OUSTR("com.sun.star.registry.ImplementationRegistration"), - m_xRemoteContext ), UNO_QUERY_THROW ); + context ), UNO_QUERY_THROW ); xImplReg->registerImplementation( m_loader, url, xServicesRDB ); //only write to unorc if registration was successful. @@ -1274,7 +1279,7 @@ void BackendImpl::ComponentPackageImpl::processPackage_( t_stringlist implNames; t_stringpairvec singletons; const Reference xLoader( - getComponentInfo( &implNames, &singletons, m_xRemoteContext ) ); + getComponentInfo( &implNames, &singletons, context ) ); data.implementationNames = implNames; data.singletons = singletons; @@ -1348,11 +1353,14 @@ void BackendImpl::ComponentPackageImpl::processPackage_( // set to VOID during revocation process: m_registered = REG_VOID; - Reference xContext; - if (m_xRemoteContext.is()) // has been activated in this process - xContext = m_xRemoteContext; - else // has been deployed in former times + //get the remote context. If it does not exist then use the local one + Reference xContext( + that->getObject( url ), UNO_QUERY ); + bool bRemoteContext = false; + if (!xContext.is()) xContext = that->getComponentContext(); + else + bRemoteContext = true; t_stringlist implNames; t_stringpairvec singletons; @@ -1427,10 +1435,8 @@ void BackendImpl::ComponentPackageImpl::processPackage_( if (isJavaTypelib) that->removeFromUnoRc( java, url, xCmdEnv ); - if (m_xRemoteContext.is()) { + if (bRemoteContext) that->releaseObject( url ); - m_xRemoteContext.clear(); - } m_registered = REG_NOT_REGISTERED; getMyBackend()->deleteDataFromDb(url); @@ -1483,6 +1489,7 @@ BackendImpl::TypelibraryPackageImpl::isRegistered_( void BackendImpl::TypelibraryPackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool startup, ::rtl::Reference const &, Reference const & xCmdEnv ) { diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index fefa6794342a..941b9a35d7f5 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -86,6 +86,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -644,6 +645,7 @@ OUString replaceOrigin( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool /*startup*/, ::rtl::Reference const &, Reference const & xCmdEnv ) { diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index 1cebd20c297a..e822a66aa85f 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -619,6 +619,7 @@ beans::Optional< beans::Ambiguous > Package::isRegistered( //______________________________________________________________________________ void Package::processPackage_impl( bool doRegisterPackage, + bool startup, Reference const & xAbortChannel, Reference const & xCmdEnv ) { @@ -646,6 +647,7 @@ void Package::processPackage_impl( + displayName ); processPackage_( guard, doRegisterPackage, + startup, AbortChannel::get(xAbortChannel), xCmdEnv ); } @@ -683,6 +685,7 @@ void Package::processPackage_impl( //______________________________________________________________________________ void Package::registerPackage( + sal_Bool startup, Reference const & xAbortChannel, Reference const & xCmdEnv ) throw (deployment::DeploymentException, @@ -692,7 +695,7 @@ void Package::registerPackage( { if (m_bRemoved) throw deployment::ExtensionRemovedException(); - processPackage_impl( true /* register */, xAbortChannel, xCmdEnv ); + processPackage_impl( true /* register */, startup, xAbortChannel, xCmdEnv ); } //______________________________________________________________________________ @@ -703,7 +706,7 @@ void Package::revokePackage( CommandFailedException, CommandAbortedException, lang::IllegalArgumentException, RuntimeException) { - processPackage_impl( false /* revoke */, xAbortChannel, xCmdEnv ); + processPackage_impl( false /* revoke */, false, xAbortChannel, xCmdEnv ); } diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index 1dc4cdde64ea..ac83302f9fb4 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -62,6 +62,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -202,6 +203,7 @@ BackendImpl::ExecutablePackageImpl::isRegistered_( void BackendImpl::ExecutablePackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool /*startup*/, ::rtl::Reference const & abortChannel, Reference const & /*xCmdEnv*/ ) { diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index a523a1aa20a5..7e8f128bbf12 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -76,6 +76,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -278,6 +279,7 @@ BackendImpl::PackageImpl::isRegistered_( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool /* startup */, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ) { diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 7ad55d29ba2f..7b11ae456d5d 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -67,6 +67,7 @@ class Package : protected ::dp_misc::MutexHolder, public t_PackageBase PackageRegistryBackend * getMyBackend() const; void processPackage_impl( bool registerPackage, + bool startup, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ); @@ -97,6 +98,7 @@ protected: virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference< ::dp_misc::AbortChannel > const & abortChannel, css::uno::Reference const & xCmdEnv ) = 0; @@ -193,6 +195,7 @@ public: css::uno::RuntimeException); virtual void SAL_CALL registerPackage( + sal_Bool startup, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 822e744b8fc2..a5426bf26b54 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -159,6 +159,7 @@ class BackendImpl : public ImplBaseT virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -847,6 +848,7 @@ uno::Reference< graphic::XGraphic > BackendImpl::PackageImpl::getIcon( sal_Bool void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ) { @@ -865,7 +867,7 @@ void BackendImpl::PackageImpl::processPackage_( xPackage->createAbortChannel() ); AbortChannel::Chain chain( abortChannel, xSubAbortChannel ); try { - xPackage->registerPackage( xSubAbortChannel, xCmdEnv ); + xPackage->registerPackage( startup, xSubAbortChannel, xCmdEnv ); } catch (RuntimeException &) { throw; diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index 5023a501c67e..b2eddfaf74e0 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -80,6 +80,7 @@ class BackendImpl : public t_helper virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -379,6 +380,7 @@ BackendImpl::PackageImpl::isRegistered_( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool /* startup */, ::rtl::Reference const &, Reference const & xCmdEnv ) { diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx index 704f4f810928..8a4ee1b45fbc 100644 --- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx +++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx @@ -77,6 +77,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend virtual void processPackage_( ::osl::ResettableMutexGuard & guard, bool registerPackage, + bool startup, ::rtl::Reference const & abortChannel, Reference const & xCmdEnv ); @@ -371,6 +372,7 @@ BackendImpl::PackageImpl::isRegistered_( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, + bool /* startup */, ::rtl::Reference const &, Reference const & ) { diff --git a/desktop/source/migration/services/extensionmigration.cxx b/desktop/source/migration/services/extensionmigration.cxx index a926f17c0c19..66f32744a782 100755 --- a/desktop/source/migration/services/extensionmigration.cxx +++ b/desktop/source/migration/services/extensionmigration.cxx @@ -236,7 +236,7 @@ namespace migration if ( (sMediaType.equals(sBasicType) || sMediaType.equals(sDialogType)) && isBasicPackageEnabled(xPkg)) { - xPkg->registerPackage(uno::Reference< task::XAbortChannel >(), + xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); } } @@ -288,7 +288,7 @@ namespace migration if ( bRegistered && !sMediaType.equals(sBasicType) && !sMediaType.equals(sDialogType) ) { seqPkg[l]->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - seqPkg[l]->registerPackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); + seqPkg[l]->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); } } } @@ -297,7 +297,7 @@ namespace migration registerBasicPackage(aPackage); { aPackage->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - aPackage->registerPackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); + aPackage->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); } } } diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index a077eaddb911..2d17a654b29b 100755 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -146,7 +146,7 @@ void OO3ExtensionMigration::registerConfigurationPackage( const uno::Reference< if ( (sMediaType.equals(sConfigurationDataType) || sMediaType.equals(sConfigurationSchemaType) ) ) { xPkg->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - xPkg->registerPackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); + xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); } } diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index ba8cd56085f8..2f4a7f1d7146 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -400,12 +400,7 @@ extern "C" int unopkg_main() Reference p( findPackage(repository, xExtensionManager, xCmdEnv, cmdPackage ) ); - //Todo. temporary preventing exception in bundled case. - //In case of a bundled extension, remove would be called as a result of - //uninstalling a rpm. Then we do not want to show an error when the - //extension does not exist, because the package will be uninstalled anyway - //and the error would only confuse people. - if ( !p.is() && !option_bundled) + if ( !p.is()) throw; else if (p.is()) xExtensionManager->removeExtension( -- cgit From 9bfe25036358e6befdb2e9ddcbc1084f6a3d8c7f Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 23 Apr 2010 11:43:48 +0200 Subject: jl152 import 263450 from native0jl:#i77196# XExtensionManager.isReadOnlyRepositor, fixed removing xcu exceptions, executable backend --- .../deployment/manager/dp_commandenvironments.cxx | 31 ++++ .../deployment/manager/dp_commandenvironments.hxx | 18 ++- .../deployment/manager/dp_extensionmanager.cxx | 4 + .../deployment/manager/dp_extensionmanager.hxx | 2 + desktop/source/deployment/manager/dp_manager.cxx | 3 + .../source/deployment/registry/dp_backenddb.cxx | 8 +- .../registry/executable/dp_executable.cxx | 61 ++++++-- .../registry/executable/dp_executablebackenddb.cxx | 165 +++++++++++++++++++++ .../registry/executable/dp_executablebackenddb.hxx | 91 ++++++++++++ .../deployment/registry/executable/makefile.mk | 3 +- .../deployment/registry/help/dp_helpbackenddb.cxx | 24 --- .../deployment/registry/package/dp_package.cxx | 6 - .../deployment/registry/script/dp_script.cxx | 17 ++- 13 files changed, 382 insertions(+), 51 deletions(-) create mode 100644 desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx create mode 100644 desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_commandenvironments.cxx b/desktop/source/deployment/manager/dp_commandenvironments.cxx index 814dc818b2a6..c2801ba1d965 100644 --- a/desktop/source/deployment/manager/dp_commandenvironments.cxx +++ b/desktop/source/deployment/manager/dp_commandenvironments.cxx @@ -250,6 +250,37 @@ void NoLicenseCommandEnv::handle( handle_(approve, abort, xRequest); } + +// NoExceptionCommandEnv::NoExceptionCommandEnv( +// css::uno::Reference< css::task::XInteractionHandler> const & handler, +// css::uno::Type const & type): +// BaseCommandEnv(handler), +// m_type(type) +// { +// } +// // XInteractionHandler +// void NoExceptionCommandEnv::handle( +// Reference< task::XInteractionRequest> const & xRequest ) +// throw (uno::RuntimeException) +// { +// uno::Any request( xRequest->getRequest() ); +// OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION ); + + +// deployment::LicenseException licExc; + +// bool approve = false; +// bool abort = false; + +// if (request.getValueType() == m_type) +// { +// approve = true; +// } +// handle_(approve, abort, xRequest); +// } + + + } // namespace dp_manager diff --git a/desktop/source/deployment/manager/dp_commandenvironments.hxx b/desktop/source/deployment/manager/dp_commandenvironments.hxx index ad47fd2af549..0bdad4fd09cc 100644 --- a/desktop/source/deployment/manager/dp_commandenvironments.hxx +++ b/desktop/source/deployment/manager/dp_commandenvironments.hxx @@ -32,7 +32,7 @@ #include "cppuhelper/compbase3.hxx" //#include "cppuhelper/implbase2.hxx" #include "ucbhelper/content.hxx" - +#include "com/sun/star/uno/Type.hxx" namespace css = ::com::sun::star; @@ -137,6 +137,22 @@ public: }; +// class NoExceptionCommandEnv : public BaseCommandEnv +// { +// css::uno::Type m_type; +// public: +// NoExceptionCommandEnv::NoExceptionCommandEnv(){}; +// NoExceptionCommandEnv::NoExceptionCommandEnv( +// css::uno::Reference< css::task::XInteractionHandler> const & handler, +// css::uno::Type const & type); + +// // XInteractionHandler +// virtual void SAL_CALL handle( +// css::uno::Reference const & xRequest ) +// throw (css::uno::RuntimeException); + +// }; + } diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index bbe476e57fba..44f34991889e 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -1224,6 +1224,10 @@ ExtensionManager::getExtensionsWithUnacceptedLicenses( return xPackageManager->getExtensionsWithUnacceptedLicenses(xCmdEnv); } +sal_Bool ExtensionManager::isReadOnlyRepository(::rtl::OUString const & repository) +{ + return getPackageManager(repository)->isReadOnly(); +} //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 10bf3713c410..158fd35e2fa0 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -202,6 +202,8 @@ public: throw (css::deployment::DeploymentException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnlyRepository(::rtl::OUString const & repository); + private: struct StrSyncRepository : public ::dp_misc::StaticResourceString< diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 8c55f2508680..83105406f253 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -1368,6 +1368,9 @@ void PackageManagerImpl::synchronizeAddedExtensions( rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8); + //It it sufficient to check for the folder name, because when the administor + //installed the extension it was already checked if there is one with the + //same identifier. const MatchTempDir match(titleEncoded); if (::std::find_if( id2temp.begin(), id2temp.end(), match ) == id2temp.end()) diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 1c0451c77cd6..fe8b39b94d44 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -150,7 +150,7 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) //find the extension element that is to be removed Reference aNode = xpathApi->selectSingleNode(root, sXPathExpression); - OSL_ASSERT(aNode.is()); + if (aNode.is()) { root->removeChild(aNode); @@ -174,6 +174,7 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) } +//Only writes the data if there is at least one entry void BackendDb::writeVectorOfPair( ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > const & vecPairs, OUString const & sVectorTagName, @@ -183,6 +184,8 @@ void BackendDb::writeVectorOfPair( css::uno::Reference const & xParent) { try{ + if (vecPairs.size() == 0) + return; const OUString sNameSpace = getDbNSName(); OSL_ASSERT(sNameSpace.getLength()); Reference doc = getDocument(); @@ -287,6 +290,7 @@ BackendDb::readVectorOfPair( } } +//Only writes the data if there is at least one entry void BackendDb::writeSimpleList( ::std::list< ::rtl::OUString> const & list, OUString const & sListTagName, @@ -295,6 +299,8 @@ void BackendDb::writeSimpleList( { try { + if (list.size() == 0) + return; const OUString sNameSpace = getDbNSName(); Reference doc = getDocument(); diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index ac83302f9fb4..c72a97d88891 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_desktop.hxx" +#include "dp_misc.h" #include "dp_backend.h" #include "dp_ucb.h" #include "dp_interact.h" @@ -37,10 +38,12 @@ #include "comphelper/servicedecl.hxx" #include "svl/inettype.hxx" #include "cppuhelper/implbase1.hxx" +#include "dp_executablebackenddb.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::ucb; +using namespace dp_misc; using ::rtl::OUString; namespace dp_registry { @@ -68,7 +71,6 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend bool getFileAttributes(sal_uInt64& out_Attributes); bool isUrlTargetInExtension(); - public: inline ExecutablePackageImpl( ::rtl::Reference const & myBackend, @@ -89,8 +91,12 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend OUString const & url, OUString const & mediaType, sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); - Reference m_xExecutableTypeInfo; + void addDataToDb(OUString const & url); + bool isRegisteredInDb(OUString const & url); + void deleteDataFromDb(OUString const & url); + Reference m_xExecutableTypeInfo; + std::auto_ptr m_backendDb; public: BackendImpl( Sequence const & args, Reference const & xComponentContext ); @@ -114,7 +120,32 @@ BackendImpl::BackendImpl( RID_IMG_COMPONENT, RID_IMG_COMPONENT_HC ) ) { + if (!transientMode()) + { + OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml")); + m_backendDb.reset( + new ExecutableBackendDb(getComponentContext(), dbFile)); + } +} +void BackendImpl::addDataToDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url); +} + +bool BackendImpl::isRegisteredInDb(OUString const & url) +{ + bool ret = false; + if (m_backendDb.get()) + ret = m_backendDb->getEntry(url); + return ret; +} + +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); } // XPackageRegistry @@ -186,18 +217,11 @@ BackendImpl::ExecutablePackageImpl::isRegistered_( ::rtl::Reference const &, Reference const & ) { - //We must return Optional.isPresent = true, otherwise - //processPackage is not called. - //The user shall not be able to enable/disable the executable. This is not needed since - //the executable does not affect the office. The best thing is to show no - //status at all. See also BackendImpl::PackageImpl::isRegistered_ (dp_package.cxx) - //On Windows there is no executable file attribute. One has to use security API for this. - //However, on Windows we do not have the problem, that after unzipping the file cannot be - //executed. + bool registered = getMyBackend()->isRegisteredInDb(getURL()); return beans::Optional< beans::Ambiguous >( sal_True /* IsPresent */, beans::Ambiguous( - sal_True, sal_True /* IsAmbiguous */ ) ); + registered, sal_False /* IsAmbiguous */ ) ); } void BackendImpl::ExecutablePackageImpl::processPackage_( @@ -224,7 +248,9 @@ void BackendImpl::ExecutablePackageImpl::processPackage_( else if (getMyBackend()->m_context.equals(OUSTR("shared"))) attributes |= (osl_File_Attribute_OwnExe | osl_File_Attribute_GrpExe | osl_File_Attribute_OthExe); - else + else if (!getMyBackend()->m_context.equals(OUSTR("bundled"))) + //Bundled extension are required to be in the properly + //installed. That is an executable must have the right flags OSL_ASSERT(0); //This won't have affect on Windows @@ -232,11 +258,18 @@ void BackendImpl::ExecutablePackageImpl::processPackage_( dp_misc::expandUnoRcUrl(m_url), attributes)) OSL_ENSURE(0, "Extension Manager: Could not set executable file attribute."); } + getMyBackend()->addDataToDb(getURL()); + } + else + { + getMyBackend()->deleteDataFromDb(getURL()); } } -//We currently cannot check if this XPackage represents a content of a particular exension +//We currently cannot check if this XPackage represents a content of a particular extension //But we can check if we are within $UNO_USER_PACKAGES_CACHE etc. +//Done for security reasons. For example an extension manifest could contain a path to +//an executable outside the extension. bool BackendImpl::ExecutablePackageImpl::isUrlTargetInExtension() { bool bSuccess = false; @@ -245,6 +278,8 @@ bool BackendImpl::ExecutablePackageImpl::isUrlTargetInExtension() sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$UNO_USER_PACKAGES_CACHE")); else if (getMyBackend()->m_context.equals(OUSTR("shared"))) sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$UNO_SHARED_PACKAGES_CACHE")); + else if (getMyBackend()->m_context.equals(OUSTR("bundled"))) + sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$BUNDLED_EXTENSIONS")); else OSL_ASSERT(0); //remove file ellipses diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx new file mode 100644 index 000000000000..893a58ee8c64 --- /dev/null +++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_package.cxx,v $ + * $Revision: 1.34.16.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" + +#include "dp_executablebackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + +#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/executable-registry/2010" +#define NS_PREFIX "exe" +#define ROOT_ELEMENT_NAME "executable-backend-db" + +namespace dp_registry { +namespace backend { +namespace executable { + +ExecutableBackendDb::ExecutableBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +OUString ExecutableBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString ExecutableBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + +OUString ExecutableBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +void ExecutableBackendDb::addEntry(::rtl::OUString const & url) +{ + try{ + + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + OUString sExpression( + sPrefix + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); + Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + Reference helpElement( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":executable"))); + + helpElement->setAttribute(OUSTR("url"), url); + + Reference helpNode( + helpElement, UNO_QUERY_THROW); + root->appendChild(helpNode); + +// Reference dataNode( +// doc->createElementNS(sNameSpace, sPrefix + OUSTR(":data-url")), +// UNO_QUERY_THROW); +// helpNode->appendChild(dataNode); + +// Reference dataValue( +// doc->createTextNode(data.dataUrl), UNO_QUERY_THROW); +// dataNode->appendChild(dataValue); + + save(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +void ExecutableBackendDb::removeEntry(::rtl::OUString const & url) +{ + OUString sExpression( + OUSTR(NS_PREFIX) + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); + removeElement(sExpression); +} + +bool ExecutableBackendDb::getEntry(::rtl::OUString const & url) +{ + try + { + const OUString sPrefix = getNSPrefix(); + const OUString sExpression( + sPrefix + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + if (!aNode.is()) + { + return false; + } + return true; + } + 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 executable +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx new file mode 100644 index 000000000000..2634d1d9d376 --- /dev/null +++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_backend.h,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_EXECUTABLEBACKENDDB_HXX +#define INCLUDED_DP_EXECUTABLEBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "rtl/string.hxx" +#include +#include +#include "boost/optional.hpp" +#include "dp_backenddb.hxx" + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } + namespace xml { namespace dom { + class XDocument; + class XNode; + }} + namespace xml { namespace xpath { + class XXPathAPI; + }} +}}} + +namespace dp_registry { +namespace backend { +namespace executable { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + The format looks like this: + + + */ +class ExecutableBackendDb: public dp_registry::backend::BackendDb +{ +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getNSPrefix(); + + virtual ::rtl::OUString getRootElementName(); + +public: + + ExecutableBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + + void addEntry(::rtl::OUString const & url); + void removeEntry(::rtl::OUString const & url); + bool getEntry(::rtl::OUString const & url); +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/executable/makefile.mk b/desktop/source/deployment/registry/executable/makefile.mk index 1e57f5ecf3b1..81b2baa44e5d 100644 --- a/desktop/source/deployment/registry/executable/makefile.mk +++ b/desktop/source/deployment/registry/executable/makefile.mk @@ -36,7 +36,8 @@ ENABLE_EXCEPTIONS = TRUE INCPRE += ..$/..$/inc SLOFILES = \ - $(SLO)$/dp_executable.obj + $(SLO)$/dp_executable.obj \ + $(SLO)$/dp_executablebackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx index f36eb6d7b8cb..cad6ddecf751 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -111,20 +111,6 @@ void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) doc->createTextNode(data.dataUrl), UNO_QUERY_THROW); dataNode->appendChild(dataValue); -// writeSimpleList( -// data.implementationNames, -// OUSTR("implementation-names"), -// OUSTR("name"), -// componentNode); - -// writeVectorOfPair( -// data.singletons, -// OUSTR("singletons"), -// OUSTR("item"), -// OUSTR("key"), -// OUSTR("value"), -// componentNode); - save(); } catch(css::uno::Exception &) @@ -166,16 +152,6 @@ HelpBackendDb::getEntry(::rtl::OUString const & url) Reference dataUrlVal = xpathApi->selectSingleNode(aNode, sExprDataUrl); retData.dataUrl = dataUrlVal->getNodeValue(); - -// retData.implementationNames = -// readList( -// aNode, OUSTR("reg:implementation-names"), OUSTR("reg:name")); - -// retData.singletons = -// readVectorOfPair( -// aNode, OUSTR("reg:singletons"), OUSTR("item"), OUSTR("key"), -// OUSTR("value")); - } else { diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index a5426bf26b54..3d4842f62bfd 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -530,12 +530,6 @@ BackendImpl::PackageImpl::isRegistered_( for ( sal_Int32 pos = bundle.getLength(); pos--; ) { Reference const & xPackage = bundle[ pos ]; - //disregard executable (application/vnd.sun.star.executable) - //it will not be disabled/enabled. - OUString sType = xPackage->getPackageType()->getMediaType(); - if (sType.equals(OUSTR("application/vnd.sun.star.executable"))) - continue; - Reference xSubAbortChannel( xPackage->createAbortChannel() ); AbortChannel::Chain chain( abortChannel, xSubAbortChannel ); diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index b2eddfaf74e0..e808cd0f5e73 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -227,15 +227,22 @@ Reference BackendImpl::bindPackage_( { if (type.EqualsIgnoreCaseAscii("application")) { + OUString dialogURL( makeURL( url, OUSTR("dialog.xlb") ) ); + if (! create_ucb_content( + 0, dialogURL, xCmdEnv, false /* no throw */ )) { + dialogURL = OUString(); + } + if (subType.EqualsIgnoreCaseAscii("vnd.sun.star.basic-library")) { - OUString dialogURL( makeURL( url, OUSTR("dialog.xlb") ) ); + OUString scriptURL( makeURL( url, OUSTR("script.xlb"))); if (! create_ucb_content( - 0, dialogURL, xCmdEnv, false /* no throw */ )) { - dialogURL = OUString(); + 0, scriptURL, xCmdEnv, false /* no throw */ )) { + scriptURL = OUString(); } + return new PackageImpl( - this, url, xCmdEnv, makeURL( url, OUSTR("script.xlb") ), + this, url, xCmdEnv, scriptURL, dialogURL, bRemoved, identifier); } else if (subType.EqualsIgnoreCaseAscii( @@ -243,7 +250,7 @@ Reference BackendImpl::bindPackage_( return new PackageImpl( this, url, xCmdEnv, OUString() /* no script lib */, - makeURL( url, OUSTR("dialog.xlb") ), + dialogURL, bRemoved, identifier); } } -- cgit From 3807193d03962da3247a7b74bd58d2d511786fc2 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Wed, 28 Apr 2010 11:44:09 +0200 Subject: jl152 import 263451 from native0jl:#i77196# Use ExtensionManager instead of PackageManager --- desktop/source/app/check_ext_deps.cxx | 2 +- desktop/source/deployment/gui/dp_gui.h | 9 +-- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 91 +++++++++------------- desktop/source/deployment/gui/dp_gui_dialog2.hxx | 34 +++----- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 73 +++++++---------- .../deployment/gui/dp_gui_extensioncmdqueue.hxx | 8 +- .../source/deployment/gui/dp_gui_extlistbox.cxx | 39 +++++----- .../source/deployment/gui/dp_gui_extlistbox.hxx | 8 +- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 53 ++++++------- desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 8 +- .../source/deployment/gui/dp_gui_updatedata.hxx | 7 +- .../source/deployment/gui/dp_gui_updatedialog.cxx | 53 ++++++------- .../source/deployment/gui/dp_gui_updatedialog.hxx | 5 +- .../deployment/gui/dp_gui_updateinstalldialog.cxx | 11 ++- .../deployment/gui/dp_gui_updateinstalldialog.hxx | 6 ++ .../deployment/registry/component/dp_component.cxx | 2 +- 16 files changed, 172 insertions(+), 237 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 6a9beae58ccd..c3eb81dfc3ec 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -163,7 +163,7 @@ void SilentCommandEnv::push( uno::Any const & rStatus ) if ( rStatus.hasValue() && ( rStatus >>= sText) ) { - if ( mnLevel == 1 ) + if ( mnLevel <= 2 ) mpDesktop->SetSplashScreenText( sText ); else mpDesktop->SetSplashScreenProgress( ++mnProgress ); diff --git a/desktop/source/deployment/gui/dp_gui.h b/desktop/source/deployment/gui/dp_gui.h index 85e6eaef3544..092b232ce96d 100644 --- a/desktop/source/deployment/gui/dp_gui.h +++ b/desktop/source/deployment/gui/dp_gui.h @@ -79,21 +79,18 @@ enum PackageState { REGISTERED, NOT_REGISTERED, AMBIGUOUS, NOT_AVAILABLE }; class SelectedPackage: public salhelper::SimpleReferenceObject { public: SelectedPackage() {} - SelectedPackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> &xPackage, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> &xPackageManager ) - : m_xPackage( xPackage ), - m_xPackageManager( xPackageManager ) + SelectedPackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> &xPackage) + : m_xPackage( xPackage ) {} virtual ~SelectedPackage(); ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> getPackage() const { return m_xPackage; } - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> getPackageManager() const { return m_xPackageManager; } + private: SelectedPackage(SelectedPackage &); // not defined void operator =(SelectedPackage &); // not defined ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage; - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> m_xPackageManager; }; } // namespace dp_gui diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 5f0cf3d91012..164bb833fd6d 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -74,8 +74,6 @@ #include "com/sun/star/uno/Any.hxx" #include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" - #include #include #include @@ -108,10 +106,8 @@ struct StrAllFiles : public rtl::StaticWithInit< const OUString, StrAllFiles > }; //------------------------------------------------------------------------------ -UpdateListEntry::UpdateListEntry( const uno::Reference< deployment::XPackage > &xPackage, - const uno::Reference< deployment::XPackageManager > &xPackageManager ) : - m_xPackage( xPackage ), - m_xPackageManager( xPackageManager ) +UpdateListEntry::UpdateListEntry( const uno::Reference< deployment::XPackage > &xPackage ) : + m_xPackage( xPackage ) {} //------------------------------------------------------------------------------ @@ -415,17 +411,13 @@ void ExtBoxWithBtns_Impl::MouseButtonDown( const MouseEvent& rMEvt ) switch( ShowPopupMenu( aMousePos, nPos ) ) { case CMD_NONE: break; - case CMD_ENABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackageManager, - GetEntryData( nPos )->m_xPackage, true ); + case CMD_ENABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, true ); break; - case CMD_DISABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackageManager, - GetEntryData( nPos )->m_xPackage, false ); + case CMD_DISABLE: m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, false ); break; - case CMD_UPDATE: m_pParent->updatePackage( GetEntryData( nPos )->m_xPackageManager, - GetEntryData( nPos )->m_xPackage ); + case CMD_UPDATE: m_pParent->updatePackage( GetEntryData( nPos )->m_xPackage ); break; - case CMD_REMOVE: m_pParent->removePackage( GetEntryData( nPos )->m_xPackageManager, - GetEntryData( nPos )->m_xPackage ); + case CMD_REMOVE: m_pParent->removePackage( GetEntryData( nPos )->m_xPackage ); break; } } @@ -529,9 +521,7 @@ IMPL_LINK( ExtBoxWithBtns_Impl, HandleEnableBtn, void*, EMPTYARG ) TEntry_Impl pEntry = GetEntryData( nActive ); const bool bEnable( pEntry->m_eState != REGISTERED ); - m_pParent->enablePackage( pEntry->m_xPackageManager, - pEntry->m_xPackage, - bEnable ); + m_pParent->enablePackage( pEntry->m_xPackage, bEnable ); } return 1; @@ -545,8 +535,7 @@ IMPL_LINK( ExtBoxWithBtns_Impl, HandleRemoveBtn, void*, EMPTYARG ) if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND ) { TEntry_Impl pEntry = GetEntryData( nActive ); - m_pParent->removePackage( pEntry->m_xPackageManager, - pEntry->m_xPackage ); + m_pParent->removePackage( pEntry->m_xPackage ); } return 1; @@ -592,21 +581,21 @@ String DialogHelper::getResourceString( USHORT id ) } //------------------------------------------------------------------------------ -bool DialogHelper::IsSharedPkgMgr( const uno::Reference< deployment::XPackageManager > &xPackageManager ) +bool DialogHelper::IsSharedPkgMgr( const uno::Reference< deployment::XPackage > &xPackage ) { - if ( xPackageManager->getContext().equals( OUSTR("shared") ) ) + if ( xPackage->getRepositoryName().equals( OUSTR("shared") ) ) return true; else return false; } //------------------------------------------------------------------------------ -bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment::XPackageManager > &xPackageManager, +bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment::XPackage > &xPackage, Window *pParent, const USHORT nResID, bool &bHadWarning ) { - if ( !bHadWarning && IsSharedPkgMgr( xPackageManager ) ) + if ( !bHadWarning && IsSharedPkgMgr( xPackage ) ) { const ::vos::OGuard guard( Application::GetSolarMutex() ); WarningBox aInfoBox( pParent, getResId( nResID ) ); @@ -779,11 +768,10 @@ void ExtMgrDialog::setGetExtensionsURL( const ::rtl::OUString &rURL ) } //------------------------------------------------------------------------------ -long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage, - const uno::Reference< deployment::XPackageManager > &xPackageManager ) +long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage ) { m_aUpdateBtn.Enable( true ); - return m_pExtensionBox->addEntry( xPackage, xPackageManager ); + return m_pExtensionBox->addEntry( xPackage ); } //------------------------------------------------------------------------------ @@ -813,21 +801,20 @@ bool ExtMgrDialog::removeExtensionWarn( const OUString &rExtensionName ) const } //------------------------------------------------------------------------------ -bool ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager, - const uno::Reference< deployment::XPackage > &xPackage, +bool ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage, bool bEnable ) { - if ( !xPackageManager.is() || !xPackage.is() ) + if ( !xPackage.is() ) return false; if ( bEnable ) { - if ( ! continueOnSharedExtension( xPackageManager, this, RID_WARNINGBOX_ENABLE_SHARED_EXTENSION, m_bEnableWarning ) ) + if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_ENABLE_SHARED_EXTENSION, m_bEnableWarning ) ) return false; } else { - if ( ! continueOnSharedExtension( xPackageManager, this, RID_WARNINGBOX_DISABLE_SHARED_EXTENSION, m_bDisableWarning ) ) + if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_DISABLE_SHARED_EXTENSION, m_bDisableWarning ) ) return false; } @@ -837,35 +824,33 @@ bool ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackageMana } //------------------------------------------------------------------------------ -bool ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager, - const uno::Reference< deployment::XPackage > &xPackage ) +bool ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackage > &xPackage ) { - if ( !xPackageManager.is() || !xPackage.is() ) + if ( !xPackage.is() ) return false; - if ( !IsSharedPkgMgr( xPackageManager ) || m_bDeleteWarning ) + if ( !IsSharedPkgMgr( xPackage ) || m_bDeleteWarning ) { if ( ! removeExtensionWarn( xPackage->getDisplayName() ) ) return false; } - if ( ! continueOnSharedExtension( xPackageManager, this, RID_WARNINGBOX_REMOVE_SHARED_EXTENSION, m_bDeleteWarning ) ) + if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_REMOVE_SHARED_EXTENSION, m_bDeleteWarning ) ) return false; - m_pManager->removePackage( xPackageManager, xPackage ); + m_pManager->removePackage( xPackage ); return true; } //------------------------------------------------------------------------------ -bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager, - const uno::Reference< deployment::XPackage > &xPackage ) +bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackage > &xPackage ) { - if ( !xPackageManager.is() || !xPackage.is() ) + if ( !xPackage.is() ) return false; std::vector< TUpdateListEntry > vEntries; - TUpdateListEntry pEntry( new UpdateListEntry( xPackage, xPackageManager ) ); + TUpdateListEntry pEntry( new UpdateListEntry( xPackage ) ); vEntries.push_back( pEntry ); m_pManager->updatePackages( vEntries ); @@ -874,7 +859,7 @@ bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackageMana } //------------------------------------------------------------------------------ -uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker( const uno::Reference< deployment::XPackageManager > &xPackageManager ) +uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker() { const uno::Any mode( static_cast< sal_Int16 >( ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE ) ); const uno::Reference< uno::XComponentContext > xContext( m_pManager->getContext() ); @@ -892,7 +877,7 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker( const uno::Reference< de t_string2string title2filter; OUString sDefaultFilter( StrAllFiles::get() ); - const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( xPackageManager->getSupportedPackageTypes() ); + const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( m_pManager->getExtensionManager()->getSupportedPackageTypes( OUSTR("user") ) ); for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos ) { @@ -1046,8 +1031,7 @@ IMPL_LINK( ExtMgrDialog, HandleAddBtn, void*, EMPTYARG ) { setBusy( true ); - uno::Reference< deployment::XPackageManager > xUserPkgMgr = m_pManager->getUserPkgMgr(); - uno::Sequence< OUString > aFileList = raiseAddPicker( xUserPkgMgr ); + uno::Sequence< OUString > aFileList = raiseAddPicker(); if ( aFileList.getLength() ) { @@ -1317,15 +1301,14 @@ UpdateRequiredDialog::~UpdateRequiredDialog() } //------------------------------------------------------------------------------ -long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage, - const uno::Reference< deployment::XPackageManager > &xPackageManager ) +long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage ) { // We will only add entries to the list with unsatisfied dependencies if ( !checkDependencies( xPackage ) ) { - m_bHasLockedEntries |= (bool) xPackageManager->isReadOnly(); + m_bHasLockedEntries |= m_pManager->isReadOnly( xPackage ); m_aUpdateBtn.Enable( true ); - return m_pExtensionBox->addEntry( xPackage, xPackageManager ); + return m_pExtensionBox->addEntry( xPackage ); } return 0; } @@ -1350,9 +1333,8 @@ void UpdateRequiredDialog::checkEntries() } //------------------------------------------------------------------------------ -bool UpdateRequiredDialog::enablePackage( const uno::Reference< deployment::XPackageManager > &, - const uno::Reference< deployment::XPackage > &xPackage, - bool bEnable ) +bool UpdateRequiredDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage, + bool bEnable ) { m_pManager->enablePackage( xPackage, bEnable ); @@ -1476,8 +1458,7 @@ IMPL_LINK( UpdateRequiredDialog, HandleUpdateBtn, void*, EMPTYARG ) for ( sal_Int32 i = 0; i < nCount; ++i ) { TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( i ); - TUpdateListEntry pUpdateEntry( new UpdateListEntry( pEntry->m_xPackage, - pEntry->m_xPackageManager ) ); + TUpdateListEntry pUpdateEntry( new UpdateListEntry( pEntry->m_xPackage ) ); vUpdateEntries.push_back( pUpdateEntry ); } @@ -1738,7 +1719,7 @@ void UpdateRequiredDialog::disableAllEntries() for ( long nIndex = 0; nIndex < nCount; nIndex++ ) { TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( nIndex ); - enablePackage( pEntry->m_xPackageManager, pEntry->m_xPackage, false ); + enablePackage( pEntry->m_xPackage, false ); } setBusy( false ); diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx index cadc127446ea..4c99d64740db 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -46,7 +46,6 @@ #include "com/sun/star/awt/XWindow.hpp" #include "com/sun/star/deployment/XPackage.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/ui/dialogs/XExecutableDialog.hpp" #include "com/sun/star/util/XModifyListener.hpp" @@ -82,16 +81,15 @@ public: virtual void updateProgress( const long nProgress ) = 0; virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0; - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > & ) = 0; + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0; virtual void prepareChecking() = 0; virtual void checkEntries() = 0; static ResId getResId( USHORT nId ); static String getResourceString( USHORT id ); - static bool IsSharedPkgMgr( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &); - static bool continueOnSharedExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &, + static bool IsSharedPkgMgr( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &); + static bool continueOnSharedExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, Window *pParent, const USHORT nResID, bool &bHadWarning ); @@ -159,20 +157,16 @@ public: virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void setGetExtensionsURL( const ::rtl::OUString &rURL ); - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > & ); - bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &); + bool enablePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); - bool removePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); - bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + bool removePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + bool updatePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); virtual void prepareChecking(); virtual void checkEntries(); - ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker(); }; //============================================================================== @@ -234,18 +228,14 @@ public: virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void selectEntry( long nPos ); - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > & ); - bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, - bool bEnable ); - bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & ); + bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); + bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); virtual void prepareChecking(); virtual void checkEntries(); - ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker(); bool installForAllUsers( bool &bInstallForAll ) const; bool installExtensionWarn( const ::rtl::OUString &rExtensionURL ) const; diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 647c46b754c8..4c9357e03e9f 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -48,7 +48,6 @@ #include "com/sun/star/deployment/DeploymentException.hpp" #include "com/sun/star/deployment/UpdateInformationProvider.hpp" #include "com/sun/star/deployment/XPackage.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" #include "com/sun/star/task/XAbortChannel.hpp" #include "com/sun/star/task/XInteractionAbort.hpp" @@ -201,25 +200,18 @@ struct ExtensionCmd E_CMD_TYPE m_eCmdType; bool m_bWarnUser; OUString m_sExtensionURL; - uno::Reference< deployment::XPackageManager > m_xPackageManager; - uno::Reference< deployment::XPackage > m_xPackage; - std::vector< TUpdateListEntry > m_vExtensionList; + OUString m_sRepository; + uno::Reference< deployment::XPackage > m_xPackage; + std::vector< TUpdateListEntry > m_vExtensionList; ExtensionCmd( const E_CMD_TYPE eCommand, - const uno::Reference< deployment::XPackageManager > &rPackageManager, const OUString &rExtensionURL, + const OUString &rRepository, const bool bWarnUser ) : m_eCmdType( eCommand ), m_bWarnUser( bWarnUser ), m_sExtensionURL( rExtensionURL ), - m_xPackageManager( rPackageManager ) {}; - ExtensionCmd( const E_CMD_TYPE eCommand, - const uno::Reference< deployment::XPackageManager > &rPackageManager, - const uno::Reference< deployment::XPackage > &rPackage ) - : m_eCmdType( eCommand ), - m_bWarnUser( false ), - m_xPackageManager( rPackageManager ), - m_xPackage( rPackage ) {}; + m_sRepository( rRepository ) {}; ExtensionCmd( const E_CMD_TYPE eCommand, const uno::Reference< deployment::XPackage > &rPackage ) : m_eCmdType( eCommand ), @@ -242,11 +234,10 @@ public: TheExtensionManager *pManager, const uno::Reference< uno::XComponentContext > & rContext ); - void addExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const OUString &rExtensionURL, + void addExtension( const OUString &rExtensionURL, + const OUString &rRepository, const bool bWarnUser ); - void removeExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const uno::Reference< deployment::XPackage > &rPackage ); + void removeExtension( const uno::Reference< deployment::XPackage > &rPackage ); void enableExtension( const uno::Reference< deployment::XPackage > &rPackage, const bool bEnable ); void checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ); @@ -266,11 +257,10 @@ private: virtual void SAL_CALL onTerminated(); void _addExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, - const uno::Reference< deployment::XPackageManager > &xPackageManager, const OUString &rPackageURL, + const OUString &rRepository, const bool bWarnUser ); void _removeExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, - const uno::Reference< deployment::XPackageManager > &xPackageManager, const uno::Reference< deployment::XPackage > &xPackage ); void _enableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, const uno::Reference< deployment::XPackage > &xPackage ); @@ -645,8 +635,8 @@ ExtensionCmdQueue::Thread::Thread( DialogHelper *pDialogHelper, } //------------------------------------------------------------------------------ -void ExtensionCmdQueue::Thread::addExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const ::rtl::OUString &rExtensionURL, +void ExtensionCmdQueue::Thread::addExtension( const ::rtl::OUString &rExtensionURL, + const ::rtl::OUString &rRepository, const bool bWarnUser ) { ::osl::MutexGuard aGuard( m_mutex ); @@ -657,7 +647,7 @@ void ExtensionCmdQueue::Thread::addExtension( const uno::Reference< deployment:: if ( rExtensionURL.getLength() ) { - TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::ADD, rPackageManager, rExtensionURL, bWarnUser ) ); + TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::ADD, rExtensionURL, rRepository, bWarnUser ) ); m_queue.push( pEntry ); m_eInput = START; @@ -666,8 +656,7 @@ void ExtensionCmdQueue::Thread::addExtension( const uno::Reference< deployment:: } //------------------------------------------------------------------------------ -void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const uno::Reference< deployment::XPackage > &rPackage ) +void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deployment::XPackage > &rPackage ) { ::osl::MutexGuard aGuard( m_mutex ); @@ -675,9 +664,9 @@ void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deploymen if ( m_bStopped ) return; - if ( rPackageManager.is() && rPackage.is() ) + if ( rPackage.is() ) { - TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::REMOVE, rPackageManager, rPackage ) ); + TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::REMOVE, rPackage ) ); m_queue.push( pEntry ); m_eInput = START; @@ -811,10 +800,10 @@ void ExtensionCmdQueue::Thread::execute() switch ( pEntry->m_eCmdType ) { case ExtensionCmd::ADD : - _addExtension( currentCmdEnv, pEntry->m_xPackageManager, pEntry->m_sExtensionURL, pEntry->m_bWarnUser ); + _addExtension( currentCmdEnv, pEntry->m_sExtensionURL, pEntry->m_sRepository, pEntry->m_bWarnUser ); break; case ExtensionCmd::REMOVE : - _removeExtension( currentCmdEnv, pEntry->m_xPackageManager, pEntry->m_xPackage ); + _removeExtension( currentCmdEnv, pEntry->m_xPackage ); break; case ExtensionCmd::ENABLE : _enableExtension( currentCmdEnv, pEntry->m_xPackage ); @@ -904,8 +893,8 @@ void ExtensionCmdQueue::Thread::execute() //------------------------------------------------------------------------------ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, - const uno::Reference< deployment::XPackageManager > &xPackageManager, const OUString &rPackageURL, + const OUString &rRepository, const bool bWarnUser ) { //check if we have a string in anyTitle. For example "unopkg gui \" caused anyTitle to be void @@ -928,17 +917,16 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv } rCmdEnv->setWarnUser( bWarnUser ); - uno::Reference< task::XAbortChannel > xAbortChannel( xPackageManager->createAbortChannel() ); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); OUString sTitle = searchAndReplaceAll( m_sAddingPackages, OUSTR("%EXTENSION_NAME"), sName ); rCmdEnv->progressSection( sTitle, xAbortChannel ); try { - OUString sPackageManager = xPackageManager->getContext(); - uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); uno::Reference< deployment::XPackage > xPackage( xExtMgr->addExtension(rPackageURL, uno::Sequence(), - sPackageManager, xAbortChannel, rCmdEnv.get() ) ); + rRepository, xAbortChannel, rCmdEnv.get() ) ); OSL_ASSERT( xPackage.is() ); } catch ( ucb::CommandFailedException & ) @@ -956,19 +944,17 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv //------------------------------------------------------------------------------ void ExtensionCmdQueue::Thread::_removeExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, - const uno::Reference< deployment::XPackageManager > &xPackageManager, const uno::Reference< deployment::XPackage > &xPackage ) { - uno::Reference< task::XAbortChannel > xAbortChannel( xPackageManager->createAbortChannel() ); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); OUString sTitle = searchAndReplaceAll( m_sRemovingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); rCmdEnv->progressSection( sTitle, xAbortChannel ); OUString id( dp_misc::getIdentifier( xPackage ) ); try { - OUString sPackageManager = xPackageManager->getContext(); - uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); - xExtMgr->removeExtension( id, xPackage->getName(), sPackageManager, xAbortChannel, rCmdEnv.get() ); + xExtMgr->removeExtension( id, xPackage->getName(), xPackage->getRepositoryName(), xAbortChannel, rCmdEnv.get() ); } catch ( deployment::DeploymentException & ) {} @@ -1120,17 +1106,16 @@ ExtensionCmdQueue::~ExtensionCmdQueue() { stop(); } -void ExtensionCmdQueue::addExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const ::rtl::OUString & extensionURL, +void ExtensionCmdQueue::addExtension( const ::rtl::OUString & extensionURL, + const ::rtl::OUString & repository, const bool bWarnUser ) { - m_thread->addExtension( rPackageManager, extensionURL, bWarnUser ); + m_thread->addExtension( extensionURL, repository, bWarnUser ); } -void ExtensionCmdQueue::removeExtension( const uno::Reference< deployment::XPackageManager > &rPackageManager, - const uno::Reference< deployment::XPackage > &rPackage ) +void ExtensionCmdQueue::removeExtension( const uno::Reference< deployment::XPackage > &rPackage ) { - m_thread->removeExtension( rPackageManager, rPackage ); + m_thread->removeExtension( rPackage ); } void ExtensionCmdQueue::enableExtension( const uno::Reference< deployment::XPackage > &rPackage, diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx index f984c71c6c1c..69ad7da24769 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx @@ -40,7 +40,6 @@ /// @HTML namespace com { namespace sun { namespace star { - namespace deployment { class XPackageManager; } namespace task { class XInteractionRequest; } namespace uno { class XComponentContext; } } } } @@ -78,11 +77,10 @@ public: /** */ - void addExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &rPackageManager, - const ::rtl::OUString &rExtensionURL, + void addExtension( const ::rtl::OUString &rExtensionURL, + const ::rtl::OUString &rRepository, const bool bWarnUser ); - void removeExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &rPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage ); + void removeExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage ); void enableExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage, const bool bEnable ); void checkForUpdates( const std::vector< TUpdateListEntry > &vList ); diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 7d616b103c21..18911ce63ea2 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -44,6 +44,10 @@ #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) +#define USER_PACKAGE_MANAGER OUSTR("user") +#define SHARED_PACKAGE_MANAGER OUSTR("shared") +#define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") + using namespace ::com::sun::star; namespace dp_gui { @@ -52,10 +56,9 @@ namespace dp_gui { // struct Entry_Impl //------------------------------------------------------------------------------ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, - const uno::Reference< deployment::XPackageManager > &xPackageManager, - PackageState eState ) : + const PackageState eState, const bool bReadOnly ) : m_bActive( false ), - m_bLocked( false ), + m_bLocked( bReadOnly ), m_bHasOptions( false ), m_bShared( false ), m_bUser( false ), @@ -65,8 +68,7 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, m_bHasButtons( false ), m_eState( eState ), m_pPublisher( NULL ), - m_xPackage( xPackage ), - m_xPackageManager( xPackageManager ) + m_xPackage( xPackage ) { m_sTitle = xPackage->getDisplayName(); m_sVersion = xPackage->getVersion(); @@ -87,8 +89,6 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, else m_aIconHC = m_aIcon; - m_bLocked = m_xPackageManager->isReadOnly(); - if ( eState == AMBIGUOUS ) m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS ); else if ( eState == NOT_REGISTERED ) @@ -108,14 +108,11 @@ StringCompare Entry_Impl::CompareTo( const CollatorWrapper *pCollator, const TEn eCompare = m_sVersion.CompareTo( pEntry->m_sVersion ); if ( eCompare == COMPARE_EQUAL ) { - if ( m_xPackageManager != pEntry->m_xPackageManager ) - { - sal_Int32 nCompare = m_xPackageManager->getContext().compareTo( pEntry->m_xPackageManager->getContext() ); - if ( nCompare < 0 ) - eCompare = COMPARE_LESS; - else if ( nCompare > 0 ) - eCompare = COMPARE_GREATER; - } + sal_Int32 nCompare = m_xPackage->getRepositoryName().compareTo( pEntry->m_xPackage->getRepositoryName() ); + if ( nCompare < 0 ) + eCompare = COMPARE_LESS; + else if ( nCompare > 0 ) + eCompare = COMPARE_GREATER; } } return eCompare; @@ -955,13 +952,13 @@ bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl pEntry, const long nStar } //------------------------------------------------------------------------------ -long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage, - const uno::Reference< deployment::XPackageManager > &xPackageManager ) +long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage ) { - long nPos = 0; + long nPos = 0; PackageState eState = m_pManager->getPackageState( xPackage ); + bool bLocked = m_pManager->isReadOnly( xPackage ); - TEntry_Impl pEntry( new Entry_Impl( xPackage, xPackageManager, eState ) ); + TEntry_Impl pEntry( new Entry_Impl( xPackage, eState, bLocked ) ); xPackage->addEventListener( uno::Reference< lang::XEventListener > ( m_xRemoveListener, uno::UNO_QUERY ) ); ::osl::ClearableMutexGuard guard(m_entriesMutex); @@ -982,8 +979,8 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & } pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - pEntry->m_bUser = ( m_pManager->getUserPkgMgr() == xPackageManager ); - pEntry->m_bShared = !pEntry->m_bUser && ( m_pManager->getSharedPkgMgr() == xPackageManager ); + pEntry->m_bUser = xPackage->getRepositoryName().equals( USER_PACKAGE_MANAGER ); + pEntry->m_bShared = xPackage->getRepositoryName().equals( SHARED_PACKAGE_MANAGER ); pEntry->m_bNew = m_bInCheckMode; //access to m_nActive must be guarded diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx index 1ea3d0d72fcc..0f56d022492b 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx @@ -38,7 +38,6 @@ #include "com/sun/star/lang/Locale.hpp" #include "com/sun/star/lang/XEventListener.hpp" #include "com/sun/star/deployment/XPackage.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" #include @@ -86,11 +85,9 @@ struct Entry_Impl svt::FixedHyperlink *m_pPublisher; ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage; - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> m_xPackageManager; Entry_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - PackageState eState ); + const PackageState eState, const bool bReadOnly ); ~Entry_Impl(); StringCompare CompareTo( const CollatorWrapper *pCollator, const TEntry_Impl pEntry ) const; @@ -208,8 +205,7 @@ public: //----------------- virtual void selectEntry( const long nPos ); - long addEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + long addEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void updateEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void removeEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index cd37f07729bb..65a1bf021d29 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -35,8 +35,6 @@ #include "toolkit/helper/vclunohelper.hxx" #include "com/sun/star/beans/XPropertySet.hpp" -#include "com/sun/star/deployment/XPackageManagerFactory.hpp" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" #include "dp_gui_dialog2.hxx" #include "dp_gui_extensioncmdqueue.hxx" @@ -74,17 +72,8 @@ TheExtensionManager::TheExtensionManager( Window *pParent, m_pExtMgrDialog( NULL ), m_pUpdReqDialog( NULL ) { - m_sPackageManagers.realloc(3); - m_sPackageManagers[0] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( USER_PACKAGE_MANAGER ); - m_sPackageManagers[1] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( SHARED_PACKAGE_MANAGER ); - m_sPackageManagers[2] = deployment::thePackageManagerFactory::get( m_xContext )->getPackageManager( BUNDLED_PACKAGE_MANAGER ); - - for ( sal_Int32 i = 0; i < m_sPackageManagers.getLength(); ++i ) - { - m_sPackageManagers[i]->addModifyListener( this ); - } - m_xExtensionManager = deployment::ExtensionManager::get( xContext ); + m_xExtensionManager->addModifyListener( this ); uno::Reference< lang::XMultiServiceFactory > xConfig( xContext->getServiceManager()->createInstanceWithContext( @@ -241,7 +230,7 @@ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bPare uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; if ( xPackage.is() ) { - TUpdateListEntry pEntry( new UpdateListEntry( xPackage, m_sPackageManagers[j] ) ); + TUpdateListEntry pEntry( new UpdateListEntry( xPackage ) ); vEntries.push_back( pEntry ); } } @@ -261,10 +250,9 @@ bool TheExtensionManager::enablePackage( const uno::Reference< deployment::XPack } //------------------------------------------------------------------------------ -bool TheExtensionManager::removePackage( const uno::Reference< deployment::XPackageManager > &xPackageManager, - const uno::Reference< deployment::XPackage > &xPackage ) +bool TheExtensionManager::removePackage( const uno::Reference< deployment::XPackage > &xPackage ) { - m_pExecuteCmdQueue->removeExtension( xPackageManager, xPackage ); + m_pExecuteCmdQueue->removeExtension( xPackage ); return true; } @@ -285,22 +273,20 @@ bool TheExtensionManager::installPackage( const OUString &rPackageURL, bool bWar createDialog( false ); - uno::Reference< deployment::XPackageManager > xUserPkgMgr = getUserPkgMgr(); - uno::Reference< deployment::XPackageManager > xSharedPkgMgr = getSharedPkgMgr(); - bool bInstall = true; bool bInstallForAll = false; - if ( !bWarnUser && ! xSharedPkgMgr->isReadOnly() ) + // DV! missing function is read only repository from extension manager + if ( !bWarnUser && ! m_xExtensionManager->isReadOnlyRepository( SHARED_PACKAGE_MANAGER ) ) bInstall = getDialogHelper()->installForAllUsers( bInstallForAll ); if ( !bInstall ) return false; if ( bInstallForAll ) - m_pExecuteCmdQueue->addExtension( xSharedPkgMgr, rPackageURL, false ); + m_pExecuteCmdQueue->addExtension( rPackageURL, SHARED_PACKAGE_MANAGER, false ); else - m_pExecuteCmdQueue->addExtension( xUserPkgMgr, rPackageURL, bWarnUser ); + m_pExecuteCmdQueue->addExtension( rPackageURL, USER_PACKAGE_MANAGER, bWarnUser ); return true; } @@ -357,7 +343,7 @@ void TheExtensionManager::createPackageList() if ( xPackage.is() ) { PackageState eState = getPackageState( xPackage ); - getDialogHelper()->addPackageToList( xPackage, m_sPackageManagers[j] ); + getDialogHelper()->addPackageToList( xPackage ); // When the package is enabled, we can stop here, otherwise we have to look for // another version of this package if ( ( eState == REGISTERED ) || ( eState == NOT_AVAILABLE ) ) @@ -395,6 +381,17 @@ PackageState TheExtensionManager::getPackageState( const uno::Reference< deploym } } +//------------------------------------------------------------------------------ +bool TheExtensionManager::isReadOnly( const uno::Reference< deployment::XPackage > &xPackage ) const +{ + if ( m_xExtensionManager.is() && xPackage.is() ) + { + return m_xExtensionManager->isReadOnlyRepository( xPackage->getRepositoryName() ); + } + else + return true; +} + //------------------------------------------------------------------------------ // The function investigates if the extension supports options. bool TheExtensionManager::supportsOptions( const uno::Reference< deployment::XPackage > &xPackage ) const @@ -509,13 +506,9 @@ void TheExtensionManager::notifyTermination( ::lang::EventObject const & rEvt ) void TheExtensionManager::modified( ::lang::EventObject const & rEvt ) throw ( uno::RuntimeException ) { - uno::Reference< deployment::XPackageManager > xPackageManager( rEvt.Source, uno::UNO_QUERY ); - if ( xPackageManager.is() ) - { - getDialogHelper()->prepareChecking(); - createPackageList(); - getDialogHelper()->checkEntries(); - } + getDialogHelper()->prepareChecking(); + createPackageList(); + getDialogHelper()->checkEntries(); } //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx index 2b8f86de9955..6605b5907dab 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -33,7 +33,6 @@ #include "cppuhelper/implbase2.hxx" #include "com/sun/star/container/XNameAccess.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" #include "com/sun/star/deployment/XExtensionManager.hpp" #include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/frame/XDesktop.hpp" @@ -60,7 +59,6 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > m_xDesktop; ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> > m_sPackageManagers; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xNameAccessNodes; ::std::auto_ptr< ExtensionCmdQueue > m_pExecuteCmdQueue; @@ -100,8 +98,7 @@ public: bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); - bool removePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + bool removePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); bool installPackage( const ::rtl::OUString &rPackageURL, bool bWarnUser = false ); bool queryTermination(); @@ -111,9 +108,8 @@ public: bool supportsOptions( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; PackageState getPackageState( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext; } - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > getUserPkgMgr() const { return m_sPackageManagers[0]; } - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > getSharedPkgMgr() const { return m_sPackageManagers[1]; } ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > getExtensionManager() const { return m_xExtensionManager; } + bool isReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; //----------------- static ::rtl::Reference get( diff --git a/desktop/source/deployment/gui/dp_gui_updatedata.hxx b/desktop/source/deployment/gui/dp_gui_updatedata.hxx index dda6126f70d0..2082b92e923a 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedata.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedata.hxx @@ -35,7 +35,6 @@ namespace com { namespace sun { namespace star { namespace deployment { - class XPackageManager; class XPackage; }}}} namespace com { namespace sun { namespace star { namespace xml { namespace dom { @@ -48,10 +47,8 @@ namespace dp_gui { struct UpdateListEntry { ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage; - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> m_xPackageManager; - UpdateListEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager ); + UpdateListEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); ~UpdateListEntry(); }; @@ -61,8 +58,6 @@ typedef ::boost::shared_ptr< UpdateListEntry > TUpdateListEntry; struct UpdateData { ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > aInstalledPackage; - - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > aPackageManager; // The content of the update information ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > aUpdateInfo; //The URL of the locally downloaded extension. It will only be set if there were no errors diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index 61479f799e6f..fca7d97c798a 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -54,7 +54,8 @@ #include "com/sun/star/deployment/DeploymentException.hpp" #include "com/sun/star/deployment/UpdateInformationProvider.hpp" #include "com/sun/star/deployment/XPackage.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/XExtensionManager.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/deployment/XUpdateInformationProvider.hpp" #include "com/sun/star/frame/XDesktop.hpp" #include "com/sun/star/frame/XDispatch.hpp" @@ -240,12 +241,9 @@ private: struct Entry { explicit Entry( css::uno::Reference< css::deployment::XPackage > const & thePackage, - css::uno::Reference< css::deployment::XPackageManager > const & - thePackageManager, rtl::OUString const & theVersion); css::uno::Reference< css::deployment::XPackage > package; - css::uno::Reference< css::deployment::XPackageManager > packageManager; rtl::OUString version; css::uno::Reference< css::xml::dom::XNode > info; }; @@ -271,14 +269,10 @@ private: void handle( css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::deployment::XPackageManager > const & - packageManager, Map * map); bool update( css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::deployment::XPackageManager > const & - packageManager, css::uno::Reference< css::xml::dom::XNode > const & updateInfo) const; css::uno::Reference< css::uno::XComponentContext > m_context; @@ -333,11 +327,8 @@ void UpdateDialog::Thread::stop() { UpdateDialog::Thread::Entry::Entry( css::uno::Reference< css::deployment::XPackage > const & thePackage, - css::uno::Reference< css::deployment::XPackageManager > const & - thePackageManager, rtl::OUString const & theVersion): package(thePackage), - packageManager(thePackageManager), version(theVersion) {} @@ -356,7 +347,6 @@ void UpdateDialog::Thread::execute() for ( ITER iIndex = m_vExtensionList.begin(); iIndex < m_vExtensionList.end(); ++iIndex ) { css::uno::Reference< css::deployment::XPackage > p = (*iIndex)->m_xPackage; - css::uno::Reference< css::deployment::XPackageManager > m = (*iIndex)->m_xPackageManager; if ( p.is() ) { { @@ -365,7 +355,7 @@ void UpdateDialog::Thread::execute() return; } } - handle( p, m, &map ); + handle( p, &map ); } } @@ -399,9 +389,7 @@ void UpdateDialog::Thread::execute() } for (Map::const_iterator i(map.begin()); i != map.end(); ++i) { if (i->second.info.is() && - !update( - i->second.package, i->second.packageManager, - i->second.info)) + !update( i->second.package, i->second.info )) { break; } @@ -468,8 +456,6 @@ UpdateDialog::Thread::getUpdateInformation( void UpdateDialog::Thread::handle( css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::deployment::XPackageManager > const & - packageManager, Map * map) { rtl::OUString id(dp_misc::getIdentifier(package)); @@ -478,7 +464,7 @@ void UpdateDialog::Thread::handle( if (urls.getLength() == 0) { map->insert( Map::value_type( - id, Entry(package, packageManager, package->getVersion()))); + id, Entry(package, package->getVersion()))); } else { css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > infos(getUpdateInformation(package, urls, id)); @@ -504,18 +490,15 @@ void UpdateDialog::Thread::handle( } } if (latestIndex != -1) { - update( - package, packageManager, - css::uno::Reference< css::xml::dom::XNode >( - infos[latestIndex], css::uno::UNO_QUERY_THROW)); + update( package, + css::uno::Reference< css::xml::dom::XNode >( + infos[latestIndex], css::uno::UNO_QUERY_THROW)); } } } bool UpdateDialog::Thread::update( css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::deployment::XPackageManager > const & - packageManager, css::uno::Reference< css::xml::dom::XNode > const & updateInfo) const { dp_misc::DescriptionInfoset infoset(m_context, updateInfo); @@ -529,7 +512,7 @@ bool UpdateDialog::Thread::update( for (sal_Int32 i = 0; i < ds.getLength(); ++i) { du.unsatisfiedDependencies[i] = dp_misc::Dependencies::getErrorText(ds[i]); } - du.permission = ! packageManager->isReadOnly(); + du.permission = ! m_dialog.isReadOnly( package ); const ::boost::optional< ::rtl::OUString> updateWebsiteURL(infoset.getLocalizedUpdateWebsiteURL()); rtl::OUStringBuffer b(package->getDisplayName()); b.append(static_cast< sal_Unicode >(' ')); @@ -559,7 +542,6 @@ bool UpdateDialog::Thread::update( { dp_gui::UpdateData data; data.aInstalledPackage = package; - data.aPackageManager = packageManager; data.aUpdateInfo = updateInfo; if (updateWebsiteURL) data.sWebsiteURL = *updateWebsiteURL; @@ -626,6 +608,9 @@ UpdateDialog::UpdateDialog( // m_extensionManagerDialog(extensionManagerDialog) { OSL_ASSERT(updateData != NULL); + + m_xExtensionManager = css::deployment::ExtensionManager::get( context ); + css::uno::Reference< css::awt::XToolkit > toolkit; try { toolkit = css::uno::Reference< css::awt::XToolkit >( @@ -1055,6 +1040,16 @@ bool UpdateDialog::showDescription( const String& rDescription, bool bWithPublis return true; } +bool UpdateDialog::isReadOnly( const css::uno::Reference< css::deployment::XPackage > &xPackage ) const +{ + if ( m_xExtensionManager.is() && xPackage.is() ) + { + return m_xExtensionManager->isReadOnlyRepository( xPackage->getRepositoryName() ); + } + else + return true; +} + IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG) { rtl::OUStringBuffer b; @@ -1233,10 +1228,10 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG) typedef ::std::vector::const_iterator CIT; for (CIT i = m_enabledUpdates.begin(); i < m_enabledUpdates.end(); i++) { - OSL_ASSERT(i->aPackageManager.is()); + OSL_ASSERT(i->aInstalledPackage.is()); //If the user has no write access to the shared folder then the update //for a shared extension is disable, that is it cannot be in m_enabledUpdates - OSL_ASSERT(i->aPackageManager->isReadOnly() == sal_False); + OSL_ASSERT(isReadOnly(i->aInstalledPackage) == sal_False); #if 0 // TODO: check! OSL_ASSERT(m_extensionManagerDialog.get()); diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx index 1a8484e2c20f..1e72b22a68c7 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx @@ -60,7 +60,8 @@ class Window; namespace com { namespace sun { namespace star { namespace awt { class XThrobber; } - namespace deployment { class XPackageManager; } + namespace deployment { class XExtensionManager; + class XPackage; } namespace uno { class XComponentContext; } } } } @@ -171,6 +172,7 @@ private: bool showDescription( ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & aUpdateInfo); bool showDescription( const String& rDescription, bool bWithPublisher ); + bool isReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; DECL_LINK(selectionHandler, void *); DECL_LINK(allHandler, void *); @@ -214,6 +216,7 @@ private: std::vector< UpdateDialog::SpecificError > m_specificErrors; std::vector< dp_gui::UpdateData > & m_updateData; rtl::Reference< UpdateDialog::Thread > m_thread; + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; Point m_aFirstLinePos; Size m_aFirstLineSize; diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx index f607713118f0..f2f8b8b0d6e2 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx @@ -54,7 +54,8 @@ #include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp" #include "com/sun/star/ucb/XCommandEnvironment.hpp" #include "com/sun/star/ucb/XProgressHandler.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/XExtensionManager.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/deployment/XUpdateInformationProvider.hpp" #include "com/sun/star/deployment/DependencyException.hpp" #include "com/sun/star/deployment/LicenseException.hpp" @@ -257,6 +258,8 @@ UpdateInstallDialog::UpdateInstallDialog( { FreeResource(); + m_xExtensionManager = css::deployment::ExtensionManager::get( xCtx ); + m_cancel.SetClickHdl(LINK(this, UpdateInstallDialog, cancelHandler)); m_mle_info.EnableCursor(FALSE); if ( ! dp_misc::office_is_running()) @@ -496,7 +499,7 @@ void UpdateInstallDialog::Thread::installExtensions() if (curData.sLocalURL.getLength() == 0) continue; cssu::Reference< css::task::XAbortChannel > xAbortChannel( - curData.aPackageManager->createAbortChannel() ); + curData.aInstalledPackage->createAbortChannel() ); { vos::OGuard g(Application::GetSolarMutex()); if (m_stop) { @@ -504,9 +507,9 @@ void UpdateInstallDialog::Thread::installExtensions() } m_abort = xAbortChannel; } - xPackage = curData.aPackageManager->addPackage( + xPackage = m_dialog.getExtensionManager()->addExtension( curData.sLocalURL, css::uno::Sequence(), - OUString(), xAbortChannel, m_updateCmdEnv.get()); + curData.aInstalledPackage->getRepositoryName(), xAbortChannel, m_updateCmdEnv.get()); } catch (css::deployment::DeploymentException & de) { diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx index c3d01c8ee6d9..c0e64a8028e8 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.hxx @@ -41,6 +41,9 @@ #include "dp_gui_autoscrolledit.hxx" /// @HTML +namespace com { namespace sun { namespace star { namespace deployment { + class XExtensionManager; +}}}} namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; }}}} @@ -102,9 +105,12 @@ private: }; void setError(INSTALL_ERROR err, ::rtl::OUString const & sExtension, ::rtl::OUString const & exceptionMessage); void setError(::rtl::OUString const & exceptionMessage); + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > getExtensionManager() const + { return m_xExtensionManager; } rtl::Reference< Thread > m_thread; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xComponentContext; + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; //Signals that an error occurred during download and installation bool m_bError; bool m_bNoEntry; diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index b3b8a8249994..edb53d134c8b 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -1489,7 +1489,7 @@ BackendImpl::TypelibraryPackageImpl::isRegistered_( void BackendImpl::TypelibraryPackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, - bool startup, + bool /*startup*/, ::rtl::Reference const &, Reference const & xCmdEnv ) { -- cgit From 86e2dc0dcb9d79f1267dbd88d68bba6da3de871e Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 3 May 2010 11:51:05 +0200 Subject: jl152 import 263452 from native0jl:#i77196# fixed bundled extension help tree view, scripts in shared extensions... --- .../registry/component/dp_compbackenddb.cxx | 93 ++----- .../registry/component/dp_compbackenddb.hxx | 3 +- .../source/deployment/registry/dp_backenddb.cxx | 308 ++++++++++++++++++--- .../registry/executable/dp_executablebackenddb.cxx | 89 +----- .../registry/executable/dp_executablebackenddb.hxx | 18 +- .../deployment/registry/help/dp_helpbackenddb.cxx | 76 ++--- .../deployment/registry/help/dp_helpbackenddb.hxx | 7 +- .../deployment/registry/inc/dp_backenddb.hxx | 35 +++ .../registry/package/dp_extbackenddb.cxx | 65 ++--- .../registry/package/dp_extbackenddb.hxx | 3 +- .../deployment/registry/script/dp_script.cxx | 254 ++++++++--------- .../registry/script/dp_scriptbackenddb.cxx | 88 ++++++ .../registry/script/dp_scriptbackenddb.hxx | 76 +++++ .../source/deployment/registry/script/makefile.mk | 3 +- 14 files changed, 675 insertions(+), 443 deletions(-) create mode 100644 desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx create mode 100644 desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx (limited to 'desktop') diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx index 568ecca08138..898e7c931f6d 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx @@ -46,6 +46,7 @@ using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/component-registry/2010" #define NS_PREFIX "comp" #define ROOT_ELEMENT_NAME "component-backend-db" +#define KEY_ELEMENT_NAME "component" namespace dp_registry { namespace backend { @@ -73,54 +74,31 @@ OUString ComponentBackendDb::getRootElementName() return OUSTR(ROOT_ELEMENT_NAME); } +OUString ComponentBackendDb::getKeyElementName() +{ + return OUSTR(KEY_ELEMENT_NAME); +} + void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - const OUString sNameSpace = getDbNSName(); - const OUString sPrefix = getNSPrefix(); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - -#if OSL_DEBUG_LEVEL > 0 - //There must not be yet an entry with the same url - OUString sExpression( - sPrefix + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); - Reference _extensionNode = - getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); -#endif - Reference componentElement( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":component"))); - - componentElement->setAttribute(OUSTR("url"), url); - - Reference componentNode( - componentElement, UNO_QUERY_THROW); - - root->appendChild(componentNode); - - Reference javaTypeLibNode( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":java-type-library")), UNO_QUERY_THROW); - - componentNode->appendChild(javaTypeLibNode); - - Reference javaTypeLibValueNode( - doc->createTextNode(OUString::valueOf((sal_Bool) data.javaTypeLibrary)), - UNO_QUERY_THROW); - javaTypeLibNode->appendChild(javaTypeLibValueNode); + Reference componentNode = writeKeyElement(url); + writeSimpleElement(OUSTR("java-type-library"), + OUString::valueOf((sal_Bool) data.javaTypeLibrary), + componentNode); writeSimpleList( data.implementationNames, - sPrefix + OUSTR(":implementation-names"), - sPrefix + OUSTR(":name"), + OUSTR("implementation-names"), + OUSTR("name"), componentNode); writeVectorOfPair( data.singletons, - sPrefix + OUSTR(":singletons"), - sPrefix + OUSTR(":item"), - sPrefix + OUSTR(":key"), - sPrefix + OUSTR(":value"), + OUSTR("singletons"), + OUSTR("item"), + OUSTR("key"), + OUSTR("value"), componentNode); save(); @@ -134,50 +112,31 @@ void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data } } -void ComponentBackendDb::removeEntry(::rtl::OUString const & url) -{ - OUString sExpression( - OUSTR(NS_PREFIX) + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); - removeElement(sExpression); -} - ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & url) { try { - const OUString sPrefix = getNSPrefix(); ComponentBackendDb::Data retData; - const OUString sExpression( - sPrefix + OUSTR(":component[@url = \"") + url + OUSTR("\"]")); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - - Reference xpathApi = getXPathAPI(); - //find the extension element that is to be removed - Reference aNode = - xpathApi->selectSingleNode(root, sExpression); + Reference aNode = getKeyElement(url); if (aNode.is()) { - const OUString sExprJavaTypeLib(sPrefix + OUSTR(":java-type-library/text()")); - - Reference idValueNode = - xpathApi->selectSingleNode(aNode, sExprJavaTypeLib); - retData.javaTypeLibrary = - idValueNode->getNodeValue().equals(OUSTR("true")) ? true : false; + bool bJava = readSimpleElement(OUSTR("java-type-library"), aNode) + .equals(OUSTR("true")) ? true : false; + retData.javaTypeLibrary = bJava; retData.implementationNames = readList( aNode, - sPrefix + OUSTR(":implementation-names"), - sPrefix + OUSTR(":name")); + OUSTR("implementation-names"), + OUSTR("name")); retData.singletons = readVectorOfPair( aNode, - sPrefix + OUSTR(":singletons"), - sPrefix + OUSTR(":item"), - sPrefix + OUSTR(":key"), - sPrefix + OUSTR(":value")); + OUSTR("singletons"), + OUSTR("item"), + OUSTR("key"), + OUSTR("value")); } return retData; } diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx index 90ff41f2a4b8..b9a5ed737b7c 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx @@ -85,6 +85,7 @@ protected: virtual ::rtl::OUString getDbNSName(); virtual ::rtl::OUString getNSPrefix(); virtual ::rtl::OUString getRootElementName(); + virtual ::rtl::OUString getKeyElementName(); public: struct Data @@ -104,7 +105,7 @@ public: ::rtl::OUString const & url); void addEntry(::rtl::OUString const & url, Data const & data); - void removeEntry(::rtl::OUString const & url); + Data getEntry(::rtl::OUString const & url); diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index fe8b39b94d44..660c5ad80bf1 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -63,13 +63,13 @@ BackendDb::BackendDb( void BackendDb::save() { - Reference xDataSource(m_doc,css::uno::UNO_QUERY_THROW); + const Reference xDataSource(m_doc,css::uno::UNO_QUERY_THROW); ::rtl::ByteSequence bytes; xDataSource->setOutputStream(::xmlscript::createOutputStream(&bytes)); - Reference xDataControl(m_doc,css::uno::UNO_QUERY_THROW); + const Reference xDataControl(m_doc,css::uno::UNO_QUERY_THROW); xDataControl->start(); - Reference xData( + const Reference xData( ::xmlscript::createInputStream(bytes)); ::ucbhelper::Content ucbDb(m_urlDb, 0); ucbDb.writeStream(xData, true /*replace existing*/); @@ -79,7 +79,7 @@ css::uno::Reference BackendDb::getDocument() { if (!m_doc.is()) { - Reference xDocBuilder( + const Reference xDocBuilder( m_xContext->getServiceManager()->createInstanceWithContext( OUSTR("com.sun.star.xml.dom.DocumentBuilder"), m_xContext ), css::uno::UNO_QUERY); @@ -97,11 +97,10 @@ css::uno::Reference BackendDb::getDocument() { //Create a new document and insert some basic stuff m_doc = xDocBuilder->newDocument(); - Reference rootNode = + const Reference rootNode = m_doc->createElementNS(getDbNSName(), getNSPrefix() + OUSTR(":") + getRootElementName()); -// rootNode->setAttribute( -// OUSTR("xmlns"), getDbNSName()); + m_doc->appendChild(Reference( rootNode, UNO_QUERY_THROW)); save(); @@ -144,11 +143,11 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) { try { - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - Reference xpathApi = getXPathAPI(); + const Reference doc = getDocument(); + const Reference root = doc->getFirstChild(); + const Reference xpathApi = getXPathAPI(); //find the extension element that is to be removed - Reference aNode = + const Reference aNode = xpathApi->selectSingleNode(root, sXPathExpression); if (aNode.is()) @@ -159,7 +158,7 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) #if OSL_DEBUG_LEVEL > 0 //There must not be any other entry with the same url - Reference nextNode = + const Reference nextNode = xpathApi->selectSingleNode(root, sXPathExpression); OSL_ASSERT(! nextNode.is()); #endif @@ -171,7 +170,50 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression) OUSTR("Extension Manager: failed to write data entry in backend db: ") + m_urlDb, 0, exc); } +} +void BackendDb::removeEntry(::rtl::OUString const & url) +{ + const OUString sKeyElement = getKeyElementName(); + const OUString sPrefix = getNSPrefix(); + ::rtl::OUStringBuffer sExpression(500); + sExpression.append(sPrefix); + sExpression.appendAscii(":"); + sExpression.append(sKeyElement); + sExpression.append(OUSTR("[@url = \"")); + sExpression.append(url); + sExpression.appendAscii("\"]"); + + removeElement(sExpression.makeStringAndClear()); +} + +Reference BackendDb::getKeyElement( + ::rtl::OUString const & url) +{ + try + { + const OUString sPrefix = getNSPrefix(); + const OUString sKeyElement = getKeyElementName(); + ::rtl::OUStringBuffer sExpression(500); + sExpression.append(sPrefix); + sExpression.appendAscii(":"); + sExpression.append(sKeyElement); + sExpression.append(OUSTR("[@url = \"")); + sExpression.append(url); + sExpression.appendAscii("\"]"); + + const Reference doc = getDocument(); + const Reference root = doc->getFirstChild(); + const Reference xpathApi = getXPathAPI(); + return xpathApi->selectSingleNode(root, sExpression.makeStringAndClear()); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read key element in backend db: ") + + m_urlDb, 0, exc); + } } //Only writes the data if there is at least one entry @@ -188,11 +230,12 @@ void BackendDb::writeVectorOfPair( return; const OUString sNameSpace = getDbNSName(); OSL_ASSERT(sNameSpace.getLength()); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); + const OUString sPrefix(getNSPrefix() + OUSTR(":")); + const Reference doc = getDocument(); + const Reference root = doc->getFirstChild(); - Reference vectorNode( - doc->createElementNS(sNameSpace, sVectorTagName)); + const Reference vectorNode( + doc->createElementNS(sNameSpace, sPrefix + sVectorTagName)); xParent->appendChild( Reference( @@ -200,35 +243,35 @@ void BackendDb::writeVectorOfPair( typedef ::std::vector< ::std::pair< OUString, OUString > >::const_iterator CIT; for (CIT i = vecPairs.begin(); i != vecPairs.end(); i++) { - Reference pairNode( - doc->createElementNS(sNameSpace, sPairTagName)); + const Reference pairNode( + doc->createElementNS(sNameSpace, sPrefix + sPairTagName)); vectorNode->appendChild( Reference( pairNode, css::uno::UNO_QUERY_THROW)); - Reference firstNode( - doc->createElementNS(sNameSpace, sFirstTagName)); + const Reference firstNode( + doc->createElementNS(sNameSpace, sPrefix + sFirstTagName)); pairNode->appendChild( Reference( firstNode, css::uno::UNO_QUERY_THROW)); - Reference firstTextNode( + const Reference firstTextNode( doc->createTextNode( i->first)); firstNode->appendChild( Reference( firstTextNode, css::uno::UNO_QUERY_THROW)); - Reference secondNode( - doc->createElementNS(sNameSpace, sSecondTagName)); + const Reference secondNode( + doc->createElementNS(sNameSpace, sPrefix + sSecondTagName)); pairNode->appendChild( Reference( secondNode, css::uno::UNO_QUERY_THROW)); - Reference secondTextNode( + const Reference secondTextNode( doc->createTextNode( i->second)); secondNode->appendChild( @@ -256,23 +299,24 @@ BackendDb::readVectorOfPair( try { OSL_ASSERT(parent.is()); - Reference xpathApi = getXPathAPI(); - OUString sExprPairs( - sListTagName + OUSTR("/") + sPairTagName); - Reference listPairs = + const OUString sPrefix(getNSPrefix() + OUSTR(":")); + const Reference xpathApi = getXPathAPI(); + const OUString sExprPairs( + sPrefix + sListTagName + OUSTR("/") + sPrefix + sPairTagName); + const Reference 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 aPair = listPairs->item(i); - OUString sExprFirst(sFirstTagName + OUSTR("/text()")); - Reference first = + const Reference aPair = listPairs->item(i); + const OUString sExprFirst(sPrefix + sFirstTagName + OUSTR("/text()")); + const Reference first = xpathApi->selectSingleNode(aPair, sExprFirst); - OUString sExprSecond(sSecondTagName + OUSTR("/text()")); - Reference second = + const OUString sExprSecond(sPrefix + sSecondTagName + OUSTR("/text()")); + const Reference second = xpathApi->selectSingleNode(aPair, sExprSecond); OSL_ASSERT(first.is() && second.is()); @@ -302,10 +346,11 @@ void BackendDb::writeSimpleList( if (list.size() == 0) return; const OUString sNameSpace = getDbNSName(); - Reference doc = getDocument(); + const OUString sPrefix(getNSPrefix() + OUSTR(":")); + const Reference doc = getDocument(); - Reference listNode( - doc->createElementNS(sNameSpace, sListTagName)); + const Reference listNode( + doc->createElementNS(sNameSpace, sPrefix + sListTagName)); xParent->appendChild( Reference( @@ -314,12 +359,12 @@ void BackendDb::writeSimpleList( typedef ::std::list::const_iterator ITC_ITEMS; for (ITC_ITEMS i = list.begin(); i != list.end(); i++) { - Reference memberNode( - doc->createElementNS(sNameSpace, sMemberTagName), css::uno::UNO_QUERY_THROW); + const Reference memberNode( + doc->createElementNS(sNameSpace, sPrefix + sMemberTagName), css::uno::UNO_QUERY_THROW); listNode->appendChild(memberNode); - Reference textNode( + const Reference textNode( doc->createTextNode( *i), css::uno::UNO_QUERY_THROW); memberNode->appendChild(textNode); @@ -332,9 +377,105 @@ void BackendDb::writeSimpleList( OUSTR("Extension Manager: failed to write data entry in backend db: ") + m_urlDb, 0, exc); } +} + +//Writes only the element if is has a value. +//The prefix is automatically added to the element name +void BackendDb::writeSimpleElement( + OUString const & sElementName, OUString const & value, + Reference const & xParent) +{ + try + { + if (value.getLength() == 0) + return; + const OUString sPrefix = getNSPrefix(); + const Reference doc = getDocument(); + const OUString sNameSpace = getDbNSName(); + const Reference dataNode( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sElementName), + UNO_QUERY_THROW); + xParent->appendChild(dataNode); + + const Reference dataValue( + doc->createTextNode(value), UNO_QUERY_THROW); + dataNode->appendChild(dataValue); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry(writeSimpleElement) in backend db: ") + + m_urlDb, 0, exc); + } + +} + +/** The key elements have an url attribute and are always children of the root + element. +*/ +Reference BackendDb::writeKeyElement( + ::rtl::OUString const & url) +{ + try + { + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); + const OUString sElementName = getKeyElementName(); + const Reference doc = getDocument(); + const Reference root = doc->getFirstChild(); +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + const OUString sExpression( + sPrefix + OUSTR(":") + sElementName + OUSTR("[@url = \"") + url + OUSTR("\"]")); + const Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + const Reference keyElement( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sElementName)); + + keyElement->setAttribute(OUSTR("url"), url); + + const Reference keyNode( + keyElement, UNO_QUERY_THROW); + root->appendChild(keyNode); + return keyNode; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write key element in backend db: ") + + m_urlDb, 0, exc); + } } +OUString BackendDb::readSimpleElement( + OUString const & sElementName, Reference const & xParent) +{ + try + { + const OUString sPrefix = getNSPrefix(); + const OUString sExpr(sPrefix + OUSTR(":") + sElementName + OUSTR("/text()")); + const Reference xpathApi = getXPathAPI(); + const Reference val = + xpathApi->selectSingleNode(xParent, sExpr); + if (val.is()) + return val->getNodeValue(); + return OUString(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data (readSimpleElement) in backend db: ") + + m_urlDb, 0, exc); + } +} + + ::std::list< OUString> BackendDb::readList( Reference const & parent, OUString const & sListTagName, @@ -343,17 +484,18 @@ void BackendDb::writeSimpleList( try { OSL_ASSERT(parent.is()); - Reference xpathApi = getXPathAPI(); - OUString sExprList( - sListTagName + OUSTR("/") + sMemberTagName + OUSTR("/text()")); - Reference list = + const OUString sPrefix(getNSPrefix() + OUSTR(":")); + const Reference xpathApi = getXPathAPI(); + const OUString sExprList( + sPrefix + sListTagName + OUSTR("/") + sPrefix + sMemberTagName + OUSTR("/text()")); + const Reference list = xpathApi->selectNodeList(parent, sExprList); ::std::list retList; sal_Int32 length = list->getLength(); for (sal_Int32 i = 0; i < length; i++) { - Reference member = list->item(i); + const Reference member = list->item(i); retList.push_back(member->getNodeValue()); } return retList; @@ -369,6 +511,84 @@ void BackendDb::writeSimpleList( +//================================================================================ +RegisteredDb::RegisteredDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +void RegisteredDb::addEntry(::rtl::OUString const & url) +{ + try{ + + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); + const OUString sEntry = getKeyElementName(); + + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + +#if OSL_DEBUG_LEVEL > 0 + //There must not be yet an entry with the same url + OUString sExpression( + sPrefix + OUSTR(":") + sEntry + OUSTR("[@url = \"") + url + OUSTR("\"]")); + Reference _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); +#endif + Reference helpElement( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sEntry)); + + helpElement->setAttribute(OUSTR("url"), url); + + Reference helpNode( + helpElement, UNO_QUERY_THROW); + root->appendChild(helpNode); + + save(); + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +bool RegisteredDb::getEntry(::rtl::OUString const & url) +{ + try + { + const OUString sPrefix = getNSPrefix(); + const OUString sEntry = getKeyElementName(); + const OUString sExpression( + sPrefix + OUSTR(":") + sEntry + OUSTR("[@url = \"") + url + OUSTR("\"]")); + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + //find the extension element that is to be removed + Reference aNode = + xpathApi->selectSingleNode(root, sExpression); + if (!aNode.is()) + { + return false; + } + return true; + } + 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/executable/dp_executablebackenddb.cxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx index 893a58ee8c64..976a6281a2bd 100644 --- a/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx +++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx @@ -32,13 +32,8 @@ #include "precompiled_desktop.hxx" #include "rtl/string.h" -#include "rtl/bootstrap.hxx" -#include "cppuhelper/exc_hlp.hxx" #include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" -#include "com/sun/star/xml/xpath/XXPathAPI.hpp" #include "dp_misc.h" - #include "dp_executablebackenddb.hxx" @@ -49,6 +44,7 @@ using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/executable-registry/2010" #define NS_PREFIX "exe" #define ROOT_ELEMENT_NAME "executable-backend-db" +#define ENTRY_NAME "executable" namespace dp_registry { namespace backend { @@ -56,7 +52,7 @@ namespace executable { ExecutableBackendDb::ExecutableBackendDb( Reference const & xContext, - ::rtl::OUString const & url):BackendDb(xContext, url) + ::rtl::OUString const & url):RegisteredDb(xContext, url) { } @@ -76,86 +72,9 @@ OUString ExecutableBackendDb::getRootElementName() return OUSTR(ROOT_ELEMENT_NAME); } -void ExecutableBackendDb::addEntry(::rtl::OUString const & url) +OUString ExecutableBackendDb::getKeyElementName() { - try{ - - const OUString sNameSpace = getDbNSName(); - const OUString sPrefix = getNSPrefix(); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - -#if OSL_DEBUG_LEVEL > 0 - //There must not be yet an entry with the same url - OUString sExpression( - sPrefix + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); - Reference _extensionNode = - getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); -#endif - Reference helpElement( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":executable"))); - - helpElement->setAttribute(OUSTR("url"), url); - - Reference helpNode( - helpElement, UNO_QUERY_THROW); - root->appendChild(helpNode); - -// Reference dataNode( -// doc->createElementNS(sNameSpace, sPrefix + OUSTR(":data-url")), -// UNO_QUERY_THROW); -// helpNode->appendChild(dataNode); - -// Reference dataValue( -// doc->createTextNode(data.dataUrl), UNO_QUERY_THROW); -// dataNode->appendChild(dataValue); - - save(); - } - catch(css::uno::Exception &) - { - Any exc( ::cppu::getCaughtException() ); - throw css::deployment::DeploymentException( - OUSTR("Extension Manager: failed to write data entry in backend db: ") + - m_urlDb, 0, exc); - } -} - -void ExecutableBackendDb::removeEntry(::rtl::OUString const & url) -{ - OUString sExpression( - OUSTR(NS_PREFIX) + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); - removeElement(sExpression); -} - -bool ExecutableBackendDb::getEntry(::rtl::OUString const & url) -{ - try - { - const OUString sPrefix = getNSPrefix(); - const OUString sExpression( - sPrefix + OUSTR(":executable[@url = \"") + url + OUSTR("\"]")); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - - Reference xpathApi = getXPathAPI(); - //find the extension element that is to be removed - Reference aNode = - xpathApi->selectSingleNode(root, sExpression); - if (!aNode.is()) - { - return false; - } - return true; - } - 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 OUSTR(ENTRY_NAME); } diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx index 2634d1d9d376..4f17eeda24a6 100644 --- a/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx +++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx @@ -32,10 +32,6 @@ #define INCLUDED_DP_EXECUTABLEBACKENDDB_HXX #include "rtl/ustring.hxx" -#include "rtl/string.hxx" -#include -#include -#include "boost/optional.hpp" #include "dp_backenddb.hxx" namespace css = ::com::sun::star; @@ -44,13 +40,6 @@ namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } - namespace xml { namespace dom { - class XDocument; - class XNode; - }} - namespace xml { namespace xpath { - class XXPathAPI; - }} }}} namespace dp_registry { @@ -63,7 +52,7 @@ namespace executable { */ -class ExecutableBackendDb: public dp_registry::backend::BackendDb +class ExecutableBackendDb: public dp_registry::backend::RegisteredDb { protected: virtual ::rtl::OUString getDbNSName(); @@ -72,14 +61,13 @@ protected: virtual ::rtl::OUString getRootElementName(); + virtual ::rtl::OUString getKeyElementName(); + public: ExecutableBackendDb( css::uno::Reference const & xContext, ::rtl::OUString const & url); - void addEntry(::rtl::OUString const & url); - void removeEntry(::rtl::OUString const & url); - bool getEntry(::rtl::OUString const & url); }; diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx index cad6ddecf751..4a8fa71e0618 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -49,6 +49,7 @@ using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/help-registry/2010" #define NS_PREFIX "help" #define ROOT_ELEMENT_NAME "help-backend-db" +#define KEY_ELEMENT_NAME "help" namespace dp_registry { namespace backend { @@ -76,43 +77,25 @@ OUString HelpBackendDb::getRootElementName() return OUSTR(ROOT_ELEMENT_NAME); } -void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +OUString HelpBackendDb::getKeyElementName() { - try{ - - const OUString sNameSpace = getDbNSName(); - const OUString sPrefix = getNSPrefix(); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - -#if OSL_DEBUG_LEVEL > 0 - //There must not be yet an entry with the same url - OUString sExpression( - sPrefix + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); - Reference _extensionNode = - getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); -#endif - Reference helpElement( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":help"))); - - helpElement->setAttribute(OUSTR("url"), url); - - Reference helpNode( - helpElement, UNO_QUERY_THROW); - root->appendChild(helpNode); + return OUSTR(KEY_ELEMENT_NAME); +} - Reference dataNode( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":data-url")), - UNO_QUERY_THROW); - helpNode->appendChild(dataNode); - Reference dataValue( - doc->createTextNode(data.dataUrl), UNO_QUERY_THROW); - dataNode->appendChild(dataValue); +void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +{ + try{ + Reference helpNode + = writeKeyElement(url); + writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); save(); } + catch (css::deployment::DeploymentException& ) + { + throw; + } catch(css::uno::Exception &) { Any exc( ::cppu::getCaughtException() ); @@ -122,36 +105,17 @@ void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) } } -void HelpBackendDb::removeEntry(::rtl::OUString const & url) -{ - OUString sExpression( - OUSTR(NS_PREFIX) + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); - removeElement(sExpression); -} ::boost::optional HelpBackendDb::getEntry(::rtl::OUString const & url) { try { - const OUString sPrefix = getNSPrefix(); HelpBackendDb::Data retData; - const OUString sExpression( - sPrefix + OUSTR(":help[@url = \"") + url + OUSTR("\"]")); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - - Reference xpathApi = getXPathAPI(); - //find the extension element that is to be removed - Reference aNode = - xpathApi->selectSingleNode(root, sExpression); + Reference aNode = getKeyElement(url); if (aNode.is()) { - const OUString sExprDataUrl(sPrefix + OUSTR(":data-url/text()")); - - Reference dataUrlVal = - xpathApi->selectSingleNode(aNode, sExprDataUrl); - retData.dataUrl = dataUrlVal->getNodeValue(); + retData.dataUrl = readSimpleElement(OUSTR("data-url"), aNode); } else { @@ -159,6 +123,10 @@ HelpBackendDb::getEntry(::rtl::OUString const & url) } return ::boost::optional(retData); } + catch (css::deployment::DeploymentException& ) + { + throw; + } catch(css::uno::Exception &) { Any exc( ::cppu::getCaughtException() ); @@ -190,6 +158,10 @@ HelpBackendDb::getEntry(::rtl::OUString const & url) } return listRet; } + catch (css::deployment::DeploymentException& ) + { + throw; + } catch(css::uno::Exception &) { Any exc( ::cppu::getCaughtException() ); diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx index bf812ad96511..baecf0da48e6 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx @@ -59,9 +59,6 @@ namespace help { /* The XML file stores the extensions which are currently registered. They will be removed when they are revoked. - The format looks like this: - - */ class HelpBackendDb: public dp_registry::backend::BackendDb { @@ -72,6 +69,8 @@ protected: virtual ::rtl::OUString getRootElementName(); + virtual ::rtl::OUString getKeyElementName(); + public: struct Data { @@ -87,7 +86,7 @@ public: ::rtl::OUString const & url); void addEntry(::rtl::OUString const & url, Data const & data); - void removeEntry(::rtl::OUString const & url); + ::boost::optional getEntry(::rtl::OUString const & url); ::std::list< ::rtl::OUString> getAllDataUrls(); diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index ca28f28ac390..b8ba5facd492 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -30,6 +30,7 @@ #include "rtl/ustring.hxx" #include +#include namespace css = ::com::sun::star; @@ -75,6 +76,9 @@ protected: void save(); void removeElement(::rtl::OUString const & sXPathExpression); + css::uno::Reference getKeyElement( + ::rtl::OUString const & url); + void writeSimpleList( ::std::list< ::rtl::OUString> const & list, ::rtl::OUString const & sListTagName, @@ -89,6 +93,17 @@ protected: ::rtl::OUString const & sSecondTagName, css::uno::Reference const & xParent); + void writeSimpleElement( + ::rtl::OUString const & sElementName, ::rtl::OUString const & value, + css::uno::Reference const & xParent); + + css::uno::Reference writeKeyElement( + ::rtl::OUString const & url); + + ::rtl::OUString readSimpleElement( + ::rtl::OUString const & sElementName, + css::uno::Reference const & xParent); + ::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > > readVectorOfPair( css::uno::Reference const & parent, @@ -117,6 +132,10 @@ protected: /* returns the name of the root element without any namespace prefix. */ virtual ::rtl::OUString getRootElementName()=0; + /* returns the name of xml element for each entry + */ + virtual ::rtl::OUString getKeyElementName()=0; + public: @@ -124,8 +143,24 @@ public: ::rtl::OUString const & url); virtual ~BackendDb() {}; + void removeEntry(::rtl::OUString const & url); }; +class RegisteredDb: public BackendDb +{ + +public: + RegisteredDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + virtual ~RegisteredDb() {}; + + + virtual void addEntry(::rtl::OUString const & url); + virtual bool getEntry(::rtl::OUString const & url); + +}; + + } } #endif diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx index 99aa2178b421..2e92a907f8fb 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx @@ -46,6 +46,7 @@ using ::rtl::OUString; #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/extension-registry/2010" #define NS_PREFIX "ext" #define ROOT_ELEMENT_NAME "extension-backend-db" +#define KEY_ELEMENT_NAME "extension" namespace dp_registry { namespace backend { @@ -73,40 +74,21 @@ OUString ExtensionBackendDb::getRootElementName() return OUSTR(ROOT_ELEMENT_NAME); } +OUString ExtensionBackendDb::getKeyElementName() +{ + return OUSTR(KEY_ELEMENT_NAME); +} + void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - - const OUString sNameSpace = getDbNSName(); - const OUString sPrefix = getNSPrefix(); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - -#if OSL_DEBUG_LEVEL > 0 - //There must not be yet an entry with the same url - OUString sExpression( - sPrefix + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); - Reference _extensionNode = - getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); -#endif - // - Reference extensionNode( - doc->createElementNS(sNameSpace, - sPrefix + OUSTR(":extension"))); - - extensionNode->setAttribute(OUSTR("url"), url); - - Reference extensionNodeNode( - extensionNode, css::uno::UNO_QUERY_THROW); - root->appendChild(extensionNodeNode); - + Reference extensionNodeNode = writeKeyElement(url); writeVectorOfPair( data.items, - sPrefix + OUSTR(":extension-items"), - sPrefix + OUSTR(":item"), - sPrefix + OUSTR(":url"), - sPrefix + OUSTR(":media-type"), + OUSTR("extension-items"), + OUSTR("item"), + OUSTR("url"), + OUSTR("media-type"), extensionNodeNode); save(); } @@ -119,37 +101,22 @@ void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data } } -void ExtensionBackendDb::removeEntry(::rtl::OUString const & url) -{ - OUString sExpression( - OUSTR(NS_PREFIX) + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); - removeElement(sExpression); -} - ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & url) { try { - const OUString sPrefix = getNSPrefix(); ExtensionBackendDb::Data retData; - const OUString sExpression( - sPrefix + OUSTR(":extension[@url = \"") + url + OUSTR("\"]")); - Reference doc = getDocument(); - Reference root = doc->getFirstChild(); - - Reference xpathApi = getXPathAPI(); + Reference aNode = getKeyElement(url); - Reference aNode = - xpathApi->selectSingleNode(root, sExpression); if (aNode.is()) { retData.items = readVectorOfPair( aNode, - sPrefix + OUSTR(":extension-items"), - sPrefix + OUSTR(":item"), - sPrefix + OUSTR(":url"), - sPrefix + OUSTR(":media-type")); + OUSTR("extension-items"), + OUSTR("item"), + OUSTR("url"), + OUSTR("media-type")); } return retData; } diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx index e46c67b166de..d09fd0891a32 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx @@ -62,6 +62,7 @@ protected: virtual ::rtl::OUString getDbNSName(); virtual ::rtl::OUString getNSPrefix(); virtual ::rtl::OUString getRootElementName(); + virtual ::rtl::OUString getKeyElementName(); public: struct Data @@ -81,7 +82,7 @@ public: ::rtl::OUString const & url); void addEntry(::rtl::OUString const & url, Data const & data); - void removeEntry(::rtl::OUString const & url); + Data getEntry(::rtl::OUString const & url); }; diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index e808cd0f5e73..f0c4c9b42c6e 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -39,12 +39,12 @@ #include "comphelper/servicedecl.hxx" #include "svl/inettype.hxx" #include "com/sun/star/util/XUpdatable.hpp" -#include "com/sun/star/script/XLibraryContainer.hpp" +#include "com/sun/star/script/XLibraryContainer3.hpp" #include #include #include -#include #include +#include "dp_scriptbackenddb.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -100,15 +100,19 @@ class BackendImpl : public t_helper sal_Bool bRemoved, OUString const & identifier, Reference const & xCmdEnv ); - rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ); - rtl::OUString expandURL( const rtl::OUString& aURL ); - Reference< ucb::XSimpleFileAccess > getFileAccess( void ); - Reference< ucb::XSimpleFileAccess > m_xSFA; + void addDataToDb(OUString const & url); + void deleteDataFromDb(OUString const & url); + bool isRegisteredInDb(OUString const & url); + + + +// Reference< ucb::XSimpleFileAccess > getFileAccess( void ); +// Reference< ucb::XSimpleFileAccess > m_xSFA; const Reference m_xBasicLibTypeInfo; const Reference m_xDialogLibTypeInfo; Sequence< Reference > m_typeInfos; - + std::auto_ptr m_backendDb; public: BackendImpl( Sequence const & args, Reference const & xComponentContext ); @@ -172,6 +176,33 @@ BackendImpl::BackendImpl( m_typeInfos[ 1 ] = m_xDialogLibTypeInfo; OSL_ASSERT( ! transientMode() ); + + if (!transientMode()) + { + OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml")); + m_backendDb.reset( + new ScriptBackendDb(getComponentContext(), dbFile)); + } + +} +void BackendImpl::addDataToDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url); +} + +bool BackendImpl::isRegisteredInDb(OUString const & url) +{ + bool registered = false; + if (m_backendDb.get()) + registered = m_backendDb->getEntry(url); + return registered; +} + +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); } // XUpdatable @@ -261,90 +292,6 @@ Reference BackendImpl::bindPackage_( static_cast(-1) ); } -rtl::OUString BackendImpl::getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage ) -{ - rtl::OUString aRetURL; - if( !xPackage.is() ) - return aRetURL; - rtl::OUString aHelpURL = xPackage->getURL(); - aRetURL = expandURL( aHelpURL ); - aRetURL += rtl::OUString::createFromAscii( "/RegisteredFlag" ); - return aRetURL; -} - -rtl::OUString BackendImpl::expandURL( const rtl::OUString& aURL ) -{ - static Reference< util::XMacroExpander > xMacroExpander; - static Reference< uri::XUriReferenceFactory > xFac; - - if( !xMacroExpander.is() || !xFac.is() ) - { - Reference const & xContext = getComponentContext(); - if( xContext.is() ) - { - xFac = Reference< uri::XUriReferenceFactory >( - xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( - "com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY ); - } - if( !xFac.is() ) - { - throw RuntimeException( - ::rtl::OUString::createFromAscii( - "dp_registry::backend::help::BackendImpl::expandURL(), " - "could not instatiate UriReferenceFactory." ), - Reference< XInterface >() ); - } - - xMacroExpander = Reference< util::XMacroExpander >( - xContext->getValueByName( - ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ), - UNO_QUERY_THROW ); - } - - rtl::OUString aRetURL = aURL; - if( xMacroExpander.is() ) - { - Reference< uri::XUriReference > uriRef; - for (;;) - { - uriRef = Reference< uri::XUriReference >( xFac->parse( aRetURL ), UNO_QUERY ); - if ( uriRef.is() ) - { - Reference < uri::XVndSunStarExpandUrl > sxUri( uriRef, UNO_QUERY ); - if( !sxUri.is() ) - break; - - aRetURL = sxUri->expand( xMacroExpander ); - } - } - } - return aRetURL; -} - -Reference< ucb::XSimpleFileAccess > BackendImpl::getFileAccess( void ) -{ - if( !m_xSFA.is() ) - { - Reference const & xContext = getComponentContext(); - if( xContext.is() ) - { - m_xSFA = Reference< ucb::XSimpleFileAccess >( - xContext->getServiceManager()->createInstanceWithContext( - rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), - xContext ), UNO_QUERY ); - } - if( !m_xSFA.is() ) - { - throw RuntimeException( - ::rtl::OUString::createFromAscii( - "dp_registry::backend::help::BackendImpl::getFileAccess(), " - "could not instatiate SimpleFileAccess." ), - Reference< XInterface >() ); - } - } - return m_xSFA; -} - //############################################################################## // Package @@ -373,14 +320,11 @@ BackendImpl::PackageImpl::isRegistered_( BackendImpl * that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); - rtl::OUString aRegisteredFlagFile = that->getRegisteredFlagFileURL( xThisPackage ); - - Reference< ucb::XSimpleFileAccess > xSFA = that->getFileAccess(); - bool bReg = xSFA->exists( aRegisteredFlagFile ); + bool registered = getMyBackend()->isRegisteredInDb(getURL()); return beans::Optional< beans::Ambiguous >( true /* IsPresent */, - beans::Ambiguous( bReg, false /* IsAmbiguous */ ) ); + beans::Ambiguous( registered, false /* IsAmbiguous */ ) ); } //______________________________________________________________________________ @@ -396,15 +340,13 @@ void BackendImpl::PackageImpl::processPackage_( BackendImpl * that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); - rtl::OUString aRegisteredFlagFile = that->getRegisteredFlagFileURL( xThisPackage ); - Reference< ucb::XSimpleFileAccess > xSFA = that->getFileAccess(); Reference const & xComponentContext = that->getComponentContext(); bool bScript = (m_scriptURL.getLength() > 0); - Reference xScriptLibs; + Reference xScriptLibs; bool bDialog = (m_dialogURL.getLength() > 0); - Reference xDialogLibs; + Reference xDialogLibs; bool bRunning = office_is_running(); if( bRunning ) @@ -425,52 +367,116 @@ void BackendImpl::PackageImpl::processPackage_( xComponentContext ), UNO_QUERY_THROW ); } } - + bool bRegistered = getMyBackend()->isRegisteredInDb(getURL()); if( !doRegisterPackage ) { - if( xSFA->exists( aRegisteredFlagFile ) ) + //We cannot just call removeLibrary(name) because this could remove a + //script which was added by an extension in a different repository. For + //example, extension foo is contained in the bundled repository and then + //the user adds it it to the user repository. The extension manager will + //then register the new script and revoke the script from the bundled + //extension. removeLibrary(name) would now remove the script from the + //user repository. That is, the script of the newly added user extension does + //not work anymore. Therefore we must check if the currently active + //script comes in fact from the currently processed extension. + + if (bRegistered) { - xSFA->kill( aRegisteredFlagFile ); - - if( bScript && xScriptLibs.is() && xScriptLibs->hasByName( m_name ) ) - xScriptLibs->removeLibrary( m_name ); + if (!isRemoved()) + { + if (bScript && xScriptLibs.is() && xScriptLibs->hasByName(m_name)) + { + const OUString sScriptUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name); + if (sScriptUrl.equals(m_scriptURL)) + xScriptLibs->removeLibrary(m_name); + } - if( bDialog && xDialogLibs.is() && xDialogLibs->hasByName( m_dialogName ) ) - xDialogLibs->removeLibrary( m_dialogName ); + if (bDialog && xDialogLibs.is() && xDialogLibs->hasByName(m_dialogName)) + { + const OUString sDialogUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName); + if (sDialogUrl.equals(m_dialogURL)) + xDialogLibs->removeLibrary(m_dialogName); + } + } + getMyBackend()->deleteDataFromDb(getURL()); + return; } - return; } - - if( xSFA->exists( aRegisteredFlagFile ) ) + if (bRegistered) return; // Already registered // Update LibraryContainer bool bScriptSuccess = false; const bool bReadOnly = false; - if( bScript && xScriptLibs.is() && !xScriptLibs->hasByName( m_name ) ) + + //If there is a bundled extension, and the user installes the same extension + //then the script from the bundled extension must be removed. If this does not work + //then live deployment does not work for scripts. + if (bScript && xScriptLibs.is()) { - xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly ); - bScriptSuccess = xScriptLibs->hasByName( m_name ); + bool bCanAdd = true; + if (xScriptLibs->hasByName(m_name)) + { + const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name); + //We assume here that library names in extensions are unique, which may not be the case + //ToDo: If the script exist in another extension, then both extensions must have the + //same id + if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + { + xScriptLibs->removeLibrary(m_name); + bCanAdd = true; + } + else + { + bCanAdd = false; + } + } + + if (bCanAdd) + { + xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly ); + bScriptSuccess = xScriptLibs->hasByName( m_name ); + } } bool bDialogSuccess = false; - if( bDialog && xDialogLibs.is() && !xDialogLibs->hasByName( m_dialogName ) ) + if (bDialog && xDialogLibs.is()) { - xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly ); - bDialogSuccess = xDialogLibs->hasByName( m_dialogName ); - } + bool bCanAdd = true; + if (xDialogLibs->hasByName(m_dialogName)) + { + const OUString sOriginalUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName); + //We assume here that library names in extensions are unique, which may not be the case + //ToDo: If the script exist in another extension, then both extensions must have the + //same id + if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + { + xDialogLibs->removeLibrary(m_dialogName); + bCanAdd = true; + } + else + { + bCanAdd = false; + } + } + if (bCanAdd) + { + xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly ); + bDialogSuccess = xDialogLibs->hasByName(m_dialogName); + } + } bool bSuccess = bScript || bDialog; // Something must have happened if( bRunning ) if( (bScript && !bScriptSuccess) || (bDialog && !bDialogSuccess) ) bSuccess = false; - if( bSuccess && !xSFA->exists( aRegisteredFlagFile ) ) - { - Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aRegisteredFlagFile ); - if( xOutputStream.is() ) - xOutputStream->closeOutput(); - } + if (bSuccess) + getMyBackend()->addDataToDb(getURL()); } } // anon namespace diff --git a/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx b/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx new file mode 100644 index 000000000000..ce0d3029084d --- /dev/null +++ b/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_package.cxx,v $ + * $Revision: 1.34.16.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocument.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" +#include "dp_scriptbackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + +#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/script-registry/2010" +#define NS_PREFIX "script" +#define ROOT_ELEMENT_NAME "script-backend-db" +#define KEY_ELEMENT_NAME "script" + +namespace dp_registry { +namespace backend { +namespace script { + +ScriptBackendDb::ScriptBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):RegisteredDb(xContext, url) +{ + +} + +OUString ScriptBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString ScriptBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + +OUString ScriptBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +OUString ScriptBackendDb::getKeyElementName() +{ + return OUSTR(KEY_ELEMENT_NAME); +} + + + +} // namespace executable +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx new file mode 100644 index 000000000000..9d227f8b64b8 --- /dev/null +++ b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx @@ -0,0 +1,76 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_backend.h,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_SCRIPTBACKENDDB_HXX +#define INCLUDED_DP_SCRIPTBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "dp_backenddb.hxx" +#include "boost/optional.hpp" +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } +}}} + +namespace dp_registry { +namespace backend { +namespace script { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + */ +class ScriptBackendDb: public dp_registry::backend::RegisteredDb +{ +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getNSPrefix(); + + virtual ::rtl::OUString getRootElementName(); + + virtual ::rtl::OUString getKeyElementName(); + + +public: + + ScriptBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/script/makefile.mk b/desktop/source/deployment/registry/script/makefile.mk index ae159914a548..708def358021 100644 --- a/desktop/source/deployment/registry/script/makefile.mk +++ b/desktop/source/deployment/registry/script/makefile.mk @@ -41,7 +41,8 @@ INCPRE += ..$/..$/inc SLOFILES = \ $(SLO)$/dp_script.obj \ - $(SLO)$/dp_lib_container.obj + $(SLO)$/dp_lib_container.obj \ + $(SLO)$/dp_scriptbackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk -- cgit From 6241367966bca60d2ee49a693d23c59acfac3349 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Mon, 3 May 2010 14:22:23 +0200 Subject: jl152 import 263453 from native0jl:#i77196# Use ExtensionManager instead of PackageManager --- desktop/source/app/check_ext_deps.cxx | 2 -- 1 file changed, 2 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index c3eb81dfc3ec..7629a5c5cf83 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -47,8 +47,6 @@ #include #include #include "com/sun/star/deployment/XPackage.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" #include "com/sun/star/deployment/ExtensionManager.hpp" #include #include -- cgit From e8f78faa415a94dda55b8cd3249d3586d36dc119 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 7 May 2010 10:40:12 +0200 Subject: cws tl78: fixing windows specific build problems after merging with DEV300_m77 --- desktop/source/migration/migration.cxx | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 desktop/source/migration/migration.cxx (limited to 'desktop') diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx old mode 100644 new mode 100755 index 2181daab7454..b9be788ebd4b --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -232,6 +232,7 @@ static void insertSorted(migrations_available& rAvailableMigrations, supported_m { rAvailableMigrations.insert(pIter, aSupportedMigration ); bInserted = true; + break; } ++pIter; } -- cgit From c6f3782d96f7a93889d742520496e9d27775048e Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Mon, 10 May 2010 11:06:01 +0200 Subject: jl152: Fixed compiling errors for gcc --- desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 2 +- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 2 +- .../source/deployment/manager/dp_commandenvironments.hxx | 14 ++++++-------- .../source/deployment/manager/dp_extensionmanager.cxx | 1 + .../source/deployment/manager/dp_extensionmanager.hxx | 5 +++-- desktop/source/deployment/manager/dp_manager.cxx | 6 ++++-- desktop/source/deployment/registry/dp_backend.cxx | 10 +++++----- .../source/deployment/registry/package/dp_package.cxx | 16 ++++++++++------ desktop/source/deployment/registry/script/dp_script.cxx | 2 +- 9 files changed, 32 insertions(+), 26 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 18911ce63ea2..5fd713239e68 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -60,8 +60,8 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, m_bActive( false ), m_bLocked( bReadOnly ), m_bHasOptions( false ), - m_bShared( false ), m_bUser( false ), + m_bShared( false ), m_bNew( false ), m_bChecked( false ), m_bMissingDeps( false ), diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 65a1bf021d29..20f47139599a 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -503,7 +503,7 @@ void TheExtensionManager::notifyTermination( ::lang::EventObject const & rEvt ) //------------------------------------------------------------------------------ // XModifyListener -void TheExtensionManager::modified( ::lang::EventObject const & rEvt ) +void TheExtensionManager::modified( ::lang::EventObject const & /*rEvt*/ ) throw ( uno::RuntimeException ) { getDialogHelper()->prepareChecking(); diff --git a/desktop/source/deployment/manager/dp_commandenvironments.hxx b/desktop/source/deployment/manager/dp_commandenvironments.hxx index 0bdad4fd09cc..aa21f8281c72 100644 --- a/desktop/source/deployment/manager/dp_commandenvironments.hxx +++ b/desktop/source/deployment/manager/dp_commandenvironments.hxx @@ -84,9 +84,8 @@ public: class TmpRepositoryCommandEnv : public BaseCommandEnv { public: - TmpRepositoryCommandEnv::TmpRepositoryCommandEnv(); - TmpRepositoryCommandEnv::TmpRepositoryCommandEnv( - css::uno::Reference< css::task::XInteractionHandler> const & handler); + TmpRepositoryCommandEnv(); + TmpRepositoryCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler); // XInteractionHandler virtual void SAL_CALL handle( @@ -105,8 +104,8 @@ private: ::rtl::OUString m_repository; bool m_bSuppressLicense; public: - LicenseCommandEnv::LicenseCommandEnv(){}; - LicenseCommandEnv::LicenseCommandEnv( + LicenseCommandEnv(){}; + LicenseCommandEnv( css::uno::Reference< css::task::XInteractionHandler> const & handler, bool bSuppressLicense, ::rtl::OUString const & repository); @@ -126,9 +125,8 @@ class NoLicenseCommandEnv : public BaseCommandEnv { public: - NoLicenseCommandEnv::NoLicenseCommandEnv(){}; - NoLicenseCommandEnv::NoLicenseCommandEnv( - css::uno::Reference< css::task::XInteractionHandler> const & handler); + NoLicenseCommandEnv(){}; + NoLicenseCommandEnv(css::uno::Reference< css::task::XInteractionHandler> const & handler); // XInteractionHandler virtual void SAL_CALL handle( diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 44f34991889e..844417d5ec85 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -1225,6 +1225,7 @@ ExtensionManager::getExtensionsWithUnacceptedLicenses( } sal_Bool ExtensionManager::isReadOnlyRepository(::rtl::OUString const & repository) + throw (uno::RuntimeException) { return getPackageManager(repository)->isReadOnly(); } diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 158fd35e2fa0..e6c9ca3aa915 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -202,7 +202,8 @@ public: throw (css::deployment::DeploymentException, css::uno::RuntimeException); - virtual sal_Bool SAL_CALL isReadOnlyRepository(::rtl::OUString const & repository); + virtual sal_Bool SAL_CALL isReadOnlyRepository(::rtl::OUString const & repository) + throw (css::uno::RuntimeException); private: @@ -233,7 +234,7 @@ private: bool isUserDisabled(::rtl::OUString const & identifier, ::rtl::OUString const & filename); - bool ExtensionManager::isUserDisabled( + bool isUserDisabled( css::uno::Sequence > const & seqExtSameId); void activateExtension( diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 83105406f253..69b2baab8878 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -1471,6 +1471,8 @@ Sequence< Reference > PackageManagerImpl::getExtensionsWit Reference const & xCmdEnv) throw (deployment::DeploymentException, RuntimeException) { + ::std::vector > vec; + try { const ::osl::MutexGuard guard( getMutex() ); @@ -1479,8 +1481,6 @@ Sequence< Reference > PackageManagerImpl::getExtensionsWit ActivePackages::Entries::const_iterator i = id2temp.begin(); bool bShared = m_context.equals(OUSTR("shared")); - ::std::vector > vec; - for (; i != id2temp.end(); i++ ) { @@ -1523,6 +1523,8 @@ Sequence< Reference > PackageManagerImpl::getExtensionsWit exc <<= de; ::cppu::throwException(exc); } + + return ::comphelper::containerToSequence(vec); } sal_Int32 PackageManagerImpl::checkPrerequisites( diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index e822a66aa85f..9a83ca63d36e 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -274,12 +274,12 @@ void PackageRegistryBackend::deleteUnusedFolders( //usedFolders contains the urls to the folders which have //a trailing underscore const OUString tempFile = tempEntries[ pos ]; - const OUString tempFolder = tempFile + OUSTR("_"); + const OUString tempFolderName = tempFile + OUSTR("_"); - if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolder ) == + if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolderName ) == usedFolders.end()) { - erase_path( tempFolder, Reference(), + erase_path( tempFolderName, Reference(), false /* no throw: ignore errors */ ); erase_path( tempFile, Reference(), false /* no throw: ignore errors */ ); @@ -306,7 +306,7 @@ Package::~Package() //______________________________________________________________________________ Package::Package( ::rtl::Reference const & myBackend, OUString const & url, - OUString const & name, + OUString const & rName, OUString const & displayName, Reference const & xPackageType, bool bRemoved, @@ -314,7 +314,7 @@ Package::Package( ::rtl::Reference const & myBackend, : t_PackageBase( getMutex() ), m_myBackend( myBackend ), m_url( url ), - m_name( name ), + m_name( rName ), m_displayName( displayName ), m_xPackageType( xPackageType ), m_bRemoved(bRemoved), diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 3d4842f62bfd..a2c68dd2341f 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -228,7 +228,8 @@ class BackendImpl : public ImplBaseT virtual beans::StringPair SAL_CALL getPublisherInfo() throw (deployment::ExtensionRemovedException, RuntimeException); - virtual OUString SAL_CALL getDisplayName() throw (RuntimeException); + virtual OUString SAL_CALL getDisplayName() + throw (deployment::ExtensionRemovedException, RuntimeException); virtual Reference< graphic::XGraphic > SAL_CALL getIcon( ::sal_Bool bHighContrast ) @@ -754,9 +755,10 @@ bool BackendImpl::PackageImpl::checkDependencies( ::sal_Bool BackendImpl::PackageImpl::checkDependencies( const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv ) - throw (css::deployment::DeploymentException, - css::ucb::CommandFailedException, - css::uno::RuntimeException) + throw (deployment::DeploymentException, + deployment::ExtensionRemovedException, + ucb::CommandFailedException, + RuntimeException) { if (m_bRemoved) throw deployment::ExtensionRemovedException(); @@ -781,7 +783,8 @@ beans::Optional BackendImpl::PackageImpl::getIdentifier() true, identifier); } -OUString BackendImpl::PackageImpl::getVersion() throw (RuntimeException) +OUString BackendImpl::PackageImpl::getVersion() + throw (deployment::ExtensionRemovedException, RuntimeException) { if (m_bRemoved) throw deployment::ExtensionRemovedException(); @@ -982,7 +985,8 @@ void BackendImpl::PackageImpl::processPackage_( } //______________________________________________________________________________ -OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException) +OUString BackendImpl::PackageImpl::getDescription() + throw (deployment::ExtensionRemovedException, RuntimeException) { if (m_bRemoved) throw deployment::ExtensionRemovedException(); diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index f0c4c9b42c6e..414d4c1c61cd 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -321,7 +321,7 @@ BackendImpl::PackageImpl::isRegistered_( BackendImpl * that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); - bool registered = getMyBackend()->isRegisteredInDb(getURL()); + bool registered = that->isRegisteredInDb(getURL()); return beans::Optional< beans::Ambiguous >( true /* IsPresent */, beans::Ambiguous( registered, false /* IsAmbiguous */ ) ); -- cgit From 051f7b163fa4bf1917fb3db98fed2a6a932a827e Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Mon, 10 May 2010 12:00:49 +0200 Subject: jl152#i77196# Use ExtensionManager instead of PackageManager --- .../source/deployment/gui/dp_gui_extensioncmdqueue.cxx | 10 ++++++---- desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 17 +++++++++++++++-- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 5 +---- desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 2 -- .../source/deployment/manager/dp_extensionmanager.cxx | 2 ++ 5 files changed, 24 insertions(+), 12 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 4c9357e03e9f..8d82d969c4a0 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -1028,13 +1028,14 @@ void ExtensionCmdQueue::Thread::_enableExtension( ::rtl::Reference< ProgressCmdE if ( !xPackage.is() ) return; - uno::Reference< task::XAbortChannel > xAbortChannel( xPackage->createAbortChannel() ); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); OUString sTitle = searchAndReplaceAll( m_sEnablingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); rCmdEnv->progressSection( sTitle, xAbortChannel ); try { - xPackage->registerPackage(false, xAbortChannel, rCmdEnv.get() ); + xExtMgr->enableExtension( xPackage, xAbortChannel, rCmdEnv.get() ); if ( m_pDialogHelper ) m_pDialogHelper->updatePackageInfo( xPackage ); } @@ -1049,13 +1050,14 @@ void ExtensionCmdQueue::Thread::_disableExtension( ::rtl::Reference< ProgressCmd if ( !xPackage.is() ) return; - uno::Reference< task::XAbortChannel > xAbortChannel( xPackage->createAbortChannel() ); + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); OUString sTitle = searchAndReplaceAll( m_sDisablingPackages, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); rCmdEnv->progressSection( sTitle, xAbortChannel ); try { - xPackage->revokePackage( xAbortChannel, rCmdEnv.get() ); + xExtMgr->disableExtension( xPackage, xAbortChannel, rCmdEnv.get() ); if ( m_pDialogHelper ) m_pDialogHelper->updatePackageInfo( xPackage ); } diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 5fd713239e68..c73d8dfba136 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -1123,17 +1123,30 @@ void ExtensionBox_Impl::checkEntries() { if ( (*iIndex)->m_bChecked == false ) { + (*iIndex)->m_bChecked = true; bNeedsUpdate = true; nPos = iIndex-m_vEntries.begin(); if ( (*iIndex)->m_bNew ) - { + { // add entry to list and correct active pos if ( nNewPos == - 1) nNewPos = nPos; if ( nPos <= m_nActive ) m_nActive += 1; + iIndex++; + } + else + { // remove entry from list + if ( nPos < m_nActive ) + m_nActive -= 1; + else if ( ( nPos == m_nActive ) && ( nPos == m_vEntries.size() - 1 ) ) + m_nActive -= 1; + m_vRemovedEntries.push_back( *iIndex ); + m_vEntries.erase( iIndex ); + iIndex = m_vEntries.begin() + nPos; } } - iIndex++; + else + iIndex++; } guard.clear(); diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 20f47139599a..7c81517bbbfa 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -34,6 +34,7 @@ #include "vos/mutex.hxx" #include "toolkit/helper/vclunohelper.hxx" + #include "com/sun/star/beans/XPropertySet.hpp" #include "dp_gui_dialog2.hxx" @@ -48,10 +49,6 @@ #define SHARED_PACKAGE_MANAGER OUSTR("shared") #define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") -#define USER_PACKAGE_MANAGER OUSTR("user") -#define SHARED_PACKAGE_MANAGER OUSTR("shared") -#define BUNDLED_PACKAGE_MANAGER OUSTR("bundled") - using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx index 6605b5907dab..02e3aad56915 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -69,8 +69,6 @@ private: ::rtl::OUString m_sGetExtensionsURL; - // liste der packages ( xpackage?, mit parent manager, ... ) - void createPackageList(); public: diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 844417d5ec85..83e68dff255e 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -326,6 +326,8 @@ void ExtensionManager::activateExtension( ::std::list > > (listExtensions), bUserDisabled, bStartup, xAbortChannel, xCmdEnv); + + fireModified(); } void ExtensionManager::activateExtension( -- cgit From cbe7eeb41f84acf01241189b67d17b8a4bb4954b Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Mon, 10 May 2010 12:18:08 +0200 Subject: jl152: Fixed compiling errors for gcc --- desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index c73d8dfba136..dbb5c93cd853 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -1138,7 +1138,7 @@ void ExtensionBox_Impl::checkEntries() { // remove entry from list if ( nPos < m_nActive ) m_nActive -= 1; - else if ( ( nPos == m_nActive ) && ( nPos == m_vEntries.size() - 1 ) ) + else if ( ( nPos == m_nActive ) && ( nPos == (long) m_vEntries.size() - 1 ) ) m_nActive -= 1; m_vRemovedEntries.push_back( *iIndex ); m_vEntries.erase( iIndex ); -- cgit From dc9d30e6e99da3e63f9255a0c5dd046015437665 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 7 May 2010 17:02:22 +0200 Subject: jl152 #i77196# adapting configuration backend to changes introduced by SB on DEV300 branch concering different handling of configuration files in extensions, also fixed writing of compiled help files into the user installation --- desktop/source/deployment/inc/dp_misc.h | 3 + desktop/source/deployment/misc/dp_misc.cxx | 16 ++ .../deployment/registry/component/dp_component.cxx | 56 +++-- .../registry/configuration/dp_configuration.cxx | 240 +++++++++++++-------- .../configuration/dp_configurationbackenddb.cxx | 186 ++++++++++++++++ .../configuration/dp_configurationbackenddb.hxx | 96 +++++++++ .../deployment/registry/configuration/makefile.mk | 3 +- desktop/source/deployment/registry/dp_backend.cxx | 24 ++- .../source/deployment/registry/dp_backenddb.cxx | 45 ++++ .../source/deployment/registry/help/dp_help.cxx | 16 +- .../deployment/registry/help/dp_helpbackenddb.cxx | 6 +- .../deployment/registry/help/dp_helpbackenddb.hxx | 9 - .../source/deployment/registry/inc/dp_backend.h | 5 + .../deployment/registry/inc/dp_backenddb.hxx | 5 +- 14 files changed, 564 insertions(+), 146 deletions(-) create mode 100644 desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx create mode 100644 desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx (limited to 'desktop') diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h index 3283d20718be..a0ca7f53be03 100644 --- a/desktop/source/deployment/inc/dp_misc.h +++ b/desktop/source/deployment/inc/dp_misc.h @@ -70,6 +70,9 @@ inline void try_dispose( ::com::sun::star::uno::Reference< ::com::sun::star::uno DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString expandUnoRcTerm( ::rtl::OUString const & term ); +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +::rtl::OUString makeRcTerm( ::rtl::OUString const & url ); + //============================================================================== DESKTOP_DEPLOYMENTMISC_DLLPUBLIC ::rtl::OUString expandUnoRcUrl( ::rtl::OUString const & url ); diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 919f134b3fb9..799542a4757f 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -317,6 +317,22 @@ OUString expandUnoRcTerm( OUString const & term_ ) return term; } +OUString makeRcTerm( OUString const & url ) +{ + OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( + "vnd.sun.star.expand:") ) ); + if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) { + // cut protocol: + OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) ); + // decode uric class chars: + rcterm = ::rtl::Uri::decode( + rcterm, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); + return rcterm; + } + else + return url; +} + //============================================================================== OUString expandUnoRcUrl( OUString const & url ) { diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index edb53d134c8b..fc9880438bac 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -75,7 +75,6 @@ typedef ::std::list t_stringlist; typedef ::std::vector< ::std::pair > t_stringpairvec; #define IMPLEMENTATION_NAME "com.sun.star.comp.deployment.component.PackageRegistryBackend" -inline OUString makeRcTerm( OUString const & url ); /** return a vector of bootstrap variables which have been provided as command arguments. @@ -779,11 +778,16 @@ void BackendImpl::unorc_verify_init( OUString token( line.getToken( 0, ' ', index ).trim() ); 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 ); + if (create_ucb_content( + 0, expandUnoRcTerm(token), xCmdEnv, + false /* no throw */ )) + { + //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); @@ -797,11 +801,16 @@ void BackendImpl::unorc_verify_init( { if (token[ 0 ] == '?') token = token.copy( 1 ); - //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 ); + if (create_ucb_content( + 0, expandUnoRcTerm(token), xCmdEnv, + false /* no throw */ )) + { + //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); @@ -842,7 +851,7 @@ void BackendImpl::unorc_flush( Reference const & xCmdEnv ) ::rtl::OStringBuffer buf; buf.append(RTL_CONSTASCII_STRINGPARAM("ORIGIN=")); - OUString sOrigin = makeRcTerm(m_cachePath); + OUString sOrigin = dp_misc::makeRcTerm(m_cachePath); ::rtl::OString osOrigin = ::rtl::OUStringToOString(sOrigin, RTL_TEXTENCODING_UTF8); buf.append(osOrigin); buf.append(LF); @@ -933,28 +942,11 @@ void BackendImpl::unorc_flush( Reference const & xCmdEnv ) m_unorc_modified = false; } -//------------------------------------------------------------------------------ -inline OUString makeRcTerm( OUString const & url ) -{ - OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( - "vnd.sun.star.expand:") ) ); - if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) { - // cut protocol: - OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) ); - // decode uric class chars: - rcterm = ::rtl::Uri::decode( - rcterm, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - return rcterm; - } - else - return url; -} - //______________________________________________________________________________ bool BackendImpl::addToUnoRc( bool jarFile, OUString const & url_, Reference const & xCmdEnv ) { - const OUString rcterm( makeRcTerm(url_) ); + const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); unorc_verify_init( xCmdEnv ); t_stringlist & rSet = getTypelibs(jarFile); @@ -974,7 +966,7 @@ bool BackendImpl::removeFromUnoRc( bool jarFile, OUString const & url_, Reference const & xCmdEnv ) { - const OUString rcterm( makeRcTerm(url_) ); + const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); unorc_verify_init( xCmdEnv ); getTypelibs(jarFile).remove( rcterm ); @@ -988,7 +980,7 @@ bool BackendImpl::removeFromUnoRc( bool BackendImpl::hasInUnoRc( bool jarFile, OUString const & url_ ) { - const OUString rcterm( makeRcTerm(url_) ); + const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); t_stringlist const & rSet = getTypelibs(jarFile); return ::std::find( rSet.begin(), rSet.end(), rcterm ) != rSet.end(); diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index a97736235656..1a6738b0270b 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -55,6 +55,7 @@ #include #include +#include "dp_configurationbackenddb.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -111,6 +112,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend bool m_configmgrini_inited; bool m_configmgrini_modified; + std::auto_ptr m_backendDb; // PackageRegistryBackend virtual Reference bindPackage_( @@ -135,7 +137,11 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference const & xCmdEnv ); bool removeFromConfigmgrIni( bool isSchema, OUString const & url, Reference const & xCmdEnv ); - bool hasInConfigmgrIni( bool isSchema, OUString const & url ); + + void addDataToDb(OUString const & url, ConfigurationBackendDb::Data const & data); + ::boost::optional readDataFromDb(OUString const & url); + void deleteDataFromDb(OUString const & url); + ::std::list getAllIniEntries(); public: BackendImpl( Sequence const & args, @@ -193,18 +199,64 @@ BackendImpl::BackendImpl( const Reference xCmdEnv; - if (transientMode()) { + if (transientMode()) + { //TODO } - else { + else + { + OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml")); + m_backendDb.reset( + new ConfigurationBackendDb(getComponentContext(), dbFile)); + //clean up data folders which are no longer used. + //This must not be done in the same process where the help files + //are still registers. Only after revoking and restarting OOo the folders + //can be removed. This works now, because the extension manager is a singleton + //and the backends are only create once per process. + ::std::list folders = m_backendDb->getAllDataUrls(); + deleteUnusedFolders(OUString(), folders); + + configmgrini_verify_init( xCmdEnv ); m_registeredPackages.reset( new PersistentMap( makeURL( getCachePath(), OUSTR("registered_packages.db") ), false ) ); - } + } +} + +void BackendImpl::addDataToDb( + OUString const & url, ConfigurationBackendDb::Data const & data) +{ + if (m_backendDb.get()) + m_backendDb->addEntry(url, data); +} + +::boost::optional BackendImpl::readDataFromDb( + OUString const & url) +{ + ::boost::optional data; + if (m_backendDb.get()) + data = m_backendDb->getEntry(url); + return data; } +void BackendImpl::deleteDataFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + +::std::list BackendImpl::getAllIniEntries() +{ + if (m_backendDb.get()) + return m_backendDb->getAllIniEntries(); + else + return ::std::list(); +} + + + // XPackageRegistry //______________________________________________________________________________ Sequence< Reference > @@ -312,11 +364,12 @@ void BackendImpl::configmgrini_verify_init( if (create_ucb_content( 0, expandUnoRcTerm(token), xCmdEnv, false /* no throw */ )) { + //The file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the configmgrini. + //After running XExtensionManager::synchronize, the configmgrini is + //cleaned up m_xcs_files.push_back( token ); } - else - OSL_ENSURE( - 0, "### invalid SCHEMA entry!" ); } } while (index >= 0); @@ -333,10 +386,24 @@ void BackendImpl::configmgrini_verify_init( if (create_ucb_content( 0, expandUnoRcTerm(token), xCmdEnv, false /* no throw */ )) { + //The file may not exist anymore if a shared or bundled + //extension was removed, but it can still be in the configmgrini. + //After running XExtensionManager::synchronize, the configmgrini is + //cleaned up m_xcu_files.push_back( token ); } else - OSL_ENSURE( 0, "### invalid DATA entry!" ); + { + //Check if it was removed. Only when the file contained %origin, so that + //a new file was writen in the user installation (e.g. $BUNDLED_EXTENSIONS_USER) + //See also ConfigurationBackendDb.iniEntry + ::std::list iniEntries = getAllIniEntries(); + if (::std::find(iniEntries.begin(), iniEntries.end(), token) + != iniEntries.end()) + m_xcu_files.push_back( token ); + else + OSL_ENSURE(0, "Extension manager: Invalid configmgr.ini entry."); + } } } while (index >= 0); @@ -357,20 +424,6 @@ void BackendImpl::configmgrini_flush( return; ::rtl::OStringBuffer buf; - // UNO_USER_PACKAGES_CACHE, UNO_SHARED_PACKAGES_CACHE have to be resolved - // locally: - if (m_eContext == CONTEXT_USER) { - buf.append( RTL_CONSTASCII_STRINGPARAM( - "UNO_USER_PACKAGES_CACHE=$ORIGIN/../..") ); - } - else if (m_eContext == CONTEXT_SHARED) { - buf.append( RTL_CONSTASCII_STRINGPARAM( - "UNO_SHARED_PACKAGES_CACHE=$ORIGIN/../..") ); - } - else - OSL_ASSERT(0); - buf.append(LF); - if (! m_xcs_files.empty()) { t_stringlist::const_iterator iPos( m_xcs_files.begin() ); @@ -417,28 +470,11 @@ void BackendImpl::configmgrini_flush( m_configmgrini_modified = false; } -//------------------------------------------------------------------------------ -inline OUString makeRcTerm( OUString const & url ) -{ - OSL_ASSERT( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( - "vnd.sun.star.expand:") ) ); - if (url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.expand:") )) { - // cut protocol: - OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) ); - // decode uric class chars: - rcterm = ::rtl::Uri::decode( - rcterm, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - return rcterm; - } - else - return url; -} - //______________________________________________________________________________ bool BackendImpl::addToConfigmgrIni( bool isSchema, OUString const & url_, Reference const & xCmdEnv ) { - const OUString rcterm( makeRcTerm(url_) ); + const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); configmgrini_verify_init( xCmdEnv ); t_stringlist & rSet = getFiles(isSchema); @@ -458,15 +494,18 @@ bool BackendImpl::removeFromConfigmgrIni( bool isSchema, OUString const & url_, Reference const & xCmdEnv ) { - const OUString rcterm( makeRcTerm(url_) ); + const OUString rcterm( dp_misc::makeRcTerm(url_) ); const ::osl::MutexGuard guard( getMutex() ); configmgrini_verify_init( xCmdEnv ); t_stringlist & rSet = getFiles(isSchema); t_stringlist::iterator i(std::find(rSet.begin(), rSet.end(), rcterm)); - if (i == rSet.end() && !isSchema) { //TODO: see replaceOrigin() - i = std::find( - rSet.begin(), rSet.end(), - rcterm + OUString(RTL_CONSTASCII_USTRINGPARAM(".mod"))); + if (i == rSet.end() && !isSchema) + { + //in case the xcu contained %origin% then the configmr.ini contains the + //url to the file in the user installation (e.g. $BUNDLED_EXTENSIONS_USER) + ::boost::optional data = readDataFromDb(url_); + if (data) + i = std::find(rSet.begin(), rSet.end(), data->iniEntry); } if (i == rSet.end()) { return false; @@ -478,21 +517,6 @@ bool BackendImpl::removeFromConfigmgrIni( return true; } -//______________________________________________________________________________ -bool BackendImpl::hasInConfigmgrIni( - bool isSchema, OUString const & url_ ) -{ - const OUString rcterm( makeRcTerm(url_) ); - const ::osl::MutexGuard guard( getMutex() ); - t_stringlist const & rSet = getFiles(isSchema); - return ::std::find( rSet.begin(), rSet.end(), rcterm ) != rSet.end() - || (!isSchema && //TODO: see replaceOrigin() - ::std::find( - rSet.begin(), rSet.end(), - rcterm + OUString(RTL_CONSTASCII_USTRINGPARAM(".mod"))) != - rSet.end()); -} - //############################################################################## // Package @@ -519,14 +543,18 @@ BackendImpl::PackageImpl::isRegistered_( Reference const & ) { BackendImpl * that = getMyBackend(); - rtl::OUString url(getURL()); + const rtl::OUString url(getURL()); + + bool bReg = false; + if (that->readDataFromDb(getURL())) + bReg = true; + if (!bReg) + //fallback for user extension registered in berkeley DB + bReg = that->m_registeredPackages->has( + rtl::OUStringToOString( url, RTL_TEXTENCODING_UTF8 )); + return beans::Optional< beans::Ambiguous >( - true /* IsPresent */, - beans::Ambiguous( - that->hasInConfigmgrIni( m_isSchema, url ) || - that->m_registeredPackages->has( - rtl::OUStringToOString( url, RTL_TEXTENCODING_UTF8 ) ), - false /* IsAmbiguous */ ) ); + true, beans::Ambiguous( bReg, false ) ); } //------------------------------------------------------------------------------ @@ -564,7 +592,7 @@ OUString encodeForXml( OUString const & text ) //______________________________________________________________________________ OUString replaceOrigin( - OUString const & url, Reference< XCommandEnvironment > const & xCmdEnv ) + OUString const & url, OUString const & destFolder, Reference< XCommandEnvironment > const & xCmdEnv, bool & out_replaced) { // looking for %origin%: ::ucbhelper::Content ucb_content( url, xCmdEnv ); @@ -634,10 +662,17 @@ OUString replaceOrigin( return url; if (write_pos < filtered.getLength()) filtered.realloc( write_pos ); - rtl::OUString newUrl(url + OUString(RTL_CONSTASCII_USTRINGPARAM(".mod"))); - //TODO: unique name + rtl::OUString newUrl(url); + if (destFolder.getLength()) + { + //get the file name of the xcu and add it to the url of the temporary folder + sal_Int32 i = url.lastIndexOf('/'); + newUrl = destFolder + url.copy(i); + } + ucbhelper::Content(newUrl, xCmdEnv).writeStream( xmlscript::createInputStream(filtered), true); + out_replaced = true; return newUrl; } @@ -654,21 +689,37 @@ void BackendImpl::PackageImpl::processPackage_( if (doRegisterPackage) { - if (m_isSchema) + ConfigurationBackendDb::Data data; + if (!m_isSchema) { - com::sun::star::configuration::Update::get( - that->m_xComponentContext)->insertExtensionXcsFile( - that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + const OUString sModFolder = that->createFolder(OUString(), xCmdEnv); + bool out_replaced = false; + url = replaceOrigin(url, sModFolder, xCmdEnv, out_replaced); + if (out_replaced) + data.dataUrl = sModFolder; + else + deleteTempFolder(sModFolder); } - else + //No need for live-deployment for bundled extension, because OOo + //restarts after installation + if (that->m_eContext != CONTEXT_BUNDLED) { - url = replaceOrigin(url, xCmdEnv); - com::sun::star::configuration::Update::get( - that->m_xComponentContext)->insertExtensionXcuFile( - that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + if (m_isSchema) + { + com::sun::star::configuration::Update::get( + that->m_xComponentContext)->insertExtensionXcsFile( + that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + } + else + { + com::sun::star::configuration::Update::get( + that->m_xComponentContext)->insertExtensionXcuFile( + that->m_eContext == CONTEXT_SHARED, expandUnoRcUrl(url)); + } } - that->addToConfigmgrIni( m_isSchema, url, xCmdEnv ); + data.iniEntry = dp_misc::makeRcTerm(url); + that->addDataToDb(getURL(), data); } else // revoke { @@ -678,15 +729,31 @@ void BackendImpl::PackageImpl::processPackage_( for (t_string2string_map::iterator i(entries.begin()); i != entries.end(); ++i) { + //If the xcu file was installed before the configmgr was chaned + //to use the configmgr.ini, one needed to rebuild to whole directory + //structur containing the xcu, xcs files from all extensions. Now, + //we just add all other xcu/xcs files to the configmgr.ini instead of + //rebuilding the directory structure. rtl::OUString url2( rtl::OStringToOUString(i->first, RTL_TEXTENCODING_UTF8)); + ConfigurationBackendDb::Data data; if (url2 != url) { - bool schema = i->second.equalsIgnoreAsciiCase( - "vnd.sun.star.configuration-schema"); - if (!schema) { - url2 = replaceOrigin(url2, xCmdEnv); - } - that->addToConfigmgrIni(schema, url2, xCmdEnv); + bool schema = i->second.equalsIgnoreAsciiCase( + "vnd.sun.star.configuration-schema"); + OUString url_replaced(url2); + if (!schema) + { + const OUString sModFolder = that->createFolder(OUString(), xCmdEnv); + bool out_replaced = false; + url_replaced = replaceOrigin( + url2, sModFolder, xCmdEnv, out_replaced); + if (out_replaced) + data.dataUrl = sModFolder; + else + deleteTempFolder(sModFolder); + } + that->addToConfigmgrIni(schema, url_replaced, xCmdEnv); + that->addDataToDb(url2, data); } that->m_registeredPackages->erase(i->first); } @@ -695,6 +762,7 @@ void BackendImpl::PackageImpl::processPackage_( xCmdEnv ).executeCommand( OUSTR("delete"), Any( true /* delete physically */ ) ); } + that->deleteDataFromDb(getURL()); //TODO: revoking at runtime, possible, sensible? } diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx new file mode 100644 index 000000000000..845ba88cb813 --- /dev/null +++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx @@ -0,0 +1,186 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_package.cxx,v $ + * $Revision: 1.34.16.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + +#include "rtl/string.h" +#include "rtl/bootstrap.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/xpath/XXPathAPI.hpp" +#include "dp_misc.h" + +#include "dp_configurationbackenddb.hxx" + + +namespace css = ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + +#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/configuration-registry/2010" +#define NS_PREFIX "conf" +#define ROOT_ELEMENT_NAME "configuration-backend-db" +#define KEY_ELEMENT_NAME "configuration" + +namespace dp_registry { +namespace backend { +namespace configuration { + +ConfigurationBackendDb::ConfigurationBackendDb( + Reference const & xContext, + ::rtl::OUString const & url):BackendDb(xContext, url) +{ + +} + +OUString ConfigurationBackendDb::getDbNSName() +{ + return OUSTR(EXTENSION_REG_NS); +} + +OUString ConfigurationBackendDb::getNSPrefix() +{ + return OUSTR(NS_PREFIX); +} + +OUString ConfigurationBackendDb::getRootElementName() +{ + return OUSTR(ROOT_ELEMENT_NAME); +} + +OUString ConfigurationBackendDb::getKeyElementName() +{ + return OUSTR(KEY_ELEMENT_NAME); +} + + +void ConfigurationBackendDb::addEntry(::rtl::OUString const & url, Data const & data) +{ + try{ + Reference helpNode + = writeKeyElement(url); + + writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); + writeSimpleElement(OUSTR("ini-entry"), data.iniEntry, helpNode); + save(); + } + catch (css::deployment::DeploymentException& ) + { + throw; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to write data entry in configuration backend db: ") + + m_urlDb, 0, exc); + } +} + + +::boost::optional +ConfigurationBackendDb::getEntry(::rtl::OUString const & url) +{ + try + { + ConfigurationBackendDb::Data retData; + Reference aNode = getKeyElement(url); + if (aNode.is()) + { + retData.dataUrl = readSimpleElement(OUSTR("data-url"), aNode); + retData.iniEntry = readSimpleElement(OUSTR("ini-entry"), aNode); + } + else + { + return ::boost::optional(); + } + return ::boost::optional(retData); + } + catch (css::deployment::DeploymentException& ) + { + throw; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in configuration backend db: ") + + m_urlDb, 0, exc); + } +} + +::std::list ConfigurationBackendDb::getAllDataUrls() +{ + try + { + ::std::list listRet; + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + const OUString sPrefix = getNSPrefix(); + OUString sExpression( + sPrefix + OUSTR(":configuration/") + sPrefix + OUSTR(":data-url/text()")); + Reference nodes = + xpathApi->selectNodeList(root, sExpression); + if (nodes.is()) + { + sal_Int32 length = nodes->getLength(); + for (sal_Int32 i = 0; i < length; i++) + listRet.push_back(nodes->item(i)->getNodeValue()); + } + return listRet; + } + catch (css::deployment::DeploymentException& ) + { + throw; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to read data entry in configuration backend db: ") + + m_urlDb, 0, exc); + } +} + +::std::list ConfigurationBackendDb::getAllIniEntries() +{ + return getOneChildFromAllEntries(OUSTR("ini-entry")); +} + + + +} // namespace configuration +} // namespace backend +} // namespace dp_registry + diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx new file mode 100644 index 000000000000..1b6c4f8973a4 --- /dev/null +++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dp_backend.h,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_CONFIGURATIONBACKENDDB_HXX +#define INCLUDED_DP_CONFIGURATIONBACKENDDB_HXX + +#include "rtl/ustring.hxx" +#include "rtl/string.hxx" +#include +#include "boost/optional.hpp" +#include "dp_backenddb.hxx" + +namespace css = ::com::sun::star; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } +}}} + +namespace dp_registry { +namespace backend { +namespace configuration { + +/* The XML file stores the extensions which are currently registered. + They will be removed when they are revoked. + */ +class ConfigurationBackendDb: public dp_registry::backend::BackendDb +{ +protected: + virtual ::rtl::OUString getDbNSName(); + + virtual ::rtl::OUString getNSPrefix(); + + virtual ::rtl::OUString getRootElementName(); + + virtual ::rtl::OUString getKeyElementName(); + +public: + struct Data + { + /* the URL to the folder containing the xcu or xcs files which contained + %origin% + */ + ::rtl::OUString dataUrl; + /* the URL of the xcu or xcs file which is written in to the configmgr.ini + */ + ::rtl::OUString iniEntry; + }; + +public: + + ConfigurationBackendDb( css::uno::Reference const & xContext, + ::rtl::OUString const & url); + + void addEntry(::rtl::OUString const & url, Data const & data); + + ::boost::optional getEntry(::rtl::OUString const & url); + ::std::list< ::rtl::OUString> getAllDataUrls(); + ::std::list< ::rtl::OUString> getAllIniEntries(); +}; + + + +} +} +} +#endif + diff --git a/desktop/source/deployment/registry/configuration/makefile.mk b/desktop/source/deployment/registry/configuration/makefile.mk index f549b0e7b0f8..9bcbd50d4230 100644 --- a/desktop/source/deployment/registry/configuration/makefile.mk +++ b/desktop/source/deployment/registry/configuration/makefile.mk @@ -44,7 +44,8 @@ SRC1FILES = \ dp_configuration.src SLOFILES = \ - $(SLO)$/dp_configuration.obj + $(SLO)$/dp_configuration.obj \ + $(SLO)$/dp_configurationbackenddb.obj .INCLUDE : ..$/..$/target.pmk .INCLUDE : target.mk diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index 9a83ca63d36e..ea31f75c6b6b 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -239,6 +239,22 @@ OUString PackageRegistryBackend::createFolder( return destFolder; } +void PackageRegistryBackend::deleteTempFolder( + OUString const & folderUrl) +{ + OSL_ASSERT(folderUrl.getLength() + && folderUrl[folderUrl.getLength() - 1] == '_'); + if (folderUrl.getLength() + && folderUrl[folderUrl.getLength() - 1] == '_') + { + const OUString tempFile = folderUrl.copy(0, folderUrl.getLength() - 1); + erase_path( folderUrl, Reference(), + false /* no throw: ignore errors */ ); + erase_path( tempFile, Reference(), + false /* no throw: ignore errors */ ); + } +} + void PackageRegistryBackend::deleteUnusedFolders( OUString const & relUrl, ::std::list< OUString> const & usedFolders) @@ -273,16 +289,12 @@ void PackageRegistryBackend::deleteUnusedFolders( { //usedFolders contains the urls to the folders which have //a trailing underscore - const OUString tempFile = tempEntries[ pos ]; - const OUString tempFolderName = tempFile + OUSTR("_"); + const OUString tempFolderName = tempEntries[ pos ] + OUSTR("_"); if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolderName ) == usedFolders.end()) { - erase_path( tempFolderName, Reference(), - false /* no throw: ignore errors */ ); - erase_path( tempFile, Reference(), - false /* no throw: ignore errors */ ); + deleteTempFolder(tempFolder); } } } diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 660c5ad80bf1..1f4a62e696d7 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -509,6 +509,51 @@ OUString BackendDb::readSimpleElement( } } +::std::list BackendDb::getOneChildFromAllEntries( + OUString const & name) +{ + try + { + ::std::list listRet; + Reference doc = getDocument(); + Reference root = doc->getFirstChild(); + + Reference xpathApi = getXPathAPI(); + const OUString sPrefix = getNSPrefix(); + const OUString sKeyElement = getKeyElementName(); + ::rtl::OUStringBuffer buf(512); + buf.append(sPrefix); + buf.appendAscii(":"); + buf.append(sKeyElement); + buf.appendAscii("/"); + buf.append(sPrefix); + buf.appendAscii(":"); + buf.append(name); + buf.append(OUSTR("/text()")); + + Reference nodes = + xpathApi->selectNodeList(root, buf.makeStringAndClear()); + if (nodes.is()) + { + sal_Int32 length = nodes->getLength(); + for (sal_Int32 i = 0; i < length; i++) + listRet.push_back(nodes->item(i)->getNodeValue()); + } + return listRet; + } + catch (css::deployment::DeploymentException& ) + { + throw; + } + 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); + } +} + //================================================================================ diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 7e8f128bbf12..bc17a1f7163d 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -66,7 +66,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend { BackendImpl * getMyBackend() const; - HelpBackendDb::Data m_dbData; +// HelpBackendDb::Data m_dbData; // Package virtual beans::Optional< beans::Ambiguous > isRegistered_( @@ -234,13 +234,13 @@ BackendImpl::PackageImpl::PackageImpl( : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) { - if (bRemoved) - { - ::boost::optional opt = - getMyBackend()->readDataFromDb(url); - if (opt) - m_dbData = *opt; - } +// if (bRemoved) +// { +// ::boost::optional opt = +// getMyBackend()->readDataFromDb(url); +// if (opt) +// m_dbData = *opt; +// } } // Package diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx index 4a8fa71e0618..3bf67e0c050b 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -100,7 +100,7 @@ void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { Any exc( ::cppu::getCaughtException() ); throw css::deployment::DeploymentException( - OUSTR("Extension Manager: failed to write data entry in backend db: ") + + OUSTR("Extension Manager: failed to write data entry in help backend db: ") + m_urlDb, 0, exc); } } @@ -131,7 +131,7 @@ HelpBackendDb::getEntry(::rtl::OUString const & url) { Any exc( ::cppu::getCaughtException() ); throw css::deployment::DeploymentException( - OUSTR("Extension Manager: failed to read data entry in backend db: ") + + OUSTR("Extension Manager: failed to read data entry in help backend db: ") + m_urlDb, 0, exc); } } @@ -166,7 +166,7 @@ HelpBackendDb::getEntry(::rtl::OUString const & url) { Any exc( ::cppu::getCaughtException() ); throw css::deployment::DeploymentException( - OUSTR("Extension Manager: failed to read data entry in backend db: ") + + OUSTR("Extension Manager: failed to read data entry in help backend db: ") + m_urlDb, 0, exc); } } diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx index baecf0da48e6..edf7dfdfc284 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx @@ -32,8 +32,6 @@ #define INCLUDED_DP_HELPBACKENDDB_HXX #include "rtl/ustring.hxx" -#include "rtl/string.hxx" -#include #include #include "boost/optional.hpp" #include "dp_backenddb.hxx" @@ -44,13 +42,6 @@ namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } - namespace xml { namespace dom { - class XDocument; - class XNode; - }} - namespace xml { namespace xpath { - class XXPathAPI; - }} }}} namespace dp_registry { diff --git a/desktop/source/deployment/registry/inc/dp_backend.h b/desktop/source/deployment/registry/inc/dp_backend.h index 7b11ae456d5d..3d3bf7cf912c 100644 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -336,6 +336,11 @@ protected: void deleteUnusedFolders( ::rtl::OUString const & relUrl, ::std::list< ::rtl::OUString> const & usedFolders); + /* deletes one folder with a "temporary" name and the corresponding + tmp file, which was used to derive the folder name. + */ + static void deleteTempFolder( + ::rtl::OUString const & folderUrl); public: diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index b8ba5facd492..cf0bb5129292 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -117,7 +117,10 @@ protected: ::rtl::OUString const & sListTagName, ::rtl::OUString const & sMemberTagName); - + /* returns the values of one particulary child element of all key elements. + */ + ::std::list< ::rtl::OUString> BackendDb::getOneChildFromAllEntries( + ::rtl::OUString const & sElementName); /* returns the namespace which is to be written as xmlns attribute -- cgit From b8dc3e6f63c57c92f877d392ef013127f41c5d44 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 10 May 2010 15:19:49 +0200 Subject: jl152 fixing merge conflict --- desktop/source/deployment/registry/dp_backend.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index ea31f75c6b6b..d781ba9e40ef 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -294,7 +294,7 @@ void PackageRegistryBackend::deleteUnusedFolders( if (::std::find( usedFolders.begin(), usedFolders.end(), tempFolderName ) == usedFolders.end()) { - deleteTempFolder(tempFolder); + deleteTempFolder(tempFolderName); } } } -- cgit From be45f3f14b9f103e12ddc343f483086eff10011e Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 10 May 2010 15:53:56 +0200 Subject: jl152: #i77196# typo --- desktop/source/deployment/registry/inc/dp_backenddb.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index cf0bb5129292..a0e477979f8c 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -119,7 +119,7 @@ protected: /* returns the values of one particulary child element of all key elements. */ - ::std::list< ::rtl::OUString> BackendDb::getOneChildFromAllEntries( + ::std::list< ::rtl::OUString> getOneChildFromAllEntries( ::rtl::OUString const & sElementName); -- cgit From c288dd322747e11a5c779f155ba39e799a9920c2 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 10 May 2010 17:35:24 +0200 Subject: jl152: #i108704# allow to restart the office --- desktop/scripts/soffice.sh | 9 +++++++-- desktop/source/app/app.cxx | 21 ++++++++++++++++++++- desktop/source/inc/exithelper.hxx | 2 ++ desktop/unx/source/officeloader/officeloader.cxx | 2 +- desktop/win32/source/officeloader/officeloader.cxx | 3 ++- 5 files changed, 32 insertions(+), 5 deletions(-) (limited to 'desktop') diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh index ebbdeb9eabdb..fae9dbe4d695 100644 --- a/desktop/scripts/soffice.sh +++ b/desktop/scripts/soffice.sh @@ -120,9 +120,14 @@ trap 'kill -9 $!' TERM wait $! sd_ret=$? -while [ $sd_ret -eq 79 ] +while [ $sd_ret -eq 79 -o $sd_ret -eq 81 ] do - "$sd_prog/$sd_binary" ""$BOOTSTRAPVARS"" & + if [ $sd_ret -eq 79 ]; then + "$sd_prog/$sd_binary" ""$BOOTSTRAPVARS"" & + elif if [ $sd_ret -eq 81 ]; then + "$sd_prog/$sd_binary" "$@" & + fi + wait $! sd_ret=$? done diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 8e610fb0e141..3b0a1ea0dcf8 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -84,6 +84,7 @@ #include #include #include +#include #ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_ #include #endif @@ -103,6 +104,7 @@ #include #include #include +#include #include #ifndef _UTL__HXX_ #include @@ -140,6 +142,7 @@ #include #include #include +#include #include "vos/process.hxx" @@ -1615,6 +1618,7 @@ void Desktop::Main() // call Application::Execute to process messages in vcl message loop RTL_LOGFILE_PRODUCT_TRACE( "PERFORMANCE - enter Application::Execute()" ); + Reference< ::com::sun::star::task::XRestartManager > xRestartManager; try { // The JavaContext contains an interaction handler which is used when @@ -1622,7 +1626,11 @@ void Desktop::Main() com::sun::star::uno::ContextLayer layer2( new svt::JavaContext( com::sun::star::uno::getCurrentContext() ) ); - Execute(); + ::comphelper::ComponentContext aContext( xSMgr ); + xRestartManager.set( aContext.getSingleton( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.OfficeRestartManager" ) ) ), UNO_QUERY ); + + if ( !xRestartManager.is() || !xRestartManager->isRestartRequested( sal_True ) ) + Execute(); } catch(const com::sun::star::document::CorruptedFilterConfigurationException& exFilterCfg) { @@ -1635,6 +1643,9 @@ void Desktop::Main() FatalError( MakeStartupErrorMessage(exAnyCfg.Message) ); } + // check whether the shutdown is caused by restart + sal_Bool bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); + if (xGlobalBroadcaster.is()) { css::document::EventObject aEvent; @@ -1671,6 +1682,14 @@ void Desktop::Main() RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- deinit ucb" ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "FINISHED WITH Destop::Main" ); + if ( bRestartRequested ) + { +#ifdef MACOSX + DoRestart(); +#endif + // wouldn't the solution be more clean if SalMain returns the exit code to the system? + _exit( ExitHelper::E_NORMAL_RESTART ); + } } IMPL_LINK( Desktop, ImplInitFilterHdl, ConvertData*, pData ) diff --git a/desktop/source/inc/exithelper.hxx b/desktop/source/inc/exithelper.hxx index 2e6d7e774d98..e2604ce49b68 100644 --- a/desktop/source/inc/exithelper.hxx +++ b/desktop/source/inc/exithelper.hxx @@ -58,6 +58,8 @@ class ExitHelper E_FATAL_ERROR = 333, // Only the low 8 bits are significant 333 % 256 = 77 /// user force automatic restart after crash E_CRASH_WITH_RESTART = 79, + /// the office restarts itself + E_NORMAL_RESTART = 81 }; }; diff --git a/desktop/unx/source/officeloader/officeloader.cxx b/desktop/unx/source/officeloader/officeloader.cxx index de84985cdea6..87621960c61a 100755 --- a/desktop/unx/source/officeloader/officeloader.cxx +++ b/desktop/unx/source/officeloader/officeloader.cxx @@ -93,7 +93,7 @@ SAL_IMPLEMENT_MAIN() if ( info.Fields & osl_Process_EXITCODE ) { exitcode = info.Code; - bRestart = (ExitHelper::E_CRASH_WITH_RESTART == exitcode); + bRestart = (ExitHelper::E_CRASH_WITH_RESTART == exitcode || ExitHelper::E_NORMAL_RESTART == exitcode); } else break; diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx index f36bfc134ded..2d602a6d6507 100644 --- a/desktop/win32/source/officeloader/officeloader.cxx +++ b/desktop/win32/source/officeloader/officeloader.cxx @@ -416,7 +416,8 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) CloseHandle( aProcessInfo.hProcess ); CloseHandle( aProcessInfo.hThread ); } - } while ( fSuccess && ::desktop::ExitHelper::E_CRASH_WITH_RESTART == dwExitCode ); + } while ( fSuccess + && ( ::desktop::ExitHelper::E_CRASH_WITH_RESTART == dwExitCode || ::desktop::ExitHelper::E_NORMAL_RESTART == dwExitCode ); delete[] lpCommandLine; return fSuccess ? dwExitCode : -1; -- cgit From d3fa4e4b471979d44494079aafa2a1018cc91fa0 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 10 May 2010 17:55:28 +0200 Subject: jl152: #i108704# fix typo --- desktop/scripts/soffice.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh index fae9dbe4d695..0215f88d1ff0 100644 --- a/desktop/scripts/soffice.sh +++ b/desktop/scripts/soffice.sh @@ -124,7 +124,7 @@ while [ $sd_ret -eq 79 -o $sd_ret -eq 81 ] do if [ $sd_ret -eq 79 ]; then "$sd_prog/$sd_binary" ""$BOOTSTRAPVARS"" & - elif if [ $sd_ret -eq 81 ]; then + elif [ $sd_ret -eq 81 ]; then "$sd_prog/$sd_binary" "$@" & fi -- cgit From 2af4a389327fbf8640fdb5f69eb8d1637f0e86bf Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Wed, 12 May 2010 16:11:41 +0200 Subject: jl152 #i77196# restarting at startup when shared/bundled extensions were changed, fixed typo in win32/source/officeloader/officeloader.cxx --- desktop/source/app/check_ext_deps.cxx | 2 +- desktop/source/deployment/misc/dp_misc.cxx | 23 ++- .../deployment/registry/component/dp_component.cxx | 195 +++++++++++---------- .../registry/configuration/dp_configuration.cxx | 5 +- .../deployment/registry/script/dp_script.cxx | 99 ++++++----- desktop/win32/source/officeloader/officeloader.cxx | 2 +- 6 files changed, 178 insertions(+), 148 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 7629a5c5cf83..757135a7e2d3 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -395,7 +395,7 @@ sal_Bool Desktop::CheckExtensionDependencies() void Desktop::SynchronizeExtensionRepositories() { - RTL_LOGFILE_CONTEXT(aLog,"desktop (jl97489) ::Desktop::SynchronizeExtensionRepositories"); + RTL_LOGFILE_CONTEXT(aLog,"desktop (jl) ::Desktop::SynchronizeExtensionRepositories"); OUString sDisable; ::rtl::Bootstrap::get( UNISTRING( "DISABLE_SYNC_EXTENSIONS" ), sDisable, OUString() ); if (sDisable.getLength() > 0) diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 799542a4757f..b68593c7f174 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -42,9 +42,11 @@ #include "osl/thread.hxx" #include "osl/mutex.hxx" #include "com/sun/star/ucb/CommandAbortedException.hpp" +#include "com/sun/star/task/XInteractionHandler.hpp" #include "com/sun/star/bridge/UnoUrlResolver.hpp" #include "com/sun/star/bridge/XUnoUrlResolver.hpp" #include "com/sun/star/deployment/ExtensionManager.hpp" +#include "com/sun/star/task/XRestartManager.hpp" #include "boost/scoped_array.hpp" #include "boost/shared_ptr.hpp" #include @@ -600,7 +602,8 @@ void syncRepositories(Reference const & xCmdEnv) Reference xExtensionManager; //synchronize shared before bundled otherewise there are //more revoke and registration calls. - OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); + bool bSynced = false; + const OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); if (needToSyncRepostitory(sShared)) { xExtensionManager = @@ -611,10 +614,11 @@ void syncRepositories(Reference const & xCmdEnv) { xExtensionManager->synchronize( sShared, Reference(), xCmdEnv); + bSynced = true; } } - OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); + const OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); if (needToSyncRepostitory( sBundled)) { if (!xExtensionManager.is()) @@ -627,9 +631,22 @@ void syncRepositories(Reference const & xCmdEnv) { xExtensionManager->synchronize( sBundled, Reference(), xCmdEnv); - + bSynced = true; } } + + if (bSynced) + { + Reference restarter( + comphelper_getProcessComponentContext()->getValueByName( + OUSTR( "/singletons/com.sun.star.task.OfficeRestartManager") ), UNO_QUERY ); + if (restarter.is()) + { + fprintf(stdout, "\nrestarting\n"); + restarter->requestRestart(xCmdEnv.is() == sal_True ? xCmdEnv->getInteractionHandler() : + Reference()); + } + } } diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index fc9880438bac..e0844c227669 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -1275,63 +1275,66 @@ void BackendImpl::ComponentPackageImpl::processPackage_( data.implementationNames = implNames; data.singletons = singletons; - // factories live insertion: - const Reference xSet( - that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW ); - for ( t_stringlist::const_iterator iPos( implNames.begin() ); - iPos != implNames.end(); ++iPos ) + if (!startup) { - checkAborted( abortChannel ); - OUString const & implName = *iPos; - // activate factory: - const Reference xFactory( - xLoader->activate( - implName, OUString(), url, - xServicesRDB->getRootKey()->openKey( - OUSTR("/IMPLEMENTATIONS/") + implName ) ) ); - try { - xSet->insert( Any(xFactory) ); - } // ignore if factory has already been inserted: - catch (container::ElementExistException &) { - OSL_ENSURE( 0, "### factory already registered?" ); + // factories live insertion: + const Reference xSet( + that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW ); + for ( t_stringlist::const_iterator iPos( implNames.begin() ); + iPos != implNames.end(); ++iPos ) + { + checkAborted( abortChannel ); + OUString const & implName = *iPos; + // activate factory: + const Reference xFactory( + xLoader->activate( + implName, OUString(), url, + xServicesRDB->getRootKey()->openKey( + OUSTR("/IMPLEMENTATIONS/") + implName ) ) ); + try { + xSet->insert( Any(xFactory) ); + } // ignore if factory has already been inserted: + catch (container::ElementExistException &) { + OSL_ENSURE( 0, "### factory already registered?" ); + } } - } - if (! singletons.empty()) - { - // singletons live insertion: - const Reference xRootContext( - that->getComponentContext()->getValueByName( - OUSTR("_root") ), UNO_QUERY ); - if (xRootContext.is()) + if (! singletons.empty()) { - for ( t_stringpairvec::const_iterator iPos( - singletons.begin() ); - iPos != singletons.end(); ++iPos ) + // singletons live insertion: + const Reference xRootContext( + that->getComponentContext()->getValueByName( + OUSTR("_root") ), UNO_QUERY ); + if (xRootContext.is()) { - ::std::pair const & sp = *iPos; - const OUString name( OUSTR("/singletons/") + sp.first ); - // assure no arguments: - try { - xRootContext->removeByName( name + OUSTR("/arguments")); - } catch (container::NoSuchElementException &) {} - // used service: - try { - xRootContext->insertByName( - name + OUSTR("/service"), Any(sp.second) ); - } catch (container::ElementExistException &) { - xRootContext->replaceByName( - name + OUSTR("/service"), Any(sp.second) ); - } - // singleton entry: - try { - xRootContext->insertByName( name, Any() ); - } catch (container::ElementExistException & exc) { - (void) exc; // avoid warnings - OSL_ENSURE( - 0, OUStringToOString( - exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); - xRootContext->replaceByName( name, Any() ); + for ( t_stringpairvec::const_iterator iPos( + singletons.begin() ); + iPos != singletons.end(); ++iPos ) + { + ::std::pair const & sp = *iPos; + const OUString name( OUSTR("/singletons/") + sp.first ); + // assure no arguments: + try { + xRootContext->removeByName( name + OUSTR("/arguments")); + } catch (container::NoSuchElementException &) {} + // used service: + try { + xRootContext->insertByName( + name + OUSTR("/service"), Any(sp.second) ); + } catch (container::ElementExistException &) { + xRootContext->replaceByName( + name + OUSTR("/service"), Any(sp.second) ); + } + // singleton entry: + try { + xRootContext->insertByName( name, Any() ); + } catch (container::ElementExistException & exc) { + (void) exc; // avoid warnings + OSL_ENSURE( + 0, OUStringToOString( + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + xRootContext->replaceByName( name, Any() ); + } } } } @@ -1365,53 +1368,57 @@ void BackendImpl::ComponentPackageImpl::processPackage_( { getComponentInfo( &implNames, &singletons, xContext ); } - // factories live removal: - const Reference xSet( - that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW ); - for ( t_stringlist::const_iterator iPos( implNames.begin() ); - iPos != implNames.end(); ++iPos ) + + if (!startup) { - OUString const & implName = *iPos; - try { - xSet->remove( Any(implName) ); - } // ignore if factory has not been live deployed: - catch (container::NoSuchElementException &) { + // factories live removal: + const Reference xSet( + that->getComponentContext()->getServiceManager(), UNO_QUERY_THROW ); + for ( t_stringlist::const_iterator iPos( implNames.begin() ); + iPos != implNames.end(); ++iPos ) + { + OUString const & implName = *iPos; + try { + xSet->remove( Any(implName) ); + } // ignore if factory has not been live deployed: + catch (container::NoSuchElementException &) { + } } - } - if (! singletons.empty()) - { - // singletons live removal: - const Reference xRootContext( - that->getComponentContext()->getValueByName( - OUSTR("_root") ), UNO_QUERY ); - if (xRootContext.is()) + if (! singletons.empty()) { - for ( t_stringpairvec::const_iterator iPos( - singletons.begin() ); - iPos != singletons.end(); ++iPos ) + // singletons live removal: + const Reference xRootContext( + that->getComponentContext()->getValueByName( + OUSTR("_root") ), UNO_QUERY ); + if (xRootContext.is()) { - ::std::pair const & sp = *iPos; - const OUString name( OUSTR("/singletons/") + sp.first ); - // arguments: - try { - xRootContext->removeByName( name + OUSTR("/arguments")); - } - catch (container::NoSuchElementException &) {} - // used service: - try { - xRootContext->removeByName( name + OUSTR("/service") ); - } - catch (container::NoSuchElementException &) {} - // singleton entry: - try { - xRootContext->removeByName( name ); - } - catch (container::NoSuchElementException & exc) { - (void) exc; // avoid warnings - OSL_ENSURE( - 0, OUStringToOString( - exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + for ( t_stringpairvec::const_iterator iPos( + singletons.begin() ); + iPos != singletons.end(); ++iPos ) + { + ::std::pair const & sp = *iPos; + const OUString name( OUSTR("/singletons/") + sp.first ); + // arguments: + try { + xRootContext->removeByName( name + OUSTR("/arguments")); + } + catch (container::NoSuchElementException &) {} + // used service: + try { + xRootContext->removeByName( name + OUSTR("/service") ); + } + catch (container::NoSuchElementException &) {} + // singleton entry: + try { + xRootContext->removeByName( name ); + } + catch (container::NoSuchElementException & exc) { + (void) exc; // avoid warnings + OSL_ENSURE( + 0, OUStringToOString( + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + } } } } diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 1a6738b0270b..f892c21a6a6b 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -680,7 +680,7 @@ OUString replaceOrigin( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, - bool /*startup*/, + bool startup, ::rtl::Reference const &, Reference const & xCmdEnv ) { @@ -702,7 +702,8 @@ void BackendImpl::PackageImpl::processPackage_( } //No need for live-deployment for bundled extension, because OOo //restarts after installation - if (that->m_eContext != CONTEXT_BUNDLED) + if (that->m_eContext != CONTEXT_BUNDLED + && !startup) { if (m_isSchema) { diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index 414d4c1c61cd..3a43e916e39e 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -331,7 +331,7 @@ BackendImpl::PackageImpl::isRegistered_( void BackendImpl::PackageImpl::processPackage_( ::osl::ResettableMutexGuard &, bool doRegisterPackage, - bool /* startup */, + bool startup, ::rtl::Reference const &, Reference const & xCmdEnv ) { @@ -382,7 +382,8 @@ void BackendImpl::PackageImpl::processPackage_( if (bRegistered) { - if (!isRemoved()) + //we also prevent and live deployment at startup + if (!isRemoved() && !startup) { if (bScript && xScriptLibs.is() && xScriptLibs->hasByName(m_name)) { @@ -409,66 +410,70 @@ void BackendImpl::PackageImpl::processPackage_( bool bScriptSuccess = false; const bool bReadOnly = false; - //If there is a bundled extension, and the user installes the same extension - //then the script from the bundled extension must be removed. If this does not work - //then live deployment does not work for scripts. - if (bScript && xScriptLibs.is()) + bool bDialogSuccess = false; + if (!startup) { - bool bCanAdd = true; - if (xScriptLibs->hasByName(m_name)) + //If there is a bundled extension, and the user installes the same extension + //then the script from the bundled extension must be removed. If this does not work + //then live deployment does not work for scripts. + if (bScript && xScriptLibs.is()) { - const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name); - //We assume here that library names in extensions are unique, which may not be the case - //ToDo: If the script exist in another extension, then both extensions must have the - //same id - if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) - || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) - || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + bool bCanAdd = true; + if (xScriptLibs->hasByName(m_name)) { - xScriptLibs->removeLibrary(m_name); - bCanAdd = true; + const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name); + //We assume here that library names in extensions are unique, which may not be the case + //ToDo: If the script exist in another extension, then both extensions must have the + //same id + if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + { + xScriptLibs->removeLibrary(m_name); + bCanAdd = true; + } + else + { + bCanAdd = false; + } } - else + + if (bCanAdd) { - bCanAdd = false; + xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly ); + bScriptSuccess = xScriptLibs->hasByName( m_name ); } } - if (bCanAdd) - { - xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly ); - bScriptSuccess = xScriptLibs->hasByName( m_name ); - } - } - bool bDialogSuccess = false; - if (bDialog && xDialogLibs.is()) - { - bool bCanAdd = true; - if (xDialogLibs->hasByName(m_dialogName)) + if (bDialog && xDialogLibs.is()) { - const OUString sOriginalUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName); - //We assume here that library names in extensions are unique, which may not be the case - //ToDo: If the script exist in another extension, then both extensions must have the - //same id - if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) - || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) - || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + bool bCanAdd = true; + if (xDialogLibs->hasByName(m_dialogName)) { - xDialogLibs->removeLibrary(m_dialogName); - bCanAdd = true; + const OUString sOriginalUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName); + //We assume here that library names in extensions are unique, which may not be the case + //ToDo: If the script exist in another extension, then both extensions must have the + //same id + if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")) + || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"))) + { + xDialogLibs->removeLibrary(m_dialogName); + bCanAdd = true; + } + else + { + bCanAdd = false; + } } - else + + if (bCanAdd) { - bCanAdd = false; + xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly ); + bDialogSuccess = xDialogLibs->hasByName(m_dialogName); } } - - if (bCanAdd) - { - xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly ); - bDialogSuccess = xDialogLibs->hasByName(m_dialogName); - } } bool bSuccess = bScript || bDialog; // Something must have happened if( bRunning ) diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx index 2d602a6d6507..ef980e1e994e 100644 --- a/desktop/win32/source/officeloader/officeloader.cxx +++ b/desktop/win32/source/officeloader/officeloader.cxx @@ -417,7 +417,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) CloseHandle( aProcessInfo.hThread ); } } while ( fSuccess - && ( ::desktop::ExitHelper::E_CRASH_WITH_RESTART == dwExitCode || ::desktop::ExitHelper::E_NORMAL_RESTART == dwExitCode ); + && ( ::desktop::ExitHelper::E_CRASH_WITH_RESTART == dwExitCode || ::desktop::ExitHelper::E_NORMAL_RESTART == dwExitCode )); delete[] lpCommandLine; return fSuccess ? dwExitCode : -1; -- cgit From d0a3afc82beed2c1d2e0035a0cc5d43bb6acf774 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 17 May 2010 10:40:52 +0200 Subject: jl152 #i77196# only restarting if a extension was added/removed, XextensionManager.getSupportedArguments: removed repository argument --- desktop/source/app/app.cxx | 10 ++------ desktop/source/deployment/gui/dp_gui_dialog2.cxx | 3 ++- .../deployment/manager/dp_extensionmanager.cxx | 30 ++++++++++------------ .../deployment/manager/dp_extensionmanager.hxx | 4 +-- desktop/source/deployment/manager/dp_manager.cxx | 24 +++++++++++------ desktop/source/deployment/manager/dp_manager.h | 6 ++--- desktop/source/deployment/misc/dp_misc.cxx | 15 +++++------ 7 files changed, 45 insertions(+), 47 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 3b0a1ea0dcf8..ebc0ab743125 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1399,11 +1399,9 @@ void Desktop::Main() // and process those extensions (has to be done before checking // the extension dependencies! SynchronizeExtensionRepositories(); - bool bAbort = CheckExtensionDependencies(); if ( bAbort ) return; - // First Start Wizard allowed ? if ( ! pCmdLineArgs->IsNoFirstStartWizard()) { @@ -1447,7 +1445,6 @@ void Desktop::Main() } SetSplashScreenProgress(50); - // Backing Component sal_Bool bCrashed = sal_False; sal_Bool bExistsRecoveryData = sal_False; @@ -1628,7 +1625,6 @@ void Desktop::Main() ::comphelper::ComponentContext aContext( xSMgr ); xRestartManager.set( aContext.getSingleton( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.OfficeRestartManager" ) ) ), UNO_QUERY ); - if ( !xRestartManager.is() || !xRestartManager->isRestartRequested( sal_True ) ) Execute(); } @@ -1654,22 +1650,20 @@ void Desktop::Main() } delete pResMgr; - // Restore old value if ( pCmdLineArgs->IsHeadless() ) SvtMiscOptions().SetUseSystemFileDialog( bUseSystemFileDialog ); // remove temp directory RemoveTemporaryDirectory(); - // The acceptors in the AcceptorMap must be released (in DeregisterServices) // with the solar mutex unlocked, to avoid deadlock: nAcquireCount = Application::ReleaseSolarMutex(); + printf("###1\n"); DeregisterServices(); + printf("###2\n"); Application::AcquireSolarMutex(nAcquireCount); - tools::DeInitTestToolLib(); - // be sure that path/language options gets destroyed before // UCB is deinitialized RTL_LOGFILE_CONTEXT_TRACE( aLog, "-> dispose path/language options" ); diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 164bb833fd6d..086e39e5f18c 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -877,7 +877,8 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker() t_string2string title2filter; OUString sDefaultFilter( StrAllFiles::get() ); - const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( m_pManager->getExtensionManager()->getSupportedPackageTypes( OUSTR("user") ) ); + const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( + m_pManager->getExtensionManager()->getSupportedPackageTypes() ); for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos ) { diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 83e68dff255e..edc414dc6f5d 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -402,16 +402,19 @@ Reference ExtensionManager::backupExtension( return xBackup; } +//The supported package types are actually determined by the registry. However +//creating a registry +//(desktop/source/deployment/registry/dp_registry.cxx:PackageRegistryImpl) will +//create all the backends, so that the registry can obtain from them the package +//types. Creating the registry will also set up the registry folder containing +//all the subfolders for the respective backends. +//Because all repositories support the same backends, we can just delegate this +//call to one of the repositories. uno::Sequence< Reference > -ExtensionManager::getSupportedPackageTypes(OUString const & repository) +ExtensionManager::getSupportedPackageTypes() throw (uno::RuntimeException) { - if (repository.equals(OUSTR("user"))) - return m_userRepository->getSupportedPackageTypes(); - else if (repository.equals(OUSTR("shared"))) - return m_sharedRepository->getSupportedPackageTypes(); - else - return uno::Sequence< Reference >(); + return m_userRepository->getSupportedPackageTypes(); } // Only add to shared and user repository @@ -437,7 +440,6 @@ Reference ExtensionManager::addExtension( throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), static_cast(this), 0); - ::osl::MutexGuard guard(getMutex()); Reference xTmpExtension = getTempExtension(url, xAbortChannel, xCmdEnv); @@ -448,7 +450,6 @@ Reference ExtensionManager::addExtension( dp_misc::DescriptionInfoset info(dp_misc::getDescriptionInfoset(xTmpExtension->getURL())); const ::boost::optional licenseAttributes = info.getSimpleLicenseAttributes(); - Reference xOldExtension; Reference xExtensionBackup; @@ -481,14 +482,12 @@ Reference ExtensionManager::addExtension( //the action. checkInstall(sDisplayName, xCmdEnv); } - //Prevent showing the license if requested. Reference _xCmdEnv(xCmdEnv); ExtensionProperties props(OUString(), properties, Reference()); if (licenseAttributes && licenseAttributes->suppressIfRequired && props.isSuppressedLicense()) _xCmdEnv = Reference(new NoLicenseCommandEnv(xCmdEnv->getInteractionHandler())); - bCanInstall = xTmpExtension->checkPrerequisites( xAbortChannel, _xCmdEnv, xOldExtension.is()) == 0 ? true : false; } @@ -528,10 +527,8 @@ Reference ExtensionManager::addExtension( xOldExtension, Reference(), tmpCmdEnv); } - xNewExtension = xPackageManager->addPackage( url, properties, OUString(), xAbortChannel, xCmdEnv); - //If we add a user extension and there is already one which was //disabled by a user, then the newly installed one is enabled. If we //add to another repository then the user extension remains @@ -1023,7 +1020,7 @@ void ExtensionManager::reinstallDeployedExtensions( } } -void ExtensionManager::synchronize( +sal_Bool ExtensionManager::synchronize( OUString const & repository, Reference const & xAbortChannel, Reference const & xCmdEnv ) @@ -1035,6 +1032,7 @@ void ExtensionManager::synchronize( { try { + sal_Bool bModified = sal_False; Reference xPackageManager; OUString file; if (repository.equals(OUSTR("user"))) @@ -1065,7 +1063,7 @@ void ExtensionManager::synchronize( sSynchronizing.SearchAndReplaceAllAscii( "%NAME", repository ); dp_misc::ProgressLevel progress(xCmdEnv, sSynchronizing); - xPackageManager->synchronize(xAbortChannel, xCmdEnv); + bModified = xPackageManager->synchronize(xAbortChannel, xCmdEnv); try { const uno::Sequence > > @@ -1109,6 +1107,7 @@ void ExtensionManager::synchronize( static_cast(this), exc); } + return bModified; } catch (deploy::DeploymentException& ) { throw; } catch (ucb::CommandFailedException & ) { @@ -1202,7 +1201,6 @@ Reference ExtensionManager::getTempExtension( Reference tmpCmdEnvA(new TmpRepositoryCommandEnv()); Reference xTmpPackage = m_tmpRepository->addPackage( url, uno::Sequence(),OUString(), xAbortChannel, tmpCmdEnvA); - if (!xTmpPackage.is()) { throw deploy::DeploymentException( diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index e6c9ca3aa915..4367770945aa 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -78,7 +78,7 @@ public: //XExtensionManager virtual css::uno::Sequence< css::uno::Reference > SAL_CALL - getSupportedPackageTypes(::rtl::OUString const & repository) + getSupportedPackageTypes() throw (css::uno::RuntimeException); virtual css::uno::Reference SAL_CALL @@ -185,7 +185,7 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); - virtual void SAL_CALL synchronize( + virtual sal_Bool SAL_CALL synchronize( ::rtl::OUString const & repository, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 69b2baab8878..7844e11b0651 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -1245,7 +1245,7 @@ void PackageManagerImpl::reinstallDeployedPackages( { return m_readOnly; } -void PackageManagerImpl::synchronizeRemovedExtensions( +bool PackageManagerImpl::synchronizeRemovedExtensions( Reference const & xAbortChannel, Reference const & xCmdEnv) { @@ -1253,6 +1253,7 @@ void PackageManagerImpl::synchronizeRemovedExtensions( //find all which are in the extension data base but which //are removed already. OSL_ASSERT(!m_context.equals(OUSTR("user"))); + bool bModified = false; ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); typedef ActivePackages::Entries::const_iterator ITActive; @@ -1322,6 +1323,7 @@ void PackageManagerImpl::synchronizeRemovedExtensions( xPackage->revokePackage(xAbortChannel, xCmdEnv); removePackage(xPackage->getIdentifier().Value, xPackage->getName(), xAbortChannel, xCmdEnv); + bModified |= true; } } catch( uno::Exception & ) @@ -1329,14 +1331,15 @@ void PackageManagerImpl::synchronizeRemovedExtensions( OSL_ASSERT(0); } } + return bModified; } -void PackageManagerImpl::synchronizeAddedExtensions( +bool PackageManagerImpl::synchronizeAddedExtensions( Reference const & xAbortChannel, Reference const & xCmdEnv) { - // clean up activation layer, scan for zombie temp dirs: + bool bModified = false; ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); ::ucbhelper::Content tempFolder( @@ -1441,6 +1444,7 @@ void PackageManagerImpl::synchronizeAddedExtensions( //try to install the extension again. dbData.failedPrerequisites = OUString::valueOf(failedPrereq); insertToActivationLayerDB(id, dbData); + bModified |= true; } } } @@ -1449,9 +1453,10 @@ void PackageManagerImpl::synchronizeAddedExtensions( OSL_ASSERT(0); } } + return bModified; } -void PackageManagerImpl::synchronize( +sal_Bool PackageManagerImpl::synchronize( Reference const & xAbortChannel, Reference const & xCmdEnv) throw (css::deployment::DeploymentException, @@ -1459,12 +1464,15 @@ void PackageManagerImpl::synchronize( css::ucb::CommandAbortedException, css::uno::RuntimeException) { - check(); + bool bModified = false; if (m_context.equals(OUSTR("user"))) - return; - synchronizeRemovedExtensions(xAbortChannel, xCmdEnv); - synchronizeAddedExtensions(xAbortChannel, xCmdEnv); + return bModified; + bModified |= + synchronizeRemovedExtensions(xAbortChannel, xCmdEnv); + bModified |= synchronizeAddedExtensions(xAbortChannel, xCmdEnv); + + return bModified; } Sequence< Reference > PackageManagerImpl::getExtensionsWithUnacceptedLicenses( diff --git a/desktop/source/deployment/manager/dp_manager.h b/desktop/source/deployment/manager/dp_manager.h index 2e13c56ae968..8fe0f662011b 100644 --- a/desktop/source/deployment/manager/dp_manager.h +++ b/desktop/source/deployment/manager/dp_manager.h @@ -89,11 +89,11 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper bool isInstalled( css::uno::Reference const & package); - void synchronizeRemovedExtensions( + bool synchronizeRemovedExtensions( css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); - void synchronizeAddedExtensions( + bool synchronizeAddedExtensions( css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv); @@ -246,7 +246,7 @@ public: virtual ::sal_Bool SAL_CALL isReadOnly( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL synchronize( + virtual ::sal_Bool SAL_CALL synchronize( css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index b68593c7f174..5ccc3d7225d4 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -602,7 +602,7 @@ void syncRepositories(Reference const & xCmdEnv) Reference xExtensionManager; //synchronize shared before bundled otherewise there are //more revoke and registration calls. - bool bSynced = false; + bool bModified = false; const OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); if (needToSyncRepostitory(sShared)) { @@ -612,9 +612,8 @@ void syncRepositories(Reference const & xCmdEnv) if (xExtensionManager.is()) { - xExtensionManager->synchronize( + bModified = xExtensionManager->synchronize( sShared, Reference(), xCmdEnv); - bSynced = true; } } @@ -629,24 +628,22 @@ void syncRepositories(Reference const & xCmdEnv) } if (xExtensionManager.is()) { - xExtensionManager->synchronize( + bModified |= xExtensionManager->synchronize( sBundled, Reference(), xCmdEnv); - bSynced = true; } } - if (bSynced) + if (bModified) { Reference restarter( comphelper_getProcessComponentContext()->getValueByName( OUSTR( "/singletons/com.sun.star.task.OfficeRestartManager") ), UNO_QUERY ); if (restarter.is()) { - fprintf(stdout, "\nrestarting\n"); restarter->requestRestart(xCmdEnv.is() == sal_True ? xCmdEnv->getInteractionHandler() : Reference()); - } - } + } + } } -- cgit From 885511f9be6f9e437687216affc1fb5c7d99054b Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 17 May 2010 16:42:05 +0200 Subject: jl152 #i77196# office hangs in smoketest when it is about to restart itself --- desktop/source/deployment/misc/dp_misc.cxx | 2 +- desktop/source/offacc/acceptor.cxx | 6 ++++++ desktop/source/offacc/acceptor.hxx | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 5ccc3d7225d4..3867f741f982 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -602,7 +602,7 @@ void syncRepositories(Reference const & xCmdEnv) Reference xExtensionManager; //synchronize shared before bundled otherewise there are //more revoke and registration calls. - bool bModified = false; + sal_Bool bModified = false; const OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); if (needToSyncRepostitory(sShared)) { diff --git a/desktop/source/offacc/acceptor.cxx b/desktop/source/offacc/acceptor.cxx index 4eee12f5949a..4e100fd99665 100644 --- a/desktop/source/offacc/acceptor.cxx +++ b/desktop/source/offacc/acceptor.cxx @@ -67,6 +67,7 @@ Acceptor::Acceptor( const Reference< XMultiServiceFactory >& rFactory ) , m_aConnectString() , m_aProtocol() , m_bInit(sal_False) + , m_bDying(false) { m_rSMgr = rFactory; m_rAcceptor = Reference< XAcceptor > (m_rSMgr->createInstance( @@ -88,6 +89,9 @@ Acceptor::~Acceptor() osl::MutexGuard g(m_aMutex); t = m_thread; } + //prevent locking if the thread is still waiting + m_bDying = true; + m_cEnable.set(); osl_joinWithThread(t); { // Make the final state of m_bridges visible to this thread (since @@ -117,6 +121,8 @@ void SAL_CALL Acceptor::run() RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109)"\ "Acceptor::run waiting for office to come up"); m_cEnable.wait(); + if (m_bDying) //see destructor + break; RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109)"\ "Acceptor::run now enabled and continuing"); diff --git a/desktop/source/offacc/acceptor.hxx b/desktop/source/offacc/acceptor.hxx index 1693dd8b75d0..87f50db032dd 100644 --- a/desktop/source/offacc/acceptor.hxx +++ b/desktop/source/offacc/acceptor.hxx @@ -83,6 +83,7 @@ private: OUString m_aProtocol; sal_Bool m_bInit; + bool m_bDying; public: Acceptor( const Reference< XMultiServiceFactory >& aFactory ); -- cgit From eef1fd8ab2966ee3b2934d9050b0a14c4478e1f6 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 18 May 2010 14:59:37 +0200 Subject: jl152 #i77196# smoketest now uses new extension manager service --- desktop/source/app/app.cxx | 2 -- 1 file changed, 2 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index ebc0ab743125..5e0460891c30 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1659,9 +1659,7 @@ void Desktop::Main() // The acceptors in the AcceptorMap must be released (in DeregisterServices) // with the solar mutex unlocked, to avoid deadlock: nAcquireCount = Application::ReleaseSolarMutex(); - printf("###1\n"); DeregisterServices(); - printf("###2\n"); Application::AcquireSolarMutex(nAcquireCount); tools::DeInitTestToolLib(); // be sure that path/language options gets destroyed before -- cgit From e6d9970ba08599dfaf13998b9cc0908554f00176 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 18 May 2010 15:50:04 +0200 Subject: jl152 #i77196# adapted migration code to use new extension manager, removed old unused migration code, adapted ooo improvement dialog to appear after third start, taking into account the restarting after extension installation --- desktop/prj/build.lst | 3 +- desktop/source/deployment/dp_services.cxx | 6 - desktop/source/deployment/makefile.mk | 1 - .../source/deployment/migration/dp_migration.cxx | 251 ---------- desktop/source/deployment/migration/makefile.mk | 41 -- desktop/source/migration/services/cexports.cxx | 12 +- .../migration/services/extensionmigration.cxx | 540 --------------------- .../migration/services/extensionmigration.hxx | 130 ----- desktop/source/migration/services/makefile.mk | 2 - .../migration/services/oo3extensionmigration.cxx | 33 +- .../migration/services/oo3extensionmigration.hxx | 8 +- 11 files changed, 27 insertions(+), 1000 deletions(-) delete mode 100644 desktop/source/deployment/migration/dp_migration.cxx delete mode 100644 desktop/source/deployment/migration/makefile.mk delete mode 100755 desktop/source/migration/services/extensionmigration.cxx delete mode 100755 desktop/source/migration/services/extensionmigration.hxx (limited to 'desktop') diff --git a/desktop/prj/build.lst b/desktop/prj/build.lst index 6f611926a0df..8029b6ecc9f7 100644 --- a/desktop/prj/build.lst +++ b/desktop/prj/build.lst @@ -21,10 +21,9 @@ dt desktop\os2\source\applauncher nmake - p dt_applauncher dt_inc NULL dt desktop\unx\source\officeloader nmake - u dt_officeloader_unx dt_inc NULL dt desktop\source\pagein nmake - u dt_pagein dt_inc NULL dt desktop\source\pkgchk\unopkg nmake - all dt_unopkg dt_dp_misc dt_app dt_inc dt_guiloader.w NULL -dt desktop\source\deployment nmake - all dt_deployment dt_dp_manager dt_dp_registry dt_dp_registry_package dt_dp_registry_executable dt_dp_registry_help dt_dp_registry_script dt_dp_registry_sfwk dt_dp_registry_component dt_dp_registry_configuration dt_dp_migration dt_dp_unopkg dt_inc dt_dp_misc NULL +dt desktop\source\deployment nmake - all dt_deployment dt_dp_manager dt_dp_registry dt_dp_registry_package dt_dp_registry_executable dt_dp_registry_help dt_dp_registry_script dt_dp_registry_sfwk dt_dp_registry_component dt_dp_registry_configuration dt_dp_unopkg dt_inc dt_dp_misc NULL dt desktop\source\deployment\misc nmake - all dt_dp_misc dt_inc NULL dt desktop\source\deployment\unopkg nmake - all dt_dp_unopkg dt_inc NULL -dt desktop\source\deployment\migration nmake - all dt_dp_migration dt_inc NULL dt desktop\source\deployment\gui nmake - all dt_dp_gui dt_dp_misc dt_inc NULL dt desktop\source\deployment\manager nmake - all dt_dp_manager dt_inc NULL dt desktop\source\deployment\registry nmake - all dt_dp_registry dt_inc NULL diff --git a/desktop/source/deployment/dp_services.cxx b/desktop/source/deployment/dp_services.cxx index 05b9a2a1971a..f7ebf66355ba 100644 --- a/desktop/source/deployment/dp_services.cxx +++ b/desktop/source/deployment/dp_services.cxx @@ -77,10 +77,6 @@ namespace dp_log { extern sdecl::ServiceDecl const serviceDecl; } -namespace dp_migration { -extern sdecl::ServiceDecl const serviceDecl; -} - namespace dp_info { extern sdecl::ServiceDecl const serviceDecl; bool singleton_entries( uno::Reference const& ); @@ -110,7 +106,6 @@ sal_Bool SAL_CALL component_writeInfo( dp_registry::backend::executable::serviceDecl, dp_manager::factory::serviceDecl, dp_log::serviceDecl, - dp_migration::serviceDecl, dp_info::serviceDecl, dp_manager::serviceDecl) && dp_manager::factory::singleton_entries( pRegistryKey ) && @@ -133,7 +128,6 @@ void * SAL_CALL component_getFactory( dp_registry::backend::executable::serviceDecl, dp_manager::factory::serviceDecl, dp_log::serviceDecl, - dp_migration::serviceDecl, dp_info::serviceDecl, dp_manager::serviceDecl); } diff --git a/desktop/source/deployment/makefile.mk b/desktop/source/deployment/makefile.mk index 173ff35bec1d..6d83a5c1004b 100644 --- a/desktop/source/deployment/makefile.mk +++ b/desktop/source/deployment/makefile.mk @@ -53,7 +53,6 @@ SHL1VERSIONMAP = $(SOLARENV)/src/component.map SHL1LIBS = \ $(SLB)$/deployment_manager.lib \ - $(SLB)$/deployment_migration.lib \ $(SLB)$/deployment_registry.lib \ $(SLB)$/deployment_registry_executable.lib \ $(SLB)$/deployment_registry_component.lib \ diff --git a/desktop/source/deployment/migration/dp_migration.cxx b/desktop/source/deployment/migration/dp_migration.cxx deleted file mode 100644 index c2d0b0dc6bb8..000000000000 --- a/desktop/source/deployment/migration/dp_migration.cxx +++ /dev/null @@ -1,251 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_desktop.hxx" - -#include "dp_misc.h" -#include "dp_ucb.h" -#include "cppuhelper/implbase1.hxx" -#include "cppuhelper/implbase2.hxx" -#include "cppuhelper/exc_hlp.hxx" -#include "ucbhelper/content.hxx" -#include "comphelper/anytostring.hxx" -#include "comphelper/servicedecl.hxx" -#include "com/sun/star/lang/WrappedTargetException.hpp" -#include "com/sun/star/task/XJob.hpp" -#include "com/sun/star/task/XInteractionAbort.hpp" -#include "com/sun/star/task/XInteractionApprove.hpp" -#include "com/sun/star/sdbc/XResultSet.hpp" -#include "com/sun/star/sdbc/XRow.hpp" -#include "com/sun/star/ucb/XContentAccess.hpp" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" - - -using namespace ::com::sun::star; -using namespace ::com::sun::star::ucb; -using namespace ::com::sun::star::uno; -using namespace ::dp_misc; -using ::rtl::OUString; - -namespace dp_migration { - -class MigrationImpl : public ::cppu::WeakImplHelper1 -{ - struct CommandEnvironmentImpl - : public ::cppu::WeakImplHelper2< XCommandEnvironment, - task::XInteractionHandler > - { - // XCommandEnvironment - virtual Reference SAL_CALL - getInteractionHandler() throw (RuntimeException); - virtual Reference SAL_CALL getProgressHandler() - throw (RuntimeException); - // XInteractionHandler - virtual void SAL_CALL handle( - Reference const & xRequest ) - throw (RuntimeException); - }; - - const Reference m_xContext; - OUString m_userData; - -protected: - virtual ~MigrationImpl(); -public: - MigrationImpl( Sequence const & args, - Reference const & xComponentContext ); - - // XJob - virtual Any SAL_CALL execute( Sequence const & args ) - throw (lang::IllegalArgumentException, Exception, RuntimeException); -}; - -MigrationImpl::~MigrationImpl() -{ -} - -MigrationImpl::MigrationImpl( - Sequence const & args, Reference const & xContext ) - : m_xContext(xContext) -{ - for ( sal_Int32 pos = args.getLength(); pos--; ) - { - const beans::NamedValue nv(args[pos].get()); - if (nv.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UserData") )) - m_userData = nv.Value.get(); - } - if (m_userData.getLength() == 0) - throw lang::IllegalArgumentException( OUSTR("missing UserData!"), 0, - static_cast(-1) ); -} - -// XJob -Any MigrationImpl::execute( Sequence const & ) - throw (lang::IllegalArgumentException, Exception, RuntimeException) -{ - const Reference xManager( - deployment::thePackageManagerFactory::get( - m_xContext )->getPackageManager( OUSTR("user") ) ); - ::ucbhelper::Content packagesDir; - if (create_ucb_content( &packagesDir, - makeURL( m_userData, OUSTR("user/uno_packages") ), - Reference(), - false /* no throw */ )) - { - const Reference xCmdEnv( - new CommandEnvironmentImpl ); - OUString const & strTitle = StrTitle::get(); - const Reference xResultSet( - packagesDir.createCursor( Sequence( &strTitle, 1 ), - ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) ); - while (xResultSet->next()) - { - Reference xRow( xResultSet, UNO_QUERY_THROW ); - const OUString title( xRow->getString( 1 /* Title */ ) ); - // exclude stampIt, not migratable to OOo 2.0: - if (title.matchIgnoreAsciiCaseAsciiL( - RTL_CONSTASCII_STRINGPARAM("SSICONCT.") )) - continue; - const OUString sourceURL( Reference( - xResultSet, UNO_QUERY_THROW ) - ->queryContentIdentifierString() ); - try { - xManager->addPackage( - sourceURL, uno::Sequence(),OUString() /* detect media-type */, - Reference(), xCmdEnv ); - } - catch (RuntimeException &) { - throw; - } - catch (Exception &) { - OSL_ENSURE( 0, ::rtl::OUStringToOString( - ::comphelper::anyToString( - ::cppu::getCaughtException() ), - RTL_TEXTENCODING_UTF8 ).getStr() ); - } - } - } - return Any(); -} - -// XCommandEnvironment -Reference -MigrationImpl::CommandEnvironmentImpl::getInteractionHandler() - throw (RuntimeException) -{ - return this; -} - -Reference -MigrationImpl::CommandEnvironmentImpl::getProgressHandler() - throw (RuntimeException) -{ - return Reference(); -} - -// XInteractionHandler -void MigrationImpl::CommandEnvironmentImpl::handle( - Reference const & xRequest ) - throw (RuntimeException) -{ - Any request( xRequest->getRequest() ); - OSL_ASSERT( request.getValueTypeClass() == TypeClass_EXCEPTION ); -#if OSL_DEBUG_LEVEL > 1 - OSL_TRACE( "[dp_migration.cxx] incoming request:\n%s\n", - ::rtl::OUStringToOString( ::comphelper::anyToString(request), - RTL_TEXTENCODING_UTF8 ).getStr() ); -#endif - - // selections: - bool approve = false; - bool abort = false; - - lang::WrappedTargetException wtExc; - if (request >>= wtExc) { - OSL_ENSURE( 0, ::rtl::OUStringToOString( - ::comphelper::anyToString(wtExc.TargetException), - RTL_TEXTENCODING_UTF8 ).getStr() ); - - // ignore intermediate errors of legacy packages, i.e. - // former pkgchk behaviour: - const Reference xPackage( - wtExc.Context, UNO_QUERY ); - OSL_ASSERT( xPackage.is() ); - if (xPackage.is()) { - const Reference xPackageType( - xPackage->getPackageType() ); - OSL_ASSERT( xPackageType.is() ); - if (xPackageType.is()) { - approve = (xPackage->isBundle() && - xPackageType->getMediaType().matchAsciiL( - RTL_CONSTASCII_STRINGPARAM( - "application/" - "vnd.sun.star.legacy-package-bundle") )); - } - } - abort = !approve; - } - else - return; // unknown request => no selection at all - - // select: - const Sequence< Reference > conts( - xRequest->getContinuations() ); - for ( sal_Int32 pos = 0; pos < conts.getLength(); ++pos ) - { - if (approve) { - const Reference xInteractionApprove( - conts[ pos ], UNO_QUERY ); - if (xInteractionApprove.is()) { - xInteractionApprove->select(); - // don't query again for ongoing continuations: - approve = false; - } - } - else if (abort) { - const Reference xInteractionAbort( - conts[ pos ], UNO_QUERY ); - if (xInteractionAbort.is()) { - xInteractionAbort->select(); - // don't query again for ongoing continuations: - abort = false; - } - } - } -} - -namespace sdecl = comphelper::service_decl; -sdecl::class_ > serviceMI; -extern sdecl::ServiceDecl const serviceDecl( - serviceMI, - // a private one (config entry): - "com.sun.star.comp.deployment.migration.Migration_2_0", - "com.sun.star.comp.deployment.migration.Migration_2_0" ); - -} // namespace dp_migration - diff --git a/desktop/source/deployment/migration/makefile.mk b/desktop/source/deployment/migration/makefile.mk deleted file mode 100644 index a37b7e5bebf8..000000000000 --- a/desktop/source/deployment/migration/makefile.mk +++ /dev/null @@ -1,41 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ = ..$/..$/.. - -PRJNAME = desktop -TARGET = deployment_migration -ENABLE_EXCEPTIONS = TRUE - -.INCLUDE : settings.mk - -SLOFILES = \ - $(SLO)$/dp_migration.obj - -.INCLUDE : ..$/target.pmk -.INCLUDE : target.mk - diff --git a/desktop/source/migration/services/cexports.cxx b/desktop/source/migration/services/cexports.cxx index c1971e9d4d00..cf9a9ab30b0c 100644 --- a/desktop/source/migration/services/cexports.cxx +++ b/desktop/source/migration/services/cexports.cxx @@ -31,7 +31,7 @@ #include "cppuhelper/implementationentry.hxx" #include "basicmigration.hxx" #include "wordbookmigration.hxx" -#include "extensionmigration.hxx" +//#include "extensionmigration.hxx" extern "C" { @@ -48,11 +48,11 @@ extern "C" migration::WordbookMigration_getSupportedServiceNames, ::cppu::createSingleComponentFactory, 0, 0 }, - { - migration::ExtensionMigration_create, migration::ExtensionMigration_getImplementationName, - migration::ExtensionMigration_getSupportedServiceNames, ::cppu::createSingleComponentFactory, - 0, 0 - }, +// { +// migration::ExtensionMigration_create, migration::ExtensionMigration_getImplementationName, +// migration::ExtensionMigration_getSupportedServiceNames, ::cppu::createSingleComponentFactory, +// 0, 0 +// }, { 0, 0, 0, 0, 0, 0 } }; diff --git a/desktop/source/migration/services/extensionmigration.cxx b/desktop/source/migration/services/extensionmigration.cxx deleted file mode 100755 index 66f32744a782..000000000000 --- a/desktop/source/migration/services/extensionmigration.cxx +++ /dev/null @@ -1,540 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_desktop.hxx" -#include "extensionmigration.hxx" -#include -#include -#include -#include -#include -#include -#include -#include "comphelper/processfactory.hxx" -#include "com/sun/star/deployment/XPackageManagerFactory.hpp" -#include "com/sun/star/ucb/XCommandEnvironment.hpp" -#include "com/sun/star/xml/sax/XParser.hpp" -#include "rtl/instance.hxx" -#include "osl/file.hxx" -#include "osl/thread.h" - -#include "xmlscript/xmllib_imexp.hxx" -#include "../../deployment/inc/dp_ucb.h" - -#ifdef SYSTEM_DB -#include -#else -#include -#endif - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; - -namespace { - - struct LibDescriptor : - public rtl::StaticWithInit { - const ::xmlscript::LibDescriptorArray operator () () { - - - return ::xmlscript::LibDescriptorArray(); - } -}; -} -//......................................................................... -namespace migration -{ -//......................................................................... - - - static ::rtl::OUString sExtensionSubDir = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/uno_packages/" ) ); - static ::rtl::OUString sSubDirName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cache" ) ); - static ::rtl::OUString sConfigDir = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data" ) ); - static ::rtl::OUString sOrgDir = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data/org" ) ); - static ::rtl::OUString sExcludeDir1 = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data/org" ) ); - static ::rtl::OUString sExcludeDir2 = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/registry/data/org/openoffice" ) ); - - static ::rtl::OUString sBasicType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.basic-library")); - static ::rtl::OUString sDialogType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.dialog-library")); - - static ::rtl::OUString sConfigurationDataType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.configuration-data")); - static ::rtl::OUString sConfigurationSchemaType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.star.configuration-schema")); - - // ============================================================================= - // component operations - // ============================================================================= - - ::rtl::OUString ExtensionMigration_getImplementationName() - { - static ::rtl::OUString* pImplName = 0; - if ( !pImplName ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !pImplName ) - { - static ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.desktop.migration.Extensions" ) ); - pImplName = &aImplName; - } - } - return *pImplName; - } - - // ----------------------------------------------------------------------------- - - Sequence< ::rtl::OUString > ExtensionMigration_getSupportedServiceNames() - { - static Sequence< ::rtl::OUString >* pNames = 0; - if ( !pNames ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !pNames ) - { - static Sequence< ::rtl::OUString > aNames(1); - aNames.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.migration.Extensions" ) ); - pNames = &aNames; - } - } - return *pNames; - } - - // ============================================================================= - // ExtensionMigration - // ============================================================================= - - ExtensionMigration::ExtensionMigration(Reference< XComponentContext > const & ctx) : - m_ctx(ctx) - { - } - - // ----------------------------------------------------------------------------- - - ExtensionMigration::~ExtensionMigration() - { - } - - ::osl::FileBase::RC ExtensionMigration::checkAndCreateDirectory( INetURLObject& rDirURL ) - { - ::osl::FileBase::RC aResult = ::osl::Directory::create( rDirURL.GetMainURL( INetURLObject::DECODE_TO_IURI ) ); - if ( aResult == ::osl::FileBase::E_NOENT ) - { - INetURLObject aBaseURL( rDirURL ); - aBaseURL.removeSegment(); - checkAndCreateDirectory( aBaseURL ); - return ::osl::Directory::create( rDirURL.GetMainURL( INetURLObject::DECODE_TO_IURI ) ); - } - else - { - return aResult; - } - } - - void ExtensionMigration::prepareBasicLibs() - { - prepareBasicLibs(m_sSourceDir + ::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("/user/basic/script.xlc")), m_scriptElements); - prepareBasicLibs(m_sSourceDir + ::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("/user/basic/dialog.xlc")), m_dialogElements); - } - - void ExtensionMigration::prepareBasicLibs(const ::rtl::OUString & sURL, - ::xmlscript::LibDescriptorArray & out_elements) - { - - ::ucbhelper::Content ucb_content; - if (dp_misc::create_ucb_content( &ucb_content, sURL, - uno::Reference< ucb::XCommandEnvironment>(), false /* no throw */ )) - { - uno::Reference xParser( - m_ctx->getServiceManager()->createInstanceWithContext( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser")), - m_ctx ), UNO_QUERY_THROW ); - - xParser->setDocumentHandler( ::xmlscript::importLibraryContainer( &out_elements ) ); - xml::sax::InputSource source; - source.aInputStream = ucb_content.openStream(); - source.sSystemId = ucb_content.getURL(); - xParser->parseStream( source ); - } - //else - //The file need not exists - } - /* Checks if basic package is enabled in StarOffice 8. This is the case when the dialog.xlc or - the script.xlc in the user installation contains an entry for this package. - The passed package MUST be a basic package. - */ - bool ExtensionMigration::isBasicPackageEnabled( const uno::Reference< deployment::XPackage > & xPkg) - { - ::rtl::OUString sScriptURL = xPkg->getURL(); - if ( sScriptURL[ sScriptURL.getLength()-1 ] != '/' ) - sScriptURL += ::rtl::OUString::createFromAscii("/"); - sScriptURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("script.xlb") ); - - bool bEntryFound = false; - for ( sal_Int32 nPos = m_scriptElements.mnLibCount; nPos--; ) - { - ::xmlscript::LibDescriptor const & descr = - m_scriptElements.mpLibs[ nPos ]; - - if (descr.aStorageURL.equals(sScriptURL)) - { - bEntryFound = true; - break; - } - } - - ::rtl::OUString sDialogURL = xPkg->getURL(); - if ( sDialogURL[ sDialogURL.getLength()-1 ] != '/' ) - sDialogURL += ::rtl::OUString::createFromAscii("/"); - sScriptURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("dialog.xlb") ); - - if (!bEntryFound) - { - for ( sal_Int32 nPos = m_dialogElements.mnLibCount; nPos--; ) - { - ::xmlscript::LibDescriptor const & descr = - m_dialogElements.mpLibs[ nPos ]; - - if (descr.aStorageURL.equals(sDialogURL)) - { - bEntryFound = true; - break; - } - } - } - return bEntryFound; - } - /* This function only registers basic and dialog packages. - */ - void ExtensionMigration::registerBasicPackage( const uno::Reference< deployment::XPackage > & xPkg) - { - const ::rtl::OUString sMediaType = xPkg->getPackageType()->getMediaType(); - if ( (sMediaType.equals(sBasicType) || sMediaType.equals(sDialogType)) - && isBasicPackageEnabled(xPkg)) - { - xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment> ()); - } - } - - bool ExtensionMigration::processExtensions( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ) - { - if (!copy(sSourceDir, sTargetDir)) - return false; - - // Find all basic and script packages and reregister them - uno::Reference< deployment::XPackageManagerFactory > xPMF; - if (! ( m_ctx->getValueByName( ::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.deployment.thePackageManagerFactory"))) - >>= xPMF)) - throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "ExtensionsMigration: could not get thePackageManagerFactory")), 0); - - const uno::Reference< deployment::XPackageManager > xPackageMgr = - xPMF->getPackageManager(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user"))); - - if (!xPackageMgr.is()) - throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "ExtensionsMigration: could not get XPackageManager")), 0); - - const uno::Sequence< uno::Reference< deployment::XPackage > > allPackages = - xPackageMgr->getDeployedPackages( - uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - - for (int i = 0; i < allPackages.getLength(); i ++) - { - const uno::Reference< deployment::XPackage > aPackage = allPackages[i]; - if ( aPackage->isBundle() ) - { - const uno::Sequence< uno::Reference < deployment::XPackage > > seqPkg = - aPackage->getBundle( - uno::Reference< task::XAbortChannel >(), - uno::Reference< ucb::XCommandEnvironment> ()); - - for ( int k = 0; k < seqPkg.getLength(); k++ ) - registerBasicPackage(seqPkg[k]); - - for (int l = 0; l < seqPkg.getLength(); l++) - { - const ::rtl::OUString sMediaType = seqPkg[l]->getPackageType()->getMediaType(); - beans::Optional > opt = - seqPkg[l]->isRegistered(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - bool bRegistered = opt.IsPresent && opt.Value.IsAmbiguous == sal_False && opt.Value.Value == sal_True ? true : false; - - if ( bRegistered && !sMediaType.equals(sBasicType) && !sMediaType.equals(sDialogType) ) - { - seqPkg[l]->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - seqPkg[l]->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - } - } - } - else - { - registerBasicPackage(aPackage); - { - aPackage->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - aPackage->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - } - } - } - - - return true; - - } - -bool ExtensionMigration::isCompatibleBerkleyDb(const ::rtl::OUString& sSourceDir) -{ - try - { - ::rtl::OUString sDb(sSourceDir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "/uno_packages.db"))); - //check if the db exist at all. If not then the call to db_create would create - //the file. - ::osl::File f(sDb); - if (::osl::File::E_None != f.open(OpenFlag_Read)) - { - f.close(); - return false; - } - f.close(); - - //create a system path - ::rtl::OUString sSysPath; - if (::osl::File::getSystemPathFromFileURL(sDb, sSysPath ) != ::osl::File::E_None) - return false; - - ::rtl::OString cstr_sysPath( - ::rtl::OUStringToOString( sSysPath, osl_getThreadTextEncoding() ) ); - char const * pcstr_sysPath = cstr_sysPath.getStr(); - - //Open the db. If it works then we assume that the file was written with a - //compatible version of Berkeley Db - DB* pDB = NULL; - //using DB_RDONLY will return an "Invalid argument" error. - //DB_CREATE: only creates the file if it does not exist. - //An existing db is not modified. - if (0 != db_create(& pDB, 0, DB_CREATE)) - return false; - - if (0 != pDB->open(pDB, 0, pcstr_sysPath , 0, DB_HASH, DB_RDONLY, 0664 /* fs mode */)) - return false; - - pDB->close(pDB, 0); - } - catch (uno::Exception& ) - { - return false; - } - - return true; -} - -bool ExtensionMigration::copy( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ) -{ - bool bRet = false; - if (! isCompatibleBerkleyDb(sSourceDir)) - return false; - - INetURLObject aSourceObj( sSourceDir ); - INetURLObject aDestObj( sTargetDir ); - String aName = aDestObj.getName(); - aDestObj.removeSegment(); - aDestObj.setFinalSlash(); - - try - { - ::ucbhelper::Content aDestPath( aDestObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () ); - uno::Reference< ucb::XCommandInfo > xInfo = aDestPath.getCommands(); - ::rtl::OUString aTransferName = ::rtl::OUString::createFromAscii( "transfer" ); - if ( xInfo->hasCommandByName( aTransferName ) ) - { - aDestPath.executeCommand( aTransferName, uno::makeAny( - ucb::TransferInfo( sal_False, aSourceObj.GetMainURL( INetURLObject::NO_DECODE ), aName, ucb::NameClash::OVERWRITE ) ) ); - bRet = true; - } - } - catch( uno::Exception& ) - { - } - - return bRet; -} - - - // ----------------------------------------------------------------------------- - // XServiceInfo - // ----------------------------------------------------------------------------- - - ::rtl::OUString ExtensionMigration::getImplementationName() throw (RuntimeException) - { - return ExtensionMigration_getImplementationName(); - } - - // ----------------------------------------------------------------------------- - - sal_Bool ExtensionMigration::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException) - { - Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() ); - const ::rtl::OUString* pNames = aNames.getConstArray(); - const ::rtl::OUString* pEnd = pNames + aNames.getLength(); - for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames ) - ; - - return pNames != pEnd; - } - - // ----------------------------------------------------------------------------- - - Sequence< ::rtl::OUString > ExtensionMigration::getSupportedServiceNames() throw (RuntimeException) - { - return ExtensionMigration_getSupportedServiceNames(); - } - - // ----------------------------------------------------------------------------- - // XInitialization - // ----------------------------------------------------------------------------- - - void ExtensionMigration::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException) - { - ::osl::MutexGuard aGuard( m_aMutex ); - - const Any* pIter = aArguments.getConstArray(); - const Any* pEnd = pIter + aArguments.getLength(); - for ( ; pIter != pEnd ; ++pIter ) - { - beans::NamedValue aValue; - *pIter >>= aValue; - if ( aValue.Name.equalsAscii( "UserData" ) ) - { - if ( !(aValue.Value >>= m_sSourceDir) ) - { - OSL_ENSURE( false, "ExtensionMigration::initialize: argument UserData has wrong type!" ); - } - break; - } - } - prepareBasicLibs(); - } - - TStringVectorPtr getContent( const ::rtl::OUString& rBaseURL ) - { - TStringVectorPtr aResult( new TStringVector ); - ::osl::Directory aDir( rBaseURL); - if ( aDir.open() == ::osl::FileBase::E_None ) - { - // iterate over directory content - TStringVector aSubDirs; - ::osl::DirectoryItem aItem; - while ( aDir.getNextItem( aItem ) == ::osl::FileBase::E_None ) - { - ::osl::FileStatus aFileStatus( FileStatusMask_Type | FileStatusMask_FileURL ); - if ( aItem.getFileStatus( aFileStatus ) == ::osl::FileBase::E_None ) - aResult->push_back( aFileStatus.getFileURL() ); - } - } - - return aResult; - } - - // ----------------------------------------------------------------------------- - // XJob - // ----------------------------------------------------------------------------- - -void ExtensionMigration::copyConfig( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ) -{ - ::rtl::OUString sEx1( m_sSourceDir ); - sEx1 += sExcludeDir1; - ::rtl::OUString sEx2( m_sSourceDir ); - sEx2 += sExcludeDir2; - - TStringVectorPtr aList = getContent( sSourceDir ); - TStringVector::const_iterator aI = aList->begin(); - while ( aI != aList->end() ) - { - ::rtl::OUString sSourceLocalName = aI->copy( sSourceDir.getLength() ); - ::rtl::OUString aTemp = aI->copy( m_sSourceDir.getLength() ); - if ( aTemp != sExcludeDir1 && aTemp != sExcludeDir2 ) - { - ::rtl::OUString sTargetName = sTargetDir + sSourceLocalName; - copy( (*aI), sTargetName ); - } - ++aI; - } -} - - Any ExtensionMigration::execute( const Sequence< beans::NamedValue >& ) - throw (lang::IllegalArgumentException, Exception, RuntimeException) - { - ::osl::MutexGuard aGuard( m_aMutex ); - - ::utl::Bootstrap::PathStatus aStatus = ::utl::Bootstrap::locateUserInstallation( m_sTargetDir ); - if ( aStatus == ::utl::Bootstrap::PATH_EXISTS ) - { - // copy all extensions - ::rtl::OUString sTargetDir(m_sTargetDir), sSourceDir( m_sSourceDir ); - sTargetDir += sExtensionSubDir; - sSourceDir += sExtensionSubDir; - sSourceDir += sSubDirName; - sTargetDir += sSubDirName; - processExtensions( sSourceDir, sTargetDir ); - - // copy all user config settings in user/registry/data (except user/registry/data/org) - sSourceDir = m_sSourceDir; - sSourceDir += sConfigDir; - sTargetDir = m_sTargetDir; - sTargetDir += sConfigDir; - copyConfig( sSourceDir, sTargetDir ); - - // copy all user config settings in user/registry/data/org (except user/registry/data/org/openoffice) - sSourceDir = m_sSourceDir; - sSourceDir += sOrgDir; - sTargetDir = m_sTargetDir; - sTargetDir += sOrgDir; - copyConfig( sSourceDir, sTargetDir ); - } - - return Any(); - } - - // ============================================================================= - // component operations - // ============================================================================= - - Reference< XInterface > SAL_CALL ExtensionMigration_create( - Reference< XComponentContext > const & ctx ) - SAL_THROW( () ) - { - return static_cast< lang::XTypeProvider * >( new ExtensionMigration( - ctx) ); - } - - // ----------------------------------------------------------------------------- - -//......................................................................... -} // namespace migration -//......................................................................... diff --git a/desktop/source/migration/services/extensionmigration.hxx b/desktop/source/migration/services/extensionmigration.hxx deleted file mode 100755 index 70f6a4c44c9b..000000000000 --- a/desktop/source/migration/services/extensionmigration.hxx +++ /dev/null @@ -1,130 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _DESKTOP_EXTENSIONMIGRATION_HXX_ -#define _DESKTOP_EXTENSIONMIGRATION_HXX_ - -#include "misc.hxx" -#include -#include -#include -#include -#include -#include -#include "xmlscript/xmllib_imexp.hxx" - -namespace com { namespace sun { namespace star { - namespace uno { - class XComponentContext; - } - namespace deployment { - class XPackage; - } -}}} - - - -class INetURLObject; - - -//......................................................................... -namespace migration -{ -//......................................................................... - - ::rtl::OUString SAL_CALL ExtensionMigration_getImplementationName(); - ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ExtensionMigration_getSupportedServiceNames(); - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ExtensionMigration_create( - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext ) - SAL_THROW( (::com::sun::star::uno::Exception) ); - - - // ============================================================================= - // class ExtensionMigration - // ============================================================================= - - typedef ::cppu::WeakImplHelper3< - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::lang::XInitialization, - ::com::sun::star::task::XJob > ExtensionMigration_BASE; - - class ExtensionMigration : public ExtensionMigration_BASE - { - private: - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_ctx; - ::osl::Mutex m_aMutex; - ::rtl::OUString m_sSourceDir; - ::rtl::OUString m_sTargetDir; - - ::xmlscript::LibDescriptorArray m_scriptElements; - ::xmlscript::LibDescriptorArray m_dialogElements; - - ::osl::FileBase::RC checkAndCreateDirectory( INetURLObject& rDirURL ); - void copyConfig( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ); - bool isCompatibleBerkleyDb(const ::rtl::OUString& sSourceDir); - bool copy( const ::rtl::OUString& sSourceDir, const ::rtl::OUString& sTargetDir ); - bool processExtensions( const ::rtl::OUString& sSourceDir, - const ::rtl::OUString& sTargetDir ); - /* fills m_scriptElements and m_dialogElements - */ - void prepareBasicLibs(); - void prepareBasicLibs(const ::rtl::OUString & sURL, - ::xmlscript::LibDescriptorArray & out_elements); - bool isBasicPackageEnabled( const ::com::sun::star::uno::Reference< - ::com::sun::star::deployment::XPackage > & xPkg); - void registerBasicPackage( - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & xPkg); - - public: - ExtensionMigration(::com::sun::star::uno::Reference< - ::com::sun::star::uno::XComponentContext > const & ctx); - virtual ~ExtensionMigration(); - - // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName() - throw (::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() - throw (::com::sun::star::uno::RuntimeException); - - // XInitialization - virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) - throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); - - // XJob - virtual ::com::sun::star::uno::Any SAL_CALL execute( - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments ) - throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, - ::com::sun::star::uno::RuntimeException); - }; - -//......................................................................... -} // namespace migration -//......................................................................... - -#endif // _DESKTOP_AUTOCORRMIGRATION_HXX_ diff --git a/desktop/source/migration/services/makefile.mk b/desktop/source/migration/services/makefile.mk index 55ecff6bc06f..2f3eb9308ebd 100644 --- a/desktop/source/migration/services/makefile.mk +++ b/desktop/source/migration/services/makefile.mk @@ -51,7 +51,6 @@ SLOFILES= \ $(SLO)$/cexports.obj \ $(SLO)$/basicmigration.obj \ $(SLO)$/wordbookmigration.obj \ - $(SLO)$/extensionmigration.obj \ $(SLO)$/autocorrmigration.obj \ $(SLO)$/oo3extensionmigration.obj \ $(SLO)$/cexportsoo3.obj @@ -61,7 +60,6 @@ SHL1OBJS= \ $(SLO)$/cexports.obj \ $(SLO)$/basicmigration.obj \ $(SLO)$/wordbookmigration.obj \ - $(SLO)$/extensionmigration.obj \ $(SLO)$/autocorrmigration.obj SHL1TARGET=$(TARGET) diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index 2d17a654b29b..37608a7b1276 100755 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -43,8 +43,6 @@ #include #include -#include -#include #include #include #include @@ -53,6 +51,7 @@ #include #include #include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -140,15 +139,15 @@ OO3ExtensionMigration::~OO3ExtensionMigration() } } -void OO3ExtensionMigration::registerConfigurationPackage( const uno::Reference< deployment::XPackage > & xPkg) -{ - const ::rtl::OUString sMediaType = xPkg->getPackageType()->getMediaType(); - if ( (sMediaType.equals(sConfigurationDataType) || sMediaType.equals(sConfigurationSchemaType) ) ) - { - xPkg->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); - } -} +//void OO3ExtensionMigration::registerConfigurationPackage( const uno::Reference< deployment::XPackage > & xPkg) +//{ +// const ::rtl::OUString sMediaType = xPkg->getPackageType()->getMediaType(); +// if ( (sMediaType.equals(sConfigurationDataType) || sMediaType.equals(sConfigurationSchemaType) ) ) +// { +// xPkg->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); +// xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); +// } +//} void OO3ExtensionMigration::scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ) { @@ -343,18 +342,17 @@ bool OO3ExtensionMigration::scanDescriptionXml( const ::rtl::OUString& sDescript bool OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir ) { - if ( !m_xPackageManager.is() ) + if ( !m_xExtensionManager.is() ) { try { - m_xPackageManager = deployment::thePackageManagerFactory::get( m_ctx )->getPackageManager( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "user" )) ); + m_xExtensionManager = deployment::ExtensionManager::get( m_ctx ); } catch ( ucb::CommandFailedException & ){} catch ( uno::RuntimeException & ) {} } - if ( m_xPackageManager.is() ) + if ( m_xExtensionManager.is() ) { try { @@ -364,8 +362,9 @@ bool OO3ExtensionMigration::migrateExtension( const ::rtl::OUString& sSourceDir static_cast< cppu::OWeakObject* >( pCmdEnv ), uno::UNO_QUERY ); uno::Reference< task::XAbortChannel > xAbortChannel; uno::Reference< deployment::XPackage > xPackage = - m_xPackageManager->addPackage( - sSourceDir, uno::Sequence(),::rtl::OUString(), xAbortChannel, xCmdEnv ); + m_xExtensionManager->addExtension( + sSourceDir, uno::Sequence(), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), xAbortChannel, xCmdEnv ); if ( xPackage.is() ) return true; diff --git a/desktop/source/migration/services/oo3extensionmigration.hxx b/desktop/source/migration/services/oo3extensionmigration.hxx index a001f41d92c5..7890eb86a75c 100755 --- a/desktop/source/migration/services/oo3extensionmigration.hxx +++ b/desktop/source/migration/services/oo3extensionmigration.hxx @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -83,7 +83,7 @@ namespace migration ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_ctx; ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XDocumentBuilder > m_xDocBuilder; ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > m_xSimpleFileAccess; - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > m_xPackageManager; + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; ::osl::Mutex m_aMutex; ::rtl::OUString m_sSourceDir; ::rtl::OUString m_sTargetDir; @@ -105,8 +105,8 @@ namespace migration bool migrateExtension( const ::rtl::OUString& sSourceDir ); /* fills m_scriptElements and m_dialogElements */ - void registerConfigurationPackage( - const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & xPkg); + //void registerConfigurationPackage( + // const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & xPkg); public: OO3ExtensionMigration(::com::sun::star::uno::Reference< -- cgit From fc05fb607569bf4eff1b37c7eba1fc4369702744 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Wed, 19 May 2010 11:00:36 +0200 Subject: jl152: #i108704# use all the arguments when restarting on Windows --- desktop/win32/source/officeloader/officeloader.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'desktop') diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx index ef980e1e994e..7c2dafc79bbb 100644 --- a/desktop/win32/source/officeloader/officeloader.cxx +++ b/desktop/win32/source/officeloader/officeloader.cxx @@ -212,7 +212,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) LPTSTR lpCommandLine = NULL; int argc = 0; LPTSTR * argv = NULL; - bool first = true; + bool bFirst = true; WCHAR cwd[MAX_PATH]; DWORD cwdLen = GetCurrentDirectoryW(MAX_PATH, cwd); if (cwdLen >= MAX_PATH) { @@ -318,7 +318,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) } } - if (first) { + if ( bFirst ) { argv = GetCommandArgs(&argc); std::size_t n = wcslen(argv[0]) + 2; for (int i = 1; i < argc; ++i) { @@ -334,7 +334,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) lpCommandLine, MY_STRING(L"\"")); p = desktop_win32::commandLineAppend(p, argv[0]); for (int i = 1; i < argc; ++i) { - if (first || wcsncmp(argv[i], MY_STRING(L"-env:")) == 0) { + if (bFirst || ::desktop::ExitHelper::E_NORMAL_RESTART == dwExitCode || wcsncmp(argv[i], MY_STRING(L"-env:")) == 0) { p = desktop_win32::commandLineAppend(p, MY_STRING(L"\" \"")); p = desktop_win32::commandLineAppend(p, argv[i]); } @@ -348,7 +348,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) p = desktop_win32::commandLineAppendEncoded(p, cwd); } desktop_win32::commandLineAppend(p, MY_STRING(L"\"")); - first = false; + bFirst = false; TCHAR szParentProcessId[64]; // This is more than large enough for a 128 bit decimal value BOOL bHeadlessMode( FALSE ); -- cgit From 7df75b6fe4c992f61c593dc33bb84ba537f05f99 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 20 May 2010 11:27:05 +0200 Subject: jl152 #i77196# registering basic item at startup did not work --- .../deployment/registry/configuration/dp_configuration.cxx | 1 - desktop/source/deployment/registry/script/dp_script.cxx | 2 +- desktop/source/migration/services/oo3extensionmigration.cxx | 12 +----------- desktop/source/migration/services/oo3extensionmigration.hxx | 4 ---- 4 files changed, 2 insertions(+), 17 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index f892c21a6a6b..9ea6e8227340 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -35,7 +35,6 @@ #include "dp_backend.h" #include "dp_persmap.h" #include "dp_ucb.h" -#include "dp_xml.h" #include "rtl/string.hxx" #include "rtl/ustrbuf.hxx" #include "rtl/uri.hxx" diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index 3a43e916e39e..edeae256cbaf 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -476,7 +476,7 @@ void BackendImpl::PackageImpl::processPackage_( } } bool bSuccess = bScript || bDialog; // Something must have happened - if( bRunning ) + if( bRunning && !startup) if( (bScript && !bScriptSuccess) || (bDialog && !bDialogSuccess) ) bSuccess = false; diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index 37608a7b1276..0b757212eaa6 100755 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -139,17 +139,7 @@ OO3ExtensionMigration::~OO3ExtensionMigration() } } -//void OO3ExtensionMigration::registerConfigurationPackage( const uno::Reference< deployment::XPackage > & xPkg) -//{ -// const ::rtl::OUString sMediaType = xPkg->getPackageType()->getMediaType(); -// if ( (sMediaType.equals(sConfigurationDataType) || sMediaType.equals(sConfigurationSchemaType) ) ) -// { -// xPkg->revokePackage(uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); -// xPkg->registerPackage(false, uno::Reference< task::XAbortChannel >(), uno::Reference< ucb::XCommandEnvironment> ()); -// } -//} - - void OO3ExtensionMigration::scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ) +void OO3ExtensionMigration::scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ) { osl::Directory aScanRootDir( sSourceDir ); osl::FileStatus fs(FileStatusMask_Type | FileStatusMask_FileURL); diff --git a/desktop/source/migration/services/oo3extensionmigration.hxx b/desktop/source/migration/services/oo3extensionmigration.hxx index 7890eb86a75c..7962da177217 100755 --- a/desktop/source/migration/services/oo3extensionmigration.hxx +++ b/desktop/source/migration/services/oo3extensionmigration.hxx @@ -103,10 +103,6 @@ namespace migration void scanUserExtensions( const ::rtl::OUString& sSourceDir, TStringVector& aMigrateExtensions ); bool scanDescriptionXml( const ::rtl::OUString& sDescriptionXmlFilePath ); bool migrateExtension( const ::rtl::OUString& sSourceDir ); - /* fills m_scriptElements and m_dialogElements - */ - //void registerConfigurationPackage( - // const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & xPkg); public: OO3ExtensionMigration(::com::sun::star::uno::Reference< -- cgit From 89b704f9db9ebbff43f6a423d2a1f17314de7a5c Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 21 May 2010 09:42:27 +0200 Subject: jl152 #i77196# XExtensionManager::synchronize now has no repository argument; adapted PackageInformationProvider to use bundled extensions --- .../deployment/manager/dp_extensionmanager.cxx | 90 +++++------ .../deployment/manager/dp_extensionmanager.hxx | 1 - .../deployment/manager/dp_informationprovider.cxx | 174 +++++++++------------ desktop/source/deployment/misc/dp_misc.cxx | 22 +-- 4 files changed, 109 insertions(+), 178 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index edc414dc6f5d..2781231b8f5e 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -116,6 +116,29 @@ OUString CompIdentifiers::getName(::std::vector > co OSL_ASSERT(extension.is()); return extension->getDisplayName(); } + +void writeLastModified(OUString & url, Reference const & xCmdEnv) +{ + //Write the lastmodified file + try { + ::rtl::Bootstrap::expandMacros(url); + ::ucbhelper::Content ucbStamp(url, xCmdEnv ); + dp_misc::erase_path( url, xCmdEnv ); + ::rtl::OString stamp("1" ); + Reference xData( + ::xmlscript::createInputStream( + ::rtl::ByteSequence( + reinterpret_cast(stamp.getStr()), + stamp.getLength() ) ) ); + ucbStamp.writeStream( xData, true /* replace existing */ ); + } + catch(...) + { + uno::Any exc(::cppu::getCaughtException()); + throw deploy::DeploymentException( + OUSTR("Failed to update") + url, 0, exc); + } +} } //end namespace namespace dp_manager { @@ -1021,7 +1044,6 @@ void ExtensionManager::reinstallDeployedExtensions( } sal_Bool ExtensionManager::synchronize( - OUString const & repository, Reference const & xAbortChannel, Reference const & xCmdEnv ) throw (deploy::DeploymentException, @@ -1033,37 +1055,20 @@ sal_Bool ExtensionManager::synchronize( try { sal_Bool bModified = sal_False; - Reference xPackageManager; - OUString file; - if (repository.equals(OUSTR("user"))) - { - xPackageManager = m_userRepository; - } - else if (repository.equals(OUSTR("shared"))) - { - xPackageManager = m_sharedRepository; - file = OUString ( - RTL_CONSTASCII_USTRINGPARAM( - "$SHARED_EXTENSIONS_USER/lastsynchronized")); - } - else if (repository.equals(OUSTR("bundled"))) - { - xPackageManager = m_bundledRepository; - file = OUString ( - RTL_CONSTASCII_USTRINGPARAM( - "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); - } - else - throw lang::IllegalArgumentException( - OUSTR("No valid repository name provided."), - static_cast(this), 0); ::osl::MutexGuard guard(getMutex()); - String sSynchronizing(StrSyncRepository::get()); - sSynchronizing.SearchAndReplaceAllAscii( "%NAME", repository ); - dp_misc::ProgressLevel progress(xCmdEnv, sSynchronizing); + String sSynchronizingShared(StrSyncRepository::get()); + sSynchronizingShared.SearchAndReplaceAllAscii( "%NAME", OUSTR("shared")); + dp_misc::ProgressLevel progressShared(xCmdEnv, sSynchronizingShared); + bModified = m_sharedRepository->synchronize(xAbortChannel, xCmdEnv); + progressShared.update(OUSTR("\n\n")); + + String sSynchronizingBundled(StrSyncRepository::get()); + sSynchronizingBundled.SearchAndReplaceAllAscii( "%NAME", OUSTR("bundled")); + dp_misc::ProgressLevel progressBundled(xCmdEnv, sSynchronizingBundled); + bModified |= m_bundledRepository->synchronize(xAbortChannel, xCmdEnv); + progressBundled.update(OUSTR("\n\n")); - bModified = xPackageManager->synchronize(xAbortChannel, xCmdEnv); try { const uno::Sequence > > @@ -1082,31 +1087,8 @@ sal_Bool ExtensionManager::synchronize( //so we will no repeat this everytime OOo starts. OSL_ENSURE(0, "Extensions Manager: synchronize"); } - - - progress.update(OUSTR("\n\n")); - - //Write the lastmodified file - try { - ::rtl::Bootstrap::expandMacros(file); - ::ucbhelper::Content ucbStamp(file, xCmdEnv ); - dp_misc::erase_path( file, xCmdEnv ); - ::rtl::OString stamp("1" ); - Reference xData( - ::xmlscript::createInputStream( - ::rtl::ByteSequence( - reinterpret_cast(stamp.getStr()), - stamp.getLength() ) ) ); - ucbStamp.writeStream( xData, true /* replace existing */ ); - } - catch(...) - { - uno::Any exc(::cppu::getCaughtException()); - throw deploy::DeploymentException( - OUSTR("Failed to update") + file, - static_cast(this), exc); - - } + writeLastModified(OUSTR("$BUNDLED_EXTENSIONS_USER/lastsynchronized"), xCmdEnv); + writeLastModified(OUSTR("$SHARED_EXTENSIONS_USER/lastsynchronized"), xCmdEnv); return bModified; } catch (deploy::DeploymentException& ) { throw; diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 4367770945aa..ad0e7d95df7e 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -186,7 +186,6 @@ public: css::uno::RuntimeException); virtual sal_Bool SAL_CALL synchronize( - ::rtl::OUString const & repository, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) throw (css::deployment::DeploymentException, diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx index 9f2e0c9e1177..537b7233ef77 100644 --- a/desktop/source/deployment/manager/dp_informationprovider.cxx +++ b/desktop/source/deployment/manager/dp_informationprovider.cxx @@ -32,11 +32,10 @@ #include "comphelper/servicedecl.hxx" -#include "com/sun/star/deployment/thePackageManagerFactory.hpp" #include "com/sun/star/deployment/UpdateInformationProvider.hpp" #include "com/sun/star/deployment/XPackage.hpp" #include "com/sun/star/deployment/XPackageInformationProvider.hpp" -#include "com/sun/star/deployment/XPackageManager.hpp" +#include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/deployment/XUpdateInformationProvider.hpp" #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/registry/XRegistryKey.hpp" @@ -104,7 +103,7 @@ private: uno::Reference< uno::XComponentContext> mxContext; - rtl::OUString getPackageLocation( const uno::Reference< deployment::XPackageManager > _xManager, + rtl::OUString getPackageLocation( const rtl::OUString& repository, const rtl::OUString& _sExtensionId ); uno::Reference< deployment::XUpdateInformationProvider > mxUpdateInformation; @@ -113,10 +112,9 @@ private: getUpdateInformation( uno::Sequence< rtl::OUString > const & urls, rtl::OUString const & identifier ) const; uno::Sequence< uno::Reference< deployment::XPackage > > - getPackages( const uno::Reference< deployment::XPackageManager > _xManager ); - uno::Sequence< uno::Sequence< rtl::OUString > > isUpdateAvailable( const uno::Reference< deployment::XPackageManager > _xManager, - const rtl::OUString& _sExtensionId ); - uno::Sequence< uno::Sequence< rtl::OUString > > getExtensionList( const uno::Reference< deployment::XPackageManager > _xManager ); + getPackages(rtl::OUString const & repository); + uno::Sequence< uno::Sequence< rtl::OUString > > isUpdateAvailable( + rtl::OUString const & repository, const rtl::OUString& _sExtensionId ); uno::Sequence< uno::Sequence< rtl::OUString > > concatLists( uno::Sequence< uno::Sequence< rtl::OUString > > aFirst, uno::Sequence< uno::Sequence< rtl::OUString > > aSecond ); }; @@ -148,15 +146,18 @@ void SAL_CALL PackageInformationProvider::handle( uno::Reference< task::XInterac //------------------------------------------------------------------------------ rtl::OUString PackageInformationProvider::getPackageLocation( - const uno::Reference< deployment::XPackageManager > _xManager, - const rtl::OUString& _rExtensionId ) + const rtl::OUString & repository, + const rtl::OUString& _rExtensionId ) { rtl::OUString aLocationURL; + uno::Reference xManager = + deployment::ExtensionManager::get(mxContext); - if ( _xManager.is() ) + if ( xManager.is() ) { const uno::Sequence< uno::Reference< deployment::XPackage > > packages( - _xManager->getDeployedPackages( + xManager->getDeployedExtensions( + repository, uno::Reference< task::XAbortChannel >(), static_cast < XCommandEnvironment *> (this) ) ); @@ -187,32 +188,21 @@ rtl::OUString SAL_CALL PackageInformationProvider::getPackageLocation( const rtl::OUString& _sExtensionId ) throw ( uno::RuntimeException ) { - uno::Reference< deployment::XPackageManager > xManager; - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} - - rtl::OUString aLocationURL = getPackageLocation( xManager, _sExtensionId ); + rtl::OUString aLocationURL = getPackageLocation( UNISTRING("user"), _sExtensionId ); if ( aLocationURL.getLength() == 0 ) { - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} - - aLocationURL = getPackageLocation( xManager, _sExtensionId ); + aLocationURL = getPackageLocation( UNISTRING("shared"), _sExtensionId ); + } + if ( aLocationURL.getLength() == 0 ) + { + aLocationURL = getPackageLocation( UNISTRING("bundled"), _sExtensionId ); } - if ( aLocationURL.getLength() ) { ::ucbhelper::Content aContent( aLocationURL, NULL ); aLocationURL = aContent.getURL(); } - return aLocationURL; } @@ -222,75 +212,76 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvider::isUpdateAvailable( const rtl::OUString& _sExtensionId ) throw ( uno::RuntimeException ) { - uno::Sequence< uno::Sequence< rtl::OUString > > aUpdateListUser; + uno::Sequence< uno::Sequence< rtl::OUString > > + aUpdateListUser = isUpdateAvailable( UNISTRING("user"), _sExtensionId ); - uno::Reference< deployment::XPackageManager > xManager; - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} + uno::Sequence< uno::Sequence< rtl::OUString > > + aUpdateListShared = isUpdateAvailable( UNISTRING("shared"), _sExtensionId ); - aUpdateListUser = isUpdateAvailable( xManager, _sExtensionId ); + uno::Sequence< uno::Sequence< rtl::OUString > > + aUpdateListBundled = isUpdateAvailable( UNISTRING("bundled"), _sExtensionId ); - uno::Sequence< uno::Sequence< rtl::OUString > > aUpdateListShared; - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} - - aUpdateListShared = isUpdateAvailable( xManager, _sExtensionId ); - - if ( !aUpdateListUser.hasElements() ) - return aUpdateListShared; - else if ( !aUpdateListShared.hasElements() ) - return aUpdateListUser; - else - return concatLists( aUpdateListUser, aUpdateListShared ); + uno::Sequence< uno::Sequence< rtl::OUString > > user_shared = + concatLists( aUpdateListUser, aUpdateListShared ); + return concatLists(user_shared, aUpdateListBundled); } //------------------------------------------------------------------------------ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvider::getExtensionList() throw ( uno::RuntimeException ) { - uno::Sequence< uno::Sequence< rtl::OUString > > aListUser; + const uno::Reference mgr = + deployment::ExtensionManager::get(mxContext); - uno::Reference< deployment::XPackageManager > xManager; - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("user") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} + if (!mgr.is()) + return uno::Sequence< uno::Sequence< rtl::OUString > >(); - aListUser = getExtensionList( xManager ); + const uno::Sequence< uno::Sequence< uno::Reference > > + allExt = mgr->getAllExtensions( + uno::Reference< task::XAbortChannel >(), + static_cast < XCommandEnvironment *> (this) ); - uno::Sequence< uno::Sequence< rtl::OUString > > aListShared; - try { - xManager = deployment::thePackageManagerFactory::get( mxContext )->getPackageManager( UNISTRING("shared") ); - } - catch ( css_ucb::CommandFailedException & ){} - catch ( uno::RuntimeException & ) {} + uno::Sequence< uno::Sequence< rtl::OUString > > retList; - aListShared = getExtensionList( xManager ); + sal_Int32 cAllIds = allExt.getLength(); + retList.realloc(cAllIds); - if ( !aListUser.hasElements() ) - return aListShared; - else if ( !aListShared.hasElements() ) - return aListUser; - else - return concatLists( aListUser, aListShared ); + for (sal_Int32 i = 0; i < cAllIds; i++) + { + //The inner sequence contains extensions with the same identifier from + //all the different repositories, that is user, share, bundled. + const uno::Sequence< uno::Reference< deployment::XPackage > > & + seqExtension = allExt[i]; + sal_Int32 cExt = seqExtension.getLength(); + OSL_ASSERT(cExt == 3); + for (sal_Int32 j = 0; j < cExt; j++) + { + //ToDo according to the old code the first found extenions is used + //even if another one with the same id has a better version. Design flaw? + uno::Reference< deployment::XPackage > const & xExtension( seqExtension[j] ); + if (xExtension.is()) + { + rtl::OUString aNewEntry[2]; + aNewEntry[0] = dp_misc::getIdentifier(xExtension); + aNewEntry[1] = xExtension->getVersion(); + retList[i] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 ); + break; + } + } + } + return retList; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ uno::Sequence< uno::Reference< deployment::XPackage > > - PackageInformationProvider::getPackages( const uno::Reference< deployment::XPackageManager > _xMgr ) +PackageInformationProvider::getPackages( const rtl::OUString & repository ) { uno::Sequence< uno::Reference< deployment::XPackage > > packages; try { - packages = _xMgr->getDeployedPackages( uno::Reference< task::XAbortChannel >(), + uno::Reference xMgr = deployment::ExtensionManager::get(mxContext); + packages = xMgr->getDeployedExtensions(repository, uno::Reference< task::XAbortChannel >(), static_cast < XCommandEnvironment *> (this) ); } catch ( deployment::DeploymentException & ) @@ -329,18 +320,19 @@ uno::Sequence< uno::Reference< xml::dom::XElement > > //------------------------------------------------------------------------------ uno::Sequence< uno::Sequence< rtl::OUString > > PackageInformationProvider::isUpdateAvailable( - const uno::Reference< deployment::XPackageManager > _xManager, - const rtl::OUString& _sExtensionId ) + const rtl::OUString& repository, + const rtl::OUString& _sExtensionId ) { uno::Sequence< uno::Sequence< rtl::OUString > > aList; sal_Int32 nCount = 0; bool bPackageFound = false; + uno::Reference xManager = deployment::ExtensionManager::get(mxContext); // If the package manager is readonly then the user cannot modify anything anyway // so we can abort the search here - if ( _xManager.is() && ! _xManager->isReadOnly() ) + if ( xManager.is() && ! xManager->isReadOnlyRepository(repository) ) { - uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( _xManager ) ); + uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( repository ) ); uno::Sequence< uno::Reference< xml::dom::XElement > > defaultInfos; for ( int pos = packages.getLength(); pos-- && !bPackageFound; ) @@ -412,32 +404,6 @@ uno::Sequence< uno::Sequence< rtl::OUString > > return aList; } -//------------------------------------------------------------------------------ -uno::Sequence< uno::Sequence< rtl::OUString > > - PackageInformationProvider::getExtensionList( - const uno::Reference< deployment::XPackageManager > _xManager ) -{ - uno::Sequence< uno::Sequence< rtl::OUString > > aList; - - if ( _xManager.is() ) - { - uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( _xManager ) ); - - aList.realloc( packages.getLength() ); - - for ( int pos = packages.getLength(); pos--; ) - { - uno::Reference< deployment::XPackage > package( packages[ pos ] ); - rtl::OUString aNewEntry[2]; - - aNewEntry[0] = dp_misc::getIdentifier( package ); - aNewEntry[1] = package->getVersion(); - aList[ pos ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 ); - } - } - return aList; -} - //------------------------------------------------------------------------------ uno::Sequence< uno::Sequence< rtl::OUString > > PackageInformationProvider::concatLists( uno::Sequence< uno::Sequence< rtl::OUString > > aFirst, diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 3867f741f982..5269e3d8aac5 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -603,8 +603,8 @@ void syncRepositories(Reference const & xCmdEnv) //synchronize shared before bundled otherewise there are //more revoke and registration calls. sal_Bool bModified = false; - const OUString sShared(RTL_CONSTASCII_USTRINGPARAM("shared")); - if (needToSyncRepostitory(sShared)) + if (needToSyncRepostitory(OUString(RTL_CONSTASCII_USTRINGPARAM("shared"))) + || needToSyncRepostitory(OUString(RTL_CONSTASCII_USTRINGPARAM("bundled")))) { xExtensionManager = deployment::ExtensionManager::get( @@ -613,23 +613,7 @@ void syncRepositories(Reference const & xCmdEnv) if (xExtensionManager.is()) { bModified = xExtensionManager->synchronize( - sShared, Reference(), xCmdEnv); - } - } - - const OUString sBundled(RTL_CONSTASCII_USTRINGPARAM("bundled")); - if (needToSyncRepostitory( sBundled)) - { - if (!xExtensionManager.is()) - { - xExtensionManager = - deployment::ExtensionManager::get( - comphelper_getProcessComponentContext()); - } - if (xExtensionManager.is()) - { - bModified |= xExtensionManager->synchronize( - sBundled, Reference(), xCmdEnv); + Reference(), xCmdEnv); } } -- cgit From 7668f1f0a853091d9e24d8dcce104e6081789a55 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 21 May 2010 15:13:26 +0200 Subject: jl152 #i77196# unopkg reinstall works now --- .../deployment/manager/dp_extensionmanager.cxx | 12 ++++++-- desktop/source/pkgchk/unopkg/unopkg_app.cxx | 34 ++++++++++++++++++---- 2 files changed, 39 insertions(+), 7 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 2781231b8f5e..fddefb5ad277 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -994,6 +994,7 @@ uno::Sequence< uno::Sequence > > } } +//only to be called from unopkg!!! void ExtensionManager::reinstallDeployedExtensions( OUString const & repository, Reference const & xAbortChannel, @@ -1009,6 +1010,9 @@ void ExtensionManager::reinstallDeployedExtensions( ::osl::MutexGuard guard(getMutex()); xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv); + //We must sync here, otherwise we will get exceptions when extensions + //are removed. + dp_misc::syncRepositories(xCmdEnv); const uno::Sequence< Reference > extensions( xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv)); @@ -1087,8 +1091,12 @@ sal_Bool ExtensionManager::synchronize( //so we will no repeat this everytime OOo starts. OSL_ENSURE(0, "Extensions Manager: synchronize"); } - writeLastModified(OUSTR("$BUNDLED_EXTENSIONS_USER/lastsynchronized"), xCmdEnv); - writeLastModified(OUSTR("$SHARED_EXTENSIONS_USER/lastsynchronized"), xCmdEnv); + OUString lastSyncBundled(RTL_CONSTASCII_USTRINGPARAM( + "$BUNDLED_EXTENSIONS_USER/lastsynchronized")); + writeLastModified(lastSyncBundled, xCmdEnv); + OUString lastSyncShared(RTL_CONSTASCII_USTRINGPARAM( + "$SHARED_EXTENSIONS_USER/lastsynchronized")); + writeLastModified(lastSyncShared, xCmdEnv); return bModified; } catch (deploy::DeploymentException& ) { throw; diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 2f4a7f1d7146..621b8b0bac7c 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -35,6 +35,7 @@ #include "tools/extendapplicationenvironment.hxx" #include "rtl/ustrbuf.hxx" #include "rtl/uri.hxx" +#include "rtl/bootstrap.hxx" #include "osl/thread.h" #include "osl/process.h" #include "osl/conditn.hxx" @@ -331,10 +332,6 @@ extern "C" int unopkg_main() } } - xComponentContext = getUNO( - disposeGuard, option_verbose, option_shared, subcmd_gui, - xLocalComponentContext ); - if (repository.getLength() == 0) { if (option_shared) @@ -359,6 +356,29 @@ extern "C" int unopkg_main() } } + if (subCommand.equals(OUSTR("reinstall"))) + { + //We must prevent that services and types are loaded by UNO, + //otherwise we cannot delete the registry data folder. + OUString extensionUnorc; + if (repository.equals(OUSTR("user"))) + extensionUnorc = OUSTR("$UNO_USER_PACKAGES_CACHE/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc"); + else if (repository.equals(OUSTR("shared"))) + extensionUnorc = OUSTR("$SHARED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc"); + else if (repository.equals(OUSTR("bundled"))) + extensionUnorc = OUSTR("$BUNDLED_EXTENSIONS_USER/registry/com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc"); + else + OSL_ASSERT(0); + + ::rtl::Bootstrap::expandMacros(extensionUnorc); + oslFileError e = osl_removeFile(extensionUnorc.pData); + if (e != osl_File_E_None && e != osl_File_E_NOENT) + throw Exception(OUSTR("Could not delete ") + extensionUnorc, 0); + } + + xComponentContext = getUNO( + disposeGuard, option_verbose, option_shared, subcmd_gui, + xLocalComponentContext ); Reference xExtensionManager( deployment::ExtensionManager::get( xComponentContext ) ); @@ -368,7 +388,11 @@ extern "C" int unopkg_main() option_force, option_verbose) ); //synchronize bundled/shared extensions - if (!subcmd_gui && ! dp_misc::office_is_running()) + //Do not synchronize when command is "reinstall". This could add types and services to UNO and + //prevent the deletion of the registry data folder + //synching is done in XExtensionManager.reinstall + if (!subcmd_gui && ! subCommand.equals(OUSTR("reinstall")) + && ! dp_misc::office_is_running()) dp_misc::syncRepositories(xCmdEnv); if (subcmd_add || -- cgit From 3d3b46bb623c859265d2b95068845b18a1b64716 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 21 May 2010 16:17:24 +0200 Subject: jl152 #i77196# dp_misc::sycnRepositories cannot be switched off with bootstrap variable, because it is not necessary fro the perfomance test --- desktop/source/app/check_ext_deps.cxx | 5 ----- 1 file changed, 5 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 757135a7e2d3..e9c71bc1ea36 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -396,10 +396,5 @@ sal_Bool Desktop::CheckExtensionDependencies() void Desktop::SynchronizeExtensionRepositories() { RTL_LOGFILE_CONTEXT(aLog,"desktop (jl) ::Desktop::SynchronizeExtensionRepositories"); - OUString sDisable; - ::rtl::Bootstrap::get( UNISTRING( "DISABLE_SYNC_EXTENSIONS" ), sDisable, OUString() ); - if (sDisable.getLength() > 0) - return; - dp_misc::syncRepositories( new SilentCommandEnv( this ) ); } -- cgit 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 --- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 27 +- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 22 +- .../deployment/gui/dp_gui_extensioncmdqueue.hxx | 3 +- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 19 +- desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 3 +- .../source/deployment/gui/dp_gui_updatedata.hxx | 35 ++- .../source/deployment/gui/dp_gui_updatedialog.cxx | 331 ++++++++++++++------- .../source/deployment/gui/dp_gui_updatedialog.hxx | 20 +- .../source/deployment/gui/dp_gui_updatedialog.src | 12 - .../deployment/gui/dp_gui_updateinstalldialog.cxx | 43 ++- desktop/source/deployment/inc/dp_misc.h | 46 +++ .../deployment/manager/dp_extensionmanager.cxx | 77 ++++- .../deployment/manager/dp_extensionmanager.hxx | 15 +- .../source/deployment/manager/dp_properties.cxx | 44 ++- .../source/deployment/manager/dp_properties.hxx | 5 + desktop/source/deployment/misc/dp_misc.cxx | 142 +++++++++ 16 files changed, 635 insertions(+), 209 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 086e39e5f18c..35634d5ef851 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -38,6 +38,7 @@ #include "dp_gui_shared.hxx" #include "dp_gui_theextmgr.hxx" #include "dp_misc.h" +#include "dp_identifier.hxx" #include "vcl/ctrl.hxx" #include "vcl/menu.hxx" @@ -105,15 +106,6 @@ struct StrAllFiles : public rtl::StaticWithInit< const OUString, StrAllFiles > } }; -//------------------------------------------------------------------------------ -UpdateListEntry::UpdateListEntry( const uno::Reference< deployment::XPackage > &xPackage ) : - m_xPackage( xPackage ) -{} - -//------------------------------------------------------------------------------ -UpdateListEntry::~UpdateListEntry() -{} - //------------------------------------------------------------------------------ // ExtBoxWithBtns_Impl //------------------------------------------------------------------------------ @@ -849,9 +841,15 @@ bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackage > & if ( !xPackage.is() ) return false; - std::vector< TUpdateListEntry > vEntries; - TUpdateListEntry pEntry( new UpdateListEntry( xPackage ) ); - vEntries.push_back( pEntry ); + // get the extension with highest version + uno::Sequence > seqExtensions = + m_pManager->getExtensionManager()->getExtensionsWithSameIdentifier( + dp_misc::getIdentifier(xPackage), xPackage->getName(), uno::Reference()); + uno::Reference extension = + dp_misc::getExtensionWithHighestVersion(seqExtensions); + OSL_ASSERT(extension.is()); + std::vector< css::uno::Reference< css::deployment::XPackage > > vEntries; + vEntries.push_back(extension); m_pManager->updatePackages( vEntries ); @@ -1453,14 +1451,13 @@ IMPL_LINK( UpdateRequiredDialog, HandleUpdateBtn, void*, EMPTYARG ) { ::osl::ClearableMutexGuard aGuard( m_aMutex ); - std::vector< TUpdateListEntry > vUpdateEntries; + std::vector< uno::Reference< deployment::XPackage > > vUpdateEntries; sal_Int32 nCount = m_pExtensionBox->GetEntryCount(); for ( sal_Int32 i = 0; i < nCount; ++i ) { TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( i ); - TUpdateListEntry pUpdateEntry( new UpdateListEntry( pEntry->m_xPackage ) ); - vUpdateEntries.push_back( pUpdateEntry ); + vUpdateEntries.push_back( pEntry->m_xPackage ); } aGuard.clear(); diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 8d82d969c4a0..954f32f4c9c6 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -202,7 +202,7 @@ struct ExtensionCmd OUString m_sExtensionURL; OUString m_sRepository; uno::Reference< deployment::XPackage > m_xPackage; - std::vector< TUpdateListEntry > m_vExtensionList; + std::vector< uno::Reference< deployment::XPackage > > m_vExtensionList; ExtensionCmd( const E_CMD_TYPE eCommand, const OUString &rExtensionURL, @@ -218,7 +218,7 @@ struct ExtensionCmd m_bWarnUser( false ), m_xPackage( rPackage ) {}; ExtensionCmd( const E_CMD_TYPE eCommand, - const std::vector< TUpdateListEntry > &vExtensionList ) + const std::vector > &vExtensionList ) : m_eCmdType( eCommand ), m_bWarnUser( false ), m_vExtensionList( vExtensionList ) {}; @@ -240,7 +240,7 @@ public: void removeExtension( const uno::Reference< deployment::XPackage > &rPackage ); void enableExtension( const uno::Reference< deployment::XPackage > &rPackage, const bool bEnable ); - void checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ); + void checkForUpdates( const std::vector > &vExtensionList ); void stop(); bool isBusy(); @@ -266,7 +266,7 @@ private: const uno::Reference< deployment::XPackage > &xPackage ); void _disableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, const uno::Reference< deployment::XPackage > &xPackage ); - void _checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ); + void _checkForUpdates( const std::vector > &vExtensionList ); enum Input { NONE, START, STOP }; @@ -696,7 +696,8 @@ void ExtensionCmdQueue::Thread::enableExtension( const uno::Reference< deploymen } //------------------------------------------------------------------------------ -void ExtensionCmdQueue::Thread::checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ) +void ExtensionCmdQueue::Thread::checkForUpdates( + const std::vector > &vExtensionList ) { ::osl::MutexGuard aGuard( m_mutex ); @@ -924,10 +925,8 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv try { - uno::Reference< deployment::XPackage > xPackage( - xExtMgr->addExtension(rPackageURL, uno::Sequence(), - rRepository, xAbortChannel, rCmdEnv.get() ) ); - OSL_ASSERT( xPackage.is() ); + xExtMgr->addExtension(rPackageURL, uno::Sequence(), + rRepository, xAbortChannel, rCmdEnv.get() ); } catch ( ucb::CommandFailedException & ) { @@ -969,7 +968,8 @@ void ExtensionCmdQueue::Thread::_removeExtension( ::rtl::Reference< ProgressCmdE } //------------------------------------------------------------------------------ -void ExtensionCmdQueue::Thread::_checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ) +void ExtensionCmdQueue::Thread::_checkForUpdates( + const std::vector > &vExtensionList ) { UpdateDialog* pUpdateDialog; std::vector< UpdateData > vData; @@ -1126,7 +1126,7 @@ void ExtensionCmdQueue::enableExtension( const uno::Reference< deployment::XPack m_thread->enableExtension( rPackage, bEnable ); } -void ExtensionCmdQueue::checkForUpdates( const std::vector< TUpdateListEntry > &vExtensionList ) +void ExtensionCmdQueue::checkForUpdates( const std::vector > &vExtensionList ) { m_thread->checkForUpdates( vExtensionList ); } diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx index 69ad7da24769..cfadad84cedc 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx @@ -83,7 +83,8 @@ public: void removeExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage ); void enableExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage, const bool bEnable ); - void checkForUpdates( const std::vector< TUpdateListEntry > &vList ); + void checkForUpdates(const std::vector< ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage > > &vList ); /** This call does not block. It signals the internal thread that it should install the remaining extensions and then terminate. diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 7c81517bbbfa..fdbc1974f61c 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -201,7 +201,7 @@ bool TheExtensionManager::isVisible() //------------------------------------------------------------------------------ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bParentVisible*/ ) { - std::vector< TUpdateListEntry > vEntries; + std::vector< uno::Reference< deployment::XPackage > > vEntries; uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; try { @@ -219,17 +219,11 @@ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bPare for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) { - uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; - - // we don't want update notifications for bundled packages - for ( sal_Int32 j = 0; ( j < 2 ) && ( j < xPackageList.getLength() ); ++j ) + uno::Reference< deployment::XPackage > xPackage = dp_misc::getExtensionWithHighestVersion(xAllPackages[i]); + OSL_ASSERT(xPackage.is()); + if ( xPackage.is() ) { - uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; - if ( xPackage.is() ) - { - TUpdateListEntry pEntry( new UpdateListEntry( xPackage ) ); - vEntries.push_back( pEntry ); - } + vEntries.push_back( xPackage ); } } @@ -255,7 +249,8 @@ bool TheExtensionManager::removePackage( const uno::Reference< deployment::XPack } //------------------------------------------------------------------------------ -bool TheExtensionManager::updatePackages( const std::vector< TUpdateListEntry > &vList ) +bool TheExtensionManager::updatePackages( + const std::vector< uno::Reference< deployment::XPackage > > &vList ) { m_pExecuteCmdQueue->checkForUpdates( vList ); diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx index 02e3aad56915..da8d3c083f42 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -92,7 +92,8 @@ public: //----------------- bool checkUpdates( bool showUpdateOnly, bool parentVisible ); - bool updatePackages( const std::vector< TUpdateListEntry > &vList ); + bool updatePackages( const std::vector< ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage > > &vList ); bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); diff --git a/desktop/source/deployment/gui/dp_gui_updatedata.hxx b/desktop/source/deployment/gui/dp_gui_updatedata.hxx index 2082b92e923a..7228982da518 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedata.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedata.hxx @@ -44,27 +44,42 @@ namespace com { namespace sun { namespace star { namespace xml { namespace dom { namespace dp_gui { -struct UpdateListEntry +struct UpdateData { - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> m_xPackage; + UpdateData( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > const & aExt): + aInstalledPackage(aExt), bIsShared(false) {}; - UpdateListEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); - ~UpdateListEntry(); -}; + //When entries added to the listbox then there can be one for the user update and one + //for the shared update. However, both list entries will contain the same UpdateData. + //isShared is used to indicate which one is used for the shared entry. + bool bIsShared; -typedef ::boost::shared_ptr< UpdateListEntry > TUpdateListEntry; + //The currently installed extension which is going to be updated. If the extension exist in + //multiple repositories then it is the one with the highest version. + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > aInstalledPackage; + //The version of the update + ::rtl::OUString updateVersion; -struct UpdateData -{ - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > aInstalledPackage; - // The content of the update information + //For online update + // ====================== + // The content of the update information. + //Only if aUpdateInfo is set then there is an online update available with a better version + //than any of the currently installed extensions with the same identifier. ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > aUpdateInfo; //The URL of the locally downloaded extension. It will only be set if there were no errors //during the download ::rtl::OUString sLocalURL; //The URL of the website wher the download can be obtained. ::rtl::OUString sWebsiteURL; + + //For local update + //===================== + //The locale extension which is used as update for the user or shared repository. + //If set then the data for the online update (aUpdateInfo, sLocalURL, sWebsiteURL) + //are to be ignored. + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > + aUpdateSource; }; } diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index fca7d97c798a..d121ad976a06 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -151,7 +151,6 @@ rtl::OUString confineToParagraph(rtl::OUString const & text) { struct UpdateDialog::DisabledUpdate { rtl::OUString name; css::uno::Sequence< rtl::OUString > unsatisfiedDependencies; - bool permission; // We also want to show release notes and publisher for disabled updates ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > aUpdateInfo; }; @@ -230,7 +229,7 @@ public: Thread( css::uno::Reference< css::uno::XComponentContext > const & context, UpdateDialog & dialog, - const std::vector< TUpdateListEntry > &vExtensionList); + const std::vector< css::uno::Reference< css::deployment::XPackage > > & vExtensionList); void stop(); @@ -245,10 +244,16 @@ private: css::uno::Reference< css::deployment::XPackage > package; rtl::OUString version; + //Indicates that the extension provides its own update URLs. + //If this is true, then we must not use the default update + //URL to find the update information. + bool bProvidesOwnUpdate; css::uno::Reference< css::xml::dom::XNode > info; + UpdateDialog::DisabledUpdate disableUpdate; + dp_gui::UpdateData updateData; }; - // A multimap in case an extension is installed in both "user" and "shared": + // A multimap in case an extension is installed in "user", "shared" or "bundled" typedef std::multimap< rtl::OUString, Entry > Map; virtual ~Thread(); @@ -267,17 +272,26 @@ private: css::uno::Sequence< rtl::OUString > const & urls, rtl::OUString const & identifier) const; - void handle( + void getOwnUpdateInformation( css::uno::Reference< css::deployment::XPackage > const & package, Map * map); + ::rtl::OUString getUpdateDisplayString( + dp_gui::UpdateData const & data, ::rtl::OUString const & version = ::rtl::OUString()) const; + + void prepareUpdateData( + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > const & package, + ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & updateInfo, + UpdateDialog::DisabledUpdate & out_du, + dp_gui::UpdateData & out_data) const; + bool update( - css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::xml::dom::XNode > const & updateInfo) const; + UpdateDialog::DisabledUpdate const & du, + dp_gui::UpdateData const & data) const; css::uno::Reference< css::uno::XComponentContext > m_context; UpdateDialog & m_dialog; - std::vector< dp_gui::TUpdateListEntry > m_vExtensionList; + std::vector< css::uno::Reference< css::deployment::XPackage > > m_vExtensionList; css::uno::Reference< css::deployment::XUpdateInformationProvider > m_updateInformation; css::uno::Reference< css::task::XInteractionHandler > m_xInteractionHdl; @@ -289,7 +303,7 @@ private: UpdateDialog::Thread::Thread( css::uno::Reference< css::uno::XComponentContext > const & context, UpdateDialog & dialog, - const std::vector< dp_gui::TUpdateListEntry > &vExtensionList): + const std::vector< css::uno::Reference< css::deployment::XPackage > > &vExtensionList): m_context(context), m_dialog(dialog), m_vExtensionList(vExtensionList), @@ -328,9 +342,13 @@ void UpdateDialog::Thread::stop() { UpdateDialog::Thread::Entry::Entry( css::uno::Reference< css::deployment::XPackage > const & thePackage, rtl::OUString const & theVersion): + package(thePackage), - version(theVersion) -{} + version(theVersion), + bProvidesOwnUpdate(false), + updateData(thePackage) +{ +} UpdateDialog::Thread::~Thread() { @@ -343,10 +361,10 @@ void UpdateDialog::Thread::execute() OSL_ASSERT( ! m_vExtensionList.empty() ); Map map; - typedef std::vector< TUpdateListEntry >::const_iterator ITER; + typedef std::vector< css::uno::Reference< css::deployment::XPackage > >::const_iterator ITER; for ( ITER iIndex = m_vExtensionList.begin(); iIndex < m_vExtensionList.end(); ++iIndex ) { - css::uno::Reference< css::deployment::XPackage > p = (*iIndex)->m_xPackage; + css::uno::Reference< css::deployment::XPackage > p = *iIndex; if ( p.is() ) { { @@ -355,47 +373,113 @@ void UpdateDialog::Thread::execute() return; } } - handle( p, &map ); + getOwnUpdateInformation( p, &map ); } } - if (!map.empty()) { - const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL()); - if (sDefaultURL.getLength()) - { - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > - infos( - getUpdateInformation( - css::uno::Reference< css::deployment::XPackage >(), - css::uno::Sequence< rtl::OUString >(&sDefaultURL, 1), rtl::OUString())); - for (sal_Int32 i = 0; i < infos.getLength(); ++i) { - css::uno::Reference< css::xml::dom::XNode > node( - infos[i], css::uno::UNO_QUERY_THROW); - dp_misc::DescriptionInfoset infoset(m_context, node); - boost::optional< rtl::OUString > id(infoset.getIdentifier()); - if (!id) { - continue; - } - Map::iterator end(map.upper_bound(*id)); - for (Map::iterator j(map.lower_bound(*id)); j != end; ++j) { - rtl::OUString v(infoset.getVersion()); - if (dp_misc::compareVersions(v, j->second.version) == - dp_misc::GREATER) - { - j->second.version = v; - j->second.info = node; - } - } + const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL()); + if (sDefaultURL.getLength()) + { + css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > + infos( + getUpdateInformation( + css::uno::Reference< css::deployment::XPackage >(), + css::uno::Sequence< rtl::OUString >(&sDefaultURL, 1), rtl::OUString())); + for (sal_Int32 i = 0; i < infos.getLength(); ++i) { + css::uno::Reference< css::xml::dom::XNode > node( + infos[i], css::uno::UNO_QUERY_THROW); + dp_misc::DescriptionInfoset infoset(m_context, node); + boost::optional< rtl::OUString > id(infoset.getIdentifier()); + if (!id) { + continue; } - for (Map::const_iterator i(map.begin()); i != map.end(); ++i) { - if (i->second.info.is() && - !update( i->second.package, i->second.info )) + Map::iterator end(map.upper_bound(*id)); + for (Map::iterator j(map.lower_bound(*id)); j != end; ++j) { + //skip those extension which provide its own update urls + if (j->second.bProvidesOwnUpdate) + continue; + rtl::OUString v(infoset.getVersion()); + //look for the highest version in the online repository + if (dp_misc::compareVersions(v, j->second.version) == + dp_misc::GREATER) { - break; + j->second.version = v; + j->second.info = node; } } } } + + css::uno::Reference extMgr = + css::deployment::ExtensionManager::get(m_context); + for (Map::iterator i(map.begin()); i != map.end(); ++i) + { + //determine if online updates meet the requirements + prepareUpdateData(i->second.package, i->second.info, + i->second.disableUpdate, i->second.updateData); + + //determine if the update is installed in the user or shared repository + rtl::OUString sOnlineVersion; + if (i->second.updateData.aUpdateInfo.is()) + sOnlineVersion = i->second.version; + + rtl::OUString sVersionUser; + rtl::OUString sVersionShared; + rtl::OUString sVersionBundled; + css::uno::Sequence< css::uno::Reference< css::deployment::XPackage> > extensions; + try { + extensions = extMgr->getExtensionsWithSameIdentifier( + dp_misc::getIdentifier(i->second.package), i->second.package->getName(), + css::uno::Reference()); + } catch (css::lang::IllegalArgumentException& ) { + OSL_ASSERT(0); + } + OSL_ASSERT(extensions.getLength() == 3); + if (extensions[0].is() ) + sVersionUser = extensions[0]->getVersion(); + if (extensions[1].is() ) + sVersionShared = extensions[1]->getVersion(); + if (extensions[2].is() ) + sVersionBundled = extensions[2]->getVersion(); + + bool bSharedReadOnly = extMgr->isReadOnlyRepository(OUSTR("shared")); + + dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension( + bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion); + dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension( + bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion); + + css::uno::Reference updateSource; + if (sourceUser != dp_misc::UPDATE_SOURCE_NONE) + { + if (sourceUser == dp_misc::UPDATE_SOURCE_SHARED) + { + i->second.updateData.aUpdateSource = extensions[1]; + i->second.updateData.updateVersion = extensions[1]->getVersion(); + } + else if (sourceUser == dp_misc::UPDATE_SOURCE_BUNDLED) + { + i->second.updateData.aUpdateSource = extensions[2]; + i->second.updateData.updateVersion = extensions[2]->getVersion(); + } + if (!update(i->second.disableUpdate, i->second.updateData)) + return; + } + + if (sourceShared != dp_misc::UPDATE_SOURCE_NONE) + { + if (sourceShared == dp_misc::UPDATE_SOURCE_BUNDLED) + { + i->second.updateData.aUpdateSource = extensions[2]; + i->second.updateData.updateVersion = extensions[2]->getVersion(); + } + i->second.updateData.bIsShared = true; + if (!update(i->second.disableUpdate, i->second.updateData)) + return; + } + } + + vos::OGuard g(Application::GetSolarMutex()); if (!m_stop) { m_dialog.checkingDone(); @@ -454,7 +538,7 @@ UpdateDialog::Thread::getUpdateInformation( css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >(); } -void UpdateDialog::Thread::handle( +void UpdateDialog::Thread::getOwnUpdateInformation( css::uno::Reference< css::deployment::XPackage > const & package, Map * map) { @@ -464,11 +548,11 @@ void UpdateDialog::Thread::handle( if (urls.getLength() == 0) { map->insert( Map::value_type( - id, Entry(package, package->getVersion()))); + id, Entry(package, OUSTR("")))); } else { css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > infos(getUpdateInformation(package, urls, id)); - rtl::OUString latestVersion(package->getVersion()); + rtl::OUString latestVersion; sal_Int32 latestIndex = -1; for (sal_Int32 i = 0; i < infos.getLength(); ++i) { dp_misc::DescriptionInfoset infoset( @@ -490,80 +574,102 @@ void UpdateDialog::Thread::handle( } } if (latestIndex != -1) { - update( package, - css::uno::Reference< css::xml::dom::XNode >( - infos[latestIndex], css::uno::UNO_QUERY_THROW)); + Entry e(package, latestVersion); + e.info = css::uno::Reference< css::xml::dom::XNode >( + infos[latestIndex], css::uno::UNO_QUERY_THROW); + e.bProvidesOwnUpdate = true; + map->insert(Map::value_type(id, e)); } } } -bool UpdateDialog::Thread::update( - css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Reference< css::xml::dom::XNode > const & updateInfo) const +::rtl::OUString UpdateDialog::Thread::getUpdateDisplayString( + dp_gui::UpdateData const & data, ::rtl::OUString const & version) const { - dp_misc::DescriptionInfoset infoset(m_context, updateInfo); - OSL_ASSERT(infoset.getVersion().getLength() != 0); - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > ds( - dp_misc::Dependencies::check(infoset)); - - UpdateDialog::DisabledUpdate du; - du.aUpdateInfo = updateInfo; - du.unsatisfiedDependencies.realloc(ds.getLength()); - for (sal_Int32 i = 0; i < ds.getLength(); ++i) { - du.unsatisfiedDependencies[i] = dp_misc::Dependencies::getErrorText(ds[i]); - } - du.permission = ! m_dialog.isReadOnly( package ); - const ::boost::optional< ::rtl::OUString> updateWebsiteURL(infoset.getLocalizedUpdateWebsiteURL()); - rtl::OUStringBuffer b(package->getDisplayName()); + OSL_ASSERT(data.aInstalledPackage.is()); + rtl::OUStringBuffer b(data.aInstalledPackage->getDisplayName()); b.append(static_cast< sal_Unicode >(' ')); { vos::OGuard g( Application::GetSolarMutex() ); - if ( m_stop ) - return !m_stop; - else - b.append(m_dialog.m_version); + b.append(m_dialog.m_version); } b.append(static_cast< sal_Unicode >(' ')); - b.append(infoset.getVersion()); - if (updateWebsiteURL) + if (version.getLength()) + b.append(version); + else + b.append(data.updateVersion); + + if (data.sWebsiteURL.getLength()) { b.append(static_cast< sal_Unicode >(' ')); { vos::OGuard g( Application::GetSolarMutex() ); - if ( m_stop ) - return !m_stop; - else - b.append(m_dialog.m_browserbased); + b.append(m_dialog.m_browserbased); } } - du.name = b.makeStringAndClear(); + return b.makeStringAndClear(); +} + +/** out_data will only be filled if all dependencies are ok. + */ +void UpdateDialog::Thread::prepareUpdateData( + css::uno::Reference< css::deployment::XPackage > const & package, + css::uno::Reference< css::xml::dom::XNode > const & updateInfo, + UpdateDialog::DisabledUpdate & out_du, + dp_gui::UpdateData & out_data) const +{ + if (!updateInfo.is()) + return; + dp_misc::DescriptionInfoset infoset(m_context, updateInfo); + OSL_ASSERT(infoset.getVersion().getLength() != 0); + css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > ds( + dp_misc::Dependencies::check(infoset)); + + out_du.aUpdateInfo = updateInfo; + out_du.unsatisfiedDependencies.realloc(ds.getLength()); + for (sal_Int32 i = 0; i < ds.getLength(); ++i) { + out_du.unsatisfiedDependencies[i] = dp_misc::Dependencies::getErrorText(ds[i]); + } + + const ::boost::optional< ::rtl::OUString> updateWebsiteURL(infoset.getLocalizedUpdateWebsiteURL()); + + out_du.name = getUpdateDisplayString(out_data, infoset.getVersion()); - if (du.unsatisfiedDependencies.getLength() == 0 && du.permission) + if (out_du.unsatisfiedDependencies.getLength() == 0) { - dp_gui::UpdateData data; - data.aInstalledPackage = package; - data.aUpdateInfo = updateInfo; + out_data.aUpdateInfo = updateInfo; + out_data.updateVersion = infoset.getVersion(); if (updateWebsiteURL) - data.sWebsiteURL = *updateWebsiteURL; + out_data.sWebsiteURL = *updateWebsiteURL; + } +} + +bool UpdateDialog::Thread::update( + UpdateDialog::DisabledUpdate const & du, + dp_gui::UpdateData const & data) const +{ + if (du.unsatisfiedDependencies.getLength() == 0) + { vos::OGuard g(Application::GetSolarMutex()); if (!m_stop) { - m_dialog.addEnabledUpdate(du.name, data); + m_dialog.addEnabledUpdate(getUpdateDisplayString(data), data); } return !m_stop; } else { vos::OGuard g(Application::GetSolarMutex()); if (!m_stop) { - m_dialog.addDisabledUpdate(du); + m_dialog.addDisabledUpdate(du); } return !m_stop; } + return true; } // UpdateDialog ---------------------------------------------------------- UpdateDialog::UpdateDialog( css::uno::Reference< css::uno::XComponentContext > const & context, Window * parent, - const std::vector< dp_gui::TUpdateListEntry > &vExtensionList, + const std::vector > &vExtensionList, std::vector< dp_gui::UpdateData > * updateData): ModalDialog(parent,DpGuiResId(RID_DLG_UPDATE)), m_context(context), @@ -593,8 +699,6 @@ UpdateDialog::UpdateDialog( m_noInstall(String(DpGuiResId(RID_DLG_UPDATE_NOINSTALL))), m_noDependency(String(DpGuiResId(RID_DLG_UPDATE_NODEPENDENCY))), m_noDependencyCurVer(String(DpGuiResId(RID_DLG_UPDATE_NODEPENDENCY_CUR_VER))), - m_noPermission(String(DpGuiResId(RID_DLG_UPDATE_NOPERMISSION))), - m_noPermissionVista(String(DpGuiResId(RID_DLG_UPDATE_NOPERMISSION_VISTA))), m_browserbased(String(DpGuiResId(RID_DLG_UPDATE_BROWSERBASED))), m_version(String(DpGuiResId(RID_DLG_UPDATE_VERSION))), m_updateData(*updateData), @@ -651,9 +755,6 @@ UpdateDialog::UpdateDialog( if ( ! dp_misc::office_is_running()) m_help.Disable(); FreeResource(); - String sTemp(m_noPermissionVista); - sTemp.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() ); - m_noPermissionVista = sTemp; initDescription(); } @@ -983,12 +1084,25 @@ void UpdateDialog::clearDescription() bool UpdateDialog::showDescription(css::uno::Reference< css::xml::dom::XNode > const & aUpdateInfo) { dp_misc::DescriptionInfoset infoset(m_context, aUpdateInfo); - std::pair< rtl::OUString, rtl::OUString > pairPub = infoset.getLocalizedPublisherNameAndURL(); - rtl::OUString sPub = pairPub.first; - rtl::OUString sURL = pairPub.second; - rtl::OUString sRel = infoset.getLocalizedReleaseNotesURL(); + return showDescription(infoset.getLocalizedPublisherNameAndURL(), + infoset.getLocalizedReleaseNotesURL()); +} + +bool UpdateDialog::showDescription(css::uno::Reference< css::deployment::XPackage > const & aExtension) +{ + OSL_ASSERT(aExtension.is()); + css::beans::StringPair pubInfo = aExtension->getPublisherInfo(); + return showDescription(std::make_pair(pubInfo.First, pubInfo.Second), + OUSTR("")); +} - if ( sPub.getLength() == 0 && sURL.getLength() == 0 && sRel.getLength() == 0 ) +bool UpdateDialog::showDescription(std::pair< rtl::OUString, rtl::OUString > const & pairPublisher, + rtl::OUString const & sReleaseNotes) +{ + rtl::OUString sPub = pairPublisher.first; + rtl::OUString sURL = pairPublisher.second; + + if ( sPub.getLength() == 0 && sURL.getLength() == 0 && sReleaseNotes.getLength() == 0 ) // nothing to show return false; @@ -1002,7 +1116,7 @@ bool UpdateDialog::showDescription(css::uno::Reference< css::xml::dom::XNode > c bPublisher = true; } - if ( sRel.getLength() > 0 ) + if ( sReleaseNotes.getLength() > 0 ) { if ( !bPublisher ) { @@ -1011,7 +1125,7 @@ bool UpdateDialog::showDescription(css::uno::Reference< css::xml::dom::XNode > c } m_ReleaseNotesLabel.Show(); m_ReleaseNotesLink.Show(); - m_ReleaseNotesLink.SetURL( sRel ); + m_ReleaseNotesLink.SetURL( sReleaseNotes ); } return true; } @@ -1069,7 +1183,12 @@ IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG) const std::vector< UpdateDialog::DisabledUpdate >::size_type sizeDisabled = m_disabledUpdates.size(); if (pos < sizeEnabled) - bInserted = showDescription(m_enabledUpdates[pos].aUpdateInfo); + { + if (m_enabledUpdates[pos].aUpdateSource.is()) + bInserted = showDescription(m_enabledUpdates[pos].aUpdateSource); + else + bInserted = showDescription(m_enabledUpdates[pos].aUpdateInfo); + } else if (pos >= sizeEnabled && pos < (sizeEnabled + sizeDisabled)) bInserted = showDescription(m_disabledUpdates[pos - sizeEnabled].aUpdateInfo); @@ -1115,16 +1234,6 @@ IMPL_LINK(UpdateDialog, selectionHandler, void *, EMPTYARG) b.appendAscii(RTL_CONSTASCII_STRINGPARAM(" ")); b.append(m_noDependencyCurVer); } - if (!data.permission) { - if (b.getLength() == 0) { - b.append(m_noInstall); - } - b.append(LF); - if (isVista()) - b.append(m_noPermissionVista); - else - b.append(m_noPermission); - } break; } case GENERAL_ERROR: @@ -1231,7 +1340,7 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG) OSL_ASSERT(i->aInstalledPackage.is()); //If the user has no write access to the shared folder then the update //for a shared extension is disable, that is it cannot be in m_enabledUpdates - OSL_ASSERT(isReadOnly(i->aInstalledPackage) == sal_False); +// OSL_ASSERT(isReadOnly(i->aInstalledPackage) == sal_False); #if 0 // TODO: check! OSL_ASSERT(m_extensionManagerDialog.get()); @@ -1243,6 +1352,7 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG) #endif } + for (USHORT i = 0; i < m_updates.getItemCount(); ++i) { UpdateDialog::Index const * p = static_cast< UpdateDialog::Index const * >( @@ -1251,6 +1361,7 @@ IMPL_LINK(UpdateDialog, okHandler, void *, EMPTYARG) m_updateData.push_back(m_enabledUpdates[p->index.enabledUpdate]); } } + EndDialog(RET_OK); return 0; } diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx index 1e72b22a68c7..32c317cb8735 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx @@ -83,16 +83,17 @@ public: @param parent the parent window, may be null - @param selectedPackages - if non-null, only check for updates for the selected packages - - @param packageManagers - if non-null, check for updates for all managed packages + @param vExtensionList + check for updates for the contained extensions. There must only be one extension with + a particular identifier. If one extension is installed in several repositories, then the + one with the highest version must be used, because it contains the latest known update + information. */ UpdateDialog( com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context, Window * parent, - const std::vector< dp_gui::TUpdateListEntry > &vExtensionList, + const std::vector< com::sun::star::uno::Reference< + com::sun::star::deployment::XPackage > > & vExtensionList, std::vector< dp_gui::UpdateData > * updateData); ~UpdateDialog(); @@ -142,6 +143,7 @@ private: UpdateDialog & m_dialog; }; + friend class CheckListBox; void insertItem( @@ -169,6 +171,10 @@ private: void initDescription(); void clearDescription(); + bool showDescription(::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage > const & aExtension); + bool showDescription(std::pair< rtl::OUString, rtl::OUString > const & pairPublisher, + rtl::OUString const & sReleaseNotes); bool showDescription( ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & aUpdateInfo); bool showDescription( const String& rDescription, bool bWithPublisher ); @@ -206,8 +212,6 @@ private: rtl::OUString m_noInstall; rtl::OUString m_noDependency; rtl::OUString m_noDependencyCurVer; - rtl::OUString m_noPermission; - rtl::OUString m_noPermissionVista; rtl::OUString m_browserbased; rtl::OUString m_version; std::vector< dp_gui::UpdateData > m_enabledUpdates; diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.src b/desktop/source/deployment/gui/dp_gui_updatedialog.src index b86a8ad66f08..325d98c88d48 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.src +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.src @@ -244,18 +244,6 @@ ModalDialog RID_DLG_UPDATE { String RID_DLG_UPDATE_NODEPENDENCY_CUR_VER { Text[en-US] = "You have OpenOffice.org %VERSION"; }; - String RID_DLG_UPDATE_NOPERMISSION { - Text[en-US] = "No write permission (shared extension)."; - }; - String RID_DLG_UPDATE_NOPERMISSION_VISTA { - Text[en-US] = "No write permission. %PRODUCTNAME needs to run as administrator.\n" - "Please follow these steps to update this shared extension:\n" - "1. Close Extension Manager dialog.\n" - "2. Exit %PRODUCTNAME.\n" - "3. Exit %PRODUCTNAME Quickstarter located in the tray area of Windows.\n" - "4. Run %PRODUCTNAME as administrator. In order to do this call the context menu of the %PRODUCTNAME program icon and choose \'Run as administrator\'.\n" - "5. Call the Extension Manager dialog and update this shared extension.\n"; - }; String RID_DLG_UPDATE_BROWSERBASED { Text[en-US] = "browser based update"; }; diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx index f2f8b8b0d6e2..067a703ec413 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx @@ -380,13 +380,12 @@ void UpdateInstallDialog::Thread::downloadExtensions() { UpdateData & curData = *i; - OSL_ASSERT(curData.aUpdateInfo.is()); + if (!curData.aUpdateInfo.is() || curData.aUpdateSource.is()) + continue; //We assume that m_aVecUpdateData contains only information about extensions which //can be downloaded directly. OSL_ASSERT(curData.sWebsiteURL.getLength() == 0); - if (!curData.aUpdateInfo.is()) - continue; //update the name of the extension which is to be downloaded { ::vos::OGuard g(Application::GetSolarMutex()); @@ -491,13 +490,11 @@ void UpdateInstallDialog::Thread::installExtensions() // osl::Thread::wait(v); bool bError = false; bool bLicenseDeclined = false; - cssu::Reference xPackage; + cssu::Reference xExtension; UpdateData & curData = *i; cssu::Exception exc; try { - if (curData.sLocalURL.getLength() == 0) - continue; cssu::Reference< css::task::XAbortChannel > xAbortChannel( curData.aInstalledPackage->createAbortChannel() ); { @@ -507,9 +504,35 @@ void UpdateInstallDialog::Thread::installExtensions() } m_abort = xAbortChannel; } - xPackage = m_dialog.getExtensionManager()->addExtension( - curData.sLocalURL, css::uno::Sequence(), - curData.aInstalledPackage->getRepositoryName(), xAbortChannel, m_updateCmdEnv.get()); + if (!curData.aUpdateSource.is() && curData.sLocalURL.getLength()) + { + css::beans::NamedValue prop(OUSTR("EXTENSION_UPDATE"), css::uno::makeAny(OUSTR("1"))); + if (!curData.bIsShared) + xExtension = m_dialog.getExtensionManager()->addExtension( + curData.sLocalURL, css::uno::Sequence(&prop, 1), + OUSTR("user"), xAbortChannel, m_updateCmdEnv.get()); + else + xExtension = m_dialog.getExtensionManager()->addExtension( + curData.sLocalURL, css::uno::Sequence(&prop, 1), + OUSTR("shared"), xAbortChannel, m_updateCmdEnv.get()); + } + else if (curData.aUpdateSource.is()) + { + OSL_ASSERT(curData.aUpdateSource.is()); + //I am not sure if we should obtain the install properties and pass them into + //add extension. Currently it contains only "SUPPRESS_LICENSE". So it it could happen + //that a license is displayed when updating from the shared repository, although the + //shared extension was installed using "SUPPRESS_LICENSE". + css::beans::NamedValue prop(OUSTR("EXTENSION_UPDATE"), css::uno::makeAny(OUSTR("1"))); + if (!curData.bIsShared) + xExtension = m_dialog.getExtensionManager()->addExtension( + curData.aUpdateSource->getURL(), css::uno::Sequence(&prop, 1), + OUSTR("user"), xAbortChannel, m_updateCmdEnv.get()); + else + xExtension = m_dialog.getExtensionManager()->addExtension( + curData.aUpdateSource->getURL(), css::uno::Sequence(&prop, 1), + OUSTR("shared"), xAbortChannel, m_updateCmdEnv.get()); + } } catch (css::deployment::DeploymentException & de) { @@ -538,7 +561,7 @@ void UpdateInstallDialog::Thread::installExtensions() m_dialog.setError(UpdateInstallDialog::ERROR_LICENSE_DECLINED, curData.aInstalledPackage->getDisplayName(), OUString()); } - else if (!xPackage.is() || bError) + else if (!xExtension.is() || bError) { ::vos::OGuard g(Application::GetSolarMutex()); if (m_stop) { diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h index a0ca7f53be03..161b91a6bcde 100644 --- a/desktop/source/deployment/inc/dp_misc.h +++ b/desktop/source/deployment/inc/dp_misc.h @@ -179,6 +179,52 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC void syncRepositories(::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv); +enum UPDATE_SOURCE +{ + UPDATE_SOURCE_NONE, + UPDATE_SOURCE_SHARED, + UPDATE_SOURCE_BUNDLED, + UPDATE_SOURCE_ONLINE +}; + +/* determine if an update is available which is installed in the + user repository. + + If the return value is UPDATE_SOURCE_NONE, then no update is + available, otherwise the return value determine from which the + repository the update is used. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UPDATE_SOURCE isUpdateUserExtension( + bool bReadOnlyShared, + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion); + +/* determine if an update is available which is installed in the + shared repository. + + If the return value is UPDATE_SOURCE_NONE, then no update is + available, otherwise the return value determine from which the + repository the update is used. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UPDATE_SOURCE isUpdateSharedExtension( + bool bReadOnlyShared, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion); + +/* determines the extension with the highest identifier and returns it + + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> +getExtensionWithHighestVersion( + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId); } 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(); diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index ad0e7d95df7e..54624514adce 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -163,6 +163,17 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); + virtual css::uno::Sequence > + SAL_CALL getExtensionsWithSameIdentifier( + ::rtl::OUString const & identifier, + ::rtl::OUString const & filename, + css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv ) + throw ( + css::deployment::DeploymentException, + css::ucb::CommandFailedException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException); + virtual css::uno::Sequence< css::uno::Sequence > > SAL_CALL getAllExtensions( css::uno::Reference const &, @@ -252,7 +263,9 @@ private: ::std::list > getExtensionsWithSameId(::rtl::OUString const & identifier, - ::rtl::OUString const & fileName); + ::rtl::OUString const & fileName, + css::uno::Reference< css::ucb::XCommandEnvironment> const & xCmdEnv = + css::uno::Reference< css::ucb::XCommandEnvironment>()); css::uno::Reference backupExtension( ::rtl::OUString const & identifier, ::rtl::OUString const & fileName, diff --git a/desktop/source/deployment/manager/dp_properties.cxx b/desktop/source/deployment/manager/dp_properties.cxx index b04e8131ee15..df579944c6e4 100644 --- a/desktop/source/deployment/manager/dp_properties.cxx +++ b/desktop/source/deployment/manager/dp_properties.cxx @@ -50,6 +50,8 @@ using ::com::sun::star::uno::Reference; using ::rtl::OUString; #define PROP_SUPPRESS_LICENSE "SUPPRESS_LICENSE" +#define PROP_EXTENSION_UPDATE "EXTENSION_UPDATE" + namespace dp_manager { //Reading the file @@ -89,17 +91,11 @@ ExtensionProperties::ExtensionProperties( css::beans::NamedValue const & v = properties[i]; if (v.Name.equals(OUSTR(PROP_SUPPRESS_LICENSE))) { - OUString value; - if (v.Value >>= value) - { - if (value.equals(OUSTR("1"))) - m_prop_suppress_license = OUSTR("1"); - } - else - { - throw lang::IllegalArgumentException( - OUSTR("Extension Manager: wrong property value"), 0, -1); - } + m_prop_suppress_license = getPropertyValue(v); + } + else if (v.Name.equals(OUSTR(PROP_EXTENSION_UPDATE))) + { + m_prop_extension_update = getPropertyValue(v); } else { @@ -109,6 +105,21 @@ ExtensionProperties::ExtensionProperties( } } +OUString ExtensionProperties::getPropertyValue(css::beans::NamedValue const & v) +{ + OUString value(OUSTR("0")); + if (v.Value >>= value) + { + if (value.equals(OUSTR("1"))) + value = OUSTR("1"); + } + else + { + throw lang::IllegalArgumentException( + OUSTR("Extension Manager: wrong property value"), 0, -1); + } + return value; +} void ExtensionProperties::write() { ::ucbhelper::Content contentProps(m_propFileUrl, m_xCmdEnv); @@ -142,6 +153,17 @@ bool ExtensionProperties::isSuppressedLicense() return ret; } +bool ExtensionProperties::isExtensionUpdate() +{ + bool ret = false; + if (m_prop_extension_update) + { + if (m_prop_extension_update->equals(OUSTR("1"))) + ret = true; + } + return ret; +} + } // namespace dp_manager diff --git a/desktop/source/deployment/manager/dp_properties.hxx b/desktop/source/deployment/manager/dp_properties.hxx index 197155653de1..97fc8b8c5394 100644 --- a/desktop/source/deployment/manager/dp_properties.hxx +++ b/desktop/source/deployment/manager/dp_properties.hxx @@ -53,6 +53,9 @@ protected: ::rtl::OUString m_propFileUrl; const css::uno::Reference m_xCmdEnv; ::boost::optional< ::rtl::OUString> m_prop_suppress_license; + ::boost::optional< ::rtl::OUString> m_prop_extension_update; + + ::rtl::OUString getPropertyValue(css::beans::NamedValue const & v); public: virtual ~ExtensionProperties() {}; @@ -66,6 +69,8 @@ public: void write(); bool isSuppressedLicense(); + + bool isExtensionUpdate(); }; } diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 5269e3d8aac5..53d488095ecd 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -30,6 +30,7 @@ #include "dp_misc.h" +#include "dp_version.hxx" #include "dp_interact.h" #include "rtl/uri.hxx" #include "rtl/digest.h" @@ -630,6 +631,147 @@ void syncRepositories(Reference const & xCmdEnv) } } +/* returns the index of the greatest version, starting with 0 + + */ +int determineHighestVersion( + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + int index = 0; + OUString greatest = userVersion; + if (dp_misc::compareVersions(sharedVersion, greatest) == dp_misc::GREATER) + { + index = 1; + greatest = sharedVersion; + } + if (dp_misc::compareVersions(bundledVersion, greatest) == dp_misc::GREATER) + { + index = 2; + greatest = bundledVersion; + } + if (dp_misc::compareVersions(onlineVersion, greatest) == dp_misc::GREATER) + { + index = 3; + } + return index; +} + +UPDATE_SOURCE isUpdateUserExtension( + bool bReadOnlyShared, + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; + if (bReadOnlyShared) + { + if (userVersion.getLength()) + { + int index = determineHighestVersion( + userVersion, sharedVersion, bundledVersion, onlineVersion); + if (index == 1) + retVal = UPDATE_SOURCE_SHARED; + else if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + else if (sharedVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), sharedVersion, bundledVersion, onlineVersion); + if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + + } + else if (bundledVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), OUString(), bundledVersion, onlineVersion); + if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + } + else + { + if (userVersion.getLength()) + { + int index = determineHighestVersion( + userVersion, sharedVersion, bundledVersion, onlineVersion); + if (index == 1) + retVal = UPDATE_SOURCE_SHARED; + else if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + } + + return retVal; +} + +UPDATE_SOURCE isUpdateSharedExtension( + bool bReadOnlyShared, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + if (bReadOnlyShared) + return UPDATE_SOURCE_NONE; + UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; + + if (sharedVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), sharedVersion, bundledVersion, onlineVersion); + if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + else if (bundledVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), OUString(), bundledVersion, onlineVersion); + if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + return retVal; +} + +Reference +getExtensionWithHighestVersion( + Sequence > const & seqExt) +{ + if (seqExt.getLength() == 0) + return Reference(); + + Reference greatest; + sal_Int32 len = seqExt.getLength(); + + for (sal_Int32 i = 0; i < len; i++) + { + if (!greatest.is()) + { + greatest = seqExt[i]; + continue; + } + Reference const & current = seqExt[i]; + //greatest has a value + if (! current.is()) + continue; + + if (dp_misc::compareVersions(current->getVersion(), greatest->getVersion()) == dp_misc::GREATER) + greatest = current; + } + return greatest; +} } -- cgit From 7ef48b304fe975501f32f8261ee620ebbedc90e5 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 1 Jun 2010 16:20:28 +0200 Subject: jl152 #i77196# fix compiler warnings --- desktop/source/deployment/gui/dp_gui_updatedata.hxx | 2 +- desktop/source/deployment/gui/dp_gui_updatedialog.cxx | 11 +++++------ desktop/source/deployment/manager/dp_extensionmanager.cxx | 2 +- desktop/util/makefile.mk | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_updatedata.hxx b/desktop/source/deployment/gui/dp_gui_updatedata.hxx index 7228982da518..76eb8af31e8e 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedata.hxx +++ b/desktop/source/deployment/gui/dp_gui_updatedata.hxx @@ -47,7 +47,7 @@ namespace dp_gui { struct UpdateData { UpdateData( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > const & aExt): - aInstalledPackage(aExt), bIsShared(false) {}; + bIsShared(false), aInstalledPackage(aExt){}; //When entries added to the listbox then there can be one for the user update and one //for the shared update. However, both list entries will contain the same UpdateData. diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index d121ad976a06..a27f04326b25 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -280,7 +280,6 @@ private: dp_gui::UpdateData const & data, ::rtl::OUString const & version = ::rtl::OUString()) const; void prepareUpdateData( - ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > const & package, ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > const & updateInfo, UpdateDialog::DisabledUpdate & out_du, dp_gui::UpdateData & out_data) const; @@ -415,7 +414,7 @@ void UpdateDialog::Thread::execute() for (Map::iterator i(map.begin()); i != map.end(); ++i) { //determine if online updates meet the requirements - prepareUpdateData(i->second.package, i->second.info, + prepareUpdateData(i->second.info, i->second.disableUpdate, i->second.updateData); //determine if the update is installed in the user or shared repository @@ -613,7 +612,6 @@ void UpdateDialog::Thread::getOwnUpdateInformation( /** out_data will only be filled if all dependencies are ok. */ void UpdateDialog::Thread::prepareUpdateData( - css::uno::Reference< css::deployment::XPackage > const & package, css::uno::Reference< css::xml::dom::XNode > const & updateInfo, UpdateDialog::DisabledUpdate & out_du, dp_gui::UpdateData & out_data) const @@ -648,21 +646,22 @@ bool UpdateDialog::Thread::update( UpdateDialog::DisabledUpdate const & du, dp_gui::UpdateData const & data) const { + bool ret = false; if (du.unsatisfiedDependencies.getLength() == 0) { vos::OGuard g(Application::GetSolarMutex()); if (!m_stop) { m_dialog.addEnabledUpdate(getUpdateDisplayString(data), data); } - return !m_stop; + ret = !m_stop; } else { vos::OGuard g(Application::GetSolarMutex()); if (!m_stop) { m_dialog.addDisabledUpdate(du); } - return !m_stop; + ret = !m_stop; } - return true; + return ret; } // UpdateDialog ---------------------------------------------------------- diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 251e70a19ce6..24b5712ebd30 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -251,7 +251,7 @@ void ExtensionManager::addExtensionsToMap( ::std::list > ExtensionManager::getExtensionsWithSameId( OUString const & identifier, OUString const & fileName, - Reference< ucb::XCommandEnvironment> const & xCmdEnv) + Reference< ucb::XCommandEnvironment> const & /*xCmdEnv*/) { ::std::list > extensionList; diff --git a/desktop/util/makefile.mk b/desktop/util/makefile.mk index 47885dfd6b73..8cf03f157254 100644 --- a/desktop/util/makefile.mk +++ b/desktop/util/makefile.mk @@ -108,7 +108,7 @@ APP5RPATH=BRAND APP5OBJS=$(OBJ)$/copyright_ascii_ooo.obj $(OBJ)$/main.obj APP5STDLIBS = $(SALLIB) $(SOFFICELIB) .IF "$(OS)" == "LINUX" -APP5STDLIBS+= -lXext +APP5STDLIBS+= -lXext -lX11 #APP5STDLIBS+= -lXext -lSM -lICE .ENDIF # LINUX -- cgit From a340fb93fa310e0eb82c3bd5ac7d5b9a3b22ce70 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Wed, 2 Jun 2010 08:50:04 +0200 Subject: jl152#i77196# Enable showing license during startup check, better handling of extensions with unaccepted license --- desktop/source/app/check_ext_deps.cxx | 49 +++++++++++++++---- desktop/source/deployment/gui/dp_gui.hrc | 2 + desktop/source/deployment/gui/dp_gui_dialog.src | 10 ++++ desktop/source/deployment/gui/dp_gui_dialog2.cxx | 44 ++++++++++++----- desktop/source/deployment/gui/dp_gui_dialog2.hxx | 10 ++-- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 56 +++++++++++++++++++++- .../deployment/gui/dp_gui_extensioncmdqueue.hxx | 1 + .../source/deployment/gui/dp_gui_extlistbox.cxx | 15 +++++- .../source/deployment/gui/dp_gui_extlistbox.hxx | 4 +- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 49 ++++++++----------- desktop/source/deployment/gui/dp_gui_theextmgr.hxx | 10 +--- desktop/source/deployment/manager/dp_manager.cxx | 2 +- 12 files changed, 186 insertions(+), 66 deletions(-) mode change 100644 => 100755 desktop/source/app/check_ext_deps.cxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui.hrc mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_dialog.src mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_dialog2.cxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_dialog2.hxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_extlistbox.cxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_extlistbox.hxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_theextmgr.cxx mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_theextmgr.hxx (limited to 'desktop') diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx old mode 100644 new mode 100755 index e9c71bc1ea36..ebdc9ccdf51e --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -39,6 +39,7 @@ #include "vcl/timer.hxx" #include +#include "toolkit/helper/vclunohelper.hxx" #include #include @@ -48,10 +49,14 @@ #include #include "com/sun/star/deployment/XPackage.hpp" #include "com/sun/star/deployment/ExtensionManager.hpp" +#include "com/sun/star/deployment/LicenseException.hpp" +#include "com/sun/star/deployment/ui/LicenseDialog.hpp" #include #include #include +#include #include +#include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp" #include #include "app.hxx" @@ -132,21 +137,47 @@ Reference SilentCommandEnv::getProgressHandler() void SilentCommandEnv::handle( Reference< task::XInteractionRequest> const & xRequest ) throw (uno::RuntimeException) { + deployment::LicenseException licExc; + uno::Any request( xRequest->getRequest() ); + bool bApprove = true; + + if ( request >>= licExc ) + { + uno::Reference< uno::XComponentContext > xContext = comphelper_getProcessComponentContext(); + uno::Reference< ui::dialogs::XExecutableDialog > xDialog( + deployment::ui::LicenseDialog::create( + xContext, VCLUnoHelper::GetInterface( NULL ), + licExc.ExtensionName, licExc.Text ) ); + sal_Int16 res = xDialog->execute(); + if ( res == ui::dialogs::ExecutableDialogResults::CANCEL ) + bApprove = false; + else if ( res == ui::dialogs::ExecutableDialogResults::OK ) + bApprove = true; + else + { + OSL_ASSERT(0); + } + } // We approve everything here - uno::Sequence< Reference< task::XInteractionContinuation > > conts( - xRequest->getContinuations() ); - Reference< task::XInteractionContinuation > const * pConts = - conts.getConstArray(); + uno::Sequence< Reference< task::XInteractionContinuation > > conts( xRequest->getContinuations() ); + Reference< task::XInteractionContinuation > const * pConts = conts.getConstArray(); sal_Int32 len = conts.getLength(); + for ( sal_Int32 pos = 0; pos < len; ++pos ) { - - Reference< task::XInteractionApprove > xInteractionApprove( - pConts[ pos ], uno::UNO_QUERY ); - if (xInteractionApprove.is()) { - xInteractionApprove->select(); + if ( bApprove ) + { + uno::Reference< task::XInteractionApprove > xInteractionApprove( pConts[ pos ], uno::UNO_QUERY ); + if ( xInteractionApprove.is() ) + xInteractionApprove->select(); + } + else + { + uno::Reference< task::XInteractionAbort > xInteractionAbort( pConts[ pos ], uno::UNO_QUERY ); + if ( xInteractionAbort.is() ) + xInteractionAbort->select(); } } } diff --git a/desktop/source/deployment/gui/dp_gui.hrc b/desktop/source/deployment/gui/dp_gui.hrc old mode 100644 new mode 100755 index 022141976f55..5f52b042edf3 --- a/desktop/source/deployment/gui/dp_gui.hrc +++ b/desktop/source/deployment/gui/dp_gui.hrc @@ -153,6 +153,7 @@ #define RID_STR_REMOVING_PACKAGES (RID_DEPLOYMENT_GUI_START+86) #define RID_STR_ENABLING_PACKAGES (RID_DEPLOYMENT_GUI_START+87) #define RID_STR_DISABLING_PACKAGES (RID_DEPLOYMENT_GUI_START+88) +#define RID_STR_ACCEPT_LICENSE (RID_DEPLOYMENT_GUI_START+89) #define RID_STR_INSTALL_FOR_ALL (RID_DEPLOYMENT_GUI_START+90) #define RID_STR_INSTALL_FOR_ME (RID_DEPLOYMENT_GUI_START+91) @@ -161,6 +162,7 @@ #define RID_STR_EXIT_BTN (RID_DEPLOYMENT_GUI_START+94) #define RID_STR_NO_ADMIN_PRIVILEGE (RID_DEPLOYMENT_GUI_START+95) #define RID_STR_ERROR_MISSING_DEPENDENCIES (RID_DEPLOYMENT_GUI_START+96) +#define RID_STR_ERROR_MISSING_LICENSE (RID_DEPLOYMENT_GUI_START+97) #define WARNINGBOX_CONCURRENTINSTANCE (RID_DEPLOYMENT_GUI_START+100) diff --git a/desktop/source/deployment/gui/dp_gui_dialog.src b/desktop/source/deployment/gui/dp_gui_dialog.src old mode 100644 new mode 100755 index f9d9c0e011c6..15823288ee20 --- a/desktop/source/deployment/gui/dp_gui_dialog.src +++ b/desktop/source/deployment/gui/dp_gui_dialog.src @@ -72,6 +72,11 @@ String RID_STR_DISABLING_PACKAGES Text [ en-US ] = "Disabling %EXTENSION_NAME"; }; +String RID_STR_ACCEPT_LICENSE +{ + Text [ en-US ] = "Accept license for %EXTENSION_NAME"; +}; + String RID_STR_INSTALL_FOR_ALL { Text [ en-US ] = "~For all users"; @@ -109,6 +114,11 @@ String RID_STR_ERROR_MISSING_DEPENDENCIES Text [ en-US ] = "The extension cannot be enabled as the following system dependencies are not fulfilled:"; }; +String RID_STR_ERROR_MISSING_LICENSE +{ + Text [ en-US ] = "This extension is disabled because you haven't accepted the license yet.\n"; +}; + // Dialog layout // --------------------------------------------------- // row 1 | multi line edit diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx old mode 100644 new mode 100755 index 35634d5ef851..d34001393ba7 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -37,6 +37,7 @@ #include "dp_gui_extlistbox.hxx" #include "dp_gui_shared.hxx" #include "dp_gui_theextmgr.hxx" +#include "dp_gui_extensioncmdqueue.hxx" #include "dp_misc.h" #include "dp_identifier.hxx" @@ -291,7 +292,8 @@ void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_ENABLE ); } - if ( !pEntry->m_bUser || ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps ) + if ( ( !pEntry->m_bUser || ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps ) + && !pEntry->m_bMissingLic ) m_pEnableBtn->Hide(); else { @@ -511,9 +513,14 @@ IMPL_LINK( ExtBoxWithBtns_Impl, HandleEnableBtn, void*, EMPTYARG ) if ( nActive != EXTENSION_LISTBOX_ENTRY_NOTFOUND ) { TEntry_Impl pEntry = GetEntryData( nActive ); - const bool bEnable( pEntry->m_eState != REGISTERED ); - m_pParent->enablePackage( pEntry->m_xPackage, bEnable ); + if ( pEntry->m_bMissingLic ) + m_pParent->acceptLicense( pEntry->m_xPackage ); + else + { + const bool bEnable( pEntry->m_eState != REGISTERED ); + m_pParent->enablePackage( pEntry->m_xPackage, bEnable ); + } } return 1; @@ -760,10 +767,11 @@ void ExtMgrDialog::setGetExtensionsURL( const ::rtl::OUString &rURL ) } //------------------------------------------------------------------------------ -long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage ) +long ExtMgrDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage, + bool bLicenseMissing ) { m_aUpdateBtn.Enable( true ); - return m_pExtensionBox->addEntry( xPackage ); + return m_pExtensionBox->addEntry( xPackage, bLicenseMissing ); } //------------------------------------------------------------------------------ @@ -810,7 +818,7 @@ bool ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > & return false; } - m_pManager->enablePackage( xPackage, bEnable ); + m_pManager->getCmdQueue()->enableExtension( xPackage, bEnable ); return true; } @@ -830,7 +838,7 @@ bool ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackage > & if ( ! continueOnSharedExtension( xPackage, this, RID_WARNINGBOX_REMOVE_SHARED_EXTENSION, m_bDeleteWarning ) ) return false; - m_pManager->removePackage( xPackage ); + m_pManager->getCmdQueue()->removeExtension( xPackage ); return true; } @@ -851,7 +859,18 @@ bool ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackage > & std::vector< css::uno::Reference< css::deployment::XPackage > > vEntries; vEntries.push_back(extension); - m_pManager->updatePackages( vEntries ); + m_pManager->getCmdQueue()->checkForUpdates( vEntries ); + + return true; +} + +//------------------------------------------------------------------------------ +bool ExtMgrDialog::acceptLicense( const uno::Reference< deployment::XPackage > &xPackage ) +{ + if ( !xPackage.is() ) + return false; + + m_pManager->getCmdQueue()->acceptLicense( xPackage ); return true; } @@ -1300,10 +1319,11 @@ UpdateRequiredDialog::~UpdateRequiredDialog() } //------------------------------------------------------------------------------ -long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage ) +long UpdateRequiredDialog::addPackageToList( const uno::Reference< deployment::XPackage > &xPackage, + bool bLicenseMissing ) { // We will only add entries to the list with unsatisfied dependencies - if ( !checkDependencies( xPackage ) ) + if ( !bLicenseMissing && !checkDependencies( xPackage ) ) { m_bHasLockedEntries |= m_pManager->isReadOnly( xPackage ); m_aUpdateBtn.Enable( true ); @@ -1335,7 +1355,7 @@ void UpdateRequiredDialog::checkEntries() bool UpdateRequiredDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage, bool bEnable ) { - m_pManager->enablePackage( xPackage, bEnable ); + m_pManager->getCmdQueue()->enableExtension( xPackage, bEnable ); return true; } @@ -1462,7 +1482,7 @@ IMPL_LINK( UpdateRequiredDialog, HandleUpdateBtn, void*, EMPTYARG ) aGuard.clear(); - m_pManager->updatePackages( vUpdateEntries ); + m_pManager->getCmdQueue()->checkForUpdates( vUpdateEntries ); return 1; } diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx old mode 100644 new mode 100755 index 4c99d64740db..f0a85cce98c0 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -81,7 +81,8 @@ public: virtual void updateProgress( const long nProgress ) = 0; virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0; - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0; + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, + bool bLicenseMissing = false ) = 0; virtual void prepareChecking() = 0; virtual void checkEntries() = 0; @@ -157,11 +158,13 @@ public: virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void setGetExtensionsURL( const ::rtl::OUString &rURL ); - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &); + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, + bool bLicenseMissing = false ); bool enablePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); bool removePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); bool updatePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + bool acceptLicense(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); virtual void prepareChecking(); virtual void checkEntries(); @@ -228,7 +231,8 @@ public: virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void selectEntry( long nPos ); - virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > & ); + virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, + bool bLicenseMissing = false ); bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx old mode 100644 new mode 100755 index 954f32f4c9c6..e3c8b2bfb46b --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -195,7 +195,7 @@ public: //------------------------------------------------------------------------------ struct ExtensionCmd { - enum E_CMD_TYPE { ADD, ENABLE, DISABLE, REMOVE, CHECK_FOR_UPDATES }; + enum E_CMD_TYPE { ADD, ENABLE, DISABLE, REMOVE, CHECK_FOR_UPDATES, ACCEPT_LICENSE }; E_CMD_TYPE m_eCmdType; bool m_bWarnUser; @@ -241,6 +241,7 @@ public: void enableExtension( const uno::Reference< deployment::XPackage > &rPackage, const bool bEnable ); void checkForUpdates( const std::vector > &vExtensionList ); + void acceptLicense( const uno::Reference< deployment::XPackage > &rPackage ); void stop(); bool isBusy(); @@ -267,6 +268,8 @@ private: void _disableExtension( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, const uno::Reference< deployment::XPackage > &xPackage ); void _checkForUpdates( const std::vector > &vExtensionList ); + void _acceptLicense( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, + const uno::Reference< deployment::XPackage > &xPackage ); enum Input { NONE, START, STOP }; @@ -281,6 +284,7 @@ private: const OUString m_sAddingPackages; const OUString m_sRemovingPackages; const OUString m_sDefaultCmd; + const OUString m_sAcceptLicense; osl::Condition m_wakeup; osl::Mutex m_mutex; Input m_eInput; @@ -626,6 +630,7 @@ ExtensionCmdQueue::Thread::Thread( DialogHelper *pDialogHelper, m_sAddingPackages( DialogHelper::getResourceString( RID_STR_ADDING_PACKAGES ) ), m_sRemovingPackages( DialogHelper::getResourceString( RID_STR_REMOVING_PACKAGES ) ), m_sDefaultCmd( DialogHelper::getResourceString( RID_STR_ADD_PACKAGES ) ), + m_sAcceptLicense( DialogHelper::getResourceString( RID_STR_ACCEPT_LICENSE ) ), m_eInput( NONE ), m_bTerminated( false ), m_bStopped( false ), @@ -674,6 +679,25 @@ void ExtensionCmdQueue::Thread::removeExtension( const uno::Reference< deploymen } } +//------------------------------------------------------------------------------ +void ExtensionCmdQueue::Thread::acceptLicense( const uno::Reference< deployment::XPackage > &rPackage ) +{ + ::osl::MutexGuard aGuard( m_mutex ); + + //If someone called stop then we do not remove the extension -> game over! + if ( m_bStopped ) + return; + + if ( rPackage.is() ) + { + TExtensionCmd pEntry( new ExtensionCmd( ExtensionCmd::ACCEPT_LICENSE, rPackage ) ); + + m_queue.push( pEntry ); + m_eInput = START; + m_wakeup.set(); + } +} + //------------------------------------------------------------------------------ void ExtensionCmdQueue::Thread::enableExtension( const uno::Reference< deployment::XPackage > &rPackage, const bool bEnable ) @@ -815,6 +839,9 @@ void ExtensionCmdQueue::Thread::execute() case ExtensionCmd::CHECK_FOR_UPDATES : _checkForUpdates( pEntry->m_vExtensionList ); break; + case ExtensionCmd::ACCEPT_LICENSE : + _acceptLicense( currentCmdEnv, pEntry->m_xPackage ); + break; } } //catch ( deployment::DeploymentException &) @@ -1065,6 +1092,28 @@ void ExtensionCmdQueue::Thread::_disableExtension( ::rtl::Reference< ProgressCmd {} } +//------------------------------------------------------------------------------ +void ExtensionCmdQueue::Thread::_acceptLicense( ::rtl::Reference< ProgressCmdEnv > &rCmdEnv, + const uno::Reference< deployment::XPackage > &xPackage ) +{ + if ( !xPackage.is() ) + return; + + uno::Reference< deployment::XExtensionManager > xExtMgr = m_pManager->getExtensionManager(); + uno::Reference< task::XAbortChannel > xAbortChannel( xExtMgr->createAbortChannel() ); + OUString sTitle = searchAndReplaceAll( m_sAcceptLicense, OUSTR("%EXTENSION_NAME"), xPackage->getDisplayName() ); + rCmdEnv->progressSection( sTitle, xAbortChannel ); + + try + { + xExtMgr->checkPrerequisitesAndEnable( xPackage, xAbortChannel, rCmdEnv.get() ); + if ( m_pDialogHelper ) + m_pDialogHelper->updatePackageInfo( xPackage ); + } + catch ( ::ucb::CommandAbortedException & ) + {} +} + //------------------------------------------------------------------------------ void ExtensionCmdQueue::Thread::onTerminated() { @@ -1131,6 +1180,11 @@ void ExtensionCmdQueue::checkForUpdates( const std::vectorcheckForUpdates( vExtensionList ); } +void ExtensionCmdQueue::acceptLicense( const uno::Reference< deployment::XPackage > &rPackage ) +{ + m_thread->acceptLicense( rPackage ); +} + void ExtensionCmdQueue::stop() { m_thread->stop(); diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx old mode 100644 new mode 100755 index cfadad84cedc..29cee4292102 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx @@ -85,6 +85,7 @@ public: const bool bEnable ); void checkForUpdates(const std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > > &vList ); + void acceptLicense( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage ); /** This call does not block. It signals the internal thread that it should install the remaining extensions and then terminate. diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx old mode 100644 new mode 100755 index dbb5c93cd853..d76764fa1e53 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -66,6 +66,7 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, m_bChecked( false ), m_bMissingDeps( false ), m_bHasButtons( false ), + m_bMissingLic( false ), m_eState( eState ), m_pPublisher( NULL ), m_xPackage( xPackage ) @@ -372,6 +373,8 @@ void ExtensionBox_Impl::CalcActiveHeight( const long nPos ) aSize.Height() = 10000; rtl::OUString aText( m_vEntries[ nPos ]->m_sErrorText ); + if ( aText.getLength() ) + aText += OUSTR("\n"); aText += m_vEntries[ nPos ]->m_sDescription; Rectangle aRect = GetTextRect( Rectangle( Point(), aSize ), aText, @@ -634,7 +637,7 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr else DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aSharedImageHC : m_aSharedImage ); } - if ( ( pEntry->m_eState == AMBIGUOUS ) || pEntry->m_bMissingDeps ) + if ( ( pEntry->m_eState == AMBIGUOUS ) || pEntry->m_bMissingDeps || pEntry->m_bMissingLic ) { aPos = rRect.TopRight() + Point( -(RIGHT_ICON_OFFSET + SPACE_BETWEEN + 2*SMALL_ICON_SIZE), TOP_OFFSET ); DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aWarningImageHC : m_aWarningImage ); @@ -952,7 +955,8 @@ bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl pEntry, const long nStar } //------------------------------------------------------------------------------ -long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage ) +long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage, + bool bLicenseMissing ) { long nPos = 0; PackageState eState = m_pManager->getPackageState( xPackage ); @@ -982,6 +986,10 @@ long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & pEntry->m_bUser = xPackage->getRepositoryName().equals( USER_PACKAGE_MANAGER ); pEntry->m_bShared = xPackage->getRepositoryName().equals( SHARED_PACKAGE_MANAGER ); pEntry->m_bNew = m_bInCheckMode; + pEntry->m_bMissingLic = bLicenseMissing; + + if ( bLicenseMissing ) + pEntry->m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_MISSING_LICENSE ); //access to m_nActive must be guarded if ( !m_bInCheckMode && m_bHasActive && ( m_nActive >= nPos ) ) @@ -1017,6 +1025,9 @@ void ExtensionBox_Impl::updateEntry( const uno::Reference< deployment::XPackage else (*iIndex)->m_sErrorText = String(); + if ( eState == REGISTERED ) + (*iIndex)->m_bMissingLic = false; + if ( IsReallyVisible() ) Invalidate(); break; diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx old mode 100644 new mode 100755 index 0f56d022492b..762f50296690 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx @@ -73,6 +73,7 @@ struct Entry_Impl bool m_bChecked :1; bool m_bMissingDeps :1; bool m_bHasButtons :1; + bool m_bMissingLic :1; PackageState m_eState; String m_sTitle; String m_sVersion; @@ -205,7 +206,8 @@ public: //----------------- virtual void selectEntry( const long nPos ); - long addEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); + long addEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, + bool bLicenseMissing = false ); void updateEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); void removeEntry( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx old mode 100644 new mode 100755 index fdbc1974f61c..7bfcc79480b3 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -67,7 +67,8 @@ TheExtensionManager::TheExtensionManager( Window *pParent, m_xContext( xContext ), m_pParent( pParent ), m_pExtMgrDialog( NULL ), - m_pUpdReqDialog( NULL ) + m_pUpdReqDialog( NULL ), + m_pExecuteCmdQueue( NULL ) { m_xExtensionManager = deployment::ExtensionManager::get( xContext ); m_xExtensionManager->addModifyListener( this ); @@ -117,6 +118,8 @@ TheExtensionManager::~TheExtensionManager() delete m_pUpdReqDialog; if ( m_pExtMgrDialog ) delete m_pExtMgrDialog; + if ( m_pExecuteCmdQueue ) + delete m_pExecuteCmdQueue; } //------------------------------------------------------------------------------ @@ -129,14 +132,16 @@ void TheExtensionManager::createDialog( const bool bCreateUpdDlg ) if ( !m_pUpdReqDialog ) { m_pUpdReqDialog = new UpdateRequiredDialog( NULL, this ); - m_pExecuteCmdQueue.reset( new ExtensionCmdQueue( (DialogHelper*) m_pUpdReqDialog, this, m_xContext ) ); + delete m_pExecuteCmdQueue; + m_pExecuteCmdQueue = new ExtensionCmdQueue( (DialogHelper*) m_pUpdReqDialog, this, m_xContext ); createPackageList(); } } else if ( !m_pExtMgrDialog ) { m_pExtMgrDialog = new ExtMgrDialog( m_pParent, this ); - m_pExecuteCmdQueue.reset( new ExtensionCmdQueue( (DialogHelper*) m_pExtMgrDialog, this, m_xContext ) ); + delete m_pExecuteCmdQueue; + m_pExecuteCmdQueue = new ExtensionCmdQueue( (DialogHelper*) m_pExtMgrDialog, this, m_xContext ); m_pExtMgrDialog->setGetExtensionsURL( m_sGetExtensionsURL ); createPackageList(); } @@ -231,32 +236,6 @@ bool TheExtensionManager::checkUpdates( bool /* bShowUpdateOnly */, bool /*bPare return true; } -//------------------------------------------------------------------------------ -bool TheExtensionManager::enablePackage( const uno::Reference< deployment::XPackage > &xPackage, - bool bEnable ) -{ - m_pExecuteCmdQueue->enableExtension( xPackage, bEnable ); - - return true; -} - -//------------------------------------------------------------------------------ -bool TheExtensionManager::removePackage( const uno::Reference< deployment::XPackage > &xPackage ) -{ - m_pExecuteCmdQueue->removeExtension( xPackage ); - - return true; -} - -//------------------------------------------------------------------------------ -bool TheExtensionManager::updatePackages( - const std::vector< uno::Reference< deployment::XPackage > > &vList ) -{ - m_pExecuteCmdQueue->checkForUpdates( vList ); - - return true; -} - //------------------------------------------------------------------------------ bool TheExtensionManager::installPackage( const OUString &rPackageURL, bool bWarnUser ) { @@ -343,6 +322,18 @@ void TheExtensionManager::createPackageList() } } } + + uno::Sequence< uno::Reference< deployment::XPackage > > xNoLicPackages; + xNoLicPackages = m_xExtensionManager->getExtensionsWithUnacceptedLicenses( SHARED_PACKAGE_MANAGER, + uno::Reference< ucb::XCommandEnvironment >() ); + for ( sal_Int32 i = 0; i < xNoLicPackages.getLength(); ++i ) + { + uno::Reference< deployment::XPackage > xPackage = xNoLicPackages[i]; + if ( xPackage.is() ) + { + getDialogHelper()->addPackageToList( xPackage, true ); + } + } } //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx old mode 100644 new mode 100755 index da8d3c083f42..094e25e249b7 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx @@ -61,11 +61,10 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xNameAccessNodes; - ::std::auto_ptr< ExtensionCmdQueue > m_pExecuteCmdQueue; - Window *m_pParent; ExtMgrDialog *m_pExtMgrDialog; UpdateRequiredDialog *m_pUpdReqDialog; + ExtensionCmdQueue *m_pExecuteCmdQueue; ::rtl::OUString m_sGetExtensionsURL; @@ -83,6 +82,7 @@ public: Dialog* getDialog() { return m_pExtMgrDialog ? (Dialog*) m_pExtMgrDialog : (Dialog*) m_pUpdReqDialog; } DialogHelper* getDialogHelper() { return m_pExtMgrDialog ? (DialogHelper*) m_pExtMgrDialog : (DialogHelper*) m_pUpdReqDialog; } + ExtensionCmdQueue* getCmdQueue() const { return m_pExecuteCmdQueue; } void SetText( const ::rtl::OUString &rTitle ); void Show(); @@ -92,12 +92,6 @@ public: //----------------- bool checkUpdates( bool showUpdateOnly, bool parentVisible ); - bool updatePackages( const std::vector< ::com::sun::star::uno::Reference< - ::com::sun::star::deployment::XPackage > > &vList ); - - bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, - bool bEnable ); - bool removePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); bool installPackage( const ::rtl::OUString &rPackageURL, bool bWarnUser = false ); bool queryTermination(); diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 7844e11b0651..409cf2674184 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -927,7 +927,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_readOnly && !xPackage->isRemoved() && m_context.equals(OUSTR("shared"))) + if ( xPackage.is() && !m_readOnly && !xPackage->isRemoved() && m_context.equals(OUSTR("shared"))) { ActivePackages::Data val; m_activePackagesDB->get( & val, id, fileName); -- cgit From 057d47a436bab4ba71a101f7d2ad21cabae0cd20 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Wed, 2 Jun 2010 09:31:52 +0200 Subject: jl152#i77196# better handling of extensions with unaccepted license --- desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index d76764fa1e53..24b47aa223e3 100755 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -1020,14 +1020,14 @@ void ExtensionBox_Impl::updateEntry( const uno::Reference< deployment::XPackage (*iIndex)->m_sVersion = xPackage->getVersion(); (*iIndex)->m_sDescription = xPackage->getDescription(); + if ( eState == REGISTERED ) + (*iIndex)->m_bMissingLic = false; + if ( eState == AMBIGUOUS ) (*iIndex)->m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS ); - else + else if ( ! (*iIndex)->m_bMissingLic ) (*iIndex)->m_sErrorText = String(); - if ( eState == REGISTERED ) - (*iIndex)->m_bMissingLic = false; - if ( IsReallyVisible() ) Invalidate(); break; -- cgit From 04615ba86017896e0fb4bf951004ba2e4e22e6c9 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Thu, 3 Jun 2010 09:35:22 +0200 Subject: jl152#i77196# unopkg gui should sync repositories, too --- desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx | 6 ++++++ desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx | 1 + desktop/source/deployment/gui/dp_gui_service.cxx | 2 ++ 3 files changed, 9 insertions(+) mode change 100644 => 100755 desktop/source/deployment/gui/dp_gui_service.cxx (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index e3c8b2bfb46b..8bd8a6191201 100755 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -76,6 +76,7 @@ #include "comphelper/anytostring.hxx" #include "vcl/msgbox.hxx" #include "toolkit/helper/vclunohelper.hxx" +#include "comphelper/processfactory.hxx" #include "dp_gui.h" #include "dp_gui_thread.hxx" @@ -1185,6 +1186,11 @@ void ExtensionCmdQueue::acceptLicense( const uno::Reference< deployment::XPackag m_thread->acceptLicense( rPackage ); } +void ExtensionCmdQueue::syncRepositories( const uno::Reference< uno::XComponentContext > &xContext ) +{ + dp_misc::syncRepositories( new ProgressCmdEnv( xContext, NULL, OUSTR("Extension Manager") ) ); +} + void ExtensionCmdQueue::stop() { m_thread->stop(); diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx index 29cee4292102..7ac00e2740d4 100755 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx @@ -86,6 +86,7 @@ public: void checkForUpdates(const std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > > &vList ); void acceptLicense( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage ); + static void syncRepositories( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext ); /** This call does not block. It signals the internal thread that it should install the remaining extensions and then terminate. diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx b/desktop/source/deployment/gui/dp_gui_service.cxx old mode 100644 new mode 100755 index 061988d5b04d..c4269e6ac137 --- a/desktop/source/deployment/gui/dp_gui_service.cxx +++ b/desktop/source/deployment/gui/dp_gui_service.cxx @@ -46,6 +46,7 @@ #include "boost/bind.hpp" #include "license_dialog.hxx" #include "dp_gui_dialog2.hxx" +#include "dp_gui_extensioncmdqueue.hxx" using namespace ::dp_misc; using namespace ::com::sun::star; @@ -256,6 +257,7 @@ void ServiceImpl::startExecuteModal( + ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTVERSION).get(); app->SetDisplayName(sTitle); + ExtensionCmdQueue::syncRepositories( m_xComponentContext ); } } else -- cgit From a82d6ff3b4aa2453120cd1bcb3fb69c1d3e2aed2 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Wed, 2 Jun 2010 17:05:21 +0200 Subject: jl152 #i77196# bubble update notification now supports the new update behavior --- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 1 + desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 1 + .../source/deployment/gui/dp_gui_updatedialog.cxx | 170 ++------- desktop/source/deployment/inc/dp_misc.h | 52 --- desktop/source/deployment/inc/dp_update.hxx | 147 ++++++++ .../deployment/manager/dp_informationprovider.cxx | 275 +++++--------- desktop/source/deployment/misc/dp_misc.cxx | 152 -------- desktop/source/deployment/misc/dp_update.cxx | 397 +++++++++++++++++++++ desktop/source/deployment/misc/makefile.mk | 3 +- 9 files changed, 679 insertions(+), 519 deletions(-) create mode 100755 desktop/source/deployment/inc/dp_update.hxx create mode 100755 desktop/source/deployment/misc/dp_update.cxx (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index d34001393ba7..4ba747198c09 100755 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -39,6 +39,7 @@ #include "dp_gui_theextmgr.hxx" #include "dp_gui_extensioncmdqueue.hxx" #include "dp_misc.h" +#include "dp_update.hxx" #include "dp_identifier.hxx" #include "vcl/ctrl.hxx" diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 7bfcc79480b3..d0347c7cbf4e 100755 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -42,6 +42,7 @@ #include "dp_gui_theextmgr.hxx" #include "dp_gui_theextmgr.hxx" #include "dp_identifier.hxx" +#include "dp_update.hxx" #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index a27f04326b25..b27cd8da81fe 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -112,6 +112,7 @@ #include "dp_identifier.hxx" #include "dp_version.hxx" #include "dp_misc.h" +#include "dp_update.hxx" #include "dp_gui.h" #include "dp_gui.hrc" @@ -254,7 +255,7 @@ private: }; // A multimap in case an extension is installed in "user", "shared" or "bundled" - typedef std::multimap< rtl::OUString, Entry > Map; + typedef std::map< rtl::OUString, Entry > Map; virtual ~Thread(); @@ -357,78 +358,44 @@ UpdateDialog::Thread::~Thread() void UpdateDialog::Thread::execute() { - OSL_ASSERT( ! m_vExtensionList.empty() ); - Map map; - - typedef std::vector< css::uno::Reference< css::deployment::XPackage > >::const_iterator ITER; - for ( ITER iIndex = m_vExtensionList.begin(); iIndex < m_vExtensionList.end(); ++iIndex ) { - css::uno::Reference< css::deployment::XPackage > p = *iIndex; - if ( p.is() ) - { - { - vos::OGuard g( Application::GetSolarMutex() ); - if ( m_stop ) { - return; - } - } - getOwnUpdateInformation( p, &map ); - } - } - - const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL()); - if (sDefaultURL.getLength()) - { - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > - infos( - getUpdateInformation( - css::uno::Reference< css::deployment::XPackage >(), - css::uno::Sequence< rtl::OUString >(&sDefaultURL, 1), rtl::OUString())); - for (sal_Int32 i = 0; i < infos.getLength(); ++i) { - css::uno::Reference< css::xml::dom::XNode > node( - infos[i], css::uno::UNO_QUERY_THROW); - dp_misc::DescriptionInfoset infoset(m_context, node); - boost::optional< rtl::OUString > id(infoset.getIdentifier()); - if (!id) { - continue; - } - Map::iterator end(map.upper_bound(*id)); - for (Map::iterator j(map.lower_bound(*id)); j != end; ++j) { - //skip those extension which provide its own update urls - if (j->second.bProvidesOwnUpdate) - continue; - rtl::OUString v(infoset.getVersion()); - //look for the highest version in the online repository - if (dp_misc::compareVersions(v, j->second.version) == - dp_misc::GREATER) - { - j->second.version = v; - j->second.info = node; - } - } + vos::OGuard g( Application::GetSolarMutex() ); + if ( m_stop ) { + return; } } - css::uno::Reference extMgr = css::deployment::ExtensionManager::get(m_context); - for (Map::iterator i(map.begin()); i != map.end(); ++i) + + std::vector, css::uno::Any > > errors; + + dp_misc::UpdateInfoMap updateInfoMap = dp_misc::getOnlineUpdateInfos( + m_context, extMgr, m_updateInformation, &m_vExtensionList, errors); + + typedef std::vector, + css::uno::Any> >::const_iterator ITERROR; + for (ITERROR ite = errors.begin(); ite != errors.end(); ite ++) + handleSpecificError(ite->first, ite->second); + + for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); i++) { + dp_misc::UpdateInfo const & info = i->second; + UpdateData updateData(info.extension); + DisabledUpdate disableUpdate; //determine if online updates meet the requirements - prepareUpdateData(i->second.info, - i->second.disableUpdate, i->second.updateData); + prepareUpdateData(info.info, disableUpdate, updateData); //determine if the update is installed in the user or shared repository rtl::OUString sOnlineVersion; - if (i->second.updateData.aUpdateInfo.is()) - sOnlineVersion = i->second.version; - + if (info.info.is()) + sOnlineVersion = info.version; rtl::OUString sVersionUser; rtl::OUString sVersionShared; rtl::OUString sVersionBundled; css::uno::Sequence< css::uno::Reference< css::deployment::XPackage> > extensions; try { extensions = extMgr->getExtensionsWithSameIdentifier( - dp_misc::getIdentifier(i->second.package), i->second.package->getName(), + dp_misc::getIdentifier(info.extension), info.extension->getName(), css::uno::Reference()); } catch (css::lang::IllegalArgumentException& ) { OSL_ASSERT(0); @@ -453,15 +420,15 @@ void UpdateDialog::Thread::execute() { if (sourceUser == dp_misc::UPDATE_SOURCE_SHARED) { - i->second.updateData.aUpdateSource = extensions[1]; - i->second.updateData.updateVersion = extensions[1]->getVersion(); + updateData.aUpdateSource = extensions[1]; + updateData.updateVersion = extensions[1]->getVersion(); } else if (sourceUser == dp_misc::UPDATE_SOURCE_BUNDLED) { - i->second.updateData.aUpdateSource = extensions[2]; - i->second.updateData.updateVersion = extensions[2]->getVersion(); + updateData.aUpdateSource = extensions[2]; + updateData.updateVersion = extensions[2]->getVersion(); } - if (!update(i->second.disableUpdate, i->second.updateData)) + if (!update(disableUpdate, updateData)) return; } @@ -469,11 +436,11 @@ void UpdateDialog::Thread::execute() { if (sourceShared == dp_misc::UPDATE_SOURCE_BUNDLED) { - i->second.updateData.aUpdateSource = extensions[2]; - i->second.updateData.updateVersion = extensions[2]->getVersion(); + updateData.aUpdateSource = extensions[2]; + updateData.updateVersion = extensions[2]->getVersion(); } - i->second.updateData.bIsShared = true; - if (!update(i->second.disableUpdate, i->second.updateData)) + updateData.bIsShared = true; + if (!update(disableUpdate, updateData)) return; } } @@ -517,71 +484,6 @@ void UpdateDialog::Thread::handleSpecificError( } } -css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > -UpdateDialog::Thread::getUpdateInformation( - css::uno::Reference< css::deployment::XPackage > const & package, - css::uno::Sequence< rtl::OUString > const & urls, - rtl::OUString const & identifier) const -{ - try { - return m_updateInformation->getUpdateInformation(urls, identifier); - } catch (css::uno::RuntimeException &) { - throw; - } catch (css::ucb::CommandFailedException & e) { - handleSpecificError(package, e.Reason); - } catch (css::ucb::CommandAbortedException &) { - } catch (css::uno::Exception & e) { - handleSpecificError(package, css::uno::makeAny(e)); - } - return - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > >(); -} - -void UpdateDialog::Thread::getOwnUpdateInformation( - css::uno::Reference< css::deployment::XPackage > const & package, - Map * map) -{ - rtl::OUString id(dp_misc::getIdentifier(package)); - css::uno::Sequence< rtl::OUString > urls( - package->getUpdateInformationURLs()); - if (urls.getLength() == 0) { - map->insert( - Map::value_type( - id, Entry(package, OUSTR("")))); - } else { - css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > - infos(getUpdateInformation(package, urls, id)); - rtl::OUString latestVersion; - sal_Int32 latestIndex = -1; - for (sal_Int32 i = 0; i < infos.getLength(); ++i) { - dp_misc::DescriptionInfoset infoset( - m_context, - css::uno::Reference< css::xml::dom::XNode >( - infos[i], css::uno::UNO_QUERY_THROW)); - boost::optional< rtl::OUString > id2(infoset.getIdentifier()); - if (!id2) { - continue; - } - if (*id2 == id) { - rtl::OUString v(infoset.getVersion()); - if (dp_misc::compareVersions(v, latestVersion) == - dp_misc::GREATER) - { - latestVersion = v; - latestIndex = i; - } - } - } - if (latestIndex != -1) { - Entry e(package, latestVersion); - e.info = css::uno::Reference< css::xml::dom::XNode >( - infos[latestIndex], css::uno::UNO_QUERY_THROW); - e.bProvidesOwnUpdate = true; - map->insert(Map::value_type(id, e)); - } - } -} - ::rtl::OUString UpdateDialog::Thread::getUpdateDisplayString( dp_gui::UpdateData const & data, ::rtl::OUString const & version) const { @@ -590,7 +492,8 @@ void UpdateDialog::Thread::getOwnUpdateInformation( b.append(static_cast< sal_Unicode >(' ')); { vos::OGuard g( Application::GetSolarMutex() ); - b.append(m_dialog.m_version); + if(!m_stop) + b.append(m_dialog.m_version); } b.append(static_cast< sal_Unicode >(' ')); if (version.getLength()) @@ -603,7 +506,8 @@ void UpdateDialog::Thread::getOwnUpdateInformation( b.append(static_cast< sal_Unicode >(' ')); { vos::OGuard g( Application::GetSolarMutex() ); - b.append(m_dialog.m_browserbased); + if(!m_stop) + b.append(m_dialog.m_browserbased); } } return b.makeStringAndClear(); diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h index 161b91a6bcde..61e3fcc45418 100644 --- a/desktop/source/deployment/inc/dp_misc.h +++ b/desktop/source/deployment/inc/dp_misc.h @@ -117,11 +117,6 @@ oslProcess raiseProcess( ::rtl::OUString const & appURL, ::com::sun::star::uno::Sequence< ::rtl::OUString > const & args ); //============================================================================== -/** returns the default update URL (for the update information) which - is used when an extension does not provide its own URL. -*/ -DESKTOP_DEPLOYMENTMISC_DLLPUBLIC -::rtl::OUString getExtensionDefaultUpdateURL(); /** writes the argument string to the console. On Linux/Unix/etc. it converts the UTF16 string to an ANSI string using @@ -179,53 +174,6 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC void syncRepositories(::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv); -enum UPDATE_SOURCE -{ - UPDATE_SOURCE_NONE, - UPDATE_SOURCE_SHARED, - UPDATE_SOURCE_BUNDLED, - UPDATE_SOURCE_ONLINE -}; - -/* determine if an update is available which is installed in the - user repository. - - If the return value is UPDATE_SOURCE_NONE, then no update is - available, otherwise the return value determine from which the - repository the update is used. -*/ -DESKTOP_DEPLOYMENTMISC_DLLPUBLIC -UPDATE_SOURCE isUpdateUserExtension( - bool bReadOnlyShared, - ::rtl::OUString const & userVersion, - ::rtl::OUString const & sharedVersion, - ::rtl::OUString const & bundledVersion, - ::rtl::OUString const & onlineVersion); - -/* determine if an update is available which is installed in the - shared repository. - - If the return value is UPDATE_SOURCE_NONE, then no update is - available, otherwise the return value determine from which the - repository the update is used. -*/ -DESKTOP_DEPLOYMENTMISC_DLLPUBLIC -UPDATE_SOURCE isUpdateSharedExtension( - bool bReadOnlyShared, - ::rtl::OUString const & sharedVersion, - ::rtl::OUString const & bundledVersion, - ::rtl::OUString const & onlineVersion); - -/* determines the extension with the highest identifier and returns it - - */ -DESKTOP_DEPLOYMENTMISC_DLLPUBLIC -::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> -getExtensionWithHighestVersion( - ::com::sun::star::uno::Sequence< - ::com::sun::star::uno::Reference< - ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId); - } #endif diff --git a/desktop/source/deployment/inc/dp_update.hxx b/desktop/source/deployment/inc/dp_update.hxx new file mode 100755 index 000000000000..01511b1f2d21 --- /dev/null +++ b/desktop/source/deployment/inc/dp_update.hxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_DP_UPDATE_HXX +#define INCLUDED_DP_UPDATE_HXX + + +#include "com/sun/star/deployment/XPackage.hpp" +#include "com/sun/star/deployment/XExtensionManager.hpp" +#include "com/sun/star/deployment/XUpdateInformationProvider.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/xml/dom/XNode.hpp" + +#include "rtl/ustrbuf.hxx" +#include "dp_misc_api.hxx" + +#include +#include + +namespace dp_misc { + +/** returns the default update URL (for the update information) which + is used when an extension does not provide its own URL. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +::rtl::OUString getExtensionDefaultUpdateURL(); + +enum UPDATE_SOURCE +{ + UPDATE_SOURCE_NONE, + UPDATE_SOURCE_SHARED, + UPDATE_SOURCE_BUNDLED, + UPDATE_SOURCE_ONLINE +}; + +/* determine if an update is available which is installed in the + user repository. + + If the return value is UPDATE_SOURCE_NONE, then no update is + available, otherwise the return value determine from which the + repository the update is used. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UPDATE_SOURCE isUpdateUserExtension( + bool bReadOnlyShared, + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion); + +/* determine if an update is available which is installed in the + shared repository. + + If the return value is UPDATE_SOURCE_NONE, then no update is + available, otherwise the return value determine from which the + repository the update is used. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UPDATE_SOURCE isUpdateSharedExtension( + bool bReadOnlyShared, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion); + +/* determines the extension with the highest identifier and returns it + + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> +getExtensionWithHighestVersion( + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId); + + +struct UpdateInfo +{ + UpdateInfo( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & ext); + ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage> extension; +//version of the update + ::rtl::OUString version; + ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > info; +}; + +typedef std::map< ::rtl::OUString, UpdateInfo > UpdateInfoMap; + +/* + @param extensionList + List of extension for which online update information are to be obtained. If NULL, then + for update information are obtained for all installed extension. There may be only one extension + with a particular identifier contained in the list. If one extension is installed + in several repositories, then the one with the highest version must be used, because it contains + the more recent URLs for getting the update information (if at all). + @param out_errors + the first member of the pair is the extension and the second the exception that was produced + when processing the extension. + + @return + A map of UpdateInfo instances. If the parameter extensionList was given, then the map contains + at only information for those extensions. + */ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +UpdateInfoMap getOnlineUpdateInfos( + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const &xContext, + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager> const & xExtMgr, + ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XUpdateInformationProvider > const & updateInformation, + std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > > const * extensionList, + ::std::vector< ::std::pair< ::com::sun::star::uno::Reference< + ::com::sun::star::deployment::XPackage>, ::com::sun::star::uno::Any> > & out_errors); + +/* retunrs the highest version from the provided arguments. +*/ +DESKTOP_DEPLOYMENTMISC_DLLPUBLIC +::rtl::OUString getHighestVersion( + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion); + +} + +#endif diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx index 537b7233ef77..ca2c7b5438cf 100644 --- a/desktop/source/deployment/manager/dp_informationprovider.cxx +++ b/desktop/source/deployment/manager/dp_informationprovider.cxx @@ -55,6 +55,7 @@ #include "dp_identifier.hxx" #include "dp_version.hxx" #include "dp_misc.h" +#include "dp_update.hxx" namespace beans = com::sun::star::beans ; namespace deployment = com::sun::star::deployment ; @@ -107,16 +108,6 @@ private: const rtl::OUString& _sExtensionId ); uno::Reference< deployment::XUpdateInformationProvider > mxUpdateInformation; - - uno::Sequence< uno::Reference< xml::dom::XElement > > - getUpdateInformation( uno::Sequence< rtl::OUString > const & urls, - rtl::OUString const & identifier ) const; - uno::Sequence< uno::Reference< deployment::XPackage > > - getPackages(rtl::OUString const & repository); - uno::Sequence< uno::Sequence< rtl::OUString > > isUpdateAvailable( - rtl::OUString const & repository, const rtl::OUString& _sExtensionId ); - uno::Sequence< uno::Sequence< rtl::OUString > > concatLists( uno::Sequence< uno::Sequence< rtl::OUString > > aFirst, - uno::Sequence< uno::Sequence< rtl::OUString > > aSecond ); }; //------------------------------------------------------------------------------ @@ -212,18 +203,101 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvider::isUpdateAvailable( const rtl::OUString& _sExtensionId ) throw ( uno::RuntimeException ) { - uno::Sequence< uno::Sequence< rtl::OUString > > - aUpdateListUser = isUpdateAvailable( UNISTRING("user"), _sExtensionId ); + uno::Sequence< uno::Sequence< rtl::OUString > > aList; - uno::Sequence< uno::Sequence< rtl::OUString > > - aUpdateListShared = isUpdateAvailable( UNISTRING("shared"), _sExtensionId ); + uno::Reference extMgr = + deployment::ExtensionManager::get(mxContext); - uno::Sequence< uno::Sequence< rtl::OUString > > - aUpdateListBundled = isUpdateAvailable( UNISTRING("bundled"), _sExtensionId ); + if (!extMgr.is()) + { + OSL_ASSERT(0); + return aList; + } + std::vector, uno::Any > > errors; + dp_misc::UpdateInfoMap updateInfoMap; + if (_sExtensionId.getLength()) + { + std::vector > vecExtensions; + uno::Reference extension; + try + { + extension = dp_misc::getExtensionWithHighestVersion( + extMgr->getExtensionsWithSameIdentifier( + _sExtensionId, _sExtensionId, uno::Reference())); + vecExtensions.push_back(extension); + } + catch (lang::IllegalArgumentException &) + { + OSL_ASSERT(0); + } + updateInfoMap = dp_misc::getOnlineUpdateInfos( + mxContext, extMgr, mxUpdateInformation, &vecExtensions, errors); + } + else + { + updateInfoMap = dp_misc::getOnlineUpdateInfos( + mxContext, extMgr, mxUpdateInformation, NULL, errors); + } + + int nCount = 0; + for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); i++) + { + dp_misc::UpdateInfo const & info = i->second; + + rtl::OUString sOnlineVersion; + if (info.info.is()) + sOnlineVersion = info.version; + + rtl::OUString sVersionUser; + rtl::OUString sVersionShared; + rtl::OUString sVersionBundled; + uno::Sequence< uno::Reference< deployment::XPackage> > extensions; + try { + extensions = extMgr->getExtensionsWithSameIdentifier( + dp_misc::getIdentifier(info.extension), info.extension->getName(), + uno::Reference()); + } catch (lang::IllegalArgumentException& ) { + OSL_ASSERT(0); + } + OSL_ASSERT(extensions.getLength() == 3); + if (extensions[0].is() ) + sVersionUser = extensions[0]->getVersion(); + if (extensions[1].is() ) + sVersionShared = extensions[1]->getVersion(); + if (extensions[2].is() ) + sVersionBundled = extensions[2]->getVersion(); + + bool bSharedReadOnly = extMgr->isReadOnlyRepository(OUSTR("shared")); + + dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension( + bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion); + dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension( + bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion); + + rtl::OUString updateVersionUser; + rtl::OUString updateVersionShared; + if (sourceUser != dp_misc::UPDATE_SOURCE_NONE) + updateVersionUser = dp_misc::getHighestVersion( + rtl::OUString(), sVersionShared, sVersionBundled, sOnlineVersion); + if (sourceShared != dp_misc::UPDATE_SOURCE_NONE) + updateVersionShared = dp_misc::getHighestVersion( + rtl::OUString(), rtl::OUString(), sVersionBundled, sOnlineVersion); + rtl::OUString updateVersion; + if (dp_misc::compareVersions(updateVersionUser, updateVersionShared) == dp_misc::GREATER) + updateVersion = updateVersionUser; + else + updateVersion = updateVersionShared; + if (updateVersion.getLength()) + { - uno::Sequence< uno::Sequence< rtl::OUString > > user_shared = - concatLists( aUpdateListUser, aUpdateListShared ); - return concatLists(user_shared, aUpdateListBundled); + rtl::OUString aNewEntry[2]; + aNewEntry[0] = i->first; + aNewEntry[1] = updateVersion; + aList.realloc( ++nCount ); + aList[ nCount-1 ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 ); + } + } + return aList; } //------------------------------------------------------------------------------ @@ -257,7 +331,7 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvi for (sal_Int32 j = 0; j < cExt; j++) { //ToDo according to the old code the first found extenions is used - //even if another one with the same id has a better version. Design flaw? + //even if another one with the same id has a better version. uno::Reference< deployment::XPackage > const & xExtension( seqExtension[j] ); if (xExtension.is()) { @@ -272,167 +346,6 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvi return retList; } -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -uno::Sequence< uno::Reference< deployment::XPackage > > -PackageInformationProvider::getPackages( const rtl::OUString & repository ) -{ - uno::Sequence< uno::Reference< deployment::XPackage > > packages; - try { - uno::Reference xMgr = deployment::ExtensionManager::get(mxContext); - packages = xMgr->getDeployedExtensions(repository, uno::Reference< task::XAbortChannel >(), - static_cast < XCommandEnvironment *> (this) ); - } - catch ( deployment::DeploymentException & ) - {} - catch ( css_ucb::CommandFailedException & ) - {} - catch ( css_ucb::CommandAbortedException & ) - {} - catch ( lang::IllegalArgumentException & e ) - { - throw uno::RuntimeException(e.Message, e.Context); - } - - return packages; -} - -//------------------------------------------------------------------------------ -uno::Sequence< uno::Reference< xml::dom::XElement > > - PackageInformationProvider::getUpdateInformation( uno::Sequence< rtl::OUString > const & urls, - rtl::OUString const & identifier ) const -{ - try - { - return mxUpdateInformation->getUpdateInformation( urls, identifier ); - } - catch ( uno::RuntimeException & ) { - throw; - } - catch ( css_ucb::CommandFailedException & ) {} - catch ( css_ucb::CommandAbortedException & ) {} - catch ( uno::Exception & ) {} - - return uno::Sequence< uno::Reference< xml::dom::XElement > >(); -} - -//------------------------------------------------------------------------------ -uno::Sequence< uno::Sequence< rtl::OUString > > - PackageInformationProvider::isUpdateAvailable( - const rtl::OUString& repository, - const rtl::OUString& _sExtensionId ) -{ - uno::Sequence< uno::Sequence< rtl::OUString > > aList; - sal_Int32 nCount = 0; - bool bPackageFound = false; - - uno::Reference xManager = deployment::ExtensionManager::get(mxContext); - // If the package manager is readonly then the user cannot modify anything anyway - // so we can abort the search here - if ( xManager.is() && ! xManager->isReadOnlyRepository(repository) ) - { - uno::Sequence< uno::Reference< deployment::XPackage > > packages( getPackages( repository ) ); - uno::Sequence< uno::Reference< xml::dom::XElement > > defaultInfos; - - for ( int pos = packages.getLength(); pos-- && !bPackageFound; ) - { - uno::Reference< deployment::XPackage > package( packages[ pos ] ); - uno::Sequence< rtl::OUString > urls( package->getUpdateInformationURLs()); - uno::Sequence< uno::Reference< xml::dom::XElement > > infos; - rtl::OUString id( dp_misc::getIdentifier( package ) ); - - if ( _sExtensionId.getLength() ) - { - if ( _sExtensionId == id ) - bPackageFound = true; - else /* we have an ID and the IDs don't match, continue with next package */ - continue; - } - - if ( urls.getLength() != 0) - { - infos = getUpdateInformation( urls, id ); - } - else - { - if ( defaultInfos.getLength() == 0 ) - { - const rtl::OUString defaultURL( dp_misc::getExtensionDefaultUpdateURL() ); - if ( defaultURL.getLength() ) - defaultInfos = getUpdateInformation( uno::Sequence< rtl::OUString >( &defaultURL, 1 ), - rtl::OUString() ); - } - infos = defaultInfos; - } - rtl::OUString latestVersion( package->getVersion() ); - sal_Int32 latestIndex = -1; - for ( sal_Int32 i = 0; i < infos.getLength(); ++i ) - { - dp_misc::DescriptionInfoset infoset( mxContext, - uno::Reference< xml::dom::XNode >( infos[i], uno::UNO_QUERY_THROW)); - boost::optional< rtl::OUString > id2( infoset.getIdentifier() ); - - if (!id2) - continue; - - if (*id2 == id) - { - // check, if there are unsatisfied dependencies and ignore those updates - uno::Sequence< uno::Reference< xml::dom::XElement > > ds( dp_misc::Dependencies::check( infoset ) ); - if ( ds.getLength() ) - continue; - - rtl::OUString v( infoset.getVersion() ); - if ( dp_misc::compareVersions( v, latestVersion ) == dp_misc::GREATER ) - { - latestVersion = v; - latestIndex = i; - } - } - } - if ( latestIndex != -1 ) - { - rtl::OUString aNewEntry[2]; - aNewEntry[0] = id; - aNewEntry[1] = latestVersion; - aList.realloc( ++nCount ); - aList[ nCount-1 ] = ::uno::Sequence< rtl::OUString >( aNewEntry, 2 ); - } - } - } - return aList; -} - -//------------------------------------------------------------------------------ -uno::Sequence< uno::Sequence< rtl::OUString > > PackageInformationProvider::concatLists( - uno::Sequence< uno::Sequence< rtl::OUString > > aFirst, - uno::Sequence< uno::Sequence< rtl::OUString > > aSecond ) -{ - sal_Int32 nFirstCount = aFirst.getLength(); - sal_Int32 nSecondCount = aSecond.getLength(); - sal_Int32 nIndex = nFirstCount; - - for ( sal_Int32 i=0; i < nSecondCount; i++ ) - { - bool bDuplicateEntry = false; - for ( sal_Int32 j=0; j < nFirstCount; j++ ) - { - if ( aFirst[ j ][0] == aSecond[ i ][0] ) - { - bDuplicateEntry = true; - break; - } - } - if ( !bDuplicateEntry ) - { - nIndex += 1; - aFirst.realloc( nIndex ); - aFirst[ nIndex - 1 ] = aSecond[ i ]; - } - } - return aFirst; -} //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 53d488095ecd..fe3490903043 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -477,17 +477,6 @@ Reference resolveUnoURL( } } -OUString getExtensionDefaultUpdateURL() -{ - ::rtl::OUString sUrl( - RTL_CONSTASCII_USTRINGPARAM( - "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") - ":Version:ExtensionUpdateURL}")); - ::rtl::Bootstrap::expandMacros(sUrl); - return sUrl; -} - - #ifdef WNT void writeConsoleWithStream(::rtl::OUString const & sText, HANDLE stream) { @@ -631,147 +620,6 @@ void syncRepositories(Reference const & xCmdEnv) } } -/* returns the index of the greatest version, starting with 0 - - */ -int determineHighestVersion( - ::rtl::OUString const & userVersion, - ::rtl::OUString const & sharedVersion, - ::rtl::OUString const & bundledVersion, - ::rtl::OUString const & onlineVersion) -{ - int index = 0; - OUString greatest = userVersion; - if (dp_misc::compareVersions(sharedVersion, greatest) == dp_misc::GREATER) - { - index = 1; - greatest = sharedVersion; - } - if (dp_misc::compareVersions(bundledVersion, greatest) == dp_misc::GREATER) - { - index = 2; - greatest = bundledVersion; - } - if (dp_misc::compareVersions(onlineVersion, greatest) == dp_misc::GREATER) - { - index = 3; - } - return index; -} - -UPDATE_SOURCE isUpdateUserExtension( - bool bReadOnlyShared, - ::rtl::OUString const & userVersion, - ::rtl::OUString const & sharedVersion, - ::rtl::OUString const & bundledVersion, - ::rtl::OUString const & onlineVersion) -{ - UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; - if (bReadOnlyShared) - { - if (userVersion.getLength()) - { - int index = determineHighestVersion( - userVersion, sharedVersion, bundledVersion, onlineVersion); - if (index == 1) - retVal = UPDATE_SOURCE_SHARED; - else if (index == 2) - retVal = UPDATE_SOURCE_BUNDLED; - else if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - } - else if (sharedVersion.getLength()) - { - int index = determineHighestVersion( - OUString(), sharedVersion, bundledVersion, onlineVersion); - if (index == 2) - retVal = UPDATE_SOURCE_BUNDLED; - else if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - - } - else if (bundledVersion.getLength()) - { - int index = determineHighestVersion( - OUString(), OUString(), bundledVersion, onlineVersion); - if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - } - } - else - { - if (userVersion.getLength()) - { - int index = determineHighestVersion( - userVersion, sharedVersion, bundledVersion, onlineVersion); - if (index == 1) - retVal = UPDATE_SOURCE_SHARED; - else if (index == 2) - retVal = UPDATE_SOURCE_BUNDLED; - else if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - } - } - - return retVal; -} - -UPDATE_SOURCE isUpdateSharedExtension( - bool bReadOnlyShared, - ::rtl::OUString const & sharedVersion, - ::rtl::OUString const & bundledVersion, - ::rtl::OUString const & onlineVersion) -{ - if (bReadOnlyShared) - return UPDATE_SOURCE_NONE; - UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; - - if (sharedVersion.getLength()) - { - int index = determineHighestVersion( - OUString(), sharedVersion, bundledVersion, onlineVersion); - if (index == 2) - retVal = UPDATE_SOURCE_BUNDLED; - else if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - } - else if (bundledVersion.getLength()) - { - int index = determineHighestVersion( - OUString(), OUString(), bundledVersion, onlineVersion); - if (index == 3) - retVal = UPDATE_SOURCE_ONLINE; - } - return retVal; -} - -Reference -getExtensionWithHighestVersion( - Sequence > const & seqExt) -{ - if (seqExt.getLength() == 0) - return Reference(); - - Reference greatest; - sal_Int32 len = seqExt.getLength(); - - for (sal_Int32 i = 0; i < len; i++) - { - if (!greatest.is()) - { - greatest = seqExt[i]; - continue; - } - Reference const & current = seqExt[i]; - //greatest has a value - if (! current.is()) - continue; - - if (dp_misc::compareVersions(current->getVersion(), greatest->getVersion()) == dp_misc::GREATER) - greatest = current; - } - return greatest; -} } diff --git a/desktop/source/deployment/misc/dp_update.cxx b/desktop/source/deployment/misc/dp_update.cxx new file mode 100755 index 000000000000..52011f1f0ca0 --- /dev/null +++ b/desktop/source/deployment/misc/dp_update.cxx @@ -0,0 +1,397 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_desktop.hxx" + + +#include "dp_update.hxx" +#include "dp_version.hxx" +#include "dp_identifier.hxx" +#include "dp_descriptioninfoset.hxx" + +#include "rtl/bootstrap.hxx" + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using ::rtl::OUString; +using ::rtl::OString; + + +namespace dp_misc { +namespace { + +int determineHighestVersion( + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + int index = 0; + OUString greatest = userVersion; + if (dp_misc::compareVersions(sharedVersion, greatest) == dp_misc::GREATER) + { + index = 1; + greatest = sharedVersion; + } + if (dp_misc::compareVersions(bundledVersion, greatest) == dp_misc::GREATER) + { + index = 2; + greatest = bundledVersion; + } + if (dp_misc::compareVersions(onlineVersion, greatest) == dp_misc::GREATER) + { + index = 3; + } + return index; +} + +Sequence< Reference< xml::dom::XElement > > +getUpdateInformation( Reference const & updateInformation, + Sequence< OUString > const & urls, + OUString const & identifier, + uno::Any & out_error) +{ + try { + return updateInformation->getUpdateInformation(urls, identifier); + } catch (uno::RuntimeException &) { + throw; + } catch (ucb::CommandFailedException & e) { + out_error = e.Reason; + } catch (ucb::CommandAbortedException &) { + } catch (uno::Exception & e) { + out_error = uno::makeAny(e); + } + return + Sequence >(); +} + +//Put in anonymous namespace + +void getOwnUpdateInfos( + Reference const & xContext, + Reference const & updateInformation, + UpdateInfoMap& inout_map, std::vector, uno::Any> > & out_errors, + bool & out_allFound) +{ + bool allHaveOwnUpdateInformation = true; + for (UpdateInfoMap::iterator i = inout_map.begin(); i != inout_map.end(); i++) + { + OSL_ASSERT(i->second.extension.is()); + Sequence urls(i->second.extension->getUpdateInformationURLs()); + if (urls.getLength()) + { + const OUString id = dp_misc::getIdentifier(i->second.extension); + uno::Any anyError; + //It is unclear from the idl if there can be a null reference returned. + //However all valid information should be the same + Sequence > + infos(getUpdateInformation(updateInformation, urls, id, anyError)); + if (anyError.hasValue()) + out_errors.push_back(std::make_pair(i->second.extension, anyError)); + + for (sal_Int32 j = 0; j < infos.getLength(); ++j) + { + dp_misc::DescriptionInfoset infoset( + xContext, + Reference< xml::dom::XNode >(infos[j], UNO_QUERY_THROW)); + if (!infoset.hasDescription()) + continue; + boost::optional< OUString > id2(infoset.getIdentifier()); + if (!id2) + continue; + OSL_ASSERT(*id2 == id); + if (*id2 == id) + { + i->second.version = infoset.getVersion(); + i->second.info = Reference< xml::dom::XNode >( + infos[j], UNO_QUERY_THROW); + } + break; + } + } + else + { + allHaveOwnUpdateInformation &= false; + } + } + out_allFound = allHaveOwnUpdateInformation; +} + +void getDefaultUpdateInfos( + Reference const & xContext, + Reference const & updateInformation, + UpdateInfoMap& inout_map, + std::vector, uno::Any> > & out_errors) +{ + const rtl::OUString sDefaultURL(dp_misc::getExtensionDefaultUpdateURL()); + OSL_ASSERT(sDefaultURL.getLength()); + + Any anyError; + Sequence< Reference< xml::dom::XElement > > + infos( + getUpdateInformation( + updateInformation, + Sequence< OUString >(&sDefaultURL, 1), OUString(), anyError)); + if (anyError.hasValue()) + out_errors.push_back(std::make_pair(Reference(), anyError)); + for (sal_Int32 i = 0; i < infos.getLength(); ++i) + { + Reference< xml::dom::XNode > node(infos[i], UNO_QUERY_THROW); + dp_misc::DescriptionInfoset infoset(xContext, node); + boost::optional< OUString > id(infoset.getIdentifier()); + if (!id) { + continue; + } + UpdateInfoMap::iterator j = inout_map.find(*id); + if (j != inout_map.end()) + { + //skip those extension which provide its own update urls + if (j->second.extension->getUpdateInformationURLs().getLength()) + continue; + OUString v(infoset.getVersion()); + //look for the highest version in the online repository + if (dp_misc::compareVersions(v, j->second.version) == + dp_misc::GREATER) + { + j->second.version = v; + j->second.info = node; + } + } + } +} + + +} // anon namespace + + +OUString getExtensionDefaultUpdateURL() +{ + ::rtl::OUString sUrl( + RTL_CONSTASCII_USTRINGPARAM( + "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") + ":Version:ExtensionUpdateURL}")); + ::rtl::Bootstrap::expandMacros(sUrl); + return sUrl; +} + +/* returns the index of the greatest version, starting with 0 + + */ +UPDATE_SOURCE isUpdateUserExtension( + bool bReadOnlyShared, + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; + if (bReadOnlyShared) + { + if (userVersion.getLength()) + { + int index = determineHighestVersion( + userVersion, sharedVersion, bundledVersion, onlineVersion); + if (index == 1) + retVal = UPDATE_SOURCE_SHARED; + else if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + else if (sharedVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), sharedVersion, bundledVersion, onlineVersion); + if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + + } + else if (bundledVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), OUString(), bundledVersion, onlineVersion); + if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + } + else + { + if (userVersion.getLength()) + { + int index = determineHighestVersion( + userVersion, sharedVersion, bundledVersion, onlineVersion); + if (index == 1) + retVal = UPDATE_SOURCE_SHARED; + else if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + } + + return retVal; +} + +UPDATE_SOURCE isUpdateSharedExtension( + bool bReadOnlyShared, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + if (bReadOnlyShared) + return UPDATE_SOURCE_NONE; + UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE; + + if (sharedVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), sharedVersion, bundledVersion, onlineVersion); + if (index == 2) + retVal = UPDATE_SOURCE_BUNDLED; + else if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + else if (bundledVersion.getLength()) + { + int index = determineHighestVersion( + OUString(), OUString(), bundledVersion, onlineVersion); + if (index == 3) + retVal = UPDATE_SOURCE_ONLINE; + } + return retVal; +} + +Reference +getExtensionWithHighestVersion( + Sequence > const & seqExt) +{ + if (seqExt.getLength() == 0) + return Reference(); + + Reference greatest; + sal_Int32 len = seqExt.getLength(); + + for (sal_Int32 i = 0; i < len; i++) + { + if (!greatest.is()) + { + greatest = seqExt[i]; + continue; + } + Reference const & current = seqExt[i]; + //greatest has a value + if (! current.is()) + continue; + + if (dp_misc::compareVersions(current->getVersion(), greatest->getVersion()) == dp_misc::GREATER) + greatest = current; + } + return greatest; +} + +UpdateInfo::UpdateInfo( Reference< deployment::XPackage> const & ext): +extension(ext) +{ +} + + + +UpdateInfoMap getOnlineUpdateInfos( + Reference const &xContext, + Reference const & xExtMgr, + Reference const & updateInformation, + std::vector > const * extensionList, + std::vector, uno::Any> > & out_errors) +{ + OSL_ASSERT(xExtMgr.is()); + UpdateInfoMap infoMap; + if (!xExtMgr.is()) + return infoMap; + + if (!extensionList) + { + const uno::Sequence< uno::Sequence< Reference > > seqAllExt = xExtMgr->getAllExtensions( + Reference(), Reference()); + + //fill the UpdateInfoMap. key = extension identifier, value = UpdateInfo + for (int pos = seqAllExt.getLength(); pos --; ) + { + uno::Sequence > const & seqExt = seqAllExt[pos]; + + Reference extension = getExtensionWithHighestVersion(seqExt); + OSL_ASSERT(extension.is()); + + std::pair insertRet = infoMap.insert( + UpdateInfoMap::value_type( + dp_misc::getIdentifier(extension), UpdateInfo(extension))); + OSL_ASSERT(insertRet.second == true); + } + } + else + { + typedef std::vector >::const_iterator CIT; + for (CIT i = extensionList->begin(); i != extensionList->end(); i++) + { + OSL_ASSERT(i->is()); + std::pair insertRet = infoMap.insert( + UpdateInfoMap::value_type( + dp_misc::getIdentifier(*i), UpdateInfo(*i))); + OSL_ASSERT(insertRet.second == true); + } + } + + //Now find the update information for the extensions which provide their own + //URLs to update information. + bool allInfosObtained = false; + getOwnUpdateInfos(xContext, updateInformation, infoMap, out_errors, allInfosObtained); + + if (!allInfosObtained) + getDefaultUpdateInfos(xContext, updateInformation, infoMap, out_errors); + return infoMap; +} +OUString getHighestVersion( + ::rtl::OUString const & userVersion, + ::rtl::OUString const & sharedVersion, + ::rtl::OUString const & bundledVersion, + ::rtl::OUString const & onlineVersion) +{ + int index = determineHighestVersion(userVersion, sharedVersion, bundledVersion, onlineVersion); + switch (index) + { + case 0: return userVersion; + case 1: return sharedVersion; + case 2: return bundledVersion; + case 3: return onlineVersion; + default: OSL_ASSERT(0); + } + + return OUString(); +} +} //namespace dp_misc diff --git a/desktop/source/deployment/misc/makefile.mk b/desktop/source/deployment/misc/makefile.mk index 9a7f1d62e001..3e4bd68cb4c0 100644 --- a/desktop/source/deployment/misc/makefile.mk +++ b/desktop/source/deployment/misc/makefile.mk @@ -65,7 +65,8 @@ SHL1OBJS = \ $(SLO)$/dp_version.obj \ $(SLO)$/dp_descriptioninfoset.obj \ $(SLO)$/dp_dependencies.obj \ - $(SLO)$/dp_platform.obj + $(SLO)$/dp_platform.obj \ + $(SLO)$/dp_update.obj SHL1STDLIBS = \ $(BERKELEYLIB) \ -- cgit From 227d80375c8c851fe74a035d882ae316922ba6f0 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Fri, 4 Jun 2010 08:25:27 +0200 Subject: jl152#i77196# Improved progress handling on startup --- desktop/source/app/check_ext_deps.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index ebdc9ccdf51e..664e63c7f6ca 100755 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -192,7 +192,7 @@ void SilentCommandEnv::push( uno::Any const & rStatus ) if ( rStatus.hasValue() && ( rStatus >>= sText) ) { - if ( mnLevel <= 2 ) + if ( mnLevel <= 3 ) mpDesktop->SetSplashScreenText( sText ); else mpDesktop->SetSplashScreenProgress( ++mnProgress ); -- cgit From 88581862df4e46ee0f6515267ffeb46a53d1ba53 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Fri, 4 Jun 2010 16:19:25 +0200 Subject: jl152 #i77196# information upate provider now excludes online updates with unfulfilled dependencies --- desktop/source/deployment/manager/dp_informationprovider.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx index ca2c7b5438cf..4cc43a8386d8 100644 --- a/desktop/source/deployment/manager/dp_informationprovider.cxx +++ b/desktop/source/deployment/manager/dp_informationprovider.cxx @@ -246,7 +246,14 @@ PackageInformationProvider::isUpdateAvailable( const rtl::OUString& _sExtensionI rtl::OUString sOnlineVersion; if (info.info.is()) - sOnlineVersion = info.version; + { + // check, if there are unsatisfied dependencies and ignore this online update + dp_misc::DescriptionInfoset infoset(mxContext, info.info); + uno::Sequence< uno::Reference< xml::dom::XElement > > + ds( dp_misc::Dependencies::check( infoset ) ); + if ( ! ds.getLength() ) + sOnlineVersion = info.version; + } rtl::OUString sVersionUser; rtl::OUString sVersionShared; -- cgit From 421512f0dc8985da05ff9654be8a3344aae0d513 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 10 Jun 2010 14:04:48 +0200 Subject: jl152 #i77196# fixed failed start up for user without write access to share --- desktop/source/deployment/manager/dp_extensionmanager.cxx | 2 +- desktop/source/deployment/manager/dp_manager.cxx | 10 ++++++++-- .../source/deployment/registry/executable/dp_executable.cxx | 5 ++--- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 24b5712ebd30..13c43e41decf 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -1174,7 +1174,7 @@ sal_Bool ExtensionManager::synchronize( } catch (...) { uno::Any exc = ::cppu::getCaughtException(); throw deploy::DeploymentException( - OUSTR("Extension Manager: exception during enableExtension"), + OUSTR("Extension Manager: exception in synchronize"), static_cast(this), exc); } } diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 409cf2674184..44bc4d469f2f 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -183,7 +183,8 @@ void PackageManagerImpl::initActivationLayer( OSL_ASSERT( m_activePackages.getLength() > 0 ); m_activePackages_expanded = expandUnoRcUrl( m_activePackages ); m_registrationData_expanded = expandUnoRcUrl(m_registrationData); - create_folder( 0, m_activePackages_expanded, xCmdEnv, true); + if (!m_readOnly) + create_folder( 0, m_activePackages_expanded, xCmdEnv, true); OUString dbName; if (m_context.equals(OUSTR("user"))) @@ -1341,9 +1342,14 @@ bool PackageManagerImpl::synchronizeAddedExtensions( { bool bModified = false; ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); - + //check if the folder exist at all. The shared extension folder + //may not exist for a normal user. + if (!create_ucb_content( + NULL, m_activePackages_expanded, Reference(), false)) + return bModified; ::ucbhelper::Content tempFolder( m_activePackages_expanded, xCmdEnv ); + Reference xResultSet( tempFolder.createCursor( Sequence( &StrTitle::get(), 1 ), diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index c72a97d88891..968ee7297b0f 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -254,9 +254,8 @@ void BackendImpl::ExecutablePackageImpl::processPackage_( OSL_ASSERT(0); //This won't have affect on Windows - if (osl::File::E_None != osl::File::setAttributes( - dp_misc::expandUnoRcUrl(m_url), attributes)) - OSL_ENSURE(0, "Extension Manager: Could not set executable file attribute."); + osl::File::setAttributes( + dp_misc::expandUnoRcUrl(m_url), attributes); } getMyBackend()->addDataToDb(getURL()); } -- cgit From 3bdbb3f6717d8690bc5b08cf241ac6cf44518f71 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 10 Jun 2010 14:41:57 +0200 Subject: jl152 #i77196# unopkg --help prints out infos about --bundled --- desktop/source/pkgchk/unopkg/unopkg_app.cxx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'desktop') diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 621b8b0bac7c..a9a0c8271373 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -108,6 +108,8 @@ const char s_usingText [] = " deployment context;\n" " run only when no concurrent Office\n" " process(es) are running!\n" +" --bundled expert feature: operate on bundled extensions. Only\n" +" works with list, validate, reinstall;\n" " --deployment-context expert feature: explicit deployment context\n" " \n" "\n" -- cgit From 2d03198027d5422eb374696b827268033338e73e Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 10 Jun 2010 15:20:30 +0200 Subject: jl152 #i77196# unopkg checkPrerequisitesAndEnable must return sal_Int32 --- desktop/source/deployment/manager/dp_extensionmanager.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 54624514adce..64cada7da3ac 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -129,7 +129,7 @@ public: css::uno::RuntimeException); - virtual long SAL_CALL checkPrerequisitesAndEnable( + virtual sal_Int32 SAL_CALL checkPrerequisitesAndEnable( css::uno::Reference const & extension, css::uno::Reference const & xAbortChannel, css::uno::Reference const & xCmdEnv ) -- cgit From 463d6da2397ff113907eaa710fe711ee444ed3da Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 10 Jun 2010 16:55:56 +0200 Subject: jl152 #i77196# backend db wrote double entries if there was an ambiguous extension, and XExtensionManager::synchronize was run --- desktop/source/deployment/registry/dp_backenddb.cxx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 1f4a62e696d7..14b4f2374c5b 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -425,14 +425,24 @@ Reference BackendDb::writeKeyElement( const Reference doc = getDocument(); const Reference root = doc->getFirstChild(); -#if OSL_DEBUG_LEVEL > 0 - //There must not be yet an entry with the same url + //Check if there are an entry with the same url. This can be the case if the + //the status of an XPackage is ambiguous. In this case a call to activateExtension + //(dp_extensionmanager.cxx), will register the package again. See also + //Package::processPackage_impl in dp_backend.cxx. + //A package can become + //invalid after its successful registration, for example if a second extension with + //the same service is installed. const OUString sExpression( sPrefix + OUSTR(":") + sElementName + OUSTR("[@url = \"") + url + OUSTR("\"]")); - const Reference _extensionNode = + const Reference existingNode = getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); -#endif + if (existingNode.is()) + { + OSL_ASSERT(0); + //replace the existing entry. + removeEntry(url); + } + const Reference keyElement( doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sElementName)); -- cgit From 88f93ac2d640f99b46767caed96afdcd5d0cb688 Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Thu, 10 Jun 2010 17:19:42 +0200 Subject: jl152 #i77196# unopkg checkPrerequisitesAndEnable must return sal_Int32 (also in cxx) --- desktop/source/deployment/manager/dp_extensionmanager.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 13c43e41decf..de9d97db2b48 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -853,7 +853,7 @@ void ExtensionManager::enableExtension( /** */ -long ExtensionManager::checkPrerequisitesAndEnable( +sal_Int32 ExtensionManager::checkPrerequisitesAndEnable( Reference const & extension, Reference const & xAbortChannel, Reference const & xCmdEnv) -- cgit From cac00f06770da2c1217fab5b58c1426833c6a03d Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Mon, 14 Jun 2010 11:53:06 +0200 Subject: jl152 bindPackage for extensions checks only for META-INF in folders and not META-INF/manifest.xml --- desktop/source/deployment/registry/package/dp_package.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index a2c68dd2341f..2ad6478b665c 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -378,7 +378,7 @@ Reference BackendImpl::bindPackage_( //Every .oxt, uno.pkg file must contain a META-INF folder ::ucbhelper::Content metaInfContent; if (create_ucb_content( - &metaInfContent, makeURL( url, OUSTR("META-INF/manifest.xml") ), + &metaInfContent, makeURL( url, OUSTR("META-INF") ), xCmdEnv, false /* no throw */ )) { mediaType = OUSTR("application/vnd.sun.star.package-bundle"); -- cgit From 22dedfaadf4a53093a9ccbccbf3a70f78b1dbb06 Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Wed, 16 Jun 2010 14:23:17 +0200 Subject: jl152#i112437# Disabled extensions should not show an options button --- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 4ba747198c09..d57fbdb9f4ed 100755 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -281,6 +281,8 @@ void ExtBoxWithBtns_Impl::SetButtonPos( const Rectangle& rRect ) // ----------------------------------------------------------------------- void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) { + bool bShowOptionBtn = true; + pEntry->m_bHasButtons = false; if ( ( pEntry->m_eState == REGISTERED ) || ( pEntry->m_eState == NOT_AVAILABLE ) ) { @@ -291,6 +293,7 @@ void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) { m_pEnableBtn->SetText( DialogHelper::getResourceString( RID_CTX_ITEM_ENABLE ) ); m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_ENABLE ); + bShowOptionBtn = false; } if ( ( !pEntry->m_bUser || ( pEntry->m_eState == NOT_AVAILABLE ) || pEntry->m_bMissingDeps ) @@ -303,7 +306,7 @@ void ExtBoxWithBtns_Impl::SetButtonStatus( const TEntry_Impl pEntry ) pEntry->m_bHasButtons = true; } - if ( pEntry->m_bHasOptions ) + if ( pEntry->m_bHasOptions && bShowOptionBtn ) { m_pOptionsBtn->Enable( pEntry->m_bHasOptions ); m_pOptionsBtn->Show(); -- cgit