diff options
| author | Odd Stranne <odd@mullvad.net> | 2018-08-16 22:06:56 +0200 |
|---|---|---|
| committer | Odd Stranne <odd@mullvad.net> | 2018-08-29 12:14:24 +0200 |
| commit | e0fbb5dfda63ebb054a47aaf88a270ab1334a68a (patch) | |
| tree | f89aae227ff12068e03842b849f5afff52eb0db0 /windows/nsis-plugins/src/cleanup/cleanup.cpp | |
| parent | ac290fef91b3fb7fe35cffada330c56436d223ed (diff) | |
| download | mullvadvpn-e0fbb5dfda63ebb054a47aaf88a270ab1334a68a.tar.xz mullvadvpn-e0fbb5dfda63ebb054a47aaf88a270ab1334a68a.zip | |
Add uninstaller plugin for extended system cleaning
Diffstat (limited to 'windows/nsis-plugins/src/cleanup/cleanup.cpp')
| -rw-r--r-- | windows/nsis-plugins/src/cleanup/cleanup.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/windows/nsis-plugins/src/cleanup/cleanup.cpp b/windows/nsis-plugins/src/cleanup/cleanup.cpp new file mode 100644 index 0000000000..c7890d60b7 --- /dev/null +++ b/windows/nsis-plugins/src/cleanup/cleanup.cpp @@ -0,0 +1,81 @@ +#include <stdafx.h> +#include "cleaningops.h" +#include <windows.h> +#include <nsis/pluginapi.h> +#include <functional> +#include <vector> + +enum class RemoveLogsAndCacheStatus +{ + GENERAL_ERROR = 0, + SUCCESS +}; + +void __declspec(dllexport) NSISCALL RemoveLogsAndCache +( + HWND hwndParent, + int string_size, + LPTSTR variables, + stack_t **stacktop, + extra_parameters *extra, + ... +) +{ + EXDLL_INIT(); + + std::vector<std::function<void()> > functions = + { + cleaningops::RemoveLogsCacheCurrentUser, + cleaningops::RemoveLogsCacheOtherUsers, + cleaningops::RemoveLogsServiceUser, + cleaningops::RemoveCacheServiceUser, + }; + + bool success = true; + + // + // Invoke all functions and take note of any failure. + // + for (const auto &function : functions) + { + try + { + function(); + } + catch (...) + { + success = false; + } + } + + pushint(success ? RemoveLogsAndCacheStatus::SUCCESS : RemoveLogsAndCacheStatus::GENERAL_ERROR); +} + +enum class RemoveSettingsStatus +{ + GENERAL_ERROR = 0, + SUCCESS +}; + +void __declspec(dllexport) NSISCALL RemoveSettings +( + HWND hwndParent, + int string_size, + LPTSTR variables, + stack_t **stacktop, + extra_parameters *extra, + ... +) +{ + EXDLL_INIT(); + + try + { + cleaningops::RemoveSettingsServiceUser(); + pushint(RemoveSettingsStatus::SUCCESS); + } + catch (...) + { + pushint(RemoveSettingsStatus::GENERAL_ERROR); + } +} |
