1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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;
}
|