2016-10-07 18:19:25 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SafeModeDialog.hxx"
|
|
|
|
|
|
|
|
#include <config_folders.h>
|
|
|
|
#include <rtl/bootstrap.hxx>
|
|
|
|
#include <osl/file.hxx>
|
2016-10-11 16:07:37 +02:00
|
|
|
#include <sfx2/safemode.hxx>
|
2016-10-17 11:45:27 +02:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/layout.hxx>
|
|
|
|
#include <comphelper/anytostring.hxx>
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
|
|
|
#include <unotools/configmgr.hxx>
|
2016-10-07 18:19:25 +02:00
|
|
|
|
2016-10-12 13:01:15 +02:00
|
|
|
#include <com/sun/star/frame/Desktop.hpp>
|
|
|
|
#include <com/sun/star/frame/XDesktop2.hpp>
|
2016-10-12 13:26:10 +02:00
|
|
|
#include <com/sun/star/task/OfficeRestartManager.hpp>
|
|
|
|
#include <com/sun/star/task/XInteractionHandler.hpp>
|
2016-10-17 11:45:27 +02:00
|
|
|
#include <com/sun/star/system/XSystemShellExecute.hpp>
|
|
|
|
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
|
|
|
|
#include <com/sun/star/system/SystemShellExecute.hpp>
|
2016-10-12 13:01:15 +02:00
|
|
|
|
|
|
|
using namespace css;
|
|
|
|
|
2016-10-13 18:31:51 +02:00
|
|
|
SafeModeDialog::SafeModeDialog(vcl::Window* pParent)
|
|
|
|
: Dialog(pParent, "SafeModeDialog", "svx/ui/safemodedialog.ui"),
|
|
|
|
|
|
|
|
mpBtnContinue(),
|
|
|
|
mpBtnQuit(),
|
|
|
|
mpBtnRestart(),
|
|
|
|
|
|
|
|
mpCBCheckProfilesafeConfig(),
|
|
|
|
mpCBCheckProfilesafeExtensions(),
|
|
|
|
mpCBDisableAllExtensions(),
|
2016-10-20 13:30:40 +02:00
|
|
|
mpCBDeinstallUserExtensions(),
|
|
|
|
mpCBDeinstallAllExtensions(),
|
2016-10-20 18:15:05 +02:00
|
|
|
mpCBDisableHWAcceleration(),
|
2016-10-13 18:31:51 +02:00
|
|
|
mpCBResetCustomizations(),
|
|
|
|
mpCBResetWholeUserProfile(),
|
|
|
|
|
|
|
|
maBackupFileHelper()
|
2016-10-07 18:19:25 +02:00
|
|
|
{
|
|
|
|
get(mpBtnContinue, "btn_continue");
|
|
|
|
get(mpBtnQuit, "btn_quit");
|
|
|
|
get(mpBtnRestart, "btn_restart");
|
2016-10-13 18:31:51 +02:00
|
|
|
|
|
|
|
get(mpCBCheckProfilesafeConfig, "check_profilesafe_config");
|
|
|
|
get(mpCBCheckProfilesafeExtensions, "check_profilesafe_extensions");
|
|
|
|
get(mpCBDisableAllExtensions, "check_disable_all_extensions");
|
2016-10-20 13:30:40 +02:00
|
|
|
get(mpCBDeinstallUserExtensions, "check_deinstall_user_extensions");
|
|
|
|
get(mpCBDeinstallAllExtensions, "check_deinstall_all_extensions");
|
2016-10-20 18:15:05 +02:00
|
|
|
get(mpCBDisableHWAcceleration, "check_disable_hw_acceleration");
|
2016-10-13 18:31:51 +02:00
|
|
|
get(mpCBResetCustomizations, "check_reset_customizations");
|
|
|
|
get(mpCBResetWholeUserProfile, "check_reset_whole_userprofile");
|
2016-10-07 18:19:25 +02:00
|
|
|
|
2016-10-17 11:45:27 +02:00
|
|
|
get(mpBugLink, "linkbutton_bugs");
|
2016-10-31 16:20:47 +01:00
|
|
|
get(mpUserProfileLink, "linkbutton_profile");
|
2016-10-17 11:45:27 +02:00
|
|
|
|
2016-10-07 18:19:25 +02:00
|
|
|
mpBtnContinue->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl));
|
|
|
|
mpBtnQuit->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl));
|
|
|
|
mpBtnRestart->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl));
|
2016-10-12 13:35:52 +02:00
|
|
|
|
2016-10-13 18:31:51 +02:00
|
|
|
mpCBCheckProfilesafeConfig->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
|
|
|
|
mpCBCheckProfilesafeExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
|
|
|
|
mpCBDisableAllExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
|
2016-10-20 13:30:40 +02:00
|
|
|
mpCBDeinstallUserExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
|
|
|
|
mpCBDeinstallAllExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
|
2016-10-20 18:15:05 +02:00
|
|
|
mpCBDisableHWAcceleration->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
|
2016-10-13 18:31:51 +02:00
|
|
|
mpCBResetCustomizations->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
|
|
|
|
mpCBResetWholeUserProfile->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
|
2016-10-12 13:35:52 +02:00
|
|
|
|
|
|
|
// Disable restart btn until some checkbox is active
|
|
|
|
mpBtnRestart->Disable();
|
2016-10-13 18:31:51 +02:00
|
|
|
|
|
|
|
if (!maBackupFileHelper.isPopPossible())
|
|
|
|
{
|
|
|
|
mpCBCheckProfilesafeConfig->Disable();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!maBackupFileHelper.isPopPossibleExtensionInfo())
|
|
|
|
{
|
|
|
|
mpCBCheckProfilesafeExtensions->Disable();
|
|
|
|
}
|
|
|
|
|
2016-10-18 12:50:42 +02:00
|
|
|
if (!comphelper::BackupFileHelper::isTryDisableAllExtensionsPossible())
|
2016-10-13 18:31:51 +02:00
|
|
|
{
|
|
|
|
mpCBDisableAllExtensions->Disable();
|
|
|
|
}
|
|
|
|
|
2016-10-20 13:30:40 +02:00
|
|
|
if (!comphelper::BackupFileHelper::isTryDeinstallUserExtensionsPossible())
|
|
|
|
{
|
|
|
|
mpCBDeinstallUserExtensions->Disable();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!comphelper::BackupFileHelper::isTryDeinstallAllExtensionsPossible())
|
|
|
|
{
|
|
|
|
mpCBDeinstallAllExtensions->Disable();
|
|
|
|
}
|
|
|
|
|
2016-10-18 12:50:42 +02:00
|
|
|
if (!comphelper::BackupFileHelper::isTryResetCustomizationsPossible())
|
2016-10-13 18:31:51 +02:00
|
|
|
{
|
|
|
|
mpCBResetCustomizations->Disable();
|
|
|
|
}
|
2016-10-17 11:45:27 +02:00
|
|
|
|
2016-10-20 13:30:40 +02:00
|
|
|
// no disabe of mpCBResetWholeUserProfile, always possible (as last choice)
|
|
|
|
|
2016-10-17 11:45:27 +02:00
|
|
|
// Set URL for help button (module=safemode)
|
|
|
|
OUString sURL("http://hub.libreoffice.org/send-feedback/?LOversion=" + utl::ConfigManager::getAboutBoxProductVersion() +
|
|
|
|
"&LOlocale=" + utl::ConfigManager::getLocale() + "&LOmodule=safemode");
|
|
|
|
mpBugLink->SetURL(sURL);
|
2016-10-31 16:20:47 +01:00
|
|
|
|
|
|
|
mpUserProfileLink->SetURL(comphelper::BackupFileHelper::getUserProfileURL());
|
2016-10-07 18:19:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SafeModeDialog::~SafeModeDialog()
|
|
|
|
{
|
|
|
|
disposeOnce();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SafeModeDialog::dispose()
|
|
|
|
{
|
|
|
|
mpBtnContinue.clear();
|
|
|
|
mpBtnQuit.clear();
|
|
|
|
mpBtnRestart.clear();
|
2016-10-13 18:31:51 +02:00
|
|
|
|
|
|
|
mpCBCheckProfilesafeConfig.clear();
|
|
|
|
mpCBCheckProfilesafeExtensions.clear();
|
|
|
|
mpCBDisableAllExtensions.clear();
|
2016-10-20 13:30:40 +02:00
|
|
|
mpCBDeinstallUserExtensions.clear();
|
|
|
|
mpCBDeinstallAllExtensions.clear();
|
2016-10-20 18:15:05 +02:00
|
|
|
mpCBDisableHWAcceleration.clear();
|
2016-10-13 18:31:51 +02:00
|
|
|
mpCBResetCustomizations.clear();
|
|
|
|
mpCBResetWholeUserProfile.clear();
|
2016-10-07 18:19:25 +02:00
|
|
|
|
2016-10-17 11:45:27 +02:00
|
|
|
mpBugLink.clear();
|
2016-10-31 16:20:47 +01:00
|
|
|
mpUserProfileLink.clear();
|
2016-10-17 11:45:27 +02:00
|
|
|
|
2016-10-07 18:19:25 +02:00
|
|
|
Dialog::dispose();
|
|
|
|
}
|
|
|
|
|
2016-10-12 11:18:08 +02:00
|
|
|
bool SafeModeDialog::Close()
|
|
|
|
{
|
|
|
|
// Remove the safe mode flag before exiting this dialog
|
|
|
|
sfx2::SafeMode::removeFlag();
|
|
|
|
|
|
|
|
return Dialog::Close();
|
|
|
|
}
|
|
|
|
|
2016-10-12 13:26:10 +02:00
|
|
|
void SafeModeDialog::applyChanges()
|
|
|
|
{
|
2016-10-13 18:31:51 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2016-10-20 13:30:40 +02:00
|
|
|
if (mpCBDeinstallUserExtensions->IsChecked())
|
|
|
|
{
|
|
|
|
// Deinstall all User Extensions (installed for User only)
|
|
|
|
comphelper::BackupFileHelper::tryDeinstallUserExtensions();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mpCBDeinstallAllExtensions->IsChecked())
|
|
|
|
{
|
|
|
|
// Deinstall all Extensions (user|shared|bundled)
|
|
|
|
comphelper::BackupFileHelper::tryDeinstallAllExtensions();
|
|
|
|
}
|
|
|
|
|
2016-10-20 18:15:05 +02:00
|
|
|
if (mpCBDisableHWAcceleration->IsChecked())
|
|
|
|
{
|
|
|
|
comphelper::BackupFileHelper::tryDisableHWAcceleration();
|
|
|
|
}
|
|
|
|
|
2016-10-13 18:31:51 +02:00
|
|
|
if (mpCBResetCustomizations->IsChecked())
|
|
|
|
{
|
|
|
|
// Reset customizations (Settings and UserInterface modifications)
|
2016-10-18 12:50:42 +02:00
|
|
|
comphelper::BackupFileHelper::tryResetCustomizations();
|
2016-10-13 18:31:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mpCBResetWholeUserProfile->IsChecked())
|
|
|
|
{
|
|
|
|
// Reset the whole UserProfile
|
2016-10-18 12:50:42 +02:00
|
|
|
comphelper::BackupFileHelper::tryResetUserProfile();
|
2016-10-13 18:31:51 +02:00
|
|
|
}
|
2016-10-12 13:26:10 +02:00
|
|
|
|
|
|
|
// Then restart
|
|
|
|
css::task::OfficeRestartManager::get(comphelper::getProcessComponentContext())->requestRestart(
|
|
|
|
css::uno::Reference< css::task::XInteractionHandler >());
|
|
|
|
}
|
|
|
|
|
2016-10-07 18:19:25 +02:00
|
|
|
IMPL_LINK(SafeModeDialog, BtnHdl, Button*, pBtn, void)
|
|
|
|
{
|
|
|
|
if (pBtn == mpBtnContinue.get())
|
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
else if (pBtn == mpBtnQuit.get())
|
|
|
|
{
|
2016-10-18 13:11:02 +02:00
|
|
|
Close();
|
|
|
|
Application::Quit();
|
2016-10-07 18:19:25 +02:00
|
|
|
}
|
|
|
|
else if (pBtn == mpBtnRestart.get())
|
|
|
|
{
|
2016-10-20 18:15:05 +02:00
|
|
|
//Close();
|
2016-10-12 13:26:10 +02:00
|
|
|
applyChanges();
|
2016-10-07 18:19:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-12 13:35:52 +02:00
|
|
|
IMPL_LINK(SafeModeDialog, CheckBoxHdl, CheckBox&, /*pCheckBox*/, void)
|
|
|
|
{
|
2016-10-13 18:31:51 +02:00
|
|
|
const bool bEnable(
|
|
|
|
mpCBCheckProfilesafeConfig->IsChecked() ||
|
|
|
|
mpCBCheckProfilesafeExtensions->IsChecked() ||
|
|
|
|
mpCBDisableAllExtensions->IsChecked() ||
|
2016-10-20 13:30:40 +02:00
|
|
|
mpCBDeinstallUserExtensions->IsChecked() ||
|
|
|
|
mpCBDeinstallAllExtensions->IsChecked() ||
|
2016-10-20 18:15:05 +02:00
|
|
|
mpCBDisableHWAcceleration->IsChecked() ||
|
2016-10-13 18:31:51 +02:00
|
|
|
mpCBResetCustomizations->IsChecked() ||
|
|
|
|
mpCBResetWholeUserProfile->IsChecked());
|
|
|
|
|
2016-10-12 13:35:52 +02:00
|
|
|
mpBtnRestart->Enable(bEnable);
|
|
|
|
}
|
|
|
|
|
2016-10-07 18:19:25 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|