2022-07-06 17:51:51 +00:00
|
|
|
|
/*
|
|
|
|
|
* settings.c
|
|
|
|
|
*
|
|
|
|
|
* Created on: 6 июл. 2022 г.
|
|
|
|
|
* Author: alexander
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <iup.h>
|
2022-07-07 16:35:48 +00:00
|
|
|
|
|
2022-07-06 17:51:51 +00:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
#include "arguments.h"
|
2022-07-07 16:35:48 +00:00
|
|
|
|
#include "node_settings.h"
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
void toggleActive(Ihandle *self, char *name)
|
|
|
|
|
{
|
|
|
|
|
IupSetInt(IupGetDialogChild(self, name), "ACTIVE", !IupGetInt(IupGetDialogChild(self, name), "ACTIVE"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-07-07 16:35:48 +00:00
|
|
|
|
static int settingsClose(Ihandle *self)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
resetChangeSettings();
|
2022-07-07 16:35:48 +00:00
|
|
|
|
IupSetAttribute(IupGetDialog(self), "SIMULATEMODAL", "OFF");
|
|
|
|
|
IupHide(IupGetDialog(self));
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int settingsSave(Ihandle *self)
|
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
saveChangeSettings();
|
2022-07-07 16:35:48 +00:00
|
|
|
|
IupSetAttribute(IupGetDialog(self), "SIMULATEMODAL", "OFF");
|
|
|
|
|
IupHide(IupGetDialog(self));
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int settingsTglMultimonitor(Ihandle *self)
|
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
changeParameter(PARAMETER_MULTIMONITOR);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int settingsTglFullscreen(Ihandle *self)
|
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
changeParameter(PARAMETER_FULLSCREEN);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-07 16:35:48 +00:00
|
|
|
|
static int settingsTglAuthentication(Ihandle *self)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
changeParameter(PARAMETER_AUTHENTICATION);
|
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int settingsUseSecurity(Ihandle *self)
|
|
|
|
|
{
|
|
|
|
|
changeParameter(PARAMETER_SECURITY);
|
|
|
|
|
toggleActive(self, "SECURITY_TLS");
|
|
|
|
|
toggleActive(self, "SECURITY_RDP");
|
|
|
|
|
toggleActive(self, "SECURITY_NLA");
|
|
|
|
|
toggleActive(self, "SECURITY_EXT");
|
|
|
|
|
|
2022-07-07 16:35:48 +00:00
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
static void settingsChooseSecurity(Ihandle *self, int state)
|
|
|
|
|
{
|
|
|
|
|
if (state == 1)
|
|
|
|
|
{
|
|
|
|
|
int tool_index = IupGetInt(self, "TOOLINDEX");
|
|
|
|
|
switch (tool_index)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
{
|
|
|
|
|
changeValue(PARAMETER_SECURITY, VALUE_SECURITY_TLS);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 1:
|
|
|
|
|
{
|
|
|
|
|
changeValue(PARAMETER_SECURITY, VALUE_SECURITY_RDP);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2:
|
|
|
|
|
{
|
|
|
|
|
changeValue(PARAMETER_SECURITY, VALUE_SECURITY_NLA);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 3:
|
|
|
|
|
{
|
|
|
|
|
changeValue(PARAMETER_SECURITY, VALUE_SECURITY_EXT);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-07 16:35:48 +00:00
|
|
|
|
/*
|
|
|
|
|
* Блок настроек
|
|
|
|
|
*/
|
2022-07-08 16:45:45 +00:00
|
|
|
|
static Ihandle* settingsBoxCheckbox()
|
2022-07-07 16:35:48 +00:00
|
|
|
|
{
|
|
|
|
|
Ihandle *tglMultimonitor, *tglFullscreen, *tglAuthentication;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
tglMultimonitor = IupToggle("Несколько мониторов", NULL);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
tglFullscreen = IupToggle("На весь экран", NULL);
|
2022-07-07 16:35:48 +00:00
|
|
|
|
tglAuthentication = IupToggle("Аутентификация", NULL);
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
IupSetInt(tglMultimonitor, "VALUE", getSetParameter(PARAMETER_MULTIMONITOR));
|
|
|
|
|
IupSetInt(tglFullscreen, "VALUE", getSetParameter(PARAMETER_FULLSCREEN));
|
|
|
|
|
IupSetInt(tglAuthentication, "VALUE", getSetParameter(PARAMETER_AUTHENTICATION));
|
2022-07-07 16:35:48 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
return IupHbox(IupSetAttributes(IupFrame(IupVbox(
|
2022-07-07 16:35:48 +00:00
|
|
|
|
IupSetCallbacks(IupSetAttributes(tglMultimonitor, "NAME=SETTINGS_TGL_MULTIMONITOR"), "ACTION",
|
|
|
|
|
(Icallback) settingsTglMultimonitor, NULL),
|
|
|
|
|
IupSetCallbacks(IupSetAttributes(tglFullscreen, "NAME=SETTINGS_TGL_FULLSCREEN"), "ACTION",
|
|
|
|
|
(Icallback) settingsTglFullscreen, NULL),
|
|
|
|
|
IupSetCallbacks(IupSetAttributes(tglAuthentication, "NAME=SETTINGS_TGL_AUTHENTICATION"), "ACTION",
|
|
|
|
|
(Icallback) settingsTglAuthentication, NULL),
|
2022-07-08 16:45:45 +00:00
|
|
|
|
NULL)), "TITLE=\"Общие\""), NULL);
|
2022-07-07 16:35:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
static Ihandle* settingsBoxSecurity()
|
2022-07-07 16:35:48 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
Ihandle *tglSecurity;
|
|
|
|
|
Ihandle *tglTLS, *tglRDP, *tglNLA, *tglEXT;
|
|
|
|
|
Ihandle *grdSecurity;
|
|
|
|
|
|
|
|
|
|
tglSecurity = IupToggle("Использовать", NULL);
|
|
|
|
|
IupSetInt(tglSecurity, "VALUE", getSetParameter(PARAMETER_SECURITY));
|
|
|
|
|
IupSetCallback(tglSecurity, "ACTION", (Icallback)settingsUseSecurity);
|
|
|
|
|
|
|
|
|
|
tglTLS = IupToggle("TLS", NULL);
|
|
|
|
|
IupSetInt(tglTLS, "VALUE", getSetValue(PARAMETER_SECURITY, VALUE_SECURITY_TLS));
|
|
|
|
|
IupSetInt(tglTLS, "ACTIVE", getSetParameter(PARAMETER_SECURITY));
|
|
|
|
|
tglRDP = IupToggle("RDP", NULL);
|
|
|
|
|
IupSetInt(tglRDP, "VALUE", getSetValue(PARAMETER_SECURITY, VALUE_SECURITY_RDP));
|
|
|
|
|
IupSetInt(tglRDP, "ACTIVE", getSetParameter(PARAMETER_SECURITY));
|
|
|
|
|
tglNLA = IupToggle("NLA", NULL);
|
|
|
|
|
IupSetInt(tglNLA, "VALUE", getSetValue(PARAMETER_SECURITY, VALUE_SECURITY_NLA));
|
|
|
|
|
IupSetInt(tglNLA, "ACTIVE", getSetParameter(PARAMETER_SECURITY));
|
|
|
|
|
tglEXT = IupToggle("EXT", NULL);
|
|
|
|
|
IupSetInt(tglEXT, "VALUE", getSetValue(PARAMETER_SECURITY, VALUE_SECURITY_EXT));
|
|
|
|
|
IupSetInt(tglEXT, "ACTIVE", getSetParameter(PARAMETER_SECURITY));
|
|
|
|
|
|
|
|
|
|
grdSecurity = IupRadio(IupGridBox(
|
|
|
|
|
IupSetCallbacks(IupSetAttributes(tglTLS, "NAME=SECURITY_TLS, TOOLINDEX=0"), "ACTION", (Icallback)settingsChooseSecurity, NULL),
|
|
|
|
|
IupSetCallbacks(IupSetAttributes(tglRDP, "NAME=SECURITY_RDP, TOOLINDEX=1"), "ACTION", (Icallback)settingsChooseSecurity, NULL),
|
|
|
|
|
IupSetCallbacks(IupSetAttributes(tglNLA, "NAME=SECURITY_NLA, TOOLINDEX=2"), "ACTION", (Icallback)settingsChooseSecurity, NULL),
|
|
|
|
|
IupSetCallbacks(IupSetAttributes(tglEXT, "NAME=SECURITY_EXT, TOOLINDEX=3"), "ACTION", (Icallback)settingsChooseSecurity, NULL),
|
|
|
|
|
NULL));
|
|
|
|
|
|
|
|
|
|
return IupHbox(IupSetAttributes(IupFrame(IupVbox(tglSecurity, grdSecurity, NULL)), "TITLE=\"Протокол безопасности\", MARGIN=15x10"), NULL);
|
|
|
|
|
}
|
2022-07-07 16:35:48 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
static Ihandle* settingsHorizontalBox()
|
|
|
|
|
{
|
|
|
|
|
return IupSetAttributes(IupHbox(settingsBoxCheckbox(), settingsBoxSecurity(), NULL), "MARGIN=5x5");
|
2022-07-07 16:35:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Блок кнопок
|
|
|
|
|
*/
|
2022-07-08 16:45:45 +00:00
|
|
|
|
static Ihandle* settingsHorizontalBoxButtons()
|
2022-07-07 16:35:48 +00:00
|
|
|
|
{
|
|
|
|
|
Ihandle *btnSave, *btnClose;
|
|
|
|
|
|
|
|
|
|
btnSave = IupButton("Сохранить", NULL);
|
|
|
|
|
IupSetAttribute(btnSave, "NAME", "SETTIGS_BTN_SAVE");
|
|
|
|
|
IupSetAttribute(btnSave, "TIP", "Сохранить настройки");
|
|
|
|
|
|
|
|
|
|
btnClose = IupButton("Закрыть", NULL);
|
|
|
|
|
IupSetAttribute(btnClose, "NAME", "SETTIGS_BTN_CLOSE");
|
2022-07-08 16:45:45 +00:00
|
|
|
|
IupSetAttribute(btnClose, "TIP", "Отменить изменения");
|
2022-07-07 16:35:48 +00:00
|
|
|
|
|
|
|
|
|
IupSetHandle("btnClosePointer", btnClose);
|
|
|
|
|
|
|
|
|
|
return IupSetAttributes(
|
|
|
|
|
IupHbox(IupFill(), IupSetCallbacks(btnSave, "ACTION", (Icallback) settingsSave, NULL),
|
|
|
|
|
IupSetCallbacks(btnClose, "ACTION", (Icallback) settingsClose, NULL), IupFill(),
|
|
|
|
|
NULL), "ALIGNMENT=ACENTER:ACENTER, GAP=10, MARGIN=10x10");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int settingsMainWindow(Ihandle *self)
|
|
|
|
|
{
|
|
|
|
|
Ihandle *dlg;
|
|
|
|
|
Ihandle *vBoxMain;
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
vBoxMain = IupSetAttributes(IupVbox(settingsHorizontalBox(), settingsHorizontalBoxButtons(), NULL), "NMARGIN=2x2, ALIGNMENT=ACENTER");
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
|
|
|
|
dlg = IupDialog(vBoxMain);
|
|
|
|
|
IupSetAttribute(dlg, "TITLE", "Настройки");
|
2022-07-07 16:35:48 +00:00
|
|
|
|
IupSetCallback(
|
|
|
|
|
IupSetAttributes(dlg,
|
|
|
|
|
"ICON=icon, DIALOGFRAME=ON, SIMULATEMODAL=ON, DEFAULTESC=btnClosePointer, TOPMOST=YES, BRINGFRONT=YES, NAME=SETTINGS_MAIN_WINDOW"),
|
|
|
|
|
"CLOSE_CB", (Icallback) settingsClose);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
|
|
|
|
IupShowXY(dlg, IUP_CURRENT, IUP_CURRENT);
|
|
|
|
|
|
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|