GUI-FreeRDP/arguments.c

90 lines
3.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* arguments.c
*
* Created on: 6 июл. 2022 г.
* Author: alexander
*/
#include <stdlib.h>
#include "arguments.h"
#include "node_settings.h"
#include "concat.h"
#include "xrandr.h"
#include "db.h"
void settingsLoad()
{
dbGetHostsList();
if (!dbLoadData())
{
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);
addParameterKey(PARAMETER_CERTIGNORE, "/cert-ignore", true, true, NULL, NULL);
addParameterKey(PARAMETER_THEMES, "-themes", false, true, NULL, NULL);
addParameterKey(PARAMETER_WALLPAPER, "-wallpaper", false, true, NULL, NULL);
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);
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);
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);
addParameterKey(PARAMETER_BITSPERPIXEL, "/bpp:", true, true, NULL, NULL);
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);
addParameterKey(PARAMETER_USB, "/a:drive,USB,", true, true, NULL, NULL);
addParameterValue(PARAMETER_USB, VALUES_USB_DRIVE, "/mnt/usbdevice", true);
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);
}
void settingsFree()
{
freeSettings();
}
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->set)
{
if (head->value)
args->argv[(args->argc)++] = concat(head->key, getSetNodeValue(head)->current);
else
args->argv[(args->argc)++] = concat(head->key, NULL);
}
}
}
void freeArguments(Arguments *args)
{
for (int i = 0; i < args->argc; ++i)
{
free(args->argv[i]);
}
free(args->argv);
}