Добавлена возможность использования мультипараметров

This commit is contained in:
Alexander Zhirov 2022-07-08 19:45:45 +03:00
parent 3b6a0a433a
commit 5a6aef9424
10 changed files with 583 additions and 353 deletions

View File

@ -8,51 +8,51 @@
#include <stdlib.h>
#include "arguments.h"
#include "node_settings.h"
#include "concat.h"
void settingsLoad()
{
settingsAddKey(PARAMETER_XFREERDP, "xfreerdp", false, true);
settingsAddKey(PARAMETER_SERVER, "/v:", true, true);
settingsAddKey(PARAMETER_USERNAME, "/u:", true, true);
settingsAddKey(PARAMETER_PASSWORD, "/p:", true, true);
settingsAddKey(PARAMETER_MULTIMONITOR, "/multimon", false, true);
settingsAddKey(PARAMETER_FULLSCREEN, "/f", false, true);
settingsAddKey(PARAMETER_AUTHENTICATION, "-authentication", false, true);
settingsAddKey(PARAMETER_SECURITY, "/sec:", false, true);
// settingsAddKey(PARAMETER_SECURITY_TLS, "-authentication", false, true);
// settingsAddKey(PARAMETER_SECURITY_RDP, "-authentication", false, true);
// settingsAddKey(PARAMETER_SECURITY_NLA, "-authentication", false, true);
// settingsAddKey(PARAMETER_SECURITY_EXT, "-authentication", false, true);
addParameterKey(PARAMETER_XFREERDP, "xfreerdp", true, true);
addParameterKey(PARAMETER_SERVER, "/v:", true, true);
addParameterKey(PARAMETER_USERNAME, "/u:", true, true);
addParameterKey(PARAMETER_PASSWORD, "/p:", true, true);
addParameterKey(PARAMETER_MULTIMONITOR, "/multimon", true, true);
addParameterKey(PARAMETER_FULLSCREEN, "/f", true, true);
addParameterKey(PARAMETER_AUTHENTICATION, "-authentication", true, true);
addParameterKey(PARAMETER_SECURITY, "/sec:", true, true);
addParameterValue(PARAMETER_SECURITY, VALUE_SECURITY_TLS, "tls", true);
addParameterValue(PARAMETER_SECURITY, VALUE_SECURITY_RDP, "rdp", false);
addParameterValue(PARAMETER_SECURITY, VALUE_SECURITY_NLA, "nla", false);
addParameterValue(PARAMETER_SECURITY, VALUE_SECURITY_EXT, "ext", false);
}
Arguments *buildArguments()
void settingsFree()
{
Arguments *args = (Arguments *)malloc(sizeof(Arguments));
args->argc = settings.countEnable;
args->argv = (char **)malloc(sizeof(char *) * settings.countEnable);
Node *head = settings.next;
freeSettings();
}
for (size_t i = 0; i < settings.countEnable; head = head->next)
void buildArguments(Arguments *args)
{
args->argc = 0;
args->argv = (char **)malloc(sizeof(char *) * settings.countParameterSet);
for (NodeParameter *head = settings.parameter; head; head = head->next)
{
if (head->enable)
if (head->set)
{
if (head->data->isValue)
{
args->argv[i++] = head->data->fullArgument;
}
if (head->value)
args->argv[(args->argc)++] = concat(head->key, getSetNodeValue(head)->current);
else
{
args->argv[i++] = head->data->key;
}
args->argv[(args->argc)++] = concat(head->key, NULL);
}
}
return args;
}
void freeArguments(Arguments *args)
{
for (int i = 0; i < args->argc; ++i)
{
free(args->argv[i]);
}
free(args->argv);
free(args);
}

View File

@ -14,8 +14,10 @@ typedef struct
char **argv;
} Arguments;
void buildArguments(Arguments *args);
void freeArguments(Arguments *args);
void settingsLoad();
Arguments *buildArguments();
void freeArguments();
void settingsFree();
#endif /* ARGUMENTS_H_ */

View File

@ -16,7 +16,7 @@ char* concat(char *s1, char *s2)
size_t len1 = s1 ? strlen(s1) : 0;
size_t len2 = s2 ? strlen(s2) : 0;
char *result = malloc(len1 + len2 + 1);
char *result = (char *)malloc(sizeof(char) * (len1 + len2 + 1));
if (!result)
{
@ -26,11 +26,11 @@ char* concat(char *s1, char *s2)
if (s1)
{
memcpy(result, s1, len1);
strcpy(result, s1);
}
if (s2)
{
memcpy(result + len1, s2, len2 + 1);
strcpy(result + len1, s2);
}
return result;

16
gui.c
View File

@ -22,18 +22,18 @@ static int guiExit(Ihandle *self)
static int guiConnect(Ihandle *self)
{
settingsSetValue(PARAMETER_SERVER, IupGetAttribute(IupGetDialogChild(self, "SERVER"), "LINEVALUE"));
settingsSetValue(PARAMETER_USERNAME, IupGetAttribute(IupGetDialogChild(self, "USER"), "LINEVALUE"));
settingsSetValue(PARAMETER_PASSWORD, IupGetAttribute(IupGetDialogChild(self, "PASSWORD"), "LINEVALUE"));
setParameterValue(PARAMETER_SERVER, VALUE_SERVER, IupGetAttribute(IupGetDialogChild(self, "SERVER"), "LINEVALUE"));
setParameterValue(PARAMETER_USERNAME, VALUE_USERNAME, IupGetAttribute(IupGetDialogChild(self, "USER"), "LINEVALUE"));
setParameterValue(PARAMETER_PASSWORD, VALUE_PASSWORD, IupGetAttribute(IupGetDialogChild(self, "PASSWORD"), "LINEVALUE"));
Arguments *args = buildArguments();
for (int i = 0; i < args->argc; ++i)
Arguments args;
buildArguments(&args);
for (int i = 0; i < args.argc; ++i)
{
printf("%s\n", args->argv[i]);
printf("%s\n", args.argv[i]);
}
printf("\n");
freeArguments(args);
freeArguments(&args);
return IUP_DEFAULT;
}

3
main.c
View File

@ -1,8 +1,9 @@
#include <stdlib.h>
#include "gui.h"
#include "node_settings.h"
#include "arguments.h"
#include <stdio.h>
int main(int argc, char **argv)
{
settingsLoad();

View File

@ -7,40 +7,91 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "node_settings.h"
#include "concat.h"
HeadNode settings = {0, 0, NULL};
NodeHead settings =
{ NULL, 0 };
static Node* settingsCreateNode()
static NodeValue* newNodeValue(Value name, char *current, bool set)
{
Node *node = (Node*) malloc(sizeof(Node));
node->parameter = PARAMETER_NULL;
NodeValue *node = (NodeValue*) malloc(sizeof(NodeValue));
node->name = name;
node->set = set;
node->change = false;
node->next = NULL;
node->data = (SettingsData*)malloc(sizeof(SettingsData));
node->data->key = NULL;
node->data->value = NULL;
node->data->fullArgument = NULL;
node->current = (char*) malloc(sizeof(char) * strlen(current));
strcpy(node->current, current);
return node;
}
/*
* Если передан параметр PARAMETER_NULL, то возвращается последний действующий узел.
* Если возврат NULL, то ни одного узла не существует.
* Если передан параметр отличный от PARAMETER_NULL, то ищется существующий узел с этим параметром.
* Если возврат NULL, то узла с таким параметром не найдено.
*/
Node *settingsGetNode(SettingsParameters parameter)
static void freeNodeValue(NodeValue *node)
{
if (!settings.countAll)
if (node)
{
return NULL;
free(node->current);
free(node);
}
}
Node *head = settings.next;
static void freeAllNodeValue(NodeValue *node)
{
NodeValue *next = NULL;
for (NodeValue *head = node; head; head = next)
{
next = head->next;
freeNodeValue(head);
}
}
if (parameter == PARAMETER_NULL)
static NodeParameter* newNodeParameter(Parameter name, char *key, bool set, bool singleValue)
{
NodeParameter *node = (NodeParameter*) malloc(sizeof(NodeParameter));
node->name = name;
node->set = set;
node->change = false;
node->value = NULL;
node->countValue = 0;
node->singleValue = singleValue;
node->next = NULL;
node->key = (char*) malloc(sizeof(char) * strlen(key));
strcpy(node->key, key);
return node;
}
static void freeNodeParameter(NodeParameter *node)
{
if (node)
{
freeAllNodeValue(node->value);
free(node->key);
free(node);
}
}
static void freeAllNodeParameter(NodeParameter *node)
{
NodeParameter *next = NULL;
for (NodeParameter *head = node; head; head = next)
{
next = head->next;
freeNodeParameter(head);
}
}
///////////////////////////////
static NodeParameter* getLastNodeParameter()
{
NodeParameter *head = settings.parameter;
if (head)
{
while (head->next)
{
@ -49,9 +100,14 @@ Node *settingsGetNode(SettingsParameters parameter)
return head;
}
for (; head; head = head->next)
return NULL;
}
static NodeParameter* getNodeParameter(Parameter name)
{
for (NodeParameter *head = settings.parameter; head; head = head->next)
{
if (head->parameter == parameter)
if (head->name == name)
{
return head;
}
@ -60,206 +116,318 @@ Node *settingsGetNode(SettingsParameters parameter)
return NULL;
}
void settingsAddKey(SettingsParameters parameter, char *key, bool isValue, bool enable)
void addParameterKey(Parameter name, char *key, bool set, bool singleValue)
{
Node *newNode = settingsCreateNode();
newNode->parameter = parameter;
newNode->enable = enable;
newNode->change = false;
SettingsData *data = newNode->data;
data->isValue = isValue;
size_t len = strlen(key);
data->key = (char *) malloc(sizeof(char) * (len + 1));
memcpy(data->key, key, len);
Node *lastNode = settingsGetNode(PARAMETER_NULL);
if (lastNode)
if (!settings.parameter)
{
lastNode->next = newNode;
}
else
{
settings.next = newNode;
}
if (enable)
{
++settings.countEnable;
}
++settings.countAll;
}
void settingsSetValue(SettingsParameters parameter, char *value)
{
Node *currentNode = settingsGetNode(parameter);
if (!currentNode || !currentNode->data->isValue)
{
return;
}
if (!strlen(value))
{
settingsSetEnable(parameter, false);
return;
}
else
{
settingsSetEnable(parameter, true);
}
SettingsData *data = currentNode->data;
if (data->value)
{
free(data->value);
}
if (data->fullArgument)
{
free(data->fullArgument);
}
size_t len = strlen(value);
data->value = (char *) malloc(sizeof(char) * (len + 1));
memcpy(data->value, value, len);
data->fullArgument = concat(data->key, value);
}
void settingsSetEnable(SettingsParameters parameter, bool enable)
{
Node *currentNode = settingsGetNode(parameter);
if (!currentNode)
{
return;
}
if (currentNode->enable && !enable)
{
--settings.countEnable;
}
else if (!currentNode->enable && enable)
{
++settings.countEnable;
}
currentNode->enable = enable;
}
void settingsToggleEnable(SettingsParameters parameter)
{
Node *currentNode = settingsGetNode(parameter);
if (!currentNode)
{
return;
}
if (currentNode->enable)
{
--settings.countEnable;
}
else
{
++settings.countEnable;
}
currentNode->enable = !currentNode->enable;
}
void settingsToggleChange(SettingsParameters parameter)
{
Node *currentNode = settingsGetNode(parameter);
if (!currentNode)
{
return;
}
currentNode->change = !currentNode->change;
}
void settingsResetChange()
{
if (!settings.countAll)
{
return;
}
for (Node *head = settings.next; head; head = head->next)
{
if (head->change)
settings.parameter = newNodeParameter(name, key, set, singleValue);
++settings.countParameter;
if (set)
{
head->change = false;
++settings.countParameterSet;
}
return;
}
NodeParameter *node = getNodeParameter(name);
if (node)
{
fprintf(stderr, "%s \"%s\" %s", "Параметр", key, "уже существует!\n");
}
else
{
node = getLastNodeParameter();
node->next = newNodeParameter(name, key, set, singleValue);
++settings.countParameter;
if (set)
{
++settings.countParameterSet;
}
}
}
void settingsSaveSettings()
static NodeValue* getLastNodeValue(NodeParameter *node)
{
if (!settings.countAll)
NodeValue *head = node->value;
if (head)
{
while (head->next)
{
head = head->next;
}
return head;
}
return NULL;
}
static NodeValue* getNodeValue(NodeParameter *node, Value name)
{
for (NodeValue *head = node->value; head; head = head->next)
{
if (head->name == name)
{
return head;
}
}
return NULL;
}
void addParameterValue(Parameter pName, Value vName, char *current, bool set)
{
NodeParameter *nodeParameter = getNodeParameter(pName);
if (!nodeParameter)
{
fprintf(stderr, "%s \"%s\" %s", "Параметр для значения", current, "не существует!\n");
return;
}
for (Node *head = settings.next; head; head = head->next)
if (!nodeParameter->value)
{
if (head->change)
nodeParameter->value = newNodeValue(vName, current, set);
++nodeParameter->countValue;
if (set)
{
head->change = false;
++nodeParameter->countValueSet;
}
return;
}
if (head->enable)
{
--settings.countEnable;
}
else
{
++settings.countEnable;
}
head->enable = !head->enable;
NodeValue *nodeValue = getNodeValue(nodeParameter, vName);
if (nodeValue)
{
fprintf(stderr, "%s \"%s\" %s", "Значение", current, "уже существует!\n");
}
else
{
nodeValue = getLastNodeValue(nodeParameter);
nodeValue->next = newNodeValue(vName, current, set);
++nodeParameter->countValue;
if (set)
{
++nodeParameter->countValueSet;
}
}
}
bool settingsGetEnable(SettingsParameters parameter)
void freeSettings()
{
Node *currentNode = settingsGetNode(parameter);
if (!currentNode)
if (settings.parameter)
{
freeAllNodeParameter(settings.parameter);
}
}
/////////////////////////////////////////////////////////////
NodeValue* getSetNodeValue(NodeParameter *node)
{
for (NodeValue *head = node->value; head; head = head->next)
{
if (head->set)
{
return head;
}
}
return NULL;
}
////////////////////////////////////////////////////////////////
void setParameterValue(Parameter pName, Value vName, char *current)
{
NodeParameter *nodeParameter = getNodeParameter(pName);
if (!nodeParameter)
{
fprintf(stderr, "%s \"%s\" %s", "Параметр для значения", current, "не существует!\n");
return;
}
size_t length = strlen(current);
if (!length)
{
if (nodeParameter->set)
{
nodeParameter->set = false;
--settings.countParameterSet;
}
return;
}
else
{
if (!nodeParameter->set)
{
nodeParameter->set = true;
++settings.countParameterSet;
}
}
if (!nodeParameter->value)
{
nodeParameter->value = newNodeValue(vName, current, true);
++nodeParameter->countValue;
++nodeParameter->countValueSet;
return;
}
NodeValue *nodeValue = getNodeValue(nodeParameter, vName);
if (nodeValue)
{
free(nodeValue->current);
nodeValue->current = (char*) malloc(sizeof(char) * length);
strcpy(nodeValue->current, current);
}
else
{
nodeValue = getLastNodeValue(nodeParameter);
nodeValue->next = newNodeValue(vName, current, true);
++nodeParameter->countValue;
++nodeParameter->countValueSet;
}
changeValue(pName, vName);
}
////////////////////////////////////////////////////////////////
void changeParameter(Parameter name)
{
NodeParameter *node = getNodeParameter(name);
node->change = !node->change;
}
void changeValue(Parameter pName, Value vName)
{
NodeParameter *pNode = getNodeParameter(pName);
for (NodeValue *head = pNode->value; head; head = head->next)
{
if (pNode->singleValue)
{
head->change = head->name == vName && !head->set;
}
else
{
// ДОРАБОТАТЬ НА ИСПОЛЬЗОВАНИЕ МНОГИХ ПАРАМЕТРОВ
head->change = head->name == vName;
}
}
}
static void saveChangeSingleValueSettings(NodeParameter *node)
{
NodeValue *nChange = NULL;
NodeValue *nSet = NULL;
for (NodeValue *head = node->value; head; head = head->next)
{
if (head->change)
{
nChange = head;
}
if (head->set)
{
nSet = head;
}
}
if (nChange)
{
nChange->change = false;
nChange->set = true;
nSet->set = false;
++node->countValueSet;
}
}
static void saveChangeValueSettings(NodeParameter *node)
{
for (NodeValue *head = node->value; head; head = head->next)
{
if (head->change)
{
head->change = false;
head->set = !head->set;
}
if (head->set)
{
++node->countValueSet;
}
}
}
void saveChangeSettings()
{
settings.countParameterSet = 0;
for (NodeParameter *pHead = settings.parameter; pHead; pHead = pHead->next)
{
if (pHead->change)
{
pHead->change = false;
pHead->set = !pHead->set;
}
if (pHead->set)
{
++settings.countParameterSet;
}
pHead->countValueSet = 0;
if (pHead->singleValue)
saveChangeSingleValueSettings(pHead);
else
saveChangeValueSettings(pHead);
}
}
void resetChangeSettings()
{
for (NodeParameter *pHead = settings.parameter; pHead; pHead = pHead->next)
{
pHead->change = false;
for (NodeValue *vHead = pHead->value; vHead; vHead = vHead->next)
{
vHead->change = false;
}
}
}
bool getSetParameter(Parameter name)
{
NodeParameter *node = getNodeParameter(name);
if (!node)
{
return false;
}
return currentNode->enable;
return node->set;
}
static void settingsFreeData(SettingsData *data)
bool getSetValue(Parameter pName, Value vName)
{
if (data->key)
NodeParameter *pNode = getNodeParameter(pName);
if (!pNode)
{
free(data->key);
return false;
}
if (data->value)
for (NodeValue *vNode = pNode->value; vNode; vNode = vNode->next)
{
free(data->value);
if (vNode->name == vName)
{
return vNode->set;
}
}
if (data->fullArgument)
{
free(data->fullArgument);
}
free(data);
}
void settingsFree()
{
if (!settings.countAll)
{
return;
}
Node *head = settings.next;
Node *current = NULL;
while (head->next)
{
current = head->next;
settingsFreeData(head->data);
free(head);
head = current;
}
settingsFreeData(head->data);
free(head);
settings.next = NULL;
return false;
}

View File

@ -10,58 +10,52 @@
#include <stdbool.h>
typedef enum
{
PARAMETER_NULL,
PARAMETER_XFREERDP,
PARAMETER_USERNAME,
PARAMETER_SERVER,
PARAMETER_PASSWORD,
PARAMETER_MULTIMONITOR,
PARAMETER_FULLSCREEN,
PARAMETER_AUTHENTICATION,
PARAMETER_SECURITY
} SettingsParameters;
#include "parameter.h"
#include "value.h"
typedef struct
typedef struct NodeValue
{
char *key;
char *value;
char *fullArgument;
bool isValue;
} SettingsData;
typedef struct Node
{
SettingsParameters parameter;
Value name;
bool set;
bool change;
bool enable;
SettingsData *data;
struct Node *next;
} Node;
char *current;
struct NodeValue *next;
} NodeValue;
typedef struct
typedef struct NodeParameter
{
size_t countAll;
size_t countEnable;
struct Node *next;
} HeadNode;
Parameter name;
bool set;
bool change;
char *key;
NodeValue *value;
bool singleValue;
size_t countValue;
size_t countValueSet;
struct NodeParameter *next;
} NodeParameter;
extern HeadNode settings;
typedef struct NodeHead
{
NodeParameter *parameter;
size_t countParameter;
size_t countParameterSet;
} NodeHead;
/*
* Работа с Node
*/
extern NodeHead settings;
Node *settingsGetNode(SettingsParameters parameter);
void settingsAddKey(SettingsParameters parameter, char *key, bool isValue, bool enable);
void settingsSetValue(SettingsParameters parameter, char *value);
void settingsSetEnable(SettingsParameters parameter, bool enable);
void settingsToggleEnable(SettingsParameters parameter);
void settingsToggleChange(SettingsParameters parameter);
bool settingsGetEnable(SettingsParameters parameter);
void settingsFree();
void settingsSaveSettings();
void settingsResetChange();
void addParameterKey(Parameter name, char *key, bool set, bool singleValue);
void addParameterValue(Parameter pName, Value vName, char *current, bool set);
void freeSettings();
NodeValue *getSetNodeValue(NodeParameter *node);
bool getSetParameter(Parameter name);
bool getSetValue(Parameter pName, Value vName);
void changeParameter(Parameter name);
void changeValue(Parameter pName, Value vName);
void saveChangeSettings();
void resetChangeSettings();
void setParameterValue(Parameter pName, Value vName, char *current);
#endif /* SETTINGS_H_ */

23
parameter.h Normal file
View File

@ -0,0 +1,23 @@
/*
* parameters.h
*
* Created on: 7 июл. 2022 г.
* Author: alexander
*/
#ifndef PARAMETERS_H_
#define PARAMETERS_H_
typedef enum
{
PARAMETER_XFREERDP,
PARAMETER_SERVER,
PARAMETER_USERNAME,
PARAMETER_PASSWORD,
PARAMETER_MULTIMONITOR,
PARAMETER_FULLSCREEN,
PARAMETER_AUTHENTICATION,
PARAMETER_SECURITY
} Parameter;
#endif /* PARAMETERS_H_ */

View File

@ -14,9 +14,15 @@
#include "arguments.h"
#include "node_settings.h"
void toggleActive(Ihandle *self, char *name)
{
IupSetInt(IupGetDialogChild(self, name), "ACTIVE", !IupGetInt(IupGetDialogChild(self, name), "ACTIVE"));
}
static int settingsClose(Ihandle *self)
{
settingsResetChange();
resetChangeSettings();
IupSetAttribute(IupGetDialog(self), "SIMULATEMODAL", "OFF");
IupHide(IupGetDialog(self));
return IUP_DEFAULT;
@ -24,7 +30,7 @@ static int settingsClose(Ihandle *self)
static int settingsSave(Ihandle *self)
{
settingsSaveSettings();
saveChangeSettings();
IupSetAttribute(IupGetDialog(self), "SIMULATEMODAL", "OFF");
IupHide(IupGetDialog(self));
return IUP_DEFAULT;
@ -32,112 +38,131 @@ static int settingsSave(Ihandle *self)
static int settingsTglMultimonitor(Ihandle *self)
{
settingsToggleChange(PARAMETER_MULTIMONITOR);
changeParameter(PARAMETER_MULTIMONITOR);
return IUP_DEFAULT;
}
static int settingsTglFullscreen(Ihandle *self)
{
settingsToggleChange(PARAMETER_FULLSCREEN);
changeParameter(PARAMETER_FULLSCREEN);
return IUP_DEFAULT;
}
static int settingsTglAuthentication(Ihandle *self)
{
settingsToggleChange(PARAMETER_AUTHENTICATION);
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");
return IUP_DEFAULT;
}
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;
}
}
}
}
/*
* Блок настроек
*/
static Ihandle* getFrmCheckbox()
static Ihandle* settingsBoxCheckbox()
{
Ihandle *tglMultimonitor, *tglFullscreen, *tglAuthentication;
tglMultimonitor = IupToggle("Мультиэкран", NULL);
tglMultimonitor = IupToggle("Несколько мониторов", NULL);
tglFullscreen = IupToggle("На весь экран", NULL);
tglAuthentication = IupToggle("Аутентификация", NULL);
IupSetInt(tglMultimonitor, "VALUE", settingsGetEnable(PARAMETER_MULTIMONITOR));
IupSetInt(tglFullscreen, "VALUE", settingsGetEnable(PARAMETER_FULLSCREEN));
IupSetInt(tglAuthentication, "VALUE", settingsGetEnable(PARAMETER_AUTHENTICATION));
IupSetInt(tglMultimonitor, "VALUE", getSetParameter(PARAMETER_MULTIMONITOR));
IupSetInt(tglFullscreen, "VALUE", getSetParameter(PARAMETER_FULLSCREEN));
IupSetInt(tglAuthentication, "VALUE", getSetParameter(PARAMETER_AUTHENTICATION));
return IupVbox(
return IupHbox(IupSetAttributes(IupFrame(IupVbox(
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),
NULL);
NULL)), "TITLE=\"Общие\""), NULL);
}
//void tool_action_cb(Ihandle *self, int state)
//{
// if (state == 1)
// {
// int tool_index = IupGetInt(self, "TOOLINDEX");
// switch (tool_index)
// {
// case 0:
// {
// settingsSetValue(PARAMETER_SECURITY, "tls");
// break;
// }
// case 1:
// {
// settingsSetValue(PARAMETER_SECURITY, "rdp");
// break;
// }
// case 2:
// {
// settingsSetValue(PARAMETER_SECURITY, "nla");
// break;
// }
// case 3:
// {
// settingsSetValue(PARAMETER_SECURITY, "ext");
// break;
// }
// }
// }
//}
//
//static Ihandle* getFrmSecurity()
//{
// Ihandle *frmSettings;
// Ihandle *grdSecurity;
//
// grdSecurity = IupGridBox(
// IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TITLE=TLS, TOOLINDEX=0, VALUE=ON"), "ACTION", (Icallback)tool_action_cb, NULL),
// IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TITLE=RDP, TOOLINDEX=1"), "ACTION", (Icallback)tool_action_cb, NULL),
// IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TITLE=NLA, TOOLINDEX=2"), "ACTION", (Icallback)tool_action_cb, NULL),
// IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TITLE=EXT, TOOLINDEX=3"), "ACTION", (Icallback)tool_action_cb, NULL),
// NULL);
//
//// tglTLS = IupToggle("TLS", NULL);
//// tglRDP = IupToggle("RDP", NULL);
//// tglNLA = IupToggle("NLA", NULL);
//// tglEXT = IupToggle("EXT", NULL);
//
// frmSettings = IupSetAttributes(IupFrame(IupSetAttributes(getFrmCheckbox(), "MARGIN=3x2, GAP=2, ALIGNMENT=ALEFT")), "TITLE=\"Настройки\"");
//
// return frmSettings;
//}
static Ihandle* getHorBoxSettings()
static Ihandle* settingsBoxSecurity()
{
Ihandle *frmSettings;
Ihandle *tglSecurity;
Ihandle *tglTLS, *tglRDP, *tglNLA, *tglEXT;
Ihandle *grdSecurity;
frmSettings = IupSetAttributes(IupFrame(IupSetAttributes(getFrmCheckbox(), "MARGIN=3x2, GAP=2, ALIGNMENT=ALEFT")), "TITLE=\"Настройки\"");
return IupHbox(frmSettings, NULL);
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);
}
static Ihandle* settingsHorizontalBox()
{
return IupSetAttributes(IupHbox(settingsBoxCheckbox(), settingsBoxSecurity(), NULL), "MARGIN=5x5");
}
/*
* Блок кнопок
*/
static Ihandle* getHorBoxButtons()
static Ihandle* settingsHorizontalBoxButtons()
{
Ihandle *btnSave, *btnClose;
@ -147,6 +172,7 @@ static Ihandle* getHorBoxButtons()
btnClose = IupButton("Закрыть", NULL);
IupSetAttribute(btnClose, "NAME", "SETTIGS_BTN_CLOSE");
IupSetAttribute(btnClose, "TIP", "Отменить изменения");
IupSetHandle("btnClosePointer", btnClose);
@ -161,7 +187,7 @@ int settingsMainWindow(Ihandle *self)
Ihandle *dlg;
Ihandle *vBoxMain;
vBoxMain = IupSetAttributes(IupVbox(getHorBoxSettings(), getHorBoxButtons(), NULL), "NMARGIN=2x2, ALIGNMENT=ACENTER");
vBoxMain = IupSetAttributes(IupVbox(settingsHorizontalBox(), settingsHorizontalBoxButtons(), NULL), "NMARGIN=2x2, ALIGNMENT=ACENTER");
dlg = IupDialog(vBoxMain);
IupSetAttribute(dlg, "TITLE", "Настройки");

16
value.h Normal file
View File

@ -0,0 +1,16 @@
/*
* value.h
*
* Created on: 8 июл. 2022 г.
* Author: alexander
*/
#ifndef VALUE_H_
#define VALUE_H_
typedef enum
{
VALUE_SERVER, VALUE_USERNAME, VALUE_PASSWORD, VALUE_SECURITY_TLS, VALUE_SECURITY_RDP, VALUE_SECURITY_NLA, VALUE_SECURITY_EXT,
} Value;
#endif /* VALUE_H_ */