[PATCH] attempt to migrate old config from XDG path and home dir
Petr Mladek
pmladek at suse.cz
Tue Dec 6 11:58:56 PST 2011
IMPORTANT: it does not work because it do the migration in the second run;
it first check the newly created location and migrates in into itself
we might need something similar to fix problem with set XDG path
---
desktop/source/migration/migration.cxx | 58 ++++++++++------------
desktop/source/migration/migration_impl.hxx | 1 +
officecfg/registry/data/org/openoffice/Setup.xcu | 2 +-
3 files changed, 29 insertions(+), 32 deletions(-)
diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx
index 7520eb8..639fea8 100644
--- a/desktop/source/migration/migration.cxx
+++ b/desktop/source/migration/migration.cxx
@@ -533,6 +533,23 @@ static FileBase::RC _checkAndCreateDirectory(INetURLObject& dirURL)
return result;
}
+void MigrationImpl::checkConfiguration( install_info &aInfo, const ::rtl::OUString aUserInst, const ::rtl::OUString aVersion)
+{
+ fprintf(stderr, "test path: %s\n", ::rtl::OUStringToOString (aUserInst, RTL_TEXTENCODING_UTF8).pData->buffer);
+ try
+ {
+ INetURLObject aObj(aUserInst);
+ ::ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () );
+ aCnt.isDocument();
+ aInfo.userdata = aObj.GetMainURL( INetURLObject::NO_DECODE );
+ aInfo.productname = aVersion;
+ }
+ catch (const uno::Exception&)
+ {
+ }
+}
+
+
install_info MigrationImpl::findInstallation(const strings_v& rVersions)
{
install_info aInfo;
@@ -554,40 +571,19 @@ install_info MigrationImpl::findInstallation(const strings_v& rVersions)
{
::rtl::OUString aUserInst;
osl::Security().getConfigDir( aUserInst );
+ aUserInst += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + aProfileName;
+ checkConfiguration( aInfo, aUserInst, aVersion);
+
#if defined UNX && ! defined MACOSX
- const char* pXDGCfgHome = getenv("XDG_CONFIG_HOME");
- // cater for XDG_CONFIG_HOME change
- // If XDG_CONFIG_HOME is set then we;
- // assume the user knows what they are doing ( room for improvement here, we could
- // of course search the default config dir etc. also - but this is more complex,
- // we would need to weigh results from the current config dir against matches in
- // the 'old' config dir etc. ) - currently we just use the returned config dir.
- // If XDG_CONFIG_HOME is NOT set;
- // assume then we should now using the default $HOME/,config config location for
- // our user profiles, however *all* previous libreoffice and openoffice.org
- // configurations will be in the 'old' config directory and that's where we need
- // to search - we convert the returned config dir to the 'old' dir
- if ( !pXDGCfgHome && aUserInst.endsWithAsciiL( XDG_CONFIG_PART, sizeof( XDG_CONFIG_PART ) - 1 ) )
- aUserInst = aUserInst.copy( 0, aUserInst.getLength() - sizeof( XDG_CONFIG_PART ) + 2 ); // remove trailing '.config' ( but leave the terminating '/' )
-#endif
- if ( aUserInst.getLength() && aUserInst[ aUserInst.getLength()-1 ] != '/' )
- aUserInst += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
-#if defined UNX && ! defined MACOSX
- // tribute to whoever had the "great" idea to use different names on Windows and Unix
- aUserInst += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("."));
-#endif
- aUserInst += aProfileName;
- try
- {
- INetURLObject aObj(aUserInst);
- ::ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () );
- aCnt.isDocument();
- aInfo.userdata = aObj.GetMainURL( INetURLObject::NO_DECODE );
- aInfo.productname = aVersion;
- }
- catch (const uno::Exception&)
+ // we switched to XDG_CONFIG on Linux; try older configuration paths in $HOME
+ if (aInfo.userdata.isEmpty())
{
+ osl::Security().getHomeDir( aUserInst );
+ // the old paths were directly in $HOME and thus prefixed by .
+ aUserInst += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/.")) + aProfileName;
+ checkConfiguration( aInfo, aUserInst, aVersion);
}
+#endif
}
++i_ver;
}
diff --git a/desktop/source/migration/migration_impl.hxx b/desktop/source/migration/migration_impl.hxx
index 2d079ae..9a6e483 100644
--- a/desktop/source/migration/migration_impl.hxx
+++ b/desktop/source/migration/migration_impl.hxx
@@ -210,6 +210,7 @@ private:
bool alreadyMigrated();
migrations_vr readMigrationSteps(const ::rtl::OUString& rMigrationName);
sal_Int32 findPreferedMigrationProcess(const migrations_available&);
+ void checkConfiguration( install_info &aInfo, const ::rtl::OUString aUserInst, const ::rtl::OUString aVersion);
install_info findInstallation(const strings_v& rVersions);
strings_vr compileFileList();
--=-550zuZMwk6Unzj7v1dNk--
More information about the LibreOffice
mailing list