diff options
| author | David Lönnhager <david.l@mullvad.net> | 2019-12-11 13:29:50 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2019-12-16 15:16:19 +0100 |
| commit | 11ab41a02e34c0f3907faa5891f64da366bbc8c2 (patch) | |
| tree | cdef956018d9dd61e654f2157b879dced9b52ce6 /windows | |
| parent | 99eb972eb7c995216ce0b337b14c94cd89254ab4 (diff) | |
| download | mullvadvpn-11ab41a02e34c0f3907faa5891f64da366bbc8c2.tar.xz mullvadvpn-11ab41a02e34c0f3907faa5891f64da366bbc8c2.zip | |
Get rid of duplicate nsis constants
Diffstat (limited to 'windows')
| -rw-r--r-- | windows/nsis-plugins/nsis-plugins.sln | 5 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/cleanup/cleanup.cpp | 31 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/driverlogic/driverlogic.cpp | 49 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/error.h | 20 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/pathedit/pathedit.cpp | 21 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/registry/registry.cpp | 12 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/tray/tray.cpp | 12 |
7 files changed, 63 insertions, 87 deletions
diff --git a/windows/nsis-plugins/nsis-plugins.sln b/windows/nsis-plugins/nsis-plugins.sln index ef960ac28a..2268ac575d 100644 --- a/windows/nsis-plugins/nsis-plugins.sln +++ b/windows/nsis-plugins/nsis-plugins.sln @@ -36,6 +36,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pathedit", "src\pathedit\pa {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF} EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{00D73E7B-7B59-402E-B6AA-48E87B0711DB}" + ProjectSection(SolutionItems) = preProject + src\error.h = src\error.h + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 diff --git a/windows/nsis-plugins/src/cleanup/cleanup.cpp b/windows/nsis-plugins/src/cleanup/cleanup.cpp index ea8d59ac79..faef07c2f0 100644 --- a/windows/nsis-plugins/src/cleanup/cleanup.cpp +++ b/windows/nsis-plugins/src/cleanup/cleanup.cpp @@ -1,4 +1,5 @@ #include <stdafx.h> +#include "../error.h" #include "cleaningops.h" #include <libcommon/string.h> #include <windows.h> @@ -6,12 +7,6 @@ #include <functional> #include <vector> -enum class RemoveLogsAndCacheStatus -{ - GENERAL_ERROR = 0, - SUCCESS -}; - void __declspec(dllexport) NSISCALL RemoveLogsAndCache ( HWND hwndParent, @@ -49,15 +44,9 @@ void __declspec(dllexport) NSISCALL RemoveLogsAndCache } } - pushint(success ? RemoveLogsAndCacheStatus::SUCCESS : RemoveLogsAndCacheStatus::GENERAL_ERROR); + pushint(success ? NsisStatus::SUCCESS : NsisStatus::GENERAL_ERROR); } -enum class RemoveSettingsStatus -{ - GENERAL_ERROR = 0, - SUCCESS -}; - void __declspec(dllexport) NSISCALL RemoveSettings ( HWND hwndParent, @@ -73,20 +62,14 @@ void __declspec(dllexport) NSISCALL RemoveSettings try { cleaningops::RemoveSettingsServiceUser(); - pushint(RemoveSettingsStatus::SUCCESS); + pushint(NsisStatus::SUCCESS); } catch (...) { - pushint(RemoveSettingsStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } } -enum class RemoveRelayCacheStatus -{ - GENERAL_ERROR = 0, - SUCCESS -}; - void __declspec(dllexport) NSISCALL RemoveRelayCache ( HWND hwndParent, @@ -104,16 +87,16 @@ void __declspec(dllexport) NSISCALL RemoveRelayCache cleaningops::RemoveRelayCacheServiceUser(); pushstring(L""); - pushint(RemoveRelayCacheStatus::SUCCESS); + pushint(NsisStatus::SUCCESS); } catch (const std::exception &err) { pushstring(common::string::ToWide(err.what()).c_str()); - pushint(RemoveRelayCacheStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } catch (...) { pushstring(L"Unspecified error"); - pushint(RemoveRelayCacheStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } } diff --git a/windows/nsis-plugins/src/driverlogic/driverlogic.cpp b/windows/nsis-plugins/src/driverlogic/driverlogic.cpp index 1e1ecc0fc7..e57b08327b 100644 --- a/windows/nsis-plugins/src/driverlogic/driverlogic.cpp +++ b/windows/nsis-plugins/src/driverlogic/driverlogic.cpp @@ -1,4 +1,5 @@ #include <stdafx.h> +#include "../error.h" #include "context.h" #include <libcommon/string.h> #include <libcommon/valuemapper.h> @@ -52,11 +53,6 @@ void PinDll() // // Call this function once during startup. // -enum class InitializeStatus -{ - GENERAL_ERROR = 0, - SUCCESS, -}; void __declspec(dllexport) NSISCALL Initialize ( @@ -80,17 +76,17 @@ void __declspec(dllexport) NSISCALL Initialize } pushstring(L""); - pushint(InitializeStatus::SUCCESS); + pushint(NsisStatus::SUCCESS); } catch (std::exception &err) { pushstring(common::string::ToWide(err.what()).c_str()); - pushint(InitializeStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } catch (...) { pushstring(L"Unspecified error"); - pushint(InitializeStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } } @@ -227,11 +223,6 @@ void __declspec(dllexport) NSISCALL RemoveMullvadTap // By comparing with the previously captured baseline we're able to // identify the new adapter. // -enum class IdentifyNewAdapterStatus -{ - GENERAL_ERROR = 0, - SUCCESS -}; void __declspec(dllexport) NSISCALL IdentifyNewAdapter ( @@ -248,7 +239,7 @@ void __declspec(dllexport) NSISCALL IdentifyNewAdapter if (nullptr == g_context) { pushstring(L"Initialize() function was not called or was not successful"); - pushint(IdentifyNewAdapterStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); return; } @@ -259,17 +250,17 @@ void __declspec(dllexport) NSISCALL IdentifyNewAdapter auto adapter = g_context->getNewAdapter(); pushstring(adapter.alias.c_str()); - pushint(IdentifyNewAdapterStatus::SUCCESS); + pushint(NsisStatus::SUCCESS); } catch (std::exception &err) { pushstring(common::string::ToWide(err.what()).c_str()); - pushint(IdentifyNewAdapterStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } catch (...) { pushstring(L"Unspecified error"); - pushint(IdentifyNewAdapterStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } } @@ -279,11 +270,6 @@ void __declspec(dllexport) NSISCALL IdentifyNewAdapter // Updating the TAP driver may replace GUIDs and aliases. // Use this to restore the aliases to their baseline state. // -enum class RollbackTapAliasesStatus -{ - GENERAL_ERROR = 0, - SUCCESS -}; void __declspec(dllexport) NSISCALL RollbackTapAliases ( @@ -300,7 +286,7 @@ void __declspec(dllexport) NSISCALL RollbackTapAliases if (nullptr == g_context) { pushstring(L"Initialize() function was not called or was not successful"); - pushint(RollbackTapAliasesStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); return; } @@ -310,17 +296,17 @@ void __declspec(dllexport) NSISCALL RollbackTapAliases g_context->rollbackTapAliases(); pushstring(L""); - pushint(RollbackTapAliasesStatus::SUCCESS); + pushint(NsisStatus::SUCCESS); } catch (std::exception & err) { pushstring(common::string::ToWide(err.what()).c_str()); - pushint(RollbackTapAliasesStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } catch (...) { pushstring(L"Unspecified error"); - pushint(RollbackTapAliasesStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } } @@ -329,11 +315,6 @@ void __declspec(dllexport) NSISCALL RollbackTapAliases // // Call this function once during shutdown. // -enum class DeinitializeStatus -{ - GENERAL_ERROR = 0, - SUCCESS, -}; void __declspec(dllexport) NSISCALL Deinitialize ( @@ -352,17 +333,17 @@ void __declspec(dllexport) NSISCALL Deinitialize delete g_context; pushstring(L""); - pushint(InitializeStatus::SUCCESS); + pushint(NsisStatus::SUCCESS); } catch (std::exception &err) { pushstring(common::string::ToWide(err.what()).c_str()); - pushint(DeinitializeStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } catch (...) { pushstring(L"Unspecified error"); - pushint(DeinitializeStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } g_context = nullptr; diff --git a/windows/nsis-plugins/src/error.h b/windows/nsis-plugins/src/error.h new file mode 100644 index 0000000000..c254ed3af7 --- /dev/null +++ b/windows/nsis-plugins/src/error.h @@ -0,0 +1,20 @@ +#pragma once + +// +// Generic return codes for NSIS plugins +// +// +// Returned on the stack: +// +// GENERAL_ERROR: Most functions return an error message. +// SUCCESS: Most functions return an empty string. +// +// NOTE: While this is generally true, some functions only +// push a status code to the stack. +// + +enum NsisStatus +{ + GENERAL_ERROR = 0, + SUCCESS, +}; diff --git a/windows/nsis-plugins/src/pathedit/pathedit.cpp b/windows/nsis-plugins/src/pathedit/pathedit.cpp index 09f0ddbfec..8d371ce6d0 100644 --- a/windows/nsis-plugins/src/pathedit/pathedit.cpp +++ b/windows/nsis-plugins/src/pathedit/pathedit.cpp @@ -2,6 +2,7 @@ // #include "stdafx.h" +#include "../error.h" #include <windows.h> #include <libcommon/string.h> #include <libcommon/registry/registry.h> @@ -96,12 +97,6 @@ std::wstring ReadPathValue(const RegistryKey &pathKey) // AddSysEnvPath "C:\path\to\directory" // -enum class EnvPathStatus -{ - GENERAL_ERROR = 0, - SUCCESS -}; - void __declspec(dllexport) NSISCALL AddSysEnvPath ( HWND hwndParent, @@ -129,7 +124,7 @@ void __declspec(dllexport) NSISCALL AddSysEnvPath if (SysPathExists(path, pathToAppend)) { pushstring(L""); - pushint(EnvPathStatus::SUCCESS); + pushint(NsisStatus::SUCCESS); return; } @@ -148,17 +143,17 @@ void __declspec(dllexport) NSISCALL AddSysEnvPath ); pushstring(L""); - pushint(EnvPathStatus::SUCCESS); + pushint(NsisStatus::SUCCESS); } catch (const std::exception &err) { pushstring(common::string::ToWide(err.what()).c_str()); - pushint(EnvPathStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } catch (...) { pushstring(L"Unspecified error"); - pushint(EnvPathStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } } @@ -214,16 +209,16 @@ void __declspec(dllexport) NSISCALL RemoveSysEnvPath } pushstring(L""); - pushint(EnvPathStatus::SUCCESS); + pushint(NsisStatus::SUCCESS); } catch (const std::exception &err) { pushstring(common::string::ToWide(err.what()).c_str()); - pushint(EnvPathStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } catch (...) { pushstring(L"Unspecified error"); - pushint(EnvPathStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } } diff --git a/windows/nsis-plugins/src/registry/registry.cpp b/windows/nsis-plugins/src/registry/registry.cpp index e94c0540ee..7d60e3cb9c 100644 --- a/windows/nsis-plugins/src/registry/registry.cpp +++ b/windows/nsis-plugins/src/registry/registry.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#include "../error.h" #include <windows.h> #include <libcommon/string.h> #include <libcommon/registry/registry.h> @@ -43,11 +44,6 @@ std::wstring PopString() // // MoveKey "HKLM\Software\A" "HKLM\Software\B" // -enum class MoveKeyStatus -{ - GENERAL_ERROR = 0, - SUCCESS -}; void __declspec(dllexport) NSISCALL MoveKey ( @@ -73,16 +69,16 @@ void __declspec(dllexport) NSISCALL MoveKey typedDestination.subkey(), common::registry::RegistryView::Force64); pushstring(L""); - pushint(MoveKeyStatus::SUCCESS); + pushint(NsisStatus::SUCCESS); } catch (std::exception &err) { pushstring(common::string::ToWide(err.what()).c_str()); - pushint(MoveKeyStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } catch (...) { pushstring(L"Unspecified error"); - pushint(MoveKeyStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } } diff --git a/windows/nsis-plugins/src/tray/tray.cpp b/windows/nsis-plugins/src/tray/tray.cpp index 3e52ea6e1e..dc5c02ea91 100644 --- a/windows/nsis-plugins/src/tray/tray.cpp +++ b/windows/nsis-plugins/src/tray/tray.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#include "../error.h" #include "trayparser.h" #include "trayjuggler.h" #include "resource.h" @@ -116,11 +117,6 @@ void UpdateRegistry(common::registry::RegistryKey ®key, const std::wstring &v // Ensure the GUI's tray icon is placed in the visible part of the notification area. // This is accomplished by updating a binary blob in the registry. // -enum class PromoteTrayIconStatus -{ - GENERAL_ERROR = 0, - SUCCESS -}; void __declspec(dllexport) NSISCALL PromoteTrayIcon ( @@ -173,16 +169,16 @@ void __declspec(dllexport) NSISCALL PromoteTrayIcon } pushstring(L""); - pushint(PromoteTrayIconStatus::SUCCESS); + pushint(NsisStatus::SUCCESS); } catch (std::exception &err) { pushstring(common::string::ToWide(err.what()).c_str()); - pushint(PromoteTrayIconStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } catch (...) { pushstring(L"Unspecified error"); - pushint(PromoteTrayIconStatus::GENERAL_ERROR); + pushint(NsisStatus::GENERAL_ERROR); } } |
