diff options
author | Carsten Driesner <cd@openoffice.org> | 2011-01-21 17:18:37 +0100 |
---|---|---|
committer | Carsten Driesner <cd@openoffice.org> | 2011-01-21 17:18:37 +0100 |
commit | 605209eda74b0b31a8da020a2dfd2bbadbb1c7d4 (patch) | |
tree | df8a931de7a4c4b1ee5ab1f7ed5506388943ecbc /desktop | |
parent | c931cca51fec6a327e94b22e93f0e2fb3fa1e43f (diff) | |
parent | d646413d464dc5d6518f87daa8538cd0c600797f (diff) |
removetooltypes01: Rebase to DEV300m98
Diffstat (limited to 'desktop')
28 files changed, 931 insertions, 475 deletions
diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index e2515187e688..3b3cba11f5a0 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -65,6 +65,8 @@ class Desktop : public Application { friend class UserInstall; + void doShutdown(); + public: enum BootstrapError { diff --git a/desktop/scripts/unopkg.sh b/desktop/scripts/unopkg.sh index 77172e549534..5020b89194d1 100644 --- a/desktop/scripts/unopkg.sh +++ b/desktop/scripts/unopkg.sh @@ -44,16 +44,27 @@ cd "$sd_cwd" #collect all bootstrap variables specified on the command line #so that they can be passed as arguments to javaldx later on +#Recognize the "sync" option. sync must be applied without any other +#options except bootstrap variables or the verbose option for arg in $@ do case "$arg" in -env:*) BOOTSTRAPVARS=$BOOTSTRAPVARS" ""$arg";; + sync) OPTSYNC=true;; + -v) VERBOSE=true;; + --verbose) VERBOSE=true;; + *) OPTOTHER=$arg;; esac done +if [ "$OPTSYNC" = "true" ] && [ -z "$OPTOTHER" ] +then + JVMFWKPARAMS='-env:UNO_JAVA_JFW_INSTALL_DATA=$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml -env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1' +fi + # extend the ld_library_path for java: javaldx checks the sofficerc for us if [ -x "$sd_prog/../basis-link/ure-link/bin/javaldx" ] ; then - my_path=`"$sd_prog/../basis-link/ure-link/bin/javaldx" $BOOTSTRAPVARS \ + my_path=`"$sd_prog/../basis-link/ure-link/bin/javaldx" $BOOTSTRAPVARS $JVMFWKPARAMS \ "-env:INIFILENAME=vnd.sun.star.pathname:$sd_prog/redirectrc"` if [ -n "$my_path" ] ; then LD_LIBRARY_PATH=$my_path${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} @@ -70,6 +81,6 @@ unset XENVIRONMENT # SAL_NO_XINITTHREADS=true; export SAL_NO_XINITTHREADS # execute binary -exec "$sd_prog/unopkg.bin" "$@" \ +exec "$sd_prog/unopkg.bin" "$@" "$JVMFWKPARAMS" \ "-env:INIFILENAME=vnd.sun.star.pathname:$sd_prog/redirectrc" diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 3ebcb6c3cd0d..2e1ab6ef2d84 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -202,6 +202,7 @@ static const ::rtl::OUString CFG_PATH_REG ( RTL_CONSTASCII_USTRINGP static const ::rtl::OUString CFG_ENTRY_REGURL ( RTL_CONSTASCII_USTRINGPARAM( "URL" )); static const ::rtl::OUString CFG_ENTRY_TEMPLATEREGURL ( RTL_CONSTASCII_USTRINGPARAM( "TemplateURL" )); +static ::rtl::OUString getBrandSharePreregBundledPathURL(); // ---------------------------------------------------------------------------- ResMgr* Desktop::GetDesktopResManager() @@ -578,6 +579,44 @@ static ::rtl::OUString getLastSyncFileURLFromUserInstallation() return aTmp.makeStringAndClear(); } +//Checks if the argument src is the folder of the help or configuration +//backend in the prereg folder +static bool excludeTmpFilesAndFolders(const rtl::OUString & src) +{ + const char helpBackend[] = "com.sun.star.comp.deployment.help.PackageRegistryBackend"; + const char configBackend[] = "com.sun.star.comp.deployment.configuration.PackageRegistryBackend"; + if (src.endsWithAsciiL(helpBackend, sizeof(helpBackend) - 1 ) + || src.endsWithAsciiL(configBackend, sizeof(configBackend) - 1)) + { + return true; + } + return false; +} + +//If we are about to copy the contents of some special folder as determined +//by excludeTmpFilesAndFolders, then we omit those files or folders with a name +//derived from temporary folders. +static bool isExcludedFileOrFolder( const rtl::OUString & name) +{ + char const * allowed[] = { + "backenddb.xml", + "configmgr.ini", + "registered_packages.db" + }; + + const unsigned int size = sizeof(allowed) / sizeof (char const *); + bool bExclude = true; + for (unsigned int i= 0; i < size; i ++) + { + ::rtl::OUString allowedName = ::rtl::OUString::createFromAscii(allowed[i]); + if (allowedName.equals(name)) + { + bExclude = false; + break; + } + } + return bExclude; +} static osl::FileBase::RC copy_bundled_recursive( const rtl::OUString& srcUnqPath, @@ -605,6 +644,7 @@ throw() sal_Int32 n_Mask = FileStatusMask_FileURL | FileStatusMask_FileName | FileStatusMask_Type; osl::DirectoryItem aDirItem; + bool bExcludeFiles = excludeTmpFilesAndFolders(srcUnqPath); while( err == osl::FileBase::E_None && ( next = aDir.getNextItem( aDirItem ) ) == osl::FileBase::E_None ) { @@ -634,7 +674,12 @@ throw() // Special treatment for "lastsychronized" file. Must not be // copied from the bundled folder! - if ( IsDoc && aFileName.equalsAscii( pLastSyncFileName )) + //Also do not copy *.tmp files and *.tmp_ folders. This affects the files/folders + //from the help and configuration backend + if ( IsDoc && (aFileName.equalsAscii( pLastSyncFileName ) + || bExcludeFiles && isExcludedFileOrFolder(aFileName))) + bFilter = true; + else if (!IsDoc && bExcludeFiles && isExcludedFileOrFolder(aFileName)) bFilter = true; } @@ -1486,8 +1531,26 @@ void Desktop::AppEvent( const ApplicationEvent& rAppEvent ) HandleAppEvent( rAppEvent ); } +struct ExecuteGlobals +{ + Reference < css::document::XEventListener > xGlobalBroadcaster; + sal_Bool bRestartRequested; + sal_Bool bUseSystemFileDialog; + std::auto_ptr<SvtLanguageOptions> pLanguageOptions; + std::auto_ptr<SvtPathOptions> pPathOptions; + + ExecuteGlobals() + : bRestartRequested( sal_False ) + , bUseSystemFileDialog( sal_True ) + {} +}; + +static ExecuteGlobals* pExecGlobals = NULL; + void Desktop::Main() { + pExecGlobals = new ExecuteGlobals(); + RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Main" ); // Remember current context object @@ -1545,14 +1608,8 @@ void Desktop::Main() Reference< XMultiServiceFactory > xSMgr = ::comphelper::getProcessServiceFactory(); - std::auto_ptr<SvtLanguageOptions> pLanguageOptions; - std::auto_ptr<SvtPathOptions> pPathOptions; - Reference< ::com::sun::star::task::XRestartManager > xRestartManager; - sal_Bool bRestartRequested( sal_False ); - sal_Bool bUseSystemFileDialog(sal_True); int nAcquireCount( 0 ); - Reference < css::document::XEventListener > xGlobalBroadcaster; try { RegisterServices( xSMgr ); @@ -1638,7 +1695,7 @@ void Desktop::Main() SetDisplayName( aTitle ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create SvtPathOptions and SvtLanguageOptions" ); - pPathOptions.reset( new SvtPathOptions); + pExecGlobals->pPathOptions.reset( new SvtPathOptions); SetSplashScreenProgress(40); RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create SvtPathOptions and SvtLanguageOptions" ); @@ -1655,7 +1712,7 @@ void Desktop::Main() } // create service for loadin SFX (still needed in startup) - xGlobalBroadcaster = Reference < css::document::XEventListener > + pExecGlobals->xGlobalBroadcaster = Reference < css::document::XEventListener > ( xSMgr->createInstance( DEFINE_CONST_UNICODE( "com.sun.star.frame.GlobalEventBroadcaster" ) ), UNO_QUERY ); @@ -1711,13 +1768,13 @@ void Desktop::Main() } // keep a language options instance... - pLanguageOptions.reset( new SvtLanguageOptions(sal_True)); + pExecGlobals->pLanguageOptions.reset( new SvtLanguageOptions(sal_True)); - if (xGlobalBroadcaster.is()) + if (pExecGlobals->xGlobalBroadcaster.is()) { css::document::EventObject aEvent; aEvent.EventName = ::rtl::OUString::createFromAscii("OnStartApp"); - xGlobalBroadcaster->notifyEvent(aEvent); + pExecGlobals->xGlobalBroadcaster->notifyEvent(aEvent); } SetSplashScreenProgress(50); @@ -1737,7 +1794,7 @@ void Desktop::Main() } // check whether the shutdown is caused by restart - bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); + pExecGlobals->bRestartRequested = ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); if ( pCmdLineArgs->IsHeadless() ) { @@ -1745,11 +1802,11 @@ void Desktop::Main() // headless mode relies on Application::EnableHeadlessMode() // which does only work for VCL dialogs!! SvtMiscOptions aMiscOptions; - bUseSystemFileDialog = aMiscOptions.UseSystemFileDialog(); + pExecGlobals->bUseSystemFileDialog = aMiscOptions.UseSystemFileDialog(); aMiscOptions.SetUseSystemFileDialog( sal_False ); } - if ( !bRestartRequested ) + if ( !pExecGlobals->bRestartRequested ) { if ((!pCmdLineArgs->WantsToLoadDocument() ) && (SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SSTARTMODULE)) && @@ -1821,10 +1878,9 @@ void Desktop::Main() SvtAccessibilityOptions aOptions; aOptions.SetVCLSettings(); - if ( !bRestartRequested ) + if ( !pExecGlobals->bRestartRequested ) { Application::SetFilterHdl( LINK( this, Desktop, ImplInitFilterHdl ) ); - sal_Bool bTerminateRequested = sal_False; // Preload function depends on an initialized sfx application! @@ -1880,9 +1936,9 @@ void Desktop::Main() new svt::JavaContext( com::sun::star::uno::getCurrentContext() ) ); // check whether the shutdown is caused by restart just before entering the Execute - bRestartRequested = bRestartRequested || ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); + pExecGlobals->bRestartRequested = pExecGlobals->bRestartRequested || ( xRestartManager.is() && xRestartManager->isRestartRequested( sal_True ) ); - if ( !bRestartRequested ) + if ( !pExecGlobals->bRestartRequested ) { // if this run of the office is triggered by restart, some additional actions should be done DoRestartActionsIfNecessary( !pCmdLineArgs->IsInvisible() && !pCmdLineArgs->IsNoQuickstart() ); @@ -1901,44 +1957,57 @@ void Desktop::Main() FatalError( MakeStartupErrorMessage(exAnyCfg.Message) ); } } + // CAUTION: you do not necessarily get here e.g. on the Mac. + // please put all deinitialization code into doShutdown + doShutdown(); +} - if ( bRestartRequested ) +void Desktop::doShutdown() +{ + if( ! pExecGlobals ) + return; + + if ( pExecGlobals->bRestartRequested ) SetRestartState(); - if (xGlobalBroadcaster.is()) + if (pExecGlobals->xGlobalBroadcaster.is()) { css::document::EventObject aEvent; aEvent.EventName = ::rtl::OUString::createFromAscii("OnCloseApp"); - xGlobalBroadcaster->notifyEvent(aEvent); + pExecGlobals->xGlobalBroadcaster->notifyEvent(aEvent); } - delete pResMgr; + delete pResMgr, pResMgr = NULL; // Restore old value + CommandLineArgs* pCmdLineArgs = GetCommandLineArgs(); if ( pCmdLineArgs->IsHeadless() ) - SvtMiscOptions().SetUseSystemFileDialog( bUseSystemFileDialog ); + SvtMiscOptions().SetUseSystemFileDialog( pExecGlobals->bUseSystemFileDialog ); // remove temp directory RemoveTemporaryDirectory(); FlushConfiguration(); // The acceptors in the AcceptorMap must be released (in DeregisterServices) // with the solar mutex unlocked, to avoid deadlock: - nAcquireCount = Application::ReleaseSolarMutex(); + ULONG nAcquireCount = Application::ReleaseSolarMutex(); DeregisterServices(); 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" ); - pLanguageOptions.reset( 0 ); - pPathOptions.reset( 0 ); + pExecGlobals->pLanguageOptions.reset( 0 ); + pExecGlobals->pPathOptions.reset( 0 ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- dispose path/language options" ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "-> deinit ucb" ); ::ucbhelper::ContentBroker::deinitialize(); RTL_LOGFILE_CONTEXT_TRACE( aLog, "<- deinit ucb" ); + sal_Bool bRR = pExecGlobals->bRestartRequested; + delete pExecGlobals, pExecGlobals = NULL; + RTL_LOGFILE_CONTEXT_TRACE( aLog, "FINISHED WITH Destop::Main" ); - if ( bRestartRequested ) + if ( bRR ) { restartOnMac(true); // wouldn't the solution be more clean if SalMain returns the exit code to the system? @@ -2053,9 +2122,9 @@ sal_Bool Desktop::InitializeQuickstartMode( Reference< XMultiServiceFactory >& r // unfortunately this broke the QUARTZ behavior which is to always run // in quickstart mode since Mac applications do not usually quit // when the last document closes - #ifndef QUARTZ + //#ifndef QUARTZ if ( bQuickstart ) - #endif + //#endif { Reference < XComponent > xQuickstart( rSMgr->createInstanceWithArguments( DEFINE_CONST_UNICODE( "com.sun.star.office.Quickstart" ), aSeq ), @@ -2123,17 +2192,6 @@ void Desktop::SystemSettingsChanging( AllSettings& rSettings, Window* ) } hStyleSettings.SetUseImagesInMenus(bUseImagesInMenus); - sal_uInt16 nTabStyle = hStyleSettings.GetTabControlStyle(); - nTabStyle &= ~STYLE_TABCONTROL_SINGLELINE; - if( aAppearanceCfg.IsSingleLineTabCtrl() ) - nTabStyle |=STYLE_TABCONTROL_SINGLELINE; - - nTabStyle &= ~STYLE_TABCONTROL_COLOR; - if( aAppearanceCfg.IsColoredTabCtrl() ) - nTabStyle |= STYLE_TABCONTROL_COLOR; - - hStyleSettings.SetTabControlStyle(nTabStyle); - hStyleSettings.SetDragFullOptions( nDragFullOptions ); rSettings.SetStyleSettings ( hStyleSettings ); } @@ -3135,6 +3193,13 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent ) catch(const css::uno::Exception&) {} } + else if( rAppEvent.GetEvent() == "PRIVATE:DOSHUTDOWN" ) + { + Desktop* pD = dynamic_cast<Desktop*>(GetpApp()); + OSL_ENSURE( pD, "no desktop ?!?" ); + if( pD ) + pD->doShutdown(); + } } void Desktop::OpenSplashScreen() diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index 9f7271d36e2d..154736e1e056 100755 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -388,6 +388,10 @@ void UpdateDialog::Thread::execute() uno::Reference<ucb::XCommandEnvironment>()); } catch (lang::IllegalArgumentException& ) { OSL_ASSERT(0); + continue; + } catch (css::ucb::CommandFailedException& ) { + OSL_ASSERT(0); + continue; } OSL_ASSERT(extensions.getLength() == 3); if (extensions[0].is() ) diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index 709cca86c631..6eb547c4e98a 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -183,12 +183,8 @@ ExtensionManager::ExtensionManager( Reference< uno::XComponentContext > const& x ::cppu::WeakComponentImplHelper1< css::deployment::XExtensionManager >(getMutex()), m_xContext( xContext ) { - Reference<deploy::XPackageManagerFactory> xPackageManagerFactory( - deploy::thePackageManagerFactory::get(m_xContext)); - m_userRepository = xPackageManagerFactory->getPackageManager(OUSTR("user")); - m_sharedRepository = xPackageManagerFactory->getPackageManager(OUSTR("shared")); - m_bundledRepository = xPackageManagerFactory->getPackageManager(OUSTR("bundled")); - m_tmpRepository = xPackageManagerFactory->getPackageManager(OUSTR("tmp")); + m_xPackageManagerFactory = deploy::thePackageManagerFactory::get(m_xContext); + OSL_ASSERT(m_xPackageManagerFactory.is()); m_repositoryNames.push_back(OUSTR("user")); m_repositoryNames.push_back(OUSTR("shared")); @@ -201,6 +197,23 @@ ExtensionManager::~ExtensionManager() { } +Reference<deploy::XPackageManager> ExtensionManager::getUserRepository() +{ + return m_xPackageManagerFactory->getPackageManager(OUSTR("user")); +} +Reference<deploy::XPackageManager> ExtensionManager::getSharedRepository() +{ + return m_xPackageManagerFactory->getPackageManager(OUSTR("shared")); +} +Reference<deploy::XPackageManager> ExtensionManager::getBundledRepository() +{ + return m_xPackageManagerFactory->getPackageManager(OUSTR("bundled")); +} +Reference<deploy::XPackageManager> ExtensionManager::getTmpRepository() +{ + return m_xPackageManagerFactory->getPackageManager(OUSTR("tmp")); +} + Reference<task::XAbortChannel> ExtensionManager::createAbortChannel() throw (uno::RuntimeException) { @@ -213,11 +226,11 @@ ExtensionManager::getPackageManager(::rtl::OUString const & repository) { Reference<deploy::XPackageManager> xPackageManager; if (repository.equals(OUSTR("user"))) - xPackageManager = m_userRepository; + xPackageManager = getUserRepository(); else if (repository.equals(OUSTR("shared"))) - xPackageManager = m_sharedRepository; + xPackageManager = getSharedRepository(); else if (repository.equals(OUSTR("bundled"))) - xPackageManager = m_bundledRepository; + xPackageManager = getBundledRepository(); else throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), @@ -288,7 +301,7 @@ void ExtensionManager::addExtensionsToMap( ::std::list<Reference<deploy::XPackage> > extensionList; try { //will throw an exception if the extension does not exist - extensionList.push_back(m_userRepository->getDeployedPackage( + extensionList.push_back(getUserRepository()->getDeployedPackage( identifier, fileName, Reference<ucb::XCommandEnvironment>())); } catch(lang::IllegalArgumentException &) { @@ -296,7 +309,7 @@ void ExtensionManager::addExtensionsToMap( } try { - extensionList.push_back(m_sharedRepository->getDeployedPackage( + extensionList.push_back(getSharedRepository()->getDeployedPackage( identifier, fileName, Reference<ucb::XCommandEnvironment>())); } catch (lang::IllegalArgumentException &) { @@ -304,7 +317,7 @@ void ExtensionManager::addExtensionsToMap( } try { - extensionList.push_back(m_bundledRepository->getDeployedPackage( + extensionList.push_back(getBundledRepository()->getDeployedPackage( identifier, fileName, Reference<ucb::XCommandEnvironment>())); } catch (lang::IllegalArgumentException &) { @@ -508,7 +521,7 @@ Reference<deploy::XPackage> ExtensionManager::backupExtension( if (xOldExtension.is()) { - xBackup = m_tmpRepository->addPackage( + xBackup = getTmpRepository()->addPackage( xOldExtension->getURL(), uno::Sequence<beans::NamedValue>(), OUString(), Reference<task::XAbortChannel>(), tmpCmdEnv); @@ -529,7 +542,7 @@ uno::Sequence< Reference<deploy::XPackageTypeInfo> > ExtensionManager::getSupportedPackageTypes() throw (uno::RuntimeException) { - return m_userRepository->getSupportedPackageTypes(); + return getUserRepository()->getSupportedPackageTypes(); } //Do some necessary checks and user interaction. This function does not //aquire the extension manager mutex and that mutex must not be aquired @@ -649,9 +662,9 @@ Reference<deploy::XPackage> ExtensionManager::addExtension( //Determine the repository to use Reference<deploy::XPackageManager> xPackageManager; if (repository.equals(OUSTR("user"))) - xPackageManager = m_userRepository; + xPackageManager = getUserRepository(); else if (repository.equals(OUSTR("shared"))) - xPackageManager = m_sharedRepository; + xPackageManager = getSharedRepository(); else throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), @@ -664,7 +677,7 @@ Reference<deploy::XPackage> ExtensionManager::addExtension( getTempExtension(url, xAbortChannel, xCmdEnv); //Make sure the extension is removed from the tmp repository in case //of an exception - ExtensionRemoveGuard tmpExtensionRemoveGuard(xTmpExtension, m_tmpRepository); + ExtensionRemoveGuard tmpExtensionRemoveGuard(xTmpExtension, getTmpRepository()); const OUString sIdentifier = dp_misc::getIdentifier(xTmpExtension); const OUString sFileName = xTmpExtension->getName(); Reference<deploy::XPackage> xOldExtension; @@ -708,7 +721,7 @@ Reference<deploy::XPackage> ExtensionManager::addExtension( //the xTmpExtension //no command environment supplied, only this class shall interact //with the user! - xExtensionBackup = m_tmpRepository->importExtension( + xExtensionBackup = getTmpRepository()->importExtension( xOldExtension, Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>()); tmpExtensionRemoveGuard.reset(xExtensionBackup); @@ -857,9 +870,9 @@ void ExtensionManager::removeExtension( { //Determine the repository to use if (repository.equals(OUSTR("user"))) - xPackageManager = m_userRepository; + xPackageManager = getUserRepository(); else if (repository.equals(OUSTR("shared"))) - xPackageManager = m_sharedRepository; + xPackageManager = getSharedRepository(); else throw lang::IllegalArgumentException( OUSTR("No valid repository name provided."), @@ -919,7 +932,7 @@ void ExtensionManager::removeExtension( Reference<task::XAbortChannel>(), tmpCmdEnv); - m_tmpRepository->removePackage( + getTmpRepository()->removePackage( dp_misc::getIdentifier(xExtensionBackup), xExtensionBackup->getName(), xAbortChannel, xCmdEnv); fireModified(); @@ -932,7 +945,7 @@ void ExtensionManager::removeExtension( } if (xExtensionBackup.is()) - m_tmpRepository->removePackage( + getTmpRepository()->removePackage( dp_misc::getIdentifier(xExtensionBackup), xExtensionBackup->getName(), xAbortChannel, xCmdEnv); } @@ -1160,13 +1173,13 @@ uno::Sequence< uno::Sequence<Reference<deploy::XPackage> > > id2extensions mapExt; uno::Sequence<Reference<deploy::XPackage> > userExt = - m_userRepository->getDeployedPackages(xAbort, xCmdEnv); + getUserRepository()->getDeployedPackages(xAbort, xCmdEnv); addExtensionsToMap(mapExt, userExt, OUSTR("user")); uno::Sequence<Reference<deploy::XPackage> > sharedExt = - m_sharedRepository->getDeployedPackages(xAbort, xCmdEnv); + getSharedRepository()->getDeployedPackages(xAbort, xCmdEnv); addExtensionsToMap(mapExt, sharedExt, OUSTR("shared")); uno::Sequence<Reference<deploy::XPackage> > bundledExt = - m_bundledRepository->getDeployedPackages(xAbort, xCmdEnv); + getBundledRepository()->getDeployedPackages(xAbort, xCmdEnv); addExtensionsToMap(mapExt, bundledExt, OUSTR("bundled")); //copy the values of the map to a vector for sorting @@ -1236,7 +1249,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, false, false, xAbortChannel, xCmdEnv ); + activateExtension(id, fileName, false, true, xAbortChannel, xCmdEnv ); } catch (lang::DisposedException &) { @@ -1260,6 +1273,64 @@ void ExtensionManager::reinstallDeployedExtensions( } } +/** Works on the bundled repository. That is using the variables + BUNDLED_EXTENSIONS and BUNDLED_EXTENSIONS_USER. + */ +void ExtensionManager::synchronizeBundledPrereg( + Reference<task::XAbortChannel> const & xAbortChannel, + Reference<ucb::XCommandEnvironment> const & xCmdEnv ) + throw (deploy::DeploymentException, + uno::RuntimeException) +{ + try + { + String sSynchronizingBundled(StrSyncRepository::get()); + sSynchronizingBundled.SearchAndReplaceAllAscii( "%NAME", OUSTR("bundled")); + dp_misc::ProgressLevel progressBundled(xCmdEnv, sSynchronizingBundled); + + Reference<deploy::XPackageManagerFactory> xPackageManagerFactory( + deploy::thePackageManagerFactory::get(m_xContext)); + + Reference<deploy::XPackageManager> xMgr = + xPackageManagerFactory->getPackageManager(OUSTR("bundled_prereg")); + xMgr->synchronize(xAbortChannel, xCmdEnv); + progressBundled.update(OUSTR("\n\n")); + + uno::Sequence<Reference<deploy::XPackage> > extensions = xMgr->getDeployedPackages( + xAbortChannel, xCmdEnv); + try + { + for (sal_Int32 i = 0; i < extensions.getLength(); i++) + { + extensions[i]->registerPackage(true, xAbortChannel, xCmdEnv); + } + } + catch (...) + { + OSL_ASSERT(0); + } + OUString lastSyncBundled(RTL_CONSTASCII_USTRINGPARAM( + "$BUNDLED_EXTENSIONS_PREREG/lastsynchronized")); + writeLastModified(lastSyncBundled, xCmdEnv); + + } catch (deploy::DeploymentException& ) { + throw; + } catch (ucb::CommandFailedException & ) { + throw; + } catch (ucb::CommandAbortedException & ) { + throw; + } catch (lang::IllegalArgumentException &) { + throw; + } catch (uno::RuntimeException &) { + throw; + } catch (...) { + uno::Any exc = ::cppu::getCaughtException(); + throw deploy::DeploymentException( + OUSTR("Extension Manager: exception in synchronize"), + static_cast<OWeakObject*>(this), exc); + } +} + sal_Bool ExtensionManager::synchronize( Reference<task::XAbortChannel> const & xAbortChannel, Reference<ucb::XCommandEnvironment> const & xCmdEnv ) @@ -1277,13 +1348,13 @@ sal_Bool ExtensionManager::synchronize( String sSynchronizingShared(StrSyncRepository::get()); sSynchronizingShared.SearchAndReplaceAllAscii( "%NAME", OUSTR("shared")); dp_misc::ProgressLevel progressShared(xCmdEnv, sSynchronizingShared); - bModified = m_sharedRepository->synchronize(xAbortChannel, xCmdEnv); + bModified = getSharedRepository()->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); + bModified |= getBundledRepository()->synchronize(xAbortChannel, xCmdEnv); progressBundled.update(OUSTR("\n\n")); //Always determine the active extension. This is necessary for the @@ -1410,7 +1481,7 @@ Reference<deploy::XPackage> ExtensionManager::getTempExtension( { Reference<ucb::XCommandEnvironment> tmpCmdEnvA(new TmpRepositoryCommandEnv()); - Reference<deploy::XPackage> xTmpPackage = m_tmpRepository->addPackage( + Reference<deploy::XPackage> xTmpPackage = getTmpRepository()->addPackage( url, uno::Sequence<beans::NamedValue>(),OUString(), xAbortChannel, tmpCmdEnvA); if (!xTmpPackage.is()) { diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx index 683f45a1bd6e..e7a180a05de1 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.hxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx @@ -205,6 +205,12 @@ public: css::lang::IllegalArgumentException, css::uno::RuntimeException); + virtual void SAL_CALL synchronizeBundledPrereg( + css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel, + css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) + throw (css::deployment::DeploymentException, + css::uno::RuntimeException); + virtual css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > SAL_CALL getExtensionsWithUnacceptedLicenses( ::rtl::OUString const & repository, @@ -229,11 +235,7 @@ private: }; css::uno::Reference< css::uno::XComponentContext> m_xContext; - - css::uno::Reference<css::deployment::XPackageManager> m_userRepository; - css::uno::Reference<css::deployment::XPackageManager> m_sharedRepository; - css::uno::Reference<css::deployment::XPackageManager> m_bundledRepository; - css::uno::Reference<css::deployment::XPackageManager> m_tmpRepository; + css::uno::Reference<css::deployment::XPackageManagerFactory> m_xPackageManagerFactory; //only to be used within addExtension ::osl::Mutex m_addMutex; @@ -243,6 +245,11 @@ private: */ ::std::list< ::rtl::OUString > m_repositoryNames; + css::uno::Reference<css::deployment::XPackageManager> getUserRepository(); + css::uno::Reference<css::deployment::XPackageManager> getSharedRepository(); + css::uno::Reference<css::deployment::XPackageManager> getBundledRepository(); + css::uno::Reference<css::deployment::XPackageManager> getTmpRepository(); + bool isUserDisabled(::rtl::OUString const & identifier, ::rtl::OUString const & filename); diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx index 4cc43a8386d8..6d4750bb2447 100644 --- a/desktop/source/deployment/manager/dp_informationprovider.cxx +++ b/desktop/source/deployment/manager/dp_informationprovider.cxx @@ -40,9 +40,8 @@ #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/registry/XRegistryKey.hpp" #include "com/sun/star/task/XAbortChannel.hpp" -#include "com/sun/star/ucb/CommandFailedException.hpp" -#include "com/sun/star/ucb/XCommandEnvironment.hpp" #include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/ucb/XCommandEnvironment.hpp" #include "com/sun/star/xml/dom/XElement.hpp" #include "com/sun/star/xml/dom/XNode.hpp" @@ -71,9 +70,8 @@ namespace xml = com::sun::star::xml ; namespace dp_info { class PackageInformationProvider : - public ::cppu::WeakImplHelper3< deployment::XPackageInformationProvider, - css_ucb::XCommandEnvironment, - task::XInteractionHandler > + public ::cppu::WeakImplHelper1< deployment::XPackageInformationProvider > + { public: PackageInformationProvider( uno::Reference< uno::XComponentContext >const& xContext); @@ -82,16 +80,6 @@ class PackageInformationProvider : static uno::Sequence< rtl::OUString > getServiceNames(); static rtl::OUString getImplName(); - // XInteractionHandler - virtual void SAL_CALL handle( const uno::Reference< task::XInteractionRequest >& Request ) - throw( uno::RuntimeException ); - // XCommandEnvironment - virtual uno::Reference< task::XInteractionHandler > SAL_CALL getInteractionHandler() - throw ( uno::RuntimeException ) { return static_cast<task::XInteractionHandler*>(this); }; - - virtual uno::Reference< css_ucb::XProgressHandler > SAL_CALL getProgressHandler() - throw ( uno::RuntimeException ) { return uno::Reference< css_ucb::XProgressHandler >(); }; - // XPackageInformationProvider virtual rtl::OUString SAL_CALL getPackageLocation( const rtl::OUString& extensionId ) throw ( uno::RuntimeException ); @@ -125,17 +113,6 @@ PackageInformationProvider::~PackageInformationProvider() } //------------------------------------------------------------------------------ -void SAL_CALL PackageInformationProvider::handle( uno::Reference< task::XInteractionRequest > const & rRequest) - throw (uno::RuntimeException) -{ - uno::Sequence< uno::Reference< task::XInteractionContinuation > > xContinuations = rRequest->getContinuations(); - if ( xContinuations.getLength() == 1 ) - { - xContinuations[0]->select(); - } -} - -//------------------------------------------------------------------------------ rtl::OUString PackageInformationProvider::getPackageLocation( const rtl::OUString & repository, const rtl::OUString& _rExtensionId ) @@ -150,7 +127,7 @@ rtl::OUString PackageInformationProvider::getPackageLocation( xManager->getDeployedExtensions( repository, uno::Reference< task::XAbortChannel >(), - static_cast < XCommandEnvironment *> (this) ) ); + uno::Reference< css_ucb::XCommandEnvironment > () ) ); for ( int pos = packages.getLength(); pos--; ) { @@ -320,7 +297,7 @@ uno::Sequence< uno::Sequence< rtl::OUString > > SAL_CALL PackageInformationProvi const uno::Sequence< uno::Sequence< uno::Reference<deployment::XPackage > > > allExt = mgr->getAllExtensions( uno::Reference< task::XAbortChannel >(), - static_cast < XCommandEnvironment *> (this) ); + uno::Reference< css_ucb::XCommandEnvironment > () ); uno::Sequence< uno::Sequence< rtl::OUString > > retList; diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 44bc4d469f2f..2e2c5e2a2f53 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -370,6 +370,24 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create( //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("bundled_prereg") )) { + //This is a bundled repository but the registration data + //is in the brand layer: share/prereg + //It is special because the registration data are copied at the first startup + //into the user installation. The processed help and xcu files are not + //copied. Instead the backenddb.xml for the help backend references the help + //by using $BUNDLED_EXTENSION_PREREG instead $BUNDLED_EXTENSIONS_USER. The + //configmgr.ini also used $BUNDLED_EXTENSIONS_PREREG to refer to the xcu file + //which contain the replacement for %origin%. + that->m_activePackages = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS"); + that->m_registrationData = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_PREREG"); + that->m_registryCache = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_PREREG/registry"); + logFile = OUSTR( + "vnd.sun.star.expand:$BUNDLED_EXTENSIONS_PREREG/log.txt"); + } else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") )) { that->m_activePackages = OUSTR( "vnd.sun.star.expand:$TMP_EXTENSIONS/extensions"); @@ -949,6 +967,8 @@ void PackageManagerImpl::removePackage( contentRemoved.writeStream( xData, true /* replace existing */ ); } m_activePackagesDB->erase( id, fileName ); // to be removed upon next start + //remove any cached data hold by the backend + m_xRegistry->packageRemoved(xPackage->getURL(), xPackage->getPackageType()->getMediaType()); } try_dispose( xPackage ); @@ -989,7 +1009,8 @@ OUString PackageManagerImpl::getDeployPath( ActivePackages::Data const & data ) //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"))) + if (!m_context.equals(OUSTR("bundled")) + && !m_context.equals(OUSTR("bundled_prereg"))) { buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_/") ); buf.append( ::rtl::Uri::encode( data.fileName, rtl_UriCharClassPchar, @@ -1341,6 +1362,8 @@ bool PackageManagerImpl::synchronizeAddedExtensions( Reference<css::ucb::XCommandEnvironment> const & xCmdEnv) { bool bModified = false; + OSL_ASSERT(!m_context.equals(OUSTR("user"))); + ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); //check if the folder exist at all. The shared extension folder //may not exist for a normal user. @@ -1366,8 +1389,8 @@ bool PackageManagerImpl::synchronizeAddedExtensions( //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) + bool bShared = m_context.equals(OUSTR("shared")); + if (bShared) { OSL_ASSERT(title2[title2.getLength() -1] == '_'); title2 = title2.copy(0, title2.getLength() -1); @@ -1389,7 +1412,7 @@ bool PackageManagerImpl::synchronizeAddedExtensions( // an added extension OUString url(m_activePackages_expanded + OUSTR("/") + titleEncoded); OUString sExtFolder; - if (bNotBundled) //that is, shared + if (bShared) //that is, shared { //Check if the extension was not "deleted" already which is indicated //by a xxx.tmpremoved file @@ -1411,7 +1434,7 @@ bool PackageManagerImpl::synchronizeAddedExtensions( ActivePackages::Data dbData; dbData.temporaryName = titleEncoded; - if (bNotBundled) + if (bShared) dbData.fileName = sExtFolder; else dbData.fileName = title; diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx index 898e7c931f6d..458ece3d0bd8 100644 --- a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx +++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx @@ -82,26 +82,29 @@ OUString ComponentBackendDb::getKeyElementName() void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - Reference<css::xml::dom::XNode> componentNode = writeKeyElement(url); - writeSimpleElement(OUSTR("java-type-library"), - OUString::valueOf((sal_Bool) data.javaTypeLibrary), - componentNode); - - writeSimpleList( - data.implementationNames, - OUSTR("implementation-names"), - OUSTR("name"), - componentNode); - - writeVectorOfPair( - data.singletons, - OUSTR("singletons"), - OUSTR("item"), - OUSTR("key"), - OUSTR("value"), - componentNode); - - save(); + if (!activateEntry(url)) + { + Reference<css::xml::dom::XNode> componentNode = writeKeyElement(url); + writeSimpleElement(OUSTR("java-type-library"), + OUString::valueOf((sal_Bool) data.javaTypeLibrary), + componentNode); + + 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 &) { diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index d1511952a92a..650a7585d929 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -270,8 +270,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend std::auto_ptr<ComponentBackendDb> m_backendDb; void addDataToDb(OUString const & url, ComponentBackendDb::Data const & data); - void deleteDataFromDb(OUString const & url); ComponentBackendDb::Data readDataFromDb(OUString const & url); + void revokeEntryFromDb(OUString const & url); //These rdbs are for writing new service entries. The rdb files are copies @@ -327,6 +327,10 @@ public: virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); + using PackageRegistryBackend::disposing; //Will be called from ComponentPackageImpl @@ -660,12 +664,6 @@ void BackendImpl::addDataToDb( m_backendDb->addEntry(url, data); } -void BackendImpl::deleteDataFromDb(OUString const & url) -{ - if (m_backendDb.get()) - m_backendDb->removeEntry(url); -} - ComponentBackendDb::Data BackendImpl::readDataFromDb(OUString const & url) { ComponentBackendDb::Data data; @@ -674,6 +672,12 @@ ComponentBackendDb::Data BackendImpl::readDataFromDb(OUString const & url) return data; } +void BackendImpl::revokeEntryFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->revokeEntry(url); +} + // XPackageRegistry //______________________________________________________________________________ Sequence< Reference<deployment::XPackageTypeInfo> > @@ -682,6 +686,14 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) return m_typeInfos; } +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + // PackageRegistryBackend //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( @@ -1437,6 +1449,9 @@ void BackendImpl::ComponentPackageImpl::getComponentInfo( // Package //______________________________________________________________________________ +//We could use here BackendImpl::hasActiveEntry. However, this check is just as well. +//And it also shows the problem if another extension has overwritten an implementation +//entry, because it contains the same service implementation beans::Optional< beans::Ambiguous<sal_Bool> > BackendImpl::ComponentPackageImpl::isRegistered_( ::osl::ResettableMutexGuard &, @@ -1590,7 +1605,7 @@ void BackendImpl::ComponentPackageImpl::processPackage_( that->releaseObject(url); } m_registered = REG_NOT_REGISTERED; - that->deleteDataFromDb(url); + getMyBackend()->revokeEntryFromDb(url); } } @@ -1803,7 +1818,7 @@ void BackendImpl::ComponentsPackageImpl::processPackage_( that->componentLiveRemoval(that->readDataFromDb(url)); } that->releaseObject(url); - that->deleteDataFromDb(url); + that->revokeEntryFromDb(url); } } diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 1e7ee5bfac8a..24e5587cd0cc 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -132,15 +132,21 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference<XCommandEnvironment> const & xCmdEnv ); void configmgrini_flush( Reference<XCommandEnvironment> const & xCmdEnv ); - bool addToConfigmgrIni( bool isSchema, OUString const & url, + /* The paramter isURL is false in the case of adding the conf:ini-entry + value from the backend db. This entry already contains the path as it + is used in the configmgr.ini. + */ + bool addToConfigmgrIni( bool isSchema, bool isURL, OUString const & url, Reference<XCommandEnvironment> const & xCmdEnv ); bool removeFromConfigmgrIni( bool isSchema, OUString const & url, Reference<XCommandEnvironment> const & xCmdEnv ); void addDataToDb(OUString const & url, ConfigurationBackendDb::Data const & data); ::boost::optional<ConfigurationBackendDb::Data> readDataFromDb(OUString const & url); - OUString deleteDataFromDb(OUString const & url); + void revokeEntryFromDb(OUString const & url); ::std::list<OUString> getAllIniEntries(); + bool hasActiveEntry(OUString const & url); + bool activateEntry(OUString const & url); public: BackendImpl( Sequence<Any> const & args, @@ -149,6 +155,9 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); using PackageRegistryBackend::disposing; }; @@ -240,18 +249,10 @@ void BackendImpl::addDataToDb( return data; } -OUString BackendImpl::deleteDataFromDb(OUString const & url) +void BackendImpl::revokeEntryFromDb(OUString const & url) { - OUString url2(url); - if (m_backendDb.get()) { - boost::optional< ConfigurationBackendDb::Data > data( - m_backendDb->getEntry(url)); - if (data) { - url2 = expandUnoRcTerm(data->iniEntry); - } - m_backendDb->removeEntry(url); - } - return url2; + if (m_backendDb.get()) + m_backendDb->revokeEntry(url); } ::std::list<OUString> BackendImpl::getAllIniEntries() @@ -262,6 +263,20 @@ OUString BackendImpl::deleteDataFromDb(OUString const & url) return ::std::list<OUString>(); } +bool BackendImpl::hasActiveEntry(OUString const & url) +{ + if (m_backendDb.get()) + return m_backendDb->hasActiveEntry(url); + return false; +} + +bool BackendImpl::activateEntry(OUString const & url) +{ + if (m_backendDb.get()) + return m_backendDb->activateEntry(url); + return false; +} + // XPackageRegistry @@ -271,6 +286,13 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) { return m_typeInfos; } +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} // PackageRegistryBackend //______________________________________________________________________________ @@ -457,10 +479,10 @@ void BackendImpl::configmgrini_flush( } //______________________________________________________________________________ -bool BackendImpl::addToConfigmgrIni( bool isSchema, OUString const & url_, +bool BackendImpl::addToConfigmgrIni( bool isSchema, bool isURL, OUString const & url_, Reference<XCommandEnvironment> const & xCmdEnv ) { - const OUString rcterm( dp_misc::makeRcTerm(url_) ); + const OUString rcterm( isURL ? dp_misc::makeRcTerm(url_) : url_ ); const ::osl::MutexGuard guard( getMutex() ); configmgrini_verify_init( xCmdEnv ); t_stringlist & rSet = getFiles(isSchema); @@ -509,6 +531,7 @@ bool BackendImpl::removeFromConfigmgrIni( // Package //______________________________________________________________________________ + BackendImpl * BackendImpl::PackageImpl::getMyBackend() const { BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get()); @@ -534,7 +557,7 @@ BackendImpl::PackageImpl::isRegistered_( const rtl::OUString url(getURL()); bool bReg = false; - if (that->readDataFromDb(getURL())) + if (that->hasActiveEntry(getURL())) bReg = true; if (!bReg) //fallback for user extension registered in berkeley DB @@ -677,38 +700,48 @@ void BackendImpl::PackageImpl::processPackage_( if (doRegisterPackage) { - ConfigurationBackendDb::Data data; - if (!m_isSchema) + if (getMyBackend()->activateEntry(getURL())) { - 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); + ::boost::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url); + OSL_ASSERT(data); + that->addToConfigmgrIni( m_isSchema, false, data->iniEntry, xCmdEnv ); } - //No need for live-deployment for bundled extension, because OOo - //restarts after installation - if (that->m_eContext != CONTEXT_BUNDLED - && !startup) + else { - 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 + && that->m_eContext != CONTEXT_BUNDLED_PREREG + && !startup) { - 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, true, url, xCmdEnv ); + data.iniEntry = dp_misc::makeRcTerm(url); + that->addDataToDb(getURL(), data); } - that->addToConfigmgrIni( m_isSchema, url, xCmdEnv ); - data.iniEntry = dp_misc::makeRcTerm(url); - that->addDataToDb(getURL(), data); } else // revoke { @@ -741,7 +774,7 @@ void BackendImpl::PackageImpl::processPackage_( else deleteTempFolder(sModFolder); } - that->addToConfigmgrIni(schema, url_replaced, xCmdEnv); + that->addToConfigmgrIni(schema, true, url_replaced, xCmdEnv); data.iniEntry = dp_misc::makeRcTerm(url_replaced); that->addDataToDb(url2, data); } @@ -759,12 +792,17 @@ void BackendImpl::PackageImpl::processPackage_( OSL_ASSERT(0); } } - url = that->deleteDataFromDb(url); - if (!m_isSchema) { + + ::boost::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url); + //If an xcu file was life deployed then always a data entry is written. + //If the xcu file was already in the configmr.ini then there is also + //a data entry + if (!m_isSchema && data) + { com::sun::star::configuration::Update::get( - that->m_xComponentContext)->removeExtensionXcuFile( - expandUnoRcUrl(url)); + that->m_xComponentContext)->removeExtensionXcuFile(expandUnoRcTerm(data->iniEntry)); } + that->revokeEntryFromDb(url); } } diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx index 2a02c6d8efa0..2437c54ec734 100644 --- a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx @@ -83,12 +83,15 @@ OUString ConfigurationBackendDb::getKeyElementName() void ConfigurationBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - Reference<css::xml::dom::XNode> helpNode - = writeKeyElement(url); + if (!activateEntry(url)) + { + Reference<css::xml::dom::XNode> helpNode + = writeKeyElement(url); - writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); - writeSimpleElement(OUSTR("ini-entry"), data.iniEntry, helpNode); - save(); + writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); + writeSimpleElement(OUSTR("ini-entry"), data.iniEntry, helpNode); + save(); + } } catch (css::deployment::DeploymentException& ) { diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index fa53d4e78a15..266d4406cfde 100755 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -39,6 +39,7 @@ #include "ucbhelper/content.hxx" #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" #include "com/sun/star/deployment/InvalidRemovedParameterException.hpp" +#include "com/sun/star/deployment/thePackageManagerFactory.hpp" #include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp" #include "com/sun/star/ucb/IOErrorCode.hpp" #include "com/sun/star/beans/StringPair.hpp" @@ -99,6 +100,8 @@ PackageRegistryBackend::PackageRegistryBackend( m_eContext = CONTEXT_BUNDLED; else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") )) m_eContext = CONTEXT_TMP; + else if (m_context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled_prereg") )) + m_eContext = CONTEXT_BUNDLED_PREREG; else if (m_context.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:/") )) m_eContext = CONTEXT_DOCUMENT; @@ -121,6 +124,9 @@ void PackageRegistryBackend::check() void PackageRegistryBackend::disposing() { try { + for ( t_string2ref::const_iterator i = m_bound.begin(); i != m_bound.end(); i++) + i->second->removeEventListener(this); + m_bound.clear(); m_xComponentContext.clear(); WeakComponentImplHelperBase::disposing(); } diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 14b4f2374c5b..9629855aaf11 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -187,6 +187,74 @@ void BackendDb::removeEntry(::rtl::OUString const & url) removeElement(sExpression.makeStringAndClear()); } +void BackendDb::revokeEntry(::rtl::OUString const & url) +{ + try + { + Reference<css::xml::dom::XElement> entry = Reference<css::xml::dom::XElement>(getKeyElement(url), UNO_QUERY); + if (entry.is()) + { + entry->setAttribute(OUSTR("revoked"), OUSTR("true")); + save(); + } + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to revoke data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +bool BackendDb::activateEntry(::rtl::OUString const & url) +{ + try + { + bool ret = false; + Reference<css::xml::dom::XElement> entry = Reference<css::xml::dom::XElement>(getKeyElement(url), UNO_QUERY); + if (entry.is()) + { + //no attribute "active" means it is active, that is, registered. + entry->removeAttribute(OUSTR("revoked")); + save(); + ret = true; + } + return ret; + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to revoke data entry in backend db: ") + + m_urlDb, 0, exc); + } +} + +bool BackendDb::hasActiveEntry(::rtl::OUString const & url) +{ + try + { + bool ret = false; + Reference<css::xml::dom::XElement> entry = Reference<css::xml::dom::XElement>(getKeyElement(url), UNO_QUERY); + if (entry.is()) + { + OUString sActive = entry->getAttribute(OUSTR("revoked")); + if (!sActive.equals(OUSTR("true"))) + ret = true; + } + return ret; + + } + catch(css::uno::Exception &) + { + Any exc( ::cppu::getCaughtException() ); + throw css::deployment::DeploymentException( + OUSTR("Extension Manager: failed to determine an active entry in backend db: ") + + m_urlDb, 0, exc); + } +} + Reference<css::xml::dom::XNode> BackendDb::getKeyElement( ::rtl::OUString const & url) { @@ -577,32 +645,34 @@ RegisteredDb::RegisteredDb( void RegisteredDb::addEntry(::rtl::OUString const & url) { try{ + if (!activateEntry(url)) + { + const OUString sNameSpace = getDbNSName(); + const OUString sPrefix = getNSPrefix(); + const OUString sEntry = getKeyElementName(); - const OUString sNameSpace = getDbNSName(); - const OUString sPrefix = getNSPrefix(); - const OUString sEntry = getKeyElementName(); - - Reference<css::xml::dom::XDocument> doc = getDocument(); - Reference<css::xml::dom::XNode> root = doc->getFirstChild(); + Reference<css::xml::dom::XDocument> doc = getDocument(); + Reference<css::xml::dom::XNode> 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<css::xml::dom::XNode> _extensionNode = - getXPathAPI()->selectSingleNode(root, sExpression); - OSL_ASSERT(! _extensionNode.is()); + //There must not be yet an entry with the same url + OUString sExpression( + sPrefix + OUSTR(":") + sEntry + OUSTR("[@url = \"") + url + OUSTR("\"]")); + Reference<css::xml::dom::XNode> _extensionNode = + getXPathAPI()->selectSingleNode(root, sExpression); + OSL_ASSERT(! _extensionNode.is()); #endif - Reference<css::xml::dom::XElement> helpElement( - doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sEntry)); + Reference<css::xml::dom::XElement> helpElement( + doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sEntry)); - helpElement->setAttribute(OUSTR("url"), url); + helpElement->setAttribute(OUSTR("url"), url); - Reference<css::xml::dom::XNode> helpNode( - helpElement, UNO_QUERY_THROW); - root->appendChild(helpNode); + Reference<css::xml::dom::XNode> helpNode( + helpElement, UNO_QUERY_THROW); + root->appendChild(helpNode); - save(); + save(); + } } catch(css::uno::Exception &) { diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index 0f309a5b729f..eecae4e391b7 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -135,6 +135,10 @@ public: lang::IllegalArgumentException, RuntimeException); virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + RuntimeException); + }; //______________________________________________________________________________ @@ -185,6 +189,20 @@ OUString normalizeMediaType( OUString const & mediaType ) //______________________________________________________________________________ +void PackageRegistryImpl::packageRemoved( + ::rtl::OUString const & url, ::rtl::OUString const & mediaType) + throw (css::deployment::DeploymentException, + css::uno::RuntimeException) +{ + const t_string2registry::const_iterator i = + m_mediaType2backend.find(mediaType); + + if (i != m_mediaType2backend.end()) + { + i->second->packageRemoved(url, mediaType); + } +} + void PackageRegistryImpl::insertBackend( Reference<deployment::XPackageRegistry> const & xBackend ) { diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index 968ee7297b0f..5ec739153831 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -71,6 +71,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend bool getFileAttributes(sal_uInt64& out_Attributes); bool isUrlTargetInExtension(); + public: inline ExecutablePackageImpl( ::rtl::Reference<PackageRegistryBackend> const & myBackend, @@ -92,8 +93,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ); void addDataToDb(OUString const & url); - bool isRegisteredInDb(OUString const & url); - void deleteDataFromDb(OUString const & url); + bool hasActiveEntry(OUString const & url); + void revokeEntryFromDb(OUString const & url); Reference<deployment::XPackageTypeInfo> m_xExecutableTypeInfo; std::auto_ptr<ExecutableBackendDb> m_backendDb; @@ -104,6 +105,9 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); using PackageRegistryBackend::disposing; }; @@ -134,20 +138,20 @@ void BackendImpl::addDataToDb(OUString const & url) m_backendDb->addEntry(url); } -bool BackendImpl::isRegisteredInDb(OUString const & url) +void BackendImpl::revokeEntryFromDb(OUString const & url) { - bool ret = false; if (m_backendDb.get()) - ret = m_backendDb->getEntry(url); - return ret; + m_backendDb->revokeEntry(url); } -void BackendImpl::deleteDataFromDb(OUString const & url) +bool BackendImpl::hasActiveEntry(OUString const & url) { if (m_backendDb.get()) - m_backendDb->removeEntry(url); + return m_backendDb->hasActiveEntry(url); + return false; } + // XPackageRegistry Sequence< Reference<deployment::XPackageTypeInfo> > BackendImpl::getSupportedPackageTypes() throw (RuntimeException) @@ -156,6 +160,14 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) & m_xExecutableTypeInfo, 1); } +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + // PackageRegistryBackend Reference<deployment::XPackage> BackendImpl::bindPackage_( OUString const & url, OUString const & mediaType, sal_Bool bRemoved, @@ -217,7 +229,7 @@ BackendImpl::ExecutablePackageImpl::isRegistered_( ::rtl::Reference<dp_misc::AbortChannel> const &, Reference<XCommandEnvironment> const & ) { - bool registered = getMyBackend()->isRegisteredInDb(getURL()); + bool registered = getMyBackend()->hasActiveEntry(getURL()); return beans::Optional< beans::Ambiguous<sal_Bool> >( sal_True /* IsPresent */, beans::Ambiguous<sal_Bool>( @@ -248,7 +260,8 @@ 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 if (!getMyBackend()->m_context.equals(OUSTR("bundled"))) + else if (!getMyBackend()->m_context.equals(OUSTR("bundled")) + && !getMyBackend()->m_context.equals(OUSTR("bundled_prereg"))) //Bundled extension are required to be in the properly //installed. That is an executable must have the right flags OSL_ASSERT(0); @@ -261,7 +274,7 @@ void BackendImpl::ExecutablePackageImpl::processPackage_( } else { - getMyBackend()->deleteDataFromDb(getURL()); + getMyBackend()->revokeEntryFromDb(getURL()); } } @@ -277,7 +290,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"))) + else if (getMyBackend()->m_context.equals(OUSTR("bundled")) + || getMyBackend()->m_context.equals(OUSTR("bundled_prereg"))) sExtensionDir = dp_misc::expandUnoRcTerm(OUSTR("$BUNDLED_EXTENSIONS")); else OSL_ASSERT(0); diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 5a7538f6a866..0adb63614828 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -80,7 +80,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend ::rtl::Reference<AbortChannel> const & abortChannel, Reference<XCommandEnvironment> const & xCmdEnv ); - bool extensionContainsCompiledHelp(); + public: PackageImpl( ::rtl::Reference<PackageRegistryBackend> const & myBackend, @@ -88,6 +88,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend Reference<deployment::XPackageTypeInfo> const & xPackageType, bool bRemoved, OUString const & identifier); + bool extensionContainsCompiledHelp(); + //XPackage virtual css::beans::Optional< ::rtl::OUString > SAL_CALL getRegistrationDataURL() throw (deployment::ExtensionRemovedException, css::uno::RuntimeException); @@ -100,14 +102,16 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend sal_Bool bRemoved, OUString const & identifier, Reference<XCommandEnvironment> const & xCmdEnv ); - void implProcessHelp( Reference< deployment::XPackage > xPackage, bool doRegisterPackage, - bool compiledHelp, Reference<ucb::XCommandEnvironment> const & xCmdEnv); + void implProcessHelp( PackageImpl * package, bool doRegisterPackage, + Reference<ucb::XCommandEnvironment> const & xCmdEnv); void implCollectXhpFiles( const rtl::OUString& aDir, std::vector< rtl::OUString >& o_rXhpFileVector ); void addDataToDb(OUString const & url, HelpBackendDb::Data const & data); ::boost::optional<HelpBackendDb::Data> readDataFromDb(OUString const & url); - void deleteDataFromDb(OUString const & url); + bool hasActiveEntry(OUString const & url); + void revokeEntryFromDb(OUString const & url); + bool activateEntry(OUString const & url); Reference< ucb::XSimpleFileAccess > getFileAccess( void ); Reference< ucb::XSimpleFileAccess > m_xSFA; @@ -123,6 +127,10 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); + }; //______________________________________________________________________________ @@ -162,6 +170,14 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) return m_typeInfos; } +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} + // PackageRegistryBackend //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( @@ -220,12 +236,27 @@ void BackendImpl::addDataToDb( return data; } -void BackendImpl::deleteDataFromDb(OUString const & url) +bool BackendImpl::hasActiveEntry(OUString const & url) { if (m_backendDb.get()) - m_backendDb->removeEntry(url); + return m_backendDb->hasActiveEntry(url); + return false; +} + +void BackendImpl::revokeEntryFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->revokeEntry(url); } +bool BackendImpl::activateEntry(OUString const & url) +{ + if (m_backendDb.get()) + return m_backendDb->activateEntry(url); + return false; +} + + //############################################################################## BackendImpl::PackageImpl::PackageImpl( ::rtl::Reference<PackageRegistryBackend> const & myBackend, @@ -235,13 +266,6 @@ BackendImpl::PackageImpl::PackageImpl( : Package( myBackend, url, name, name, xPackageType, bRemoved, identifier) { -// if (bRemoved) -// { -// ::boost::optional<HelpBackendDb::Data> opt = -// getMyBackend()->readDataFromDb(url); -// if (opt) -// m_dbData = *opt; -// } } // Package @@ -260,7 +284,6 @@ BackendImpl * BackendImpl::PackageImpl::getMyBackend() const return pBackend; } - bool BackendImpl::PackageImpl::extensionContainsCompiledHelp() { bool bCompiled = true; @@ -311,6 +334,7 @@ bool BackendImpl::PackageImpl::extensionContainsCompiledHelp() } return bCompiled; } + //______________________________________________________________________________ beans::Optional< beans::Ambiguous<sal_Bool> > BackendImpl::PackageImpl::isRegistered_( @@ -321,7 +345,7 @@ BackendImpl::PackageImpl::isRegistered_( BackendImpl * that = getMyBackend(); bool bReg = false; - if (that->readDataFromDb(getURL())) + if (that->hasActiveEntry(getURL())) bReg = true; return beans::Optional< beans::Ambiguous<sal_Bool> >( true, beans::Ambiguous<sal_Bool>( bReg, false ) ); @@ -340,9 +364,7 @@ void BackendImpl::PackageImpl::processPackage_( (void)xCmdEnv; BackendImpl* that = getMyBackend(); - Reference< deployment::XPackage > xThisPackage( this ); - that->implProcessHelp( xThisPackage, doRegisterPackage, - extensionContainsCompiledHelp(), xCmdEnv); + that->implProcessHelp( this, doRegisterPackage, xCmdEnv); } beans::Optional< OUString > BackendImpl::PackageImpl::getRegistrationDataURL() @@ -355,7 +377,7 @@ beans::Optional< OUString > BackendImpl::PackageImpl::getRegistrationDataURL() ::boost::optional<HelpBackendDb::Data> data = getMyBackend()->readDataFromDb(getURL()); - if (data) + if (data && getMyBackend()->hasActiveEntry(getURL())) return beans::Optional<OUString>(true, data->dataUrl); return beans::Optional<OUString>(true, OUString()); @@ -368,224 +390,225 @@ static rtl::OUString aSlash( rtl::OUString::createFromAscii( "/" ) ); static rtl::OUString aHelpStr( rtl::OUString::createFromAscii( "help" ) ); -void BackendImpl::implProcessHelp -( Reference< deployment::XPackage > xPackage, bool doRegisterPackage, bool compiledHelp, - Reference<ucb::XCommandEnvironment> const & xCmdEnv) +void BackendImpl::implProcessHelp( + PackageImpl * package, bool doRegisterPackage, + Reference<ucb::XCommandEnvironment> const & xCmdEnv) { + Reference< deployment::XPackage > xPackage(package); OSL_ASSERT(xPackage.is()); if (doRegisterPackage) { - HelpBackendDb::Data data; - - if (compiledHelp) + //revive already processed help if possible + if ( !activateEntry(xPackage->getURL())) { + HelpBackendDb::Data data; data.dataUrl = xPackage->getURL(); - } - else - { - const OUString sHelpFolder = createFolder(OUString(), xCmdEnv); - data.dataUrl = sHelpFolder; - - 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 (!package->extensionContainsCompiledHelp()) { - rtl::OUString aErrStr = getResourceString( RID_STR_HELPPROCESSING_GENERAL_ERROR ); - aErrStr += rtl::OUString::createFromAscii( "No help folder" ); - OWeakObject* oWeakThis = static_cast<OWeakObject *>(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); - } - - Reference<XComponentContext> const & xContext = getComponentContext(); - Reference< script::XInvocation > xInvocation; - if( xContext.is() ) - { - try + const OUString sHelpFolder = createFolder(OUString(), xCmdEnv); + data.dataUrl = sHelpFolder; + + 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 ) ) { - 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<OWeakObject *>(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); } - catch (Exception &) + + Reference<XComponentContext> 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; - - // 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 = ::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.zip://" ); - 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; - - implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); + std::vector< rtl::OUString > aXhpFileVector; + + // 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 = ::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.zip://" ); + 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; - // Copy to package (later: move?) - rtl::OUString aDestPath = aDestBasePath; - rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); - aDestPath += aPureFolderName; - xSFA->copy( aSubFolderURL, aDestPath ); - } + implCollectXhpFiles( aSubFolderURL, aXhpFileVector ); - // 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; - } + // Copy to package (later: move?) + rtl::OUString aDestPath = aDestBasePath; + rtl::OUString aPureFolderName = aSubFolderURL.copy( nLenLangFolderURL ); + aDestPath += aPureFolderName; + xSFA->copy( aSubFolderURL, aDestPath ); + } - rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); - rtl::OUString aOfficeHelpPathFileURL; - ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); + // 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; + } - HelpProcessingErrorInfo aErrorInfo; - bool bSuccess = compileExtensionHelp( - aOfficeHelpPathFileURL, aHelpStr, aLangURL, - nXhpFileCount, pXhpFiles, - langFolderDestExpanded, aErrorInfo ); + rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); + rtl::OUString aOfficeHelpPathFileURL; + ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); - if( bSuccess && xInvocation.is() ) - { - Sequence<uno::Any> 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( - 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 ); - } + HelpProcessingErrorInfo aErrorInfo; + bool bSuccess = compileExtensionHelp( + aOfficeHelpPathFileURL, aHelpStr, aLangURL, + nXhpFileCount, pXhpFiles, + langFolderDestExpanded, aErrorInfo ); - if( !bSuccess ) - { - sal_uInt16 nErrStrId = 0; - switch( aErrorInfo.m_eErrorClass ) + if( bSuccess && xInvocation.is() ) { - 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 ) + Sequence<uno::Any> 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( + 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 ) { - 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 ) + USHORT nErrStrId = 0; + switch( aErrorInfo.m_eErrorClass ) { - 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() ) + 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 += 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 ) + { + 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( ", line " ); - aErrStr += ::rtl::OUString::valueOf( aErrorInfo.m_nXMLParsingLine ); + 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<OWeakObject *>(this); - throw deployment::DeploymentException( rtl::OUString(), oWeakThis, - makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + OWeakObject* oWeakThis = static_cast<OWeakObject *>(this); + throw deployment::DeploymentException( rtl::OUString(), oWeakThis, + makeAny( uno::Exception( aErrStr, oWeakThis ) ) ); + } } } } + //Writing the data entry replaces writing the flag file. If we got to this + //point the registration was successful. + addDataToDb(xPackage->getURL(), data); } - //Writing the data entry replaces writing the flag file. If we got to this - //point the registration was successful. - addDataToDb(xPackage->getURL(), data); } //if (doRegisterPackage) else { - deleteDataFromDb(xPackage->getURL()); + revokeEntryFromDb(xPackage->getURL()); } } diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx index 8ec9a39d5050..81057f744640 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx @@ -83,11 +83,14 @@ OUString HelpBackendDb::getKeyElementName() void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - Reference<css::xml::dom::XNode> helpNode - = writeKeyElement(url); + if (!activateEntry(url)) + { + Reference<css::xml::dom::XNode> helpNode + = writeKeyElement(url); - writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); - save(); + writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode); + save(); + } } catch (css::deployment::DeploymentException& ) { diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx index c7b730fd1b99..bcff008c00ae 100644 --- a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx +++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx @@ -76,6 +76,8 @@ public: void addEntry(::rtl::OUString const & url, Data const & data); ::boost::optional<Data> getEntry(::rtl::OUString const & url); + //must also return the data urls for entries with @activ="false". That is, + //those are currently revoked. ::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 20fc2a8dc7e1..80aec2402a59 100755 --- a/desktop/source/deployment/registry/inc/dp_backend.h +++ b/desktop/source/deployment/registry/inc/dp_backend.h @@ -299,7 +299,7 @@ protected: // currently only for library containers: enum { CONTEXT_UNKNOWN, - CONTEXT_USER, CONTEXT_SHARED,CONTEXT_BUNDLED, CONTEXT_TMP, + CONTEXT_USER, CONTEXT_SHARED,CONTEXT_BUNDLED, CONTEXT_TMP, CONTEXT_BUNDLED_PREREG, CONTEXT_DOCUMENT } m_eContext; bool m_readOnly; @@ -345,6 +345,18 @@ protected: static void deleteTempFolder( ::rtl::OUString const & folderUrl); + ::rtl::OUString getSharedRegistrationDataURL( + css::uno::Reference<css::deployment::XPackage> const & extension, + css::uno::Reference<css::deployment::XPackage> const & item); + + /* The backends must implement this function, which is called + from XPackageRegistry::packageRemoved (also implemented here). + This ensure that the backends clean up their registration data + when an extension was removed. + */ +// virtual void deleteDbEntry( ::rtl::OUString const & url) = 0; + + public: struct StrRegisteringPackage : public ::dp_misc::StaticResourceString< @@ -373,6 +385,12 @@ public: css::deployment::InvalidRemovedParameterException, css::ucb::CommandFailedException, css::lang::IllegalArgumentException, css::uno::RuntimeException); + +// virtual void SAL_CALL packageRemoved( +// ::rtl::OUString const & url, ::rtl::OUString const & mediaType) +// throw (css::deployment::DeploymentException, +// css::uno::RuntimeException); + }; } diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx index a0e477979f8c..299a6ec328ce 100644 --- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx +++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx @@ -147,6 +147,18 @@ public: virtual ~BackendDb() {}; void removeEntry(::rtl::OUString const & url); + + /* This is called to write the "revoked" attribute to the entry. + This is done when XPackage::revokePackage is called. + */ + void revokeEntry(::rtl::OUString const & url); + + /* returns false if the entry does not exist yet. + */ + bool activateEntry(::rtl::OUString const & url); + + bool hasActiveEntry(::rtl::OUString const & url); + }; class RegisteredDb: public BackendDb diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx index 2e92a907f8fb..660d6bb374c3 100644 --- a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx +++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx @@ -82,15 +82,19 @@ OUString ExtensionBackendDb::getKeyElementName() void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data) { try{ - Reference<css::xml::dom::XNode> extensionNodeNode = writeKeyElement(url); - writeVectorOfPair( - data.items, - OUSTR("extension-items"), - OUSTR("item"), - OUSTR("url"), - OUSTR("media-type"), - extensionNodeNode); - save(); + //reactive revoked entry if possible. + if (!activateEntry(url)) + { + Reference<css::xml::dom::XNode> extensionNodeNode = writeKeyElement(url); + writeVectorOfPair( + data.items, + OUSTR("extension-items"), + OUSTR("item"), + OUSTR("url"), + OUSTR("media-type"), + extensionNodeNode); + save(); + } } catch(css::uno::Exception &) { diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 262bbef420f2..d247597a808f 100755..100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -250,7 +250,7 @@ class BackendImpl : public ImplBaseT void addDataToDb(OUString const & url, ExtensionBackendDb::Data const & data); ExtensionBackendDb::Data readDataFromDb(OUString const & url); - void deleteDataFromDb(OUString const & url); + void revokeEntryFromDb(OUString const & url); // PackageRegistryBackend virtual Reference<deployment::XPackage> bindPackage_( @@ -276,6 +276,9 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); using ImplBaseT::disposing; }; @@ -360,6 +363,21 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) return m_typeInfos; } +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + //Notify the backend responsible for processing the different media + //types that this extension was removed. + ExtensionBackendDb::Data data = readDataFromDb(url); + for (ExtensionBackendDb::Data::ITC_ITEMS i = data.items.begin(); i != data.items.end(); i++) + { + m_xRootRegistry->packageRemoved(i->first, i->second); + } + + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} // PackageRegistryBackend @@ -460,10 +478,10 @@ ExtensionBackendDb::Data BackendImpl::readDataFromDb( return data; } -void BackendImpl::deleteDataFromDb(OUString const & url) +void BackendImpl::revokeEntryFromDb(OUString const & url) { if (m_backendDb.get()) - m_backendDb->removeEntry(url); + m_backendDb->revokeEntry(url); } @@ -973,7 +991,7 @@ void BackendImpl::PackageImpl::processPackage_( // selected } } - getMyBackend()->deleteDataFromDb(getURL()); + getMyBackend()->revokeEntryFromDb(getURL()); } } diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index edeae256cbaf..dddf82e09790 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -101,13 +101,8 @@ class BackendImpl : public t_helper Reference<XCommandEnvironment> const & xCmdEnv ); 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; + bool hasActiveEntry(OUString const & url); + void revokeEntryFromDb(OUString const & url); const Reference<deployment::XPackageTypeInfo> m_xBasicLibTypeInfo; const Reference<deployment::XPackageTypeInfo> m_xDialogLibTypeInfo; @@ -123,6 +118,10 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); + }; //______________________________________________________________________________ @@ -191,18 +190,11 @@ void BackendImpl::addDataToDb(OUString const & url) m_backendDb->addEntry(url); } -bool BackendImpl::isRegisteredInDb(OUString const & url) +bool BackendImpl::hasActiveEntry(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); + return m_backendDb->hasActiveEntry(url); + return false; } // XUpdatable @@ -219,6 +211,19 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) { return m_typeInfos; } +void BackendImpl::revokeEntryFromDb(OUString const & url) +{ + if (m_backendDb.get()) + m_backendDb->revokeEntry(url); +} + +void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ + if (m_backendDb.get()) + m_backendDb->removeEntry(url); +} // PackageRegistryBackend //______________________________________________________________________________ @@ -321,7 +326,7 @@ BackendImpl::PackageImpl::isRegistered_( BackendImpl * that = getMyBackend(); Reference< deployment::XPackage > xThisPackage( this ); - bool registered = that->isRegisteredInDb(getURL()); + bool registered = that->hasActiveEntry(getURL()); return beans::Optional< beans::Ambiguous<sal_Bool> >( true /* IsPresent */, beans::Ambiguous<sal_Bool>( registered, false /* IsAmbiguous */ ) ); @@ -367,7 +372,7 @@ void BackendImpl::PackageImpl::processPackage_( xComponentContext ), UNO_QUERY_THROW ); } } - bool bRegistered = getMyBackend()->isRegisteredInDb(getURL()); + bool bRegistered = getMyBackend()->hasActiveEntry(getURL()); if( !doRegisterPackage ) { //We cannot just call removeLibrary(name) because this could remove a @@ -399,7 +404,7 @@ void BackendImpl::PackageImpl::processPackage_( xDialogLibs->removeLibrary(m_dialogName); } } - getMyBackend()->deleteDataFromDb(getURL()); + getMyBackend()->revokeEntryFromDb(getURL()); return; } } diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx index f3195701fc7c..7e4be0f4e35a 100755 --- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx +++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx @@ -100,6 +100,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend const Reference<deployment::XPackageTypeInfo> m_xTypeInfo; + public: BackendImpl( Sequence<Any> const & args, @@ -108,6 +109,9 @@ public: // XPackageRegistry virtual Sequence< Reference<deployment::XPackageTypeInfo> > SAL_CALL getSupportedPackageTypes() throw (RuntimeException); + virtual void SAL_CALL packageRemoved(OUString const & url, OUString const & mediaType) + throw (deployment::DeploymentException, + uno::RuntimeException); }; BackendImpl * BackendImpl::PackageImpl::getMyBackend() const @@ -218,6 +222,8 @@ BackendImpl::BackendImpl( } } + + // XPackageRegistry //______________________________________________________________________________ Sequence< Reference<deployment::XPackageTypeInfo> > @@ -226,6 +232,12 @@ BackendImpl::getSupportedPackageTypes() throw (RuntimeException) return Sequence< Reference<deployment::XPackageTypeInfo> >(&m_xTypeInfo, 1); } +void BackendImpl::packageRemoved(OUString const & /*url*/, OUString const & /*mediaType*/) + throw (deployment::DeploymentException, + uno::RuntimeException) +{ +} + // PackageRegistryBackend //______________________________________________________________________________ Reference<deployment::XPackage> BackendImpl::bindPackage_( @@ -338,6 +350,11 @@ void BackendImpl::PackageImpl:: initPackageHandler() { aContext <<= OUSTR("bundled"); } + else if ( that->m_eContext == CONTEXT_BUNDLED_PREREG ) + { + aContext <<= OUSTR("bundled_prereg"); + } + else { OSL_ASSERT( 0 ); diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 4545ed862271..83552cb7c4c6 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -380,7 +380,12 @@ extern "C" int unopkg_main() } else if (subCommand.equals(OUSTR("sync"))) { - //sync is private!!!! Only for bundled extensions!!! + //sync is private!!!! Only to be called from setup!!! + //The UserInstallation is diverted to the prereg folder. But only + //the lock file is written! This requires that + //-env:UNO_JAVA_JFW_INSTALL_DATA is passed to javaldx and unopkg otherwise the + //javasettings file is written to the prereg folder. + // //For performance reasons unopkg sync is called during the setup and //creates the registration data for the repository of the bundled //extensions. It is then copied to the user installation during @@ -395,10 +400,21 @@ extern "C" int unopkg_main() //$BUNDLED_EXTENSIONS_USER if (hasNoFolder(OUSTR("$BRAND_BASE_DIR/share/extensions"))) { - removeFolder(OUSTR("$BUNDLED_EXTENSIONS_USER")); + removeFolder(OUSTR("$BUNDLED_EXTENSIONS_PREREG")); //return otherwise we create the registration data again return 0; } + //redirect the UserInstallation, so we do not create a + //user installation for the admin and we also do not need + //to call unopkg with -env:UserInstallation + ::rtl::Bootstrap::set(OUSTR("UserInstallation"), + OUSTR("$BUNDLED_EXTENSIONS_PREREG/..")); + //Setting UNO_JAVA_JFW_INSTALL_DATA causes the javasettings to be written + //in the office installation. We do not want to create the user data folder + //for the admin. The value must also be set in the unopkg script (Linux, etc.) + //when calling javaldx + ::rtl::Bootstrap::set(OUSTR("UNO_JAVA_JFW_INSTALL_DATA"), + OUSTR("$OOO_BASE_DIR/share/config/javasettingsunopkginstall.xml")); } @@ -418,6 +434,7 @@ extern "C" int unopkg_main() //prevent the deletion of the registry data folder //synching is done in XExtensionManager.reinstall if (!subcmd_gui && ! subCommand.equals(OUSTR("reinstall")) + && ! subCommand.equals(OUSTR("sync")) && ! dp_misc::office_is_running()) dp_misc::syncRepositories(xCmdEnv); @@ -613,12 +630,15 @@ extern "C" int unopkg_main() } else if (subCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("sync"))) { - //This sub command may be removed later and is only there to have a - //possibility to start extension synching without any output. - //This is just here so we do not get an error, because of an unknown - //sub-command. We do synching before - //the sub-commands are processed. - + if (! dp_misc::office_is_running()) + { + xExtensionManager->synchronizeBundledPrereg( + Reference<task::XAbortChannel>(), xCmdEnv); + } + else + { + dp_misc::writeConsoleError(OUSTR("\nError: office is running")); + } } else { diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx index d7b6e1ca2336..f6773b768062 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx @@ -396,6 +396,7 @@ Reference<XComponentContext> bootstrapStandAlone( if (! ::ucbhelper::ContentBroker::initialize( xServiceManager, ucb_args )) throw RuntimeException( OUSTR("cannot initialize UCB!"), 0 ); + disposeGuard.setDeinitUCB(); return xContext; } @@ -627,7 +628,7 @@ void removeFolder(OUString const & folderUrl) dir.close(); ::osl::Directory::remove(url); } - else + else if (rc != osl::File::E_NOENT) { dp_misc::writeConsole( OUSTR("unopkg: Error while removing ") + url + OUSTR("\n")); diff --git a/desktop/source/pkgchk/unopkg/unopkg_shared.h b/desktop/source/pkgchk/unopkg/unopkg_shared.h index 4975cc4c087b..55c86260ca8f 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_shared.h +++ b/desktop/source/pkgchk/unopkg/unopkg_shared.h @@ -34,6 +34,7 @@ #include "tools/resmgr.hxx" #include "rtl/ustring.hxx" #include "unotools/configmgr.hxx" +#include "ucbhelper/contentbroker.hxx" #define APP_NAME "unopkg" @@ -137,15 +138,14 @@ bool isBootstrapVariable(sal_uInt32 * pIndex); class DisposeGuard { css::uno::Reference<css::lang::XComponent> m_xComp; - + bool m_bDeinitUCB; public: - inline DisposeGuard() {} - inline DisposeGuard( - css::uno::Reference<css::lang::XComponent> const & xComp ) - : m_xComp( xComp ) {} - + DisposeGuard(): m_bDeinitUCB(false) {} inline ~DisposeGuard() { + if (m_bDeinitUCB) + ::ucbhelper::ContentBroker::deinitialize(); + if (m_xComp.is()) m_xComp->dispose(); } @@ -155,6 +155,12 @@ public: { m_xComp = xComp; } + + inline void setDeinitUCB() + { + m_bDeinitUCB = true; + } + }; //============================================================================== |