diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-10-11 16:07:37 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-10-12 12:33:11 +0200 |
commit | b3b9ae6c6fd19b437a5414489a9f38fb310a2843 (patch) | |
tree | fd83787466b01f0481c610475120c2c7cdfe8def /sfx2 | |
parent | 6b44a8186da2270ef7d120b97380aabc297be76b (diff) |
safemode: Add flag to indicate safemode
Change-Id: Ifdbb291715b033eaace159297eac5348530e9f36
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/Library_sfx.mk | 1 | ||||
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/safemode/safemode.cxx | 58 |
3 files changed, 61 insertions, 0 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 9ec5f0ee3af8..e3daa773a50d 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -251,6 +251,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/notify/globalevents \ sfx2/source/notify/hintpost \ sfx2/source/notify/openurlhint \ + sfx2/source/safemode/safemode \ sfx2/source/sidebar/Sidebar \ sfx2/source/sidebar/SidebarChildWindow \ sfx2/source/sidebar/SidebarDockingWindow \ diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index b09613e081e6..defd3b601d8b 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -127,6 +127,7 @@ #include <sfx2/sidebar/Sidebar.hxx> #include <sfx2/notebookbar/SfxNotebookBar.hxx> #include <sfx2/sidebar/SidebarController.hxx> +#include <sfx2/safemode.hxx> #include <comphelper/types.hxx> #include <officecfg/Office/Common.hxx> @@ -311,6 +312,7 @@ namespace IMPL_LINK_NOARG(SafeModeQueryDialog, RestartHdl, Button*, void) { EndDialog(RET_OK); + sfx2::SafeMode::putFlag(); uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); css::task::OfficeRestartManager::get(xContext)->requestRestart( css::uno::Reference< css::task::XInteractionHandler >()); diff --git a/sfx2/source/safemode/safemode.cxx b/sfx2/source/safemode/safemode.cxx new file mode 100644 index 000000000000..a5669d19587f --- /dev/null +++ b/sfx2/source/safemode/safemode.cxx @@ -0,0 +1,58 @@ +/* -*- 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 <sfx2/safemode.hxx> + +#include <config_folders.h> + +#include <osl/file.hxx> +#include <rtl/bootstrap.hxx> + +using namespace osl; + +namespace sfx2 { + +bool SafeMode::putFlag() +{ + File safeModeFile(getFileName()); + if (safeModeFile.open(osl_File_OpenFlag_Create) == FileBase::E_None) + { + safeModeFile.close(); + return true; + } + return false; +} +bool SafeMode::hasFlag() +{ + File safeModeFile(getFileName()); + if (safeModeFile.open(osl_File_OpenFlag_Read) == FileBase::E_None) + { + safeModeFile.close(); + return true; + } + return false; +} +bool SafeMode::removeFlag() +{ + return File::remove(getFileName()) == FileBase::E_None; +} + +OUString SafeMode::getFileName() +{ + OUString url("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/safemode"); + rtl::Bootstrap::expandMacros(url); + + OUString aProfilePath; + FileBase::getSystemPathFromFileURL(url, aProfilePath); + return aProfilePath; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |