summaryrefslogtreecommitdiffhomepage
path: root/windows/nsis-plugins/src/cleanup/cleanup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'windows/nsis-plugins/src/cleanup/cleanup.cpp')
-rw-r--r--windows/nsis-plugins/src/cleanup/cleanup.cpp81
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);
+ }
+}