2022-07-06 17:51:51 +00:00
|
|
|
|
/*
|
|
|
|
|
* arguments.c
|
|
|
|
|
*
|
|
|
|
|
* Created on: 6 июл. 2022 г.
|
|
|
|
|
* Author: alexander
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "arguments.h"
|
2022-07-07 16:35:48 +00:00
|
|
|
|
#include "node_settings.h"
|
2022-07-08 16:45:45 +00:00
|
|
|
|
#include "concat.h"
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-11 17:06:05 +00:00
|
|
|
|
#include "xrandr.h"
|
|
|
|
|
|
2022-07-06 17:51:51 +00:00
|
|
|
|
void settingsLoad()
|
|
|
|
|
{
|
2022-07-11 17:06:05 +00:00
|
|
|
|
addParameterKey(PARAMETER_XFREERDP, "xfreerdp", true, true, NULL, NULL);
|
|
|
|
|
addParameterKey(PARAMETER_SERVER, "/v:", true, true, NULL, NULL);
|
|
|
|
|
addParameterKey(PARAMETER_USERNAME, "/u:", true, true, NULL, NULL);
|
|
|
|
|
addParameterKey(PARAMETER_PASSWORD, "/p:", true, true, NULL, NULL);
|
2022-07-13 05:58:34 +00:00
|
|
|
|
addParameterKey(PARAMETER_CERTIGNORE, "/cert-ignore", true, true, NULL, NULL);
|
2022-07-11 17:06:05 +00:00
|
|
|
|
addParameterKey(PARAMETER_THEMES, "-themes", false, true, NULL, NULL);
|
|
|
|
|
addParameterKey(PARAMETER_WALLPAPER, "-wallpaper", false, true, NULL, NULL);
|
2022-07-13 05:58:34 +00:00
|
|
|
|
addParameterKey(PARAMETER_ENCRYPTION, "-encryption", false, true, NULL, NULL);
|
|
|
|
|
addParameterKey(PARAMETER_FONTS, "-fonts", false, true, NULL, NULL);
|
|
|
|
|
addParameterKey(PARAMETER_SOUND, "/sound", false, true, NULL, NULL);
|
|
|
|
|
addParameterKey(PARAMETER_COMPRESSION, "+compression", false, true, NULL, NULL);
|
2022-07-11 17:06:05 +00:00
|
|
|
|
addParameterKey(PARAMETER_FULLSCREEN, "/f", false, true, NULL, NULL);
|
|
|
|
|
addParameterKey(PARAMETER_MULTIMONITOR, "/multimon", false, true, getParameter(PARAMETER_FULLSCREEN), NULL);
|
|
|
|
|
addParameterKey(PARAMETER_AUTHENTICATION, "-authentication", true, true, NULL, NULL);
|
|
|
|
|
addParameterKey(PARAMETER_SECURITY, "/sec:", true, true, NULL, NULL);
|
2022-07-08 16:45:45 +00:00
|
|
|
|
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);
|
2022-07-11 17:06:05 +00:00
|
|
|
|
addParameterKey(PARAMETER_BITSPERPIXEL, "/bpp:", true, true, NULL, NULL);
|
2022-07-11 10:12:29 +00:00
|
|
|
|
addParameterValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_8, "8", true);
|
|
|
|
|
addParameterValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_16, "16", false);
|
|
|
|
|
addParameterValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_24, "24", false);
|
|
|
|
|
addParameterValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_32, "32", false);
|
2022-07-11 17:06:05 +00:00
|
|
|
|
|
2022-07-13 05:58:34 +00:00
|
|
|
|
addParameterKey(PARAMETER_USB, "/a:drive,USB,", true, true, NULL, NULL);
|
|
|
|
|
addParameterValue(PARAMETER_USB, VALUES_USB_DRIVE, "/mnt/usbdevice", true);
|
|
|
|
|
|
2022-07-11 17:06:05 +00:00
|
|
|
|
addParameterKey(PARAMETER_MONITORS, "/monitors:", false, true, getParameter(PARAMETER_FULLSCREEN), getParameter(PARAMETER_MULTIMONITOR));
|
|
|
|
|
x_info *monitors = getXInfo();
|
|
|
|
|
for (size_t i = 0; i < monitors->count; ++i)
|
|
|
|
|
{
|
|
|
|
|
addParameterValue(PARAMETER_MONITORS, i, monitors->monitor[i].ptrIndexMonitor, !i);
|
|
|
|
|
}
|
|
|
|
|
freeXInfo(monitors);
|
2022-07-08 16:45:45 +00:00
|
|
|
|
}
|
2022-07-07 16:35:48 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
void settingsFree()
|
|
|
|
|
{
|
|
|
|
|
freeSettings();
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
void buildArguments(Arguments *args)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
args->argc = 0;
|
|
|
|
|
args->argv = (char **)malloc(sizeof(char *) * settings.countParameterSet);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
for (NodeParameter *head = settings.parameter; head; head = head->next)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (head->set)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (head->value)
|
|
|
|
|
args->argv[(args->argc)++] = concat(head->key, getSetNodeValue(head)->current);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
else
|
2022-07-08 16:45:45 +00:00
|
|
|
|
args->argv[(args->argc)++] = concat(head->key, NULL);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-07 16:35:48 +00:00
|
|
|
|
void freeArguments(Arguments *args)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
for (int i = 0; i < args->argc; ++i)
|
|
|
|
|
{
|
|
|
|
|
free(args->argv[i]);
|
|
|
|
|
}
|
2022-07-07 16:35:48 +00:00
|
|
|
|
free(args->argv);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|