diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2016-09-15 12:27:28 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2016-10-11 13:56:22 +0200 |
commit | 9fa4eff9be5e440099517a522a83e20debaf2955 (patch) | |
tree | 6ac23f08cb1902fb021bf470144e213df0b4b886 /desktop/source/app | |
parent | profilesafe: Initial creation of BackupFileHelper (diff) | |
download | core-9fa4eff9be5e440099517a522a83e20debaf2955.tar.gz core-9fa4eff9be5e440099517a522a83e20debaf2955.zip |
profilesafe: Enhancements to BackupFileHelper
Added helper class to allow easy creation/deployment
of backups of a file. It works like a 'stack' of backups,
supports easy add/remove/delete of last entry (LIFO).
Added some work top allow opening dialogs in DeInit
under linux.
Change-Id: Idacec97ec2f097af9bd22a8a67b410c7677d17f1
Diffstat (limited to 'desktop/source/app')
-rw-r--r-- | desktop/source/app/app.cxx | 99 |
1 files changed, 93 insertions, 6 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index bb836d235b6d..4c52d79183cd 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -81,6 +81,7 @@ #include <comphelper/configuration.hxx> #include <comphelper/fileurl.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/backupfilehelper.hxx> #include <unotools/bootstrap.hxx> #include <unotools/configmgr.hxx> #include <unotools/moduleoptions.hxx> @@ -567,6 +568,14 @@ void Desktop::Init() { SetBootstrapError( BE_OFFICECONFIG_BROKEN, e.Message ); } + + static bool bTryHardOfficeconfigBroken(false); + + if (bTryHardOfficeconfigBroken) + { + SAL_WARN("configmgr", "################# Desktop::Init() #####################"); + SetBootstrapError(BE_OFFICECONFIG_BROKEN, OUString()); + } } if ( true ) @@ -938,15 +947,93 @@ void Desktop::HandleBootstrapErrors( } else if ( aBootstrapError == BE_OFFICECONFIG_BROKEN ) { - OUString msg( - GetMsgString( + // test restore of registrymodifications + static bool bFeatureSecureUserConfig(true); + static sal_uInt16 nNumCopies(5); + bool bFireOriginalError(true); + + if (bFeatureSecureUserConfig) + { + // try to asccess user layer configuration file + OUString conf("${CONFIGURATION_LAYERS}"); + rtl::Bootstrap::expandMacros(conf); + const OUString aTokenUser("user:"); + sal_Int32 nStart(conf.indexOf(aTokenUser)); + OUString aUser; + + if (-1 != nStart) + { + nStart += aTokenUser.getLength(); + sal_Int32 nEnd(conf.indexOf(' ', nStart)); + + if (-1 == nEnd) + { + nEnd = conf.getLength(); + } + + aUser = conf.copy(nStart, nEnd - nStart); + aUser.startsWith("!", &aUser); + } + + if (!aUser.isEmpty()) + { + comphelper::BackupFileHelper aBackupFileHelper(aUser, nNumCopies); + + if (aBackupFileHelper.isPopPossible()) + { + // for linux (and probably others?) we need to instantiate XDesktop2 + // to be able to open a *.ui-file based dialog, so do this here locally. + // does no harm on win, so better always do this (in error case only anyways) + Reference< XComponentContext > xLocalContext = ::comphelper::getProcessComponentContext(); + Reference< XDesktop2 > xDesktop = css::frame::Desktop::create(xLocalContext); + + ScopedVclPtrInstance< MessageDialog > aQueryShouldRestore( + Application::GetDefDialogParent(), + "QueryTryToRestoreConfigurationDialog", + "desktop/ui/querytrytorestoreconfigurationdialog.ui"); + + if (aQueryShouldRestore.get()) + { + if (!aErrorMessage.isEmpty()) + { + OUString aPrimaryText(aQueryShouldRestore->get_primary_text()); + + aPrimaryText += "\n(\"" + aErrorMessage + "\")"; + aQueryShouldRestore->set_primary_text(aPrimaryText); + } + + if (RET_YES == aQueryShouldRestore->Execute()) + { + aBackupFileHelper.tryPop(); + bFireOriginalError = false; + } + } + } + } + } + + // set flag at BackupFileHelper to be able to know if _exit was called and + // actions are executed after this + comphelper::BackupFileHelper::setExitWasCalled(); + + if (bFireOriginalError) + { + OUString msg( + GetMsgString( STR_CONFIG_ERR_ACCESS_GENERAL, ("A general error occurred while accessing your central" - " configuration."))); - if (!aErrorMessage.isEmpty()) { - msg += "\n(\"" + aErrorMessage + "\")"; + " configuration."))); + if (!aErrorMessage.isEmpty()) { + msg += "\n(\"" + aErrorMessage + "\")"; + } + FatalError(MakeStartupErrorMessage(msg)); + } + else + { + // Already presented all information to the user. + // just do what FatalError does at it's end + _exit(EXITHELPER_FATAL_ERROR); } - FatalError(MakeStartupErrorMessage(msg)); } else if ( aBootstrapError == BE_USERINSTALL_FAILED ) { |