Kaydet (Commit) a1b7231a authored tarafından Armin Le Grand's avatar Armin Le Grand

profilesafe: Adapted to UI

Adaptions to UI, added more modes what the user
can do in SafeMode. Adapted locations to write
pack information and added places where to enter
SafeMode. Implemented basically all five
possible user choices

Change-Id: Ic5324a8f77ab434309e840949c3803e65a75c538
Reviewed-on: https://gerrit.libreoffice.org/29785Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarArmin Le Grand <Armin.Le.Grand@cib.de>
üst 876fcb54
......@@ -951,64 +951,23 @@ void Desktop::HandleBootstrapErrors(
}
else if ( aBootstrapError == BE_OFFICECONFIG_BROKEN )
{
bool bFireOriginalError(true);
comphelper::BackupFileHelper aBackupFileHelper;
// crerate BackupFileHelper and check if active and if pop is possible
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. This method we are in will not return,
// but end up in a _exit() call
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 + "\")";
}
FatalError(MakeStartupErrorMessage(msg));
}
else
{
// Already presented all information to the user.
// just do what FatalError does at it's end
_exit(EXITHELPER_FATAL_ERROR);
// enter safe mode, too
sfx2::SafeMode::putFlag();
OUString msg(
GetMsgString(
STR_CONFIG_ERR_ACCESS_GENERAL,
("A general error occurred while accessing your central"
" configuration. SafeMode is initiated.")));
if (!aErrorMessage.isEmpty()) {
msg += "\n(\"" + aErrorMessage + "\")";
}
FatalError(MakeStartupErrorMessage(msg));
}
else if ( aBootstrapError == BE_USERINSTALL_FAILED )
{
......@@ -1824,6 +1783,7 @@ int Desktop::doShutdown()
comphelper::BackupFileHelper aBackupFileHelper;
aBackupFileHelper.tryPush();
aBackupFileHelper.tryPushExtensionInfo();
}
// The acceptors in the AcceptorMap must be released (in DeregisterServices)
......
<?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>
......@@ -106,15 +106,21 @@ namespace comphelper
*
* @return bool
* returns true if a new backup was actually created
*
* tryPushExtensionInfo is the specialized version for ExtensionInfo
*/
bool tryPush();
bool tryPushExtensionInfo();
/** finds out if a restore is possible
*
* @return bool
* returns true if a restore to an older backup is possible
*
* isPopPossibleExtensionInfo is the specialized version for ExtensionInfo
*/
bool isPopPossible();
bool isPopPossibleExtensionInfo();
/** tries to execute a restore. Will overwrite the base file
* in that case and take one version off the 'stack' of copies.
......@@ -123,8 +129,25 @@ namespace comphelper
*
* @return bool
* returns true if a restore was actually created
*
* tryPopExtensionInfo is the specialized version for ExtensionInfo
*/
bool tryPop();
bool tryPopExtensionInfo();
/** tries to iterate the extensions and to disable all of them
*/
static bool isTryDisableAllExtensionsPossible();
static void tryDisableAllExtensions();
/** resets User-Customizations like Settings and UserInterface modifications
*/
bool isTryResetCustomizationsPossible();
void tryResetCustomizations();
/** resets the whole UserProfile
*/
void tryResetUserProfile();
private:
// internal helper methods
......
......@@ -108,7 +108,7 @@ $(call gb_CustomTarget_get_workdir,instsetoo_native/setup)/$(call gb_Helper_get_
# SecureUserConfig : boolean - switches securing on/off - default false
# SecureUserConfigCompress : boolean - defines if backup data will be compressed - default true
# SecureUserConfigNumCopies : integer - defines how many compressed copies of saved content will be kept - default 2
# SecureUserConfigMode: integer - defines what to secure, default is 0
# SecureUserConfigMode: integer - defines what to secure, default is 1
# 0 : only registrymodifications.xcu
# 1 : a selected amount of user-defined configs
# 2 : everything in the user config directory
......@@ -131,7 +131,7 @@ $(call gb_CustomTarget_get_workdir,instsetoo_native/setup)/$(call gb_Helper_get_
&& echo 'SecureUserConfig=true' \
&& echo 'SecureUserConfigCompress=true' \
&& echo 'SecureUserConfigNumCopies=2' \
&& echo 'SecureUserConfigMode=0' \
&& echo 'SecureUserConfigMode=1' \
&& echo 'SecureUserConfigExtensions=true' \
) > $@
......
......@@ -22,26 +22,63 @@
using namespace css;
SafeModeDialog::SafeModeDialog(vcl::Window* pParent):
Dialog(pParent, "SafeModeDialog", "svx/ui/safemodedialog.ui")
SafeModeDialog::SafeModeDialog(vcl::Window* pParent)
: Dialog(pParent, "SafeModeDialog", "svx/ui/safemodedialog.ui"),
mpBtnContinue(),
mpBtnQuit(),
mpBtnRestart(),
mpCBCheckProfilesafeConfig(),
mpCBCheckProfilesafeExtensions(),
mpCBDisableAllExtensions(),
mpCBResetCustomizations(),
mpCBResetWholeUserProfile(),
maBackupFileHelper()
{
get(mpBtnContinue, "btn_continue");
get(mpBtnQuit, "btn_quit");
get(mpBtnRestart, "btn_restart");
get(mpCBCustomizations, "check_customizations");
get(mpCBExtensions, "check_extensions");
get(mpCBFull, "check_full");
get(mpCBCheckProfilesafeConfig, "check_profilesafe_config");
get(mpCBCheckProfilesafeExtensions, "check_profilesafe_extensions");
get(mpCBDisableAllExtensions, "check_disable_all_extensions");
get(mpCBResetCustomizations, "check_reset_customizations");
get(mpCBResetWholeUserProfile, "check_reset_whole_userprofile");
mpBtnContinue->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl));
mpBtnQuit->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl));
mpBtnRestart->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl));
mpCBCustomizations->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBFull->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBCheckProfilesafeConfig->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBCheckProfilesafeExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBDisableAllExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBResetCustomizations->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBResetWholeUserProfile->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
// Disable restart btn until some checkbox is active
mpBtnRestart->Disable();
if (!maBackupFileHelper.isPopPossible())
{
mpCBCheckProfilesafeConfig->Disable();
}
if (!maBackupFileHelper.isPopPossibleExtensionInfo())
{
mpCBCheckProfilesafeExtensions->Disable();
}
if (comphelper::BackupFileHelper::isTryDisableAllExtensionsPossible())
{
mpCBDisableAllExtensions->Disable();
}
if (maBackupFileHelper.isTryResetCustomizationsPossible())
{
mpCBResetCustomizations->Disable();
}
}
SafeModeDialog::~SafeModeDialog()
......@@ -54,9 +91,12 @@ void SafeModeDialog::dispose()
mpBtnContinue.clear();
mpBtnQuit.clear();
mpBtnRestart.clear();
mpCBCustomizations.clear();
mpCBExtensions.clear();
mpCBFull.clear();
mpCBCheckProfilesafeConfig.clear();
mpCBCheckProfilesafeExtensions.clear();
mpCBDisableAllExtensions.clear();
mpCBResetCustomizations.clear();
mpCBResetWholeUserProfile.clear();
Dialog::dispose();
}
......@@ -80,7 +120,37 @@ void SafeModeDialog::terminateOffice()
void SafeModeDialog::applyChanges()
{
// TODO: Apply apply changes
if (mpCBCheckProfilesafeConfig->IsChecked())
{
// reset UserConfiguration to last known working state
// ProfileSafeMode/BackupFileHelper
maBackupFileHelper.tryPop();
}
if (mpCBCheckProfilesafeExtensions->IsChecked())
{
// reset State of installed Extensions to last known working state
// ProfileSafeMode/BackupFileHelper
maBackupFileHelper.tryPopExtensionInfo();
}
if (mpCBDisableAllExtensions->IsChecked())
{
// Disable all extensions
comphelper::BackupFileHelper::tryDisableAllExtensions();
}
if (mpCBResetCustomizations->IsChecked())
{
// Reset customizations (Settings and UserInterface modifications)
maBackupFileHelper.tryResetCustomizations();
}
if (mpCBResetWholeUserProfile->IsChecked())
{
// Reset the whole UserProfile
maBackupFileHelper.tryResetUserProfile();
}
// Then restart
css::task::OfficeRestartManager::get(comphelper::getProcessComponentContext())->requestRestart(
......@@ -106,7 +176,13 @@ IMPL_LINK(SafeModeDialog, BtnHdl, Button*, pBtn, void)
IMPL_LINK(SafeModeDialog, CheckBoxHdl, CheckBox&, /*pCheckBox*/, void)
{
bool bEnable = mpCBCustomizations->IsChecked() || mpCBExtensions->IsChecked() || mpCBFull->IsChecked();
const bool bEnable(
mpCBCheckProfilesafeConfig->IsChecked() ||
mpCBCheckProfilesafeExtensions->IsChecked() ||
mpCBDisableAllExtensions->IsChecked() ||
mpCBResetCustomizations->IsChecked() ||
mpCBResetWholeUserProfile->IsChecked());
mpBtnRestart->Enable(bEnable);
}
......
......@@ -15,6 +15,7 @@
#include <vcl/fixed.hxx>
#include <vcl/edit.hxx>
#include <vcl/vclmedit.hxx>
#include <comphelper/backupfilehelper.hxx>
class SafeModeDialog : public Dialog
{
......@@ -34,12 +35,17 @@ private:
VclPtr<Button> mpBtnQuit;
VclPtr<Button> mpBtnRestart;
VclPtr<CheckBox> mpCBExtensions;
VclPtr<CheckBox> mpCBCustomizations;
VclPtr<CheckBox> mpCBFull;
VclPtr<CheckBox> mpCBCheckProfilesafeConfig;
VclPtr<CheckBox> mpCBCheckProfilesafeExtensions;
VclPtr<CheckBox> mpCBDisableAllExtensions;
VclPtr<CheckBox> mpCBResetCustomizations;
VclPtr<CheckBox> mpCBResetWholeUserProfile;
// local BackupFileHelper for handling possible restores
comphelper::BackupFileHelper maBackupFileHelper;
static void terminateOffice();
static void applyChanges();
void applyChanges();
DECL_LINK(CheckBoxHdl, CheckBox&, void);
DECL_LINK(BtnHdl, Button*, void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment