summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2016-09-15 12:27:28 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2016-10-11 13:56:22 +0200
commit9fa4eff9be5e440099517a522a83e20debaf2955 (patch)
tree6ac23f08cb1902fb021bf470144e213df0b4b886 /desktop
parented646dc595b2ee5248b0994a2b44a7a5a7bfbbd5 (diff)
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')
-rw-r--r--desktop/source/app/app.cxx99
-rw-r--r--desktop/uiconfig/ui/querytrytorestoreconfigurationdialog.ui37
2 files changed, 130 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 )
{
diff --git a/desktop/uiconfig/ui/querytrytorestoreconfigurationdialog.ui b/desktop/uiconfig/ui/querytrytorestoreconfigurationdialog.ui
new file mode 100644
index 000000000000..4c332d1889d6
--- /dev/null
+++ b/desktop/uiconfig/ui/querytrytorestoreconfigurationdialog.ui
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkMessageDialog" id="QueryTryToRestoreConfigurationDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes">LibreOffice Startup: General Configuration Error</property>
+ <property name="resizable">False</property>
+ <property name="type_hint">dialog</property>
+ <property name="skip_taskbar_hint">True</property>
+ <property name="message_type">question</property>
+ <property name="buttons">yes-no</property>
+ <property name="text" translatable="yes">A general error occurred during startup while accessing the central configuration.</property>
+ <property name="secondary_text" translatable="yes">A Backup of your configuration was detected. Restoring the configuration might solve this problem, but is not guaranteed to work. A restart of the Program is needed.
+
+Do you want to restore the configuration?</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="messagedialog-vbox5">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="messagedialog-action_area5">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>