[Libreoffice-commits] .: Branch 'libreoffice-3-6' - 3 commits - desktop/inc desktop/source

Petr Mladek pmladek at kemper.freedesktop.org
Fri Aug 10 08:05:48 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     |    2 
 desktop/source/deployment/misc/dp_misc.cxx                    |    5 
 desktop/source/deployment/registry/component/dp_component.cxx |   97 +-----
 desktop/source/pkgchk/unopkg/unopkg_app.cxx                   |    2 
 11 files changed, 235 insertions(+), 161 deletions(-)

New commits:
commit fd75125424b3dda0e77076d5b1709224ec22a345
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
    
    Signed-off-by: Petr Mladek <pmladek at suse.cz>

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index ea107e8..25b6352 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -130,14 +130,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 991577f..6efc9f4 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -147,6 +147,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 >());
+    }
+    rtl::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()
@@ -625,6 +764,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
@@ -1616,14 +1757,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 e9ad4a2..29fd140 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 e5a16b7..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));
 
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index 9ed579f..b225db6 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -591,7 +591,7 @@ void TRACE(::rtl::OString 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() );
@@ -602,8 +602,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 =
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" )
         {
commit 006e90e29c6ca768e3a5d8d2a558a63b04817c4b
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
    
    Signed-off-by: Petr Mladek <pmladek at suse.cz>

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 263ca3f..991577f 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -278,7 +278,6 @@ namespace
 
 CommandLineArgs& Desktop::GetCommandLineArgs()
 {
-    ensureProcessServiceFactory();
     return theCommandLineArgs::get();
 }
 
diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx
index af7ee26..473dfd6 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;
 };
commit 40c80e6a637e80c220f3e39b855cd975c3e94799
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Aug 2 15:08:52 2012 +0200

    Check for ComponentPackageImpl::isRegistered_ in the current rdb
    
    ...not the old one that does not contain the changes from the current session.
    Otherwise, actively registered components in bundled extensions would not
    necessarily be re-registered upon start up.  Any old instance would be removed,
    but the new instance would not be registered as isRegistered_ would still
    return true.
    
    To me it looks like 7a400caaa6946399ea31614d056d435350f42dc1 "jl145: #i99257#
    Extension Manager prevents running of multiple instances which acces the same
    shared data" erroneously introduced a call to getRDB_RO instead of getRDB into
    isRegistered_.  That (only) call of getRDB_RO gone allowed some clean up, incl.
    renaming remaining variables from ..._RO to ..._orig.
    
    Change-Id: I7eccac699e6fa5799f77b038b15d62e0a9c1ad17
    
    Signed-off-by: Petr Mladek <pmladek at suse.cz>

diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx
index fa871d5..0714842 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -155,10 +155,6 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
 
         const Reference<registry::XSimpleRegistry> getRDB() const;
 
-        //Provides the read-only registry (e.g. not the one based on the duplicated
-        //rdb files
-        const Reference<registry::XSimpleRegistry> getRDB_RO() const;
-
     public:
         ComponentPackageImpl(
             ::rtl::Reference<PackageRegistryBackend> const & myBackend,
@@ -305,9 +301,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
     OUString m_commonRDB;
     OUString m_nativeRDB;
 
-    //URLs of the read-only rdbs (e.g. not the ones of the duplicated files)
-    OUString m_commonRDB_RO;
-    OUString m_nativeRDB_RO;
+    //URLs of the original rdbs (before any switching):
+    OUString m_commonRDB_orig;
+    OUString m_nativeRDB_orig;
 
     std::auto_ptr<ComponentBackendDb> m_backendDb;
 
@@ -315,18 +311,9 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
     ComponentBackendDb::Data readDataFromDb(OUString const & url);
     void revokeEntryFromDb(OUString const & url);
 
-
-    //These rdbs are for writing new service entries. The rdb files are copies
-    //which are created when services are added or removed.
     Reference<registry::XSimpleRegistry> m_xCommonRDB;
     Reference<registry::XSimpleRegistry> m_xNativeRDB;
 
-    //These rdbs are created on the read-only rdbs which are already used
-    //by UNO since the startup of the current session.
-    Reference<registry::XSimpleRegistry> m_xCommonRDB_RO;
-    Reference<registry::XSimpleRegistry> m_xNativeRDB_RO;
-
-
     void unorc_verify_init( Reference<XCommandEnvironment> const & xCmdEnv );
     void unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv );
 
@@ -359,9 +346,6 @@ public:
 
     //Will be called from ComponentPackageImpl
     void initServiceRdbFiles();
-
-    //Creates the READ ONLY registries (m_xCommonRDB_RO,m_xNativeRDB_RO)
-    void initServiceRdbFiles_RO();
 };
 
 //______________________________________________________________________________
@@ -402,18 +386,6 @@ BackendImpl::ComponentPackageImpl::getRDB() const
         return that->m_xCommonRDB;
 }
 
-//Returns the read only RDB.
-const Reference<registry::XSimpleRegistry>
-BackendImpl::ComponentPackageImpl::getRDB_RO() const
-{
-    BackendImpl * that = getMyBackend();
-
-    if ( m_loader == "com.sun.star.loader.SharedLibrary" )
-        return that->m_xNativeRDB_RO;
-    else
-        return that->m_xCommonRDB_RO;
-}
-
 BackendImpl * BackendImpl::ComponentPackageImpl::getMyBackend() const
 {
     BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get());
@@ -479,13 +451,13 @@ void BackendImpl::initServiceRdbFiles()
     ::ucbhelper::Content cacheDir( getCachePath(), xCmdEnv );
     ::ucbhelper::Content oldRDB;
     // switch common rdb:
-    if (!m_commonRDB_RO.isEmpty())
+    if (!m_commonRDB_orig.isEmpty())
     {
         create_ucb_content(
-            &oldRDB, makeURL( getCachePath(), m_commonRDB_RO),
+            &oldRDB, makeURL( getCachePath(), m_commonRDB_orig),
             xCmdEnv, false /* no throw */ );
     }
-    m_commonRDB = m_commonRDB_RO == "common.rdb" ? OUSTR("common_.rdb") : OUSTR("common.rdb");
+    m_commonRDB = m_commonRDB_orig == "common.rdb" ? OUSTR("common_.rdb") : OUSTR("common.rdb");
     if (oldRDB.get().is())
     {
         if (! cacheDir.transferContent(
@@ -499,15 +471,15 @@ void BackendImpl::initServiceRdbFiles()
         oldRDB = ::ucbhelper::Content();
     }
     // switch native rdb:
-    if (!m_nativeRDB_RO.isEmpty())
+    if (!m_nativeRDB_orig.isEmpty())
     {
         create_ucb_content(
-            &oldRDB, makeURL(getCachePath(), m_nativeRDB_RO),
+            &oldRDB, makeURL(getCachePath(), m_nativeRDB_orig),
             xCmdEnv, false /* no throw */ );
     }
     const OUString plt_rdb( getPlatformString() + OUSTR(".rdb") );
     const OUString plt_rdb_( getPlatformString() + OUSTR("_.rdb") );
-    m_nativeRDB = m_nativeRDB_RO.equals( plt_rdb ) ? plt_rdb_ : plt_rdb;
+    m_nativeRDB = m_nativeRDB_orig.equals( plt_rdb ) ? plt_rdb_ : plt_rdb;
     if (oldRDB.get().is())
     {
         if (! cacheDir.transferContent(
@@ -545,38 +517,6 @@ void BackendImpl::initServiceRdbFiles()
     }
 }
 
-void BackendImpl::initServiceRdbFiles_RO()
-{
-    const Reference<XCommandEnvironment> xCmdEnv;
-
-    // common rdb for java, native rdb for shared lib components
-    if (!m_commonRDB_RO.isEmpty())
-    {
-        m_xCommonRDB_RO.set(
-            m_xComponentContext->getServiceManager()
-            ->createInstanceWithContext(
-            OUSTR("com.sun.star.registry.SimpleRegistry"),
-            m_xComponentContext), UNO_QUERY_THROW);
-        m_xCommonRDB_RO->open(
-            makeURL(expandUnoRcUrl(getCachePath()), m_commonRDB_RO),
-            sal_True, //read-only
-            sal_True); // create data source if necessary
-    }
-    if (!m_nativeRDB_RO.isEmpty())
-    {
-        m_xNativeRDB_RO.set(
-            m_xComponentContext->getServiceManager()
-            ->createInstanceWithContext(
-            OUSTR("com.sun.star.registry.SimpleRegistry"),
-            m_xComponentContext), UNO_QUERY_THROW);
-        m_xNativeRDB_RO->open(
-            makeURL(expandUnoRcUrl(getCachePath()), m_nativeRDB_RO),
-            sal_True, //read-only
-            sal_True); // create data source if necessary
-    }
-}
-
-//______________________________________________________________________________
 BackendImpl::BackendImpl(
     Sequence<Any> const & args,
     Reference<XComponentContext> const & xComponentContext )
@@ -657,12 +597,7 @@ BackendImpl::BackendImpl(
     }
     else
     {
-        //do this before initServiceRdbFiles_RO, because it determines
-        //m_commonRDB and m_nativeRDB
         unorc_verify_init( xCmdEnv );
-
-        initServiceRdbFiles_RO();
-
         OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml"));
         m_backendDb.reset(
             new ComponentBackendDb(getComponentContext(), dbFile));
@@ -936,7 +871,7 @@ void BackendImpl::unorc_verify_init(
                             token.matchAsciiL(
                                 RTL_CONSTASCII_STRINGPARAM("?$ORIGIN/")))
                         {
-                            m_commonRDB_RO = token.copy(
+                            m_commonRDB_orig = token.copy(
                                 RTL_CONSTASCII_LENGTH("?$ORIGIN/"));
                             state = 2;
                         }
@@ -964,7 +899,7 @@ void BackendImpl::unorc_verify_init(
                     xCmdEnv, false /* no throw */ )) {
                 if (readLine( &line, OUSTR("UNO_SERVICES="), ucb_content,
                               RTL_TEXTENCODING_UTF8 )) {
-                    m_nativeRDB_RO = line.copy(
+                    m_nativeRDB_orig = line.copy(
                         sizeof ("UNO_SERVICES=?$ORIGIN/") - 1 );
                 }
             }
@@ -1025,10 +960,10 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv )
     }
 
     // If we duplicated the common or native rdb then we must use those urls
-    //otherwise we use those of the original files. That is, m_commonRDB_RO and
-    //m_nativeRDB_RO;
-    OUString sCommonRDB(m_commonRDB.isEmpty() ? m_commonRDB_RO : m_commonRDB );
-    OUString sNativeRDB(m_nativeRDB.isEmpty() ? m_nativeRDB_RO : m_nativeRDB );
+    //otherwise we use those of the original files. That is, m_commonRDB_orig
+    //and m_nativeRDB_orig;
+    OUString sCommonRDB(m_commonRDB.isEmpty() ? m_commonRDB_orig : m_commonRDB );
+    OUString sNativeRDB(m_nativeRDB.isEmpty() ? m_nativeRDB_orig : m_nativeRDB );
 
     if (!sCommonRDB.isEmpty() || !sNativeRDB.isEmpty() ||
         !m_components.empty())
@@ -1443,7 +1378,7 @@ BackendImpl::ComponentPackageImpl::isRegistered_(
     {
         m_registered = REG_NOT_REGISTERED;
         bool bAmbiguousComponentName = false;
-        const Reference<registry::XSimpleRegistry> xRDB( getRDB_RO() );
+        const Reference<registry::XSimpleRegistry> xRDB( getRDB() );
         if (xRDB.is())
         {
             // lookup rdb for location URL:


More information about the Libreoffice-commits mailing list