[Libreoffice-commits] .: 2 commits - desktop/inc desktop/source offapi/com

Stephan Bergmann sbergmann at kemper.freedesktop.org
Thu Aug 9 05:38:05 PDT 2012


 desktop/inc/app.hxx                                        |    4 
 desktop/source/app/app.cxx                                 |  154 ++++++++++++-
 desktop/source/app/check_ext_deps.cxx                      |   19 +
 desktop/source/app/cmdlineargs.cxx                         |   74 +++---
 desktop/source/app/cmdlineargs.hxx                         |   34 +-
 desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx |    2 
 desktop/source/deployment/inc/dp_misc.h                    |    3 
 desktop/source/deployment/manager/dp_extensionmanager.cxx  |    9 
 desktop/source/deployment/manager/dp_extensionmanager.hxx  |    1 
 desktop/source/deployment/manager/dp_manager.cxx           |   22 -
 desktop/source/deployment/manager/dp_manager.h             |    2 
 desktop/source/deployment/misc/dp_misc.cxx                 |    7 
 desktop/source/pkgchk/unopkg/unopkg_app.cxx                |    2 
 offapi/com/sun/star/deployment/XExtensionManager.idl       |    8 
 offapi/com/sun/star/deployment/XPackageManager.idl         |    8 
 15 files changed, 232 insertions(+), 117 deletions(-)

New commits:
commit 5300f6f711c2167931d45248c1b72dbce3a7df38
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Aug 9 13:29:22 2012 +0200

    fdo#53006: Remove user/extensions/bundled cache after upgrade
    
    ... to clean out all sorts of inconsitencies that can have accrued there over
    time apparently due to how the mechanism of copying share/prereg/bundled worked,
    and to work around stale $BUNDLED_EXTENSIONS_PREREG references in a better way
    than the previous 81fd6b084b0f3c0eb5a97c77592f5ceb21d2dfb1 "fdo#53006 Force
    reinstall of all bundled extensions on upgrade."
    
    See the comment on refreshBundledExtensionsDir for how, at least in theory, that
    functionality could be removed again in the future.
    
    This effectively reverts 2d2b19dea1ab401b1b4971ff5b12b87bb11fd666 "Force
    ExtensionManager resync when the implementation changes" and
    81fd6b084b0f3c0eb5a97c77592f5ceb21d2dfb1 "fdo#53006 Force reinstall of all
    bundled extensions on upgrade" (the latter at least on master; it had never been
    cherry-picked to libreoffice-3-6), which it obsoletes.
    
    Change-Id: I8f80c07a06ec9d53b03813338eeff7d7757c9d4d

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 06dc4c7..22866ef 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -126,14 +126,12 @@ class Desktop : public Application
         static sal_Bool         isCrashReporterEnabled();
 
         // first-start (ever) related methods
-        static bool             newInstallation();
-
         static sal_Bool         CheckExtensionDependencies();
 
         static void             DoRestartActionsIfNecessary( sal_Bool bQuickStart );
         static void             SetRestartState();
 
-        void                    SynchronizeExtensionRepositories(bool force);
+        void                    SynchronizeExtensionRepositories();
         void                    SetSplashScreenText( const ::rtl::OUString& rText );
         void                    SetSplashScreenProgress( sal_Int32 );
 
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index c3152ee..84f60b8 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -152,6 +152,145 @@ static sal_Bool _bCrashReporterEnabled = sal_True;
 static ::rtl::OUString getBrandSharePreregBundledPathURL();
 #endif
 
+namespace {
+
+void removeTree(OUString const & url) {
+    osl::Directory dir(url);
+    switch (dir.open()) {
+    case osl::FileBase::E_None:
+        break;
+    case osl::FileBase::E_NOENT:
+        return; //TODO: SAL_WARN if recursive
+    default:
+        throw css::uno::RuntimeException(
+            "cannot open directory " + url,
+            css::uno::Reference< css::uno::XInterface >());
+    }
+    for (;;) {
+        osl::DirectoryItem i;
+        osl::FileBase::RC rc = dir.getNextItem(i, SAL_MAX_UINT32);
+        if (rc == osl::FileBase::E_NOENT) {
+            break;
+        }
+        if (rc != osl::FileBase::E_None) {
+            throw css::uno::RuntimeException(
+                "cannot iterate directory " + url,
+                css::uno::Reference< css::uno::XInterface >());
+        }
+        osl::FileStatus stat(
+            osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName |
+            osl_FileStatus_Mask_FileURL);
+        if (i.getFileStatus(stat) != osl::FileBase::E_None) {
+            throw css::uno::RuntimeException(
+                "cannot stat in directory " + url,
+                css::uno::Reference< css::uno::XInterface >());
+        }
+        if (stat.getFileType() == osl::FileStatus::Directory) { //TODO: symlinks
+            removeTree(stat.getFileURL());
+        } else {
+            if (osl::File::remove(stat.getFileURL()) != osl::FileBase::E_None) {
+                throw css::uno::RuntimeException(
+                    "cannot remove " + stat.getFileURL(),
+                    css::uno::Reference< css::uno::XInterface >());
+            }
+        }
+    }
+}
+
+// Remove any existing UserInstallation's user/extensions/bundled cache
+// remaining from old installations.  Apparently due to the old
+// share/prereg/bundled mechanism (disabled since
+// 5c47e5f63a79a9e72ec4a100786b1bbf65137ed4 "fdo#51252 Disable copying
+// share/prereg/bundled to avoid startup crashes"), that cache could contain
+// corrupted information (like a UNO component registered twice, which got
+// changed from active to passive registration in one LO version, but the
+// version of the corresponding bundled extension only incremented in a later LO
+// version).  At least in theory, this function could be removed again once no
+// UserInstallation can be poisoned by that old share/prereg/bundled mechanism
+// any more.  (But then Desktop::SynchronizeExtensionRepositories might need to
+// be revisited, see 2d2b19dea1ab401b1b4971ff5b12b87bb11fd666 "Force
+// ExtensionManager resync when the implementation changes" which effectively
+// got reverted again now.  Now, a mismatch between a UserInstallation's
+// user/extensions/bundled and an installation's share/extensions will always be
+// detected here and lead to a removal of user/extensions/bundled, so that
+// Desktop::SynchronizeExtensionRepositories will then definitely resync
+// share/extensions.)
+void refreshBundledExtensionsDir() {
+    OUString buildId(
+        "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":buildid}");
+    rtl::Bootstrap::expandMacros(buildId); //TODO: detect failure
+    OUString dir("$BUNDLED_EXTENSIONS_USER");
+    rtl::Bootstrap::expandMacros(dir); //TODO: detect failure
+    OUString url(dir + "/buildid");
+    osl::File f(url);
+    switch (f.open(osl_File_OpenFlag_Read)) {
+    case osl::FileBase::E_None:
+        {
+            rtl::ByteSequence s1;
+            osl::FileBase::RC rc = f.readLine(s1);
+            if (f.close() != osl::FileBase::E_None) {
+                SAL_WARN("desktop", "cannot close " + url + " after reading");
+            }
+            if (rc != osl::FileBase::E_None) {
+                throw css::uno::RuntimeException(
+                    "cannot read from " + url,
+                    css::uno::Reference< css::uno::XInterface >());
+            }
+            OUString s2(
+                reinterpret_cast< char const * >(s1.getConstArray()),
+                s1.getLength(), RTL_TEXTENCODING_ISO_8859_1);
+                // using ISO 8859-1 avoids any and all conversion errors; the
+                // content should only be a subset of ASCII, anyway
+            if (s2 == buildId) {
+                return;
+            }
+            break;
+        }
+    case osl::FileBase::E_NOENT:
+        break;
+    default:
+        throw css::uno::RuntimeException(
+            "cannot open " + url + " for reading",
+            css::uno::Reference< css::uno::XInterface >());
+    }
+    removeTree(dir);
+    switch (osl::Directory::createPath(dir)) {
+    case osl::FileBase::E_None:
+    case osl::FileBase::E_EXIST:
+        break;
+    default:
+        throw css::uno::RuntimeException(
+            "cannot create path " + dir,
+            css::uno::Reference< css::uno::XInterface >());
+    }
+    if (f.open(osl_File_OpenFlag_Write | osl_File_OpenFlag_Create) !=
+        osl::FileBase::E_None)
+    {
+        throw css::uno::RuntimeException(
+            "cannot open " + url + " for writing",
+            css::uno::Reference< css::uno::XInterface >());
+    }
+    OString buf(OUStringToOString(buildId, RTL_TEXTENCODING_UTF8));
+        // using UTF-8 avoids almost all conversion errors (and buildid
+        // containing single surrogate halves should never happen, anyway); the
+        // content should only be a subset of ASCII, anyway
+    sal_uInt64 n;
+    if (f.write(buf.getStr(), buf.getLength(), n) != osl::FileBase::E_None
+        || n != static_cast< sal_uInt32 >(buf.getLength()))
+    {
+        throw css::uno::RuntimeException(
+            "cannot write to " + url,
+            css::uno::Reference< css::uno::XInterface >());
+    }
+    if (f.close() != osl::FileBase::E_None) {
+        throw css::uno::RuntimeException(
+            "cannot close " + url + " after writing",
+            css::uno::Reference< css::uno::XInterface >());
+    }
+}
+
+}
+
 // ----------------------------------------------------------------------------
 
 ResMgr* Desktop::GetDesktopResManager()
@@ -633,6 +772,8 @@ void Desktop::Init()
     RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Init" );
     SetBootstrapStatus(BS_OK);
 
+    refreshBundledExtensionsDir();
+
     // Check for lastsynchronized file for bundled extensions in the user directory
     // and test if synchronzation is necessary!
 #ifndef ANDROID
@@ -1607,14 +1748,10 @@ int Desktop::Main()
         // Check if bundled or shared extensions were added /removed
         // and process those extensions (has to be done before checking
         // the extension dependencies!
-        bool newInst = newInstallation();
-        SynchronizeExtensionRepositories(newInst);
-        if ( newInst )
-        {
-            bool bAbort = CheckExtensionDependencies();
-            if ( bAbort )
-                return EXIT_FAILURE;
-        }
+        SynchronizeExtensionRepositories();
+        bool bAbort = CheckExtensionDependencies();
+        if ( bAbort )
+            return EXIT_FAILURE;
 
         {
             ::comphelper::ComponentContext aContext( xSMgr );
diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx
index 04b5cd7..dd01d9b 100644
--- a/desktop/source/app/check_ext_deps.cxx
+++ b/desktop/source/app/check_ext_deps.cxx
@@ -347,9 +347,9 @@ static void impl_setNeedsCompatCheck()
 // to check if we need checking the dependencies of the extensions again, we compare
 // the build id of the office with the one of the last check
 //------------------------------------------------------------------------------
-bool Desktop::newInstallation()
+static bool impl_needsCompatCheck()
 {
-    bool bNewInst = false;
+    bool bNeedsCheck = false;
     rtl::OUString aLastCheckBuildID;
     rtl::OUString aCurrentBuildID( UNISTRING( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":buildid}" ) );
     rtl::Bootstrap::expandMacros( aCurrentBuildID );
@@ -371,18 +371,18 @@ bool Desktop::newInstallation()
         result >>= aLastCheckBuildID;
         if ( aLastCheckBuildID != aCurrentBuildID )
         {
-            bNewInst = true;
+            bNeedsCheck = true;
             result <<= aCurrentBuildID;
             pset->setPropertyValue( OUString("LastCompatibilityCheckID"), result );
             Reference< util::XChangesBatch >( pset, UNO_QUERY_THROW )->commitChanges();
         }
 #ifdef DEBUG
-        bNewInst = true;
+        bNeedsCheck = true;
 #endif
     }
     catch (const com::sun::star::uno::Exception&) {}
 
-    return bNewInst;
+    return bNeedsCheck;
 }
 
 //------------------------------------------------------------------------------
@@ -390,6 +390,11 @@ bool Desktop::newInstallation()
 // When there are unresolved issues, we can't continue with startup
 sal_Bool Desktop::CheckExtensionDependencies()
 {
+    if (!impl_needsCompatCheck())
+    {
+        return false;
+    }
+
     uno::Reference< uno::XComponentContext > xContext = comphelper_getProcessComponentContext();
 
     bool bDependenciesValid = impl_checkDependencies( xContext );
@@ -408,10 +413,10 @@ sal_Bool Desktop::CheckExtensionDependencies()
         return false;
 }
 
-void Desktop::SynchronizeExtensionRepositories(bool force)
+void Desktop::SynchronizeExtensionRepositories()
 {
     RTL_LOGFILE_CONTEXT(aLog,"desktop (jl) ::Desktop::SynchronizeExtensionRepositories");
-    dp_misc::syncRepositories( force, new SilentCommandEnv( this ) );
+    dp_misc::syncRepositories( new SilentCommandEnv( this ) );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
index 7795e30..29ded17 100644
--- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
@@ -1124,7 +1124,7 @@ void ExtensionCmdQueue::acceptLicense( const uno::Reference< deployment::XPackag
 
 void ExtensionCmdQueue::syncRepositories( const uno::Reference< uno::XComponentContext > &xContext )
 {
-    dp_misc::syncRepositories( false, new ProgressCmdEnv( xContext, NULL, OUSTR("Extension Manager") ) );
+    dp_misc::syncRepositories( new ProgressCmdEnv( xContext, NULL, OUSTR("Extension Manager") ) );
 }
 
 void ExtensionCmdQueue::stop()
diff --git a/desktop/source/deployment/inc/dp_misc.h b/desktop/source/deployment/inc/dp_misc.h
index df358d7..2410c1b 100644
--- a/desktop/source/deployment/inc/dp_misc.h
+++ b/desktop/source/deployment/inc/dp_misc.h
@@ -154,8 +154,7 @@ void TRACE(::rtl::OUString const & sText);
     recently added or removed.
 */
 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
-void syncRepositories(bool force,
-                      ::com::sun::star::uno::Reference<
+void syncRepositories(::com::sun::star::uno::Reference<
                       ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv);
 
 }
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx
index 290df13..f2a6fce 100644
--- a/desktop/source/deployment/manager/dp_extensionmanager.cxx
+++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx
@@ -1223,7 +1223,7 @@ void ExtensionManager::reinstallDeployedExtensions(
         xPackageManager->reinstallDeployedPackages(xAbortChannel, xCmdEnv);
         //We must sync here, otherwise we will get exceptions when extensions
         //are removed.
-        dp_misc::syncRepositories(false, xCmdEnv);
+        dp_misc::syncRepositories(xCmdEnv);
         const uno::Sequence< Reference<deploy::XPackage> > extensions(
             xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv));
 
@@ -1278,7 +1278,7 @@ void ExtensionManager::synchronizeBundledPrereg(
 
         Reference<deploy::XPackageManager> xMgr =
             xPackageManagerFactory->getPackageManager(OUSTR("bundled_prereg"));
-        xMgr->synchronize(false, xAbortChannel, xCmdEnv);
+        xMgr->synchronize(xAbortChannel, xCmdEnv);
         progressBundled.update(OUSTR("\n\n"));
 
         uno::Sequence<Reference<deploy::XPackage> > extensions = xMgr->getDeployedPackages(
@@ -1317,7 +1317,6 @@ void ExtensionManager::synchronizeBundledPrereg(
 }
 
 sal_Bool ExtensionManager::synchronize(
-    sal_Bool forceBundled,
     Reference<task::XAbortChannel> const & xAbortChannel,
     Reference<ucb::XCommandEnvironment> const & xCmdEnv )
     throw (deploy::DeploymentException,
@@ -1334,13 +1333,13 @@ sal_Bool ExtensionManager::synchronize(
         String sSynchronizingShared(StrSyncRepository::get());
         sSynchronizingShared.SearchAndReplaceAllAscii( "%NAME", OUSTR("shared"));
         dp_misc::ProgressLevel progressShared(xCmdEnv, sSynchronizingShared);
-        bModified = getSharedRepository()->synchronize(false, 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 |= getBundledRepository()->synchronize(forceBundled, xAbortChannel, xCmdEnv);
+        bModified |= getBundledRepository()->synchronize(xAbortChannel, xCmdEnv);
         progressBundled.update(OUSTR("\n\n"));
 
         //Always determine the active extension. This is necessary for the
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.hxx b/desktop/source/deployment/manager/dp_extensionmanager.hxx
index 05fcde8..800d91f 100644
--- a/desktop/source/deployment/manager/dp_extensionmanager.hxx
+++ b/desktop/source/deployment/manager/dp_extensionmanager.hxx
@@ -193,7 +193,6 @@ public:
             css::uno::RuntimeException);
 
     virtual sal_Bool SAL_CALL synchronize(
-        sal_Bool forceBundled,
         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
         throw (css::deployment::DeploymentException,
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index d7c8a2a..a088f51 100644
--- a/desktop/source/deployment/manager/dp_manager.cxx
+++ b/desktop/source/deployment/manager/dp_manager.cxx
@@ -1248,7 +1248,6 @@ void PackageManagerImpl::reinstallDeployedPackages(
     return m_readOnly;
 }
 bool PackageManagerImpl::synchronizeRemovedExtensions(
-    bool force,
     Reference<task::XAbortChannel> const & xAbortChannel,
     Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
 {
@@ -1272,19 +1271,15 @@ bool PackageManagerImpl::synchronizeRemovedExtensions(
             if (bShared)
                 url = makeURLAppendSysPathSegment( url + OUSTR("_"), i->second.fileName);
 
-            bool bRemoved = force;
-
+            bool bRemoved = false;
             //Check if the URL to the extension is still the same
-            if (!bRemoved)
-            {
-                ::ucbhelper::Content contentExtension;
+            ::ucbhelper::Content contentExtension;
 
-                if (!create_ucb_content(
-                        &contentExtension, url,
-                        Reference<XCommandEnvironment>(), false))
-                {
-                    bRemoved = true;
-                }
+            if (!create_ucb_content(
+                    &contentExtension, url,
+                    Reference<XCommandEnvironment>(), false))
+            {
+                bRemoved = true;
             }
 
             //The folder is in the extension database, but it can still be deleted.
@@ -1469,7 +1464,6 @@ bool PackageManagerImpl::synchronizeAddedExtensions(
 }
 
 sal_Bool PackageManagerImpl::synchronize(
-    sal_Bool force,
     Reference<task::XAbortChannel> const & xAbortChannel,
     Reference<css::ucb::XCommandEnvironment> const & xCmdEnv)
     throw (css::deployment::DeploymentException,
@@ -1482,7 +1476,7 @@ sal_Bool PackageManagerImpl::synchronize(
     if (m_context.equals(OUSTR("user")))
         return bModified;
     bModified |=
-        synchronizeRemovedExtensions(force, xAbortChannel, xCmdEnv);
+        synchronizeRemovedExtensions(xAbortChannel, xCmdEnv);
     bModified |= synchronizeAddedExtensions(xAbortChannel, xCmdEnv);
 
     return bModified;
diff --git a/desktop/source/deployment/manager/dp_manager.h b/desktop/source/deployment/manager/dp_manager.h
index cb3cbe8..b88b511 100644
--- a/desktop/source/deployment/manager/dp_manager.h
+++ b/desktop/source/deployment/manager/dp_manager.h
@@ -82,7 +82,6 @@ class PackageManagerImpl : private ::dp_misc::MutexHolder, public t_pm_helper
         css::uno::Reference<css::deployment::XPackage> const & package);
 
     bool synchronizeRemovedExtensions(
-        bool force,
         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
 
@@ -240,7 +239,6 @@ public:
         throw (::com::sun::star::uno::RuntimeException);
 
     virtual ::sal_Bool SAL_CALL synchronize(
-        sal_Bool force,
         css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
         css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
         throw (css::deployment::DeploymentException,
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index 6f47e3d..ba9c983 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -546,7 +546,7 @@ void TRACE(::rtl::OUString const & sText)
 }
 
 void syncRepositories(
-    bool force, Reference<ucb::XCommandEnvironment> const & xCmdEnv)
+    Reference<ucb::XCommandEnvironment> const & xCmdEnv)
 {
     OUString sDisable;
     ::rtl::Bootstrap::get( OUSTR( "DISABLE_EXTENSION_SYNCHRONIZATION" ), sDisable, OUString() );
@@ -557,8 +557,7 @@ void syncRepositories(
     //synchronize shared before bundled otherewise there are
     //more revoke and registration calls.
     sal_Bool bModified = false;
-    if (force
-        || needToSyncRepostitory(OUString(RTL_CONSTASCII_USTRINGPARAM("shared")))
+    if (needToSyncRepostitory(OUString(RTL_CONSTASCII_USTRINGPARAM("shared")))
         || needToSyncRepostitory(OUString(RTL_CONSTASCII_USTRINGPARAM("bundled"))))
     {
         xExtensionManager =
@@ -568,7 +567,7 @@ void syncRepositories(
         if (xExtensionManager.is())
         {
             bModified = xExtensionManager->synchronize(
-                force, Reference<task::XAbortChannel>(), xCmdEnv);
+                Reference<task::XAbortChannel>(), xCmdEnv);
         }
     }
 
diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
index 205e6ef..2bd4d1b 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
@@ -432,7 +432,7 @@ extern "C" DESKTOP_DLLPUBLIC int unopkg_main()
         if (!subcmd_gui && ! subCommand.equals(OUSTR("reinstall"))
             && ! subCommand.equals(OUSTR("sync"))
             && ! dp_misc::office_is_running())
-            dp_misc::syncRepositories(false, xCmdEnv);
+            dp_misc::syncRepositories(xCmdEnv);
 
         if ( subcmd_add || subCommand == "remove" )
         {
diff --git a/offapi/com/sun/star/deployment/XExtensionManager.idl b/offapi/com/sun/star/deployment/XExtensionManager.idl
index 3809d90..7744ea6 100644
--- a/offapi/com/sun/star/deployment/XExtensionManager.idl
+++ b/offapi/com/sun/star/deployment/XExtensionManager.idl
@@ -285,19 +285,11 @@ interface XExtensionManager
        The active extensions are determined. That is, shared or bundled extensions
        are not necessaryly registered (<member>XPackage::registerPackage</member>).
 
-       @param forceBundled
-              whether to reinstall all bundled extensions even if their versions
-              have not changed (which might be necessary when an upgraded
-              installation outdates references to any share/prereg/bundled/
-              data; this parameter can go again once no exisiting
-              UserInstallation's user/extensions/bundled/ data can contain any
-              $BUNDLED_EXTENSIONS_PREREG references any longer)
        @return
               If true - then at least one extension was removed or added. Otherwise
               nothing was changed.
     */
     boolean synchronize(
-        [in] boolean forceBundled,
         [in] com::sun::star::task::XAbortChannel xAbortChannel,
         [in] com::sun::star::ucb::XCommandEnvironment xCmdEnv )
         raises (DeploymentException,
diff --git a/offapi/com/sun/star/deployment/XPackageManager.idl b/offapi/com/sun/star/deployment/XPackageManager.idl
index 842efdf..65cb24a 100644
--- a/offapi/com/sun/star/deployment/XPackageManager.idl
+++ b/offapi/com/sun/star/deployment/XPackageManager.idl
@@ -259,10 +259,6 @@ interface XPackageManager
        Added extensions will be added to the database and removed extensions
        will be removed from the database.
 
-       @param force
-            whether to reinstall all extensions even if their versions have not
-            changed (see forceBundled parameter of
-            XExtensionManager.synchronize)
        @param xAddedExtension
             new extensions which may need to be registered.
 
@@ -272,9 +268,7 @@ interface XPackageManager
             If true - then at least one extension was removed or added. Otherwise
             nothing was changed.
     */
-    boolean synchronize(
-                     [in] boolean force,
-                     [in] com::sun::star::task::XAbortChannel xAbortChannel,
+    boolean synchronize([in] com::sun::star::task::XAbortChannel xAbortChannel,
                      [in] com::sun::star::ucb::XCommandEnvironment xCmdEnv )
         raises (DeploymentException,
                 com::sun::star::ucb::CommandFailedException,
commit 6c6358a6822d3562b9b8c7668a7d60d6c644dfe8
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Aug 9 11:57:21 2012 +0200

    Related fdo#53006: Do not instantiate service manager too early
    
    ... in soffice_main calling GetCommandLineArgs, before Desktop::Init takes care
    of synchronization of the per-user bundled/shared extension information (as the
    latter potentially modifies data that the service manager consumes upon
    instantiation; this e.g. lead to bundled extensions not working during first
    start after an upgrade).
    
    The only reason GetCommandLineArgs needed ensureProcessServiceFactory appears to
    be the ExternalUriReferenceTranslator.  So defer its usage to when the relevant
    cmd line args are actually processed (which, luckily, does not yet happen in
    soffice_main's usage of GetCommandLineArgs).
    
    Change-Id: I6ebbf0a4ad1c6f64c8fbbe2b0d7628fa42a1afb6

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 84a7516..c3152ee 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -283,7 +283,6 @@ namespace
 
 CommandLineArgs& Desktop::GetCommandLineArgs()
 {
-    ensureProcessServiceFactory();
     return theCommandLineArgs::get();
 }
 
diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx
index c67db8c..f836028 100644
--- a/desktop/source/app/cmdlineargs.cxx
+++ b/desktop/source/app/cmdlineargs.cxx
@@ -32,9 +32,7 @@
 #include <rtl/ustring.hxx>
 #include "rtl/process.h"
 #include <comphelper/processfactory.hxx>
-#include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp>
 #include "tools/getprocessworkingdir.hxx"
 
 #include <svl/documentlockfile.hxx>
@@ -52,6 +50,26 @@ namespace desktop
 
 namespace {
 
+OUString translateExternalUris(OUString const & input) {
+    OUString t(
+        com::sun::star::uri::ExternalUriReferenceTranslator::create(
+            comphelper::getProcessComponentContext())->
+        translateToInternal(input));
+    return t.isEmpty() ? input : t;
+}
+
+std::vector< OUString > translateExternalUris(
+    std::vector< OUString > const & input)
+{
+    std::vector< OUString > t;
+    for (std::vector< OUString >::const_iterator i(input.begin());
+         i != input.end(); ++i)
+    {
+        t.push_back(translateExternalUris(*i));
+    }
+    return t;
+}
+
 class ExtCommandLineSupplier: public CommandLineArgs::Supplier {
 public:
     explicit ExtCommandLineSupplier():
@@ -117,14 +135,6 @@ CommandLineArgs::CommandLineArgs( Supplier& supplier )
 void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
 {
     m_cwdUrl = supplier.getCwdUrl();
-    Reference<XMultiServiceFactory> xMS(comphelper::getProcessServiceFactory(), UNO_QUERY);
-    OSL_ENSURE(xMS.is(), "CommandLineArgs: no ProcessServiceFactory.");
-
-    Reference< XExternalUriReferenceTranslator > xTranslator(
-        xMS->createInstance(
-        OUString(
-        "com.sun.star.uri.ExternalUriReferenceTranslator")),
-        UNO_QUERY);
 
     // parse command line arguments
     bool bOpenEvent(true);
@@ -150,14 +160,6 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
         {
             break;
         }
-        // convert file URLs to internal form
-        if (aArg.indexOfAsciiL(RTL_CONSTASCII_STRINGPARAM("file:"))==0 &&
-            xTranslator.is())
-        {
-            OUString tmp(xTranslator->translateToInternal(aArg));
-            if (!tmp.isEmpty())
-                aArg = tmp;
-        }
 
         if ( !aArg.isEmpty() )
         {
@@ -785,39 +787,39 @@ std::vector< rtl::OUString > const & CommandLineArgs::GetUnaccept() const
     return m_unaccept;
 }
 
-std::vector< rtl::OUString > const & CommandLineArgs::GetOpenList() const
+std::vector< rtl::OUString > CommandLineArgs::GetOpenList() const
 {
-    return m_openlist;
+    return translateExternalUris(m_openlist);
 }
 
-std::vector< rtl::OUString > const & CommandLineArgs::GetViewList() const
+std::vector< rtl::OUString > CommandLineArgs::GetViewList() const
 {
-    return m_viewlist;
+    return translateExternalUris(m_viewlist);
 }
 
-std::vector< rtl::OUString > const & CommandLineArgs::GetStartList() const
+std::vector< rtl::OUString > CommandLineArgs::GetStartList() const
 {
-    return m_startlist;
+    return translateExternalUris(m_startlist);
 }
 
-std::vector< rtl::OUString > const & CommandLineArgs::GetForceOpenList() const
+std::vector< rtl::OUString > CommandLineArgs::GetForceOpenList() const
 {
-    return m_forceopenlist;
+    return translateExternalUris(m_forceopenlist);
 }
 
-std::vector< rtl::OUString > const & CommandLineArgs::GetForceNewList() const
+std::vector< rtl::OUString > CommandLineArgs::GetForceNewList() const
 {
-    return m_forcenewlist;
+    return translateExternalUris(m_forcenewlist);
 }
 
-std::vector< rtl::OUString > const & CommandLineArgs::GetPrintList() const
+std::vector< rtl::OUString > CommandLineArgs::GetPrintList() const
 {
-    return m_printlist;
+    return translateExternalUris(m_printlist);
 }
 
-std::vector< rtl::OUString > const & CommandLineArgs::GetPrintToList() const
+std::vector< rtl::OUString > CommandLineArgs::GetPrintToList() const
 {
-    return m_printtolist;
+    return translateExternalUris(m_printtolist);
 }
 
 rtl::OUString CommandLineArgs::GetPrinterName() const
@@ -835,9 +837,9 @@ std::vector< rtl::OUString > const & CommandLineArgs::GetInFilter() const
     return m_infilter;
 }
 
-std::vector< rtl::OUString > const & CommandLineArgs::GetConversionList() const
+std::vector< rtl::OUString > CommandLineArgs::GetConversionList() const
 {
-    return m_conversionlist;
+    return translateExternalUris(m_conversionlist);
 }
 
 rtl::OUString CommandLineArgs::GetConversionParams() const
@@ -846,7 +848,7 @@ rtl::OUString CommandLineArgs::GetConversionParams() const
 }
 rtl::OUString CommandLineArgs::GetConversionOut() const
 {
-    return m_conversionout;
+    return translateExternalUris(m_conversionout);
 }
 
 bool CommandLineArgs::IsEmpty() const
diff --git a/desktop/source/app/cmdlineargs.hxx b/desktop/source/app/cmdlineargs.hxx
index 4cd19d9..c6286d2 100644
--- a/desktop/source/app/cmdlineargs.hxx
+++ b/desktop/source/app/cmdlineargs.hxx
@@ -100,17 +100,17 @@ class CommandLineArgs: private boost::noncopyable
         bool                    HasSplashPipe() const;
         std::vector< rtl::OUString > const & GetAccept() const;
         std::vector< rtl::OUString > const & GetUnaccept() const;
-        std::vector< rtl::OUString > const & GetOpenList() const;
-        std::vector< rtl::OUString > const & GetViewList() const;
-        std::vector< rtl::OUString > const & GetStartList() const;
-        std::vector< rtl::OUString > const & GetForceOpenList() const;
-        std::vector< rtl::OUString > const & GetForceNewList() const;
-        std::vector< rtl::OUString > const & GetPrintList() const;
-        std::vector< rtl::OUString > const & GetPrintToList() const;
+        std::vector< rtl::OUString > GetOpenList() const;
+        std::vector< rtl::OUString > GetViewList() const;
+        std::vector< rtl::OUString > GetStartList() const;
+        std::vector< rtl::OUString > GetForceOpenList() const;
+        std::vector< rtl::OUString > GetForceNewList() const;
+        std::vector< rtl::OUString > GetPrintList() const;
+        std::vector< rtl::OUString > GetPrintToList() const;
         rtl::OUString       GetPrinterName() const;
         rtl::OUString       GetLanguage() const;
         std::vector< rtl::OUString > const & GetInFilter() const;
-        std::vector< rtl::OUString > const & GetConversionList() const;
+        std::vector< rtl::OUString > GetConversionList() const;
         rtl::OUString       GetConversionParams() const;
         rtl::OUString       GetConversionOut() const;
 
@@ -160,17 +160,17 @@ class CommandLineArgs: private boost::noncopyable
         bool m_bDocumentArgs; // A document creation/open/load arg is used
         std::vector< rtl::OUString > m_accept;
         std::vector< rtl::OUString > m_unaccept;
-        std::vector< rtl::OUString > m_openlist;
-        std::vector< rtl::OUString > m_viewlist;
-        std::vector< rtl::OUString > m_startlist;
-        std::vector< rtl::OUString > m_forceopenlist;
-        std::vector< rtl::OUString > m_forcenewlist;
-        std::vector< rtl::OUString > m_printlist;
-        std::vector< rtl::OUString > m_printtolist;
+        std::vector< rtl::OUString > m_openlist; // contains external URIs
+        std::vector< rtl::OUString > m_viewlist; // contains external URIs
+        std::vector< rtl::OUString > m_startlist; // contains external URIs
+        std::vector< rtl::OUString > m_forceopenlist; // contains external URIs
+        std::vector< rtl::OUString > m_forcenewlist; // contains external URIs
+        std::vector< rtl::OUString > m_printlist; // contains external URIs
+        std::vector< rtl::OUString > m_printtolist; // contains external URIs
         rtl::OUString m_printername;
-        std::vector< rtl::OUString > m_conversionlist;
+        std::vector< rtl::OUString > m_conversionlist; // contains external URIs
         rtl::OUString m_conversionparams;
-        rtl::OUString m_conversionout;
+        rtl::OUString m_conversionout; // contains external URIs
         std::vector< rtl::OUString > m_infilter;
         rtl::OUString m_language;
 };


More information about the Libreoffice-commits mailing list