diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-25 17:33:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-11-25 17:34:10 +0000 |
commit | 83ba6762cc43d9db581b979bb5e3445669e46cc2 (patch) | |
tree | 2e69833b43f791ed253a7a20318b767ebe56cdb8 /src/claim/ui.c | |
parent | Releasing debian version 1.47.5-1. (diff) | |
download | netdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.tar.xz netdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.zip |
Merging upstream version 2.0.3+dfsg (Closes: #923993, #1042533, #1045145).
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/claim/ui.c')
-rw-r--r-- | src/claim/ui.c | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/claim/ui.c b/src/claim/ui.c new file mode 100644 index 000000000..30a001d0b --- /dev/null +++ b/src/claim/ui.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#define UNICODE +#define _UNICODE +#include <windows.h> +#include "richedit.h" +#include "tchar.h" +#include "main.h" + +static LPCTSTR szWindowClass = _T("DesktopApp"); + +static HINSTANCE hInst; +static HWND hToken; +static HWND hRoom; + +LRESULT CALLBACK WndProc(HWND hNetdatawnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + PAINTSTRUCT ps; + HDC hdc; + LPCTSTR topMsg[] = { L" Help", + L" ", + L"In this initial version of the software, there are no fields for data", + L" entry. To claim your agent, you must use the following options:", + L" ", + L"/T TOKEN: The cloud token;", + L"/R ROOMS: A list of rooms to claim;", + L"/P PROXY: The proxy information;", + L"/U URL : The cloud URL;", + L"/I : Use insecure connection;", + L"/F File : file to store cloud info;" + }; + + switch (message) + { + case WM_PAINT: { + hdc = BeginPaint(hNetdatawnd, &ps); + + int i; + for (i = 0; i < sizeof(topMsg) / sizeof(LPCTSTR); i++) { + TextOut(hdc, 5, 5 + 15*i, topMsg[i], wcslen(topMsg[i])); + } + EndPaint(hNetdatawnd, &ps); + break; + } + case WM_COMMAND: + case WM_DESTROY: { + PostQuitMessage(0); + break; + } + default: { + return DefWindowProc(hNetdatawnd, message, wParam, lParam); + break; + } + } + + return 0; +} + +int netdata_claim_window_loop(HINSTANCE hInstance, int nCmdShow) +{ + WNDCLASSEX wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(wcex.hInstance, MAKEINTRESOURCEW(11)); + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = NULL; + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, IDI_APPLICATION); + + if (!RegisterClassEx(&wcex)) { + MessageBoxW(NULL, L"Call to RegisterClassEx failed!", L"Error", 0); + return 1; + } + + hInst = hInstance; + + HWND hNetdatawnd = CreateWindowExW(WS_EX_OVERLAPPEDWINDOW, + szWindowClass, + L"Netdata Claim", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, + 460, 240, + NULL, + NULL, + hInstance, + NULL + ); + + if (!hNetdatawnd) { + MessageBoxW(NULL, L"Call to CreateWindow failed!", L"Error", 0); + return 1; + } + + ShowWindow(hNetdatawnd, nCmdShow); + UpdateWindow(hNetdatawnd); + + MSG msg; + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return (int) msg.wParam; +} |