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

profilesafe: Added more specific options

For Extensions there is the possibility to not only
decide enable/disable state for User ones, but also
to deinstall user or all extensions, added these
options to the dialog and the functionality.
Also unified customization name schema to have just
one source of strings to avoid errors in the future.
Small fix in tryPop_extensionInfo

Change-Id: I39acbe9a052ffd4cb78b496f24e5b583136c565a
Reviewed-on: https://gerrit.libreoffice.org/30100Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarArmin Le Grand <Armin.Le.Grand@cib.de>
üst c5feb9ad
...@@ -677,7 +677,9 @@ namespace ...@@ -677,7 +677,9 @@ namespace
} }
public: public:
void createUsingExtensionRegistryEntriesFromXML(const OUString& rUserConfigWorkURL) void createUsingExtensionRegistryEntriesFromXML(
const OUString& rUserConfigWorkURL,
bool bUser)
{ {
// This is looked up for 'user' in the user|shared|bundled deployed Extensions, // This is looked up for 'user' in the user|shared|bundled deployed Extensions,
// only the user ones seem to be able to be de/activated. The ones for user are in // only the user ones seem to be able to be de/activated. The ones for user are in
...@@ -686,13 +688,15 @@ namespace ...@@ -686,13 +688,15 @@ namespace
// in safe mode by deleting the uno_packages directory and the shared|bundled // in safe mode by deleting the uno_packages directory and the shared|bundled
// ones by deleting the extensions directory. // ones by deleting the extensions directory.
const OUString aRegPath("/registry/com.sun.star.comp.deployment.bundle.PackageRegistryBackend/backenddb.xml"); const OUString aRegPath("/registry/com.sun.star.comp.deployment.bundle.PackageRegistryBackend/backenddb.xml");
const OUString aUnoPackagReg(rUserConfigWorkURL + "/uno_packages/cache" + aRegPath); const OUString aExtensionsReg(rUserConfigWorkURL + "/extensions/shared" + aRegPath);
const OUString aUnoPackageReg(rUserConfigWorkURL + "/uno_packages/cache" + aRegPath);
const OUString aPath(bUser ? aUnoPackageReg : aExtensionsReg);
if (fileExists(aUnoPackagReg)) if (fileExists(aPath))
{ {
uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
uno::Reference< xml::dom::XDocumentBuilder > xBuilder(xml::dom::DocumentBuilder::create(xContext)); uno::Reference< xml::dom::XDocumentBuilder > xBuilder(xml::dom::DocumentBuilder::create(xContext));
uno::Reference< xml::dom::XDocument > aDocument = xBuilder->parseURI(aUnoPackagReg); uno::Reference< xml::dom::XDocument > aDocument = xBuilder->parseURI(aPath);
if (aDocument.is()) if (aDocument.is())
{ {
...@@ -1907,20 +1911,6 @@ namespace comphelper ...@@ -1907,20 +1911,6 @@ namespace comphelper
return bPopPossible; return bPopPossible;
} }
bool BackupFileHelper::isPopPossibleExtensionInfo()
{
bool bPopPossible(false);
if (mbActive && mbExtensions)
{
const OUString aPackURL(getPackURL());
bPopPossible = isPopPossible_extensionInfo(aPackURL);
}
return bPopPossible;
}
bool BackupFileHelper::tryPop() bool BackupFileHelper::tryPop()
{ {
bool bDidPop(false); bool bDidPop(false);
...@@ -1952,6 +1942,20 @@ namespace comphelper ...@@ -1952,6 +1942,20 @@ namespace comphelper
return bDidPop; return bDidPop;
} }
bool BackupFileHelper::isPopPossibleExtensionInfo()
{
bool bPopPossible(false);
if (mbActive && mbExtensions)
{
const OUString aPackURL(getPackURL());
bPopPossible = isPopPossible_extensionInfo(aPackURL);
}
return bPopPossible;
}
bool BackupFileHelper::tryPopExtensionInfo() bool BackupFileHelper::tryPopExtensionInfo()
{ {
bool bDidPop(false); bool bDidPop(false);
...@@ -1979,7 +1983,7 @@ namespace comphelper ...@@ -1979,7 +1983,7 @@ namespace comphelper
// extensions are not loaded from XExtensionManager // extensions are not loaded from XExtensionManager
class ExtensionInfo aExtensionInfo; class ExtensionInfo aExtensionInfo;
aExtensionInfo.createUsingExtensionRegistryEntriesFromXML(maUserConfigWorkURL); aExtensionInfo.createUsingExtensionRegistryEntriesFromXML(maUserConfigWorkURL, true);
return aExtensionInfo.areThereEnabledExtensions(); return aExtensionInfo.areThereEnabledExtensions();
} }
...@@ -1993,7 +1997,7 @@ namespace comphelper ...@@ -1993,7 +1997,7 @@ namespace comphelper
const ExtensionInfoEntryVector aToBeEnabled{}; const ExtensionInfoEntryVector aToBeEnabled{};
ExtensionInfoEntryVector aToBeDisabled; ExtensionInfoEntryVector aToBeDisabled;
aCurrentExtensionInfo.createUsingExtensionRegistryEntriesFromXML(maUserConfigWorkURL); aCurrentExtensionInfo.createUsingExtensionRegistryEntriesFromXML(maUserConfigWorkURL, true);
const ExtensionInfoEntryVector& rCurrentVector = aCurrentExtensionInfo.getExtensionInfoEntryVector(); const ExtensionInfoEntryVector& rCurrentVector = aCurrentExtensionInfo.getExtensionInfoEntryVector();
...@@ -2008,29 +2012,109 @@ namespace comphelper ...@@ -2008,29 +2012,109 @@ namespace comphelper
ExtensionInfo::changeEnableDisableStateInXML(maUserConfigWorkURL, aToBeEnabled, aToBeDisabled); ExtensionInfo::changeEnableDisableStateInXML(maUserConfigWorkURL, aToBeEnabled, aToBeDisabled);
} }
bool BackupFileHelper::isTryDeinstallUserExtensionsPossible()
{
// check if there are User Extensions installed.
class ExtensionInfo aExtensionInfo;
aExtensionInfo.createUsingExtensionRegistryEntriesFromXML(maUserConfigWorkURL, true);
return !aExtensionInfo.getExtensionInfoEntryVector().empty();
}
void BackupFileHelper::tryDeinstallUserExtensions()
{
// delete User Extension installs
deleteDirRecursively(maUserConfigWorkURL + "/uno_packages");
}
bool BackupFileHelper::isTryDeinstallAllExtensionsPossible()
{
// check if there are other Extensions installed (shared|bundled).
class ExtensionInfo aExtensionInfo;
aExtensionInfo.createUsingExtensionRegistryEntriesFromXML(maUserConfigWorkURL, false);
return !aExtensionInfo.getExtensionInfoEntryVector().empty();
}
void BackupFileHelper::tryDeinstallAllExtensions()
{
// delete other Extension installs (shared|bundled)
deleteDirRecursively(maUserConfigWorkURL + "/extensions");
}
const std::vector< OUString >& BackupFileHelper::getCustomizationDirNames()
{
static std::vector< OUString > aDirNames;
if (aDirNames.empty())
{
aDirNames.push_back("config"); // UI config stuff
aDirNames.push_back("registry"); // most of the registry stuff
aDirNames.push_back("psprint"); // not really needed, can be abandoned
aDirNames.push_back("store"); // not really needed, can be abandoned
aDirNames.push_back("temp"); // not really needed, can be abandoned
aDirNames.push_back("pack"); // own backup dir
}
return aDirNames;
}
const std::vector< OUString >& BackupFileHelper::getCustomizationFileNames()
{
static std::vector< OUString > aFileNames;
if (aFileNames.empty())
{
aFileNames.push_back("registrymodifications.xcu"); // personal registry stuff
}
return aFileNames;
}
bool BackupFileHelper::isTryResetCustomizationsPossible() bool BackupFileHelper::isTryResetCustomizationsPossible()
{ {
// return true if not all of the customization selection dirs are deleted // return true if not all of the customization selection dirs or files are deleted
return const std::vector< OUString >& rDirs = getCustomizationDirNames();
dirExists(maUserConfigWorkURL + "/config") || // UI config stuff
dirExists(maUserConfigWorkURL + "/registry") || // most of the registry stuff for (const auto& a : rDirs)
dirExists(maUserConfigWorkURL + "/psprint") || // not really needed, can be abandoned {
dirExists(maUserConfigWorkURL + "/store") || // not really needed, can be abandoned if (dirExists(maUserConfigWorkURL + "/" + a))
dirExists(maUserConfigWorkURL + "/temp") || // not really needed, can be abandoned {
dirExists(maUserConfigWorkURL + "/pack") || // own backup dir return true;
fileExists(maUserConfigWorkURL + "/registrymodifications.xcu"); // personal registry stuff }
}
const std::vector< OUString >& rFiles = getCustomizationFileNames();
for (const auto& b : rFiles)
{
if (fileExists(maUserConfigWorkURL + "/" + b))
{
return true;
}
}
return false;
} }
void BackupFileHelper::tryResetCustomizations() void BackupFileHelper::tryResetCustomizations()
{ {
// delete all of the customization selection dirs // delete all of the customization selection dirs
deleteDirRecursively(maUserConfigWorkURL + "/config"); const std::vector< OUString >& rDirs = getCustomizationDirNames();
deleteDirRecursively(maUserConfigWorkURL + "/registry");
deleteDirRecursively(maUserConfigWorkURL + "/psprint"); for (const auto& a : rDirs)
deleteDirRecursively(maUserConfigWorkURL + "/store"); {
deleteDirRecursively(maUserConfigWorkURL + "/temp"); deleteDirRecursively(maUserConfigWorkURL + "/" + a);
deleteDirRecursively(maUserConfigWorkURL + "/pack"); }
osl::File::remove(maUserConfigWorkURL + "/registrymodifications.xcu");
const std::vector< OUString >& rFiles = getCustomizationFileNames();
for (const auto& b : rFiles)
{
osl::File::remove(maUserConfigWorkURL + "/" + b);
}
} }
void BackupFileHelper::tryResetUserProfile() void BackupFileHelper::tryResetUserProfile()
...@@ -2375,7 +2459,7 @@ namespace comphelper ...@@ -2375,7 +2459,7 @@ namespace comphelper
// get current extension info, but from XML config files // get current extension info, but from XML config files
ExtensionInfo aCurrentExtensionInfo; ExtensionInfo aCurrentExtensionInfo;
aCurrentExtensionInfo.createUsingExtensionRegistryEntriesFromXML(maUserConfigWorkURL); aCurrentExtensionInfo.createUsingExtensionRegistryEntriesFromXML(maUserConfigWorkURL, true);
// now we have loaded last_working (aLoadedExtensionInfo) and // now we have loaded last_working (aLoadedExtensionInfo) and
// current (aCurrentExtensionInfo) ExtensionInfo and may react on // current (aCurrentExtensionInfo) ExtensionInfo and may react on
...@@ -2408,7 +2492,7 @@ namespace comphelper ...@@ -2408,7 +2492,7 @@ namespace comphelper
{ {
aToBeDisabled.push_back(rCurrentInfo); aToBeDisabled.push_back(rCurrentInfo);
} }
else if (!bCurrentEnabled && !bLoadedEnabled) else if (!bCurrentEnabled && bLoadedEnabled)
{ {
aToBeEnabled.push_back(rCurrentInfo); aToBeEnabled.push_back(rCurrentInfo);
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <osl/file.hxx> #include <osl/file.hxx>
#include <memory> #include <memory>
#include <set> #include <set>
#include <vector>
namespace comphelper namespace comphelper
{ {
...@@ -156,6 +157,16 @@ namespace comphelper ...@@ -156,6 +157,16 @@ namespace comphelper
static bool isTryDisableAllExtensionsPossible(); static bool isTryDisableAllExtensionsPossible();
static void tryDisableAllExtensions(); static void tryDisableAllExtensions();
/** Deinstall all User Extensions (installed for User only)
*/
static bool isTryDeinstallUserExtensionsPossible();
static void tryDeinstallUserExtensions();
/** Deinstall all Extensions (user|shared|bundled)
*/
static bool isTryDeinstallAllExtensionsPossible();
static void tryDeinstallAllExtensions();
/** resets User-Customizations like Settings and UserInterface modifications /** resets User-Customizations like Settings and UserInterface modifications
*/ */
static bool isTryResetCustomizationsPossible(); static bool isTryResetCustomizationsPossible();
...@@ -168,6 +179,8 @@ namespace comphelper ...@@ -168,6 +179,8 @@ namespace comphelper
private: private:
// internal helper methods // internal helper methods
static const rtl::OUString getPackURL(); static const rtl::OUString getPackURL();
static const std::vector< OUString >& getCustomizationDirNames();
static const std::vector< OUString >& getCustomizationFileNames();
// file push helpers // file push helpers
bool tryPush_Files(const std::set< OUString >& rDirs, const std::set< std::pair< OUString, OUString > >& rFiles, const OUString& rSourceURL, const OUString& rTargetURL); bool tryPush_Files(const std::set< OUString >& rDirs, const std::set< std::pair< OUString, OUString > >& rFiles, const OUString& rSourceURL, const OUString& rTargetURL);
......
...@@ -40,6 +40,8 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent) ...@@ -40,6 +40,8 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent)
mpCBCheckProfilesafeConfig(), mpCBCheckProfilesafeConfig(),
mpCBCheckProfilesafeExtensions(), mpCBCheckProfilesafeExtensions(),
mpCBDisableAllExtensions(), mpCBDisableAllExtensions(),
mpCBDeinstallUserExtensions(),
mpCBDeinstallAllExtensions(),
mpCBResetCustomizations(), mpCBResetCustomizations(),
mpCBResetWholeUserProfile(), mpCBResetWholeUserProfile(),
...@@ -52,6 +54,8 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent) ...@@ -52,6 +54,8 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent)
get(mpCBCheckProfilesafeConfig, "check_profilesafe_config"); get(mpCBCheckProfilesafeConfig, "check_profilesafe_config");
get(mpCBCheckProfilesafeExtensions, "check_profilesafe_extensions"); get(mpCBCheckProfilesafeExtensions, "check_profilesafe_extensions");
get(mpCBDisableAllExtensions, "check_disable_all_extensions"); get(mpCBDisableAllExtensions, "check_disable_all_extensions");
get(mpCBDeinstallUserExtensions, "check_deinstall_user_extensions");
get(mpCBDeinstallAllExtensions, "check_deinstall_all_extensions");
get(mpCBResetCustomizations, "check_reset_customizations"); get(mpCBResetCustomizations, "check_reset_customizations");
get(mpCBResetWholeUserProfile, "check_reset_whole_userprofile"); get(mpCBResetWholeUserProfile, "check_reset_whole_userprofile");
...@@ -64,6 +68,8 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent) ...@@ -64,6 +68,8 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent)
mpCBCheckProfilesafeConfig->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl)); mpCBCheckProfilesafeConfig->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBCheckProfilesafeExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl)); mpCBCheckProfilesafeExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBDisableAllExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl)); mpCBDisableAllExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBDeinstallUserExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBDeinstallAllExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBResetCustomizations->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl)); mpCBResetCustomizations->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBResetWholeUserProfile->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl)); mpCBResetWholeUserProfile->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
...@@ -85,11 +91,23 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent) ...@@ -85,11 +91,23 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent)
mpCBDisableAllExtensions->Disable(); mpCBDisableAllExtensions->Disable();
} }
if (!comphelper::BackupFileHelper::isTryDeinstallUserExtensionsPossible())
{
mpCBDeinstallUserExtensions->Disable();
}
if (!comphelper::BackupFileHelper::isTryDeinstallAllExtensionsPossible())
{
mpCBDeinstallAllExtensions->Disable();
}
if (!comphelper::BackupFileHelper::isTryResetCustomizationsPossible()) if (!comphelper::BackupFileHelper::isTryResetCustomizationsPossible())
{ {
mpCBResetCustomizations->Disable(); mpCBResetCustomizations->Disable();
} }
// no disabe of mpCBResetWholeUserProfile, always possible (as last choice)
// Set URL for help button (module=safemode) // Set URL for help button (module=safemode)
OUString sURL("http://hub.libreoffice.org/send-feedback/?LOversion=" + utl::ConfigManager::getAboutBoxProductVersion() + OUString sURL("http://hub.libreoffice.org/send-feedback/?LOversion=" + utl::ConfigManager::getAboutBoxProductVersion() +
"&LOlocale=" + utl::ConfigManager::getLocale() + "&LOmodule=safemode"); "&LOlocale=" + utl::ConfigManager::getLocale() + "&LOmodule=safemode");
...@@ -110,6 +128,8 @@ void SafeModeDialog::dispose() ...@@ -110,6 +128,8 @@ void SafeModeDialog::dispose()
mpCBCheckProfilesafeConfig.clear(); mpCBCheckProfilesafeConfig.clear();
mpCBCheckProfilesafeExtensions.clear(); mpCBCheckProfilesafeExtensions.clear();
mpCBDisableAllExtensions.clear(); mpCBDisableAllExtensions.clear();
mpCBDeinstallUserExtensions.clear();
mpCBDeinstallAllExtensions.clear();
mpCBResetCustomizations.clear(); mpCBResetCustomizations.clear();
mpCBResetWholeUserProfile.clear(); mpCBResetWholeUserProfile.clear();
...@@ -148,6 +168,18 @@ void SafeModeDialog::applyChanges() ...@@ -148,6 +168,18 @@ void SafeModeDialog::applyChanges()
comphelper::BackupFileHelper::tryDisableAllExtensions(); comphelper::BackupFileHelper::tryDisableAllExtensions();
} }
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();
}
if (mpCBResetCustomizations->IsChecked()) if (mpCBResetCustomizations->IsChecked())
{ {
// Reset customizations (Settings and UserInterface modifications) // Reset customizations (Settings and UserInterface modifications)
...@@ -189,6 +221,8 @@ IMPL_LINK(SafeModeDialog, CheckBoxHdl, CheckBox&, /*pCheckBox*/, void) ...@@ -189,6 +221,8 @@ IMPL_LINK(SafeModeDialog, CheckBoxHdl, CheckBox&, /*pCheckBox*/, void)
mpCBCheckProfilesafeConfig->IsChecked() || mpCBCheckProfilesafeConfig->IsChecked() ||
mpCBCheckProfilesafeExtensions->IsChecked() || mpCBCheckProfilesafeExtensions->IsChecked() ||
mpCBDisableAllExtensions->IsChecked() || mpCBDisableAllExtensions->IsChecked() ||
mpCBDeinstallUserExtensions->IsChecked() ||
mpCBDeinstallAllExtensions->IsChecked() ||
mpCBResetCustomizations->IsChecked() || mpCBResetCustomizations->IsChecked() ||
mpCBResetWholeUserProfile->IsChecked()); mpCBResetWholeUserProfile->IsChecked());
......
...@@ -39,6 +39,8 @@ private: ...@@ -39,6 +39,8 @@ private:
VclPtr<CheckBox> mpCBCheckProfilesafeConfig; VclPtr<CheckBox> mpCBCheckProfilesafeConfig;
VclPtr<CheckBox> mpCBCheckProfilesafeExtensions; VclPtr<CheckBox> mpCBCheckProfilesafeExtensions;
VclPtr<CheckBox> mpCBDisableAllExtensions; VclPtr<CheckBox> mpCBDisableAllExtensions;
VclPtr<CheckBox> mpCBDeinstallUserExtensions;
VclPtr<CheckBox> mpCBDeinstallAllExtensions;
VclPtr<CheckBox> mpCBResetCustomizations; VclPtr<CheckBox> mpCBResetCustomizations;
VclPtr<CheckBox> mpCBResetWholeUserProfile; VclPtr<CheckBox> mpCBResetWholeUserProfile;
......
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