mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
libfreerdp-client: refactor and decouple rdpSettings* from client context
This commit is contained in:
@@ -464,7 +464,7 @@ int main(int argc, char* argv[])
|
||||
instance->context->argc = argc;
|
||||
instance->context->argv = argv;
|
||||
|
||||
status = freerdp_client_parse_command_line_arguments(argc, argv, instance->settings);
|
||||
status = freerdp_client_settings_parse_command_line(instance->settings, argc, argv);
|
||||
|
||||
if (status < 0)
|
||||
exit(0);
|
||||
|
||||
@@ -36,7 +36,7 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
|
||||
int status;
|
||||
mfContext* mfc;
|
||||
|
||||
_singleDelegate = self;
|
||||
_singleDelegate = self;
|
||||
[self CreateContext];
|
||||
|
||||
status = [self ParseCommandLineArguments];
|
||||
@@ -93,8 +93,8 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
|
||||
argv[i++] = cptr;
|
||||
}
|
||||
|
||||
status = freerdp_client_parse_command_line(context, argc, argv);
|
||||
status = freerdp_client_command_line_status_print(context->argc, context->argv, context->settings, status);
|
||||
status = freerdp_client_settings_parse_command_line(context->settings, argc, argv);
|
||||
status = freerdp_client_settings_command_line_status_print(context->settings, status, context->argc, context->argv);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
channels = instance->context->channels;
|
||||
|
||||
status = freerdp_client_parse_command_line_arguments(argc, argv, instance->settings);
|
||||
status = freerdp_client_settings_parse_command_line(instance->settings, argc, argv);
|
||||
|
||||
if (status < 0)
|
||||
exit(0);
|
||||
|
||||
@@ -70,9 +70,9 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
for (index = 0; index < context->argc; index++)
|
||||
context->argv[index] = _strdup(__argv[index]);
|
||||
|
||||
status = freerdp_client_parse_command_line(context, context->argc, context->argv);
|
||||
status = freerdp_client_settings_parse_command_line(settings, context->argc, context->argv);
|
||||
|
||||
status = freerdp_client_command_line_status_print(context->argc, context->argv, settings, status);
|
||||
status = freerdp_client_settings_command_line_status_print(settings, status, context->argc, context->argv);
|
||||
|
||||
if (status)
|
||||
{
|
||||
|
||||
@@ -53,9 +53,9 @@ int main(int argc, char* argv[])
|
||||
settings = context->settings;
|
||||
xfc = (xfContext*) context;
|
||||
|
||||
status = freerdp_client_parse_command_line(context, argc, argv);
|
||||
status = freerdp_client_settings_parse_command_line(context->settings, argc, argv);
|
||||
|
||||
status = freerdp_client_command_line_status_print(argc, argv, settings, status);
|
||||
status = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
|
||||
|
||||
if (status)
|
||||
{
|
||||
|
||||
@@ -98,45 +98,39 @@ HANDLE freerdp_client_get_thread(rdpContext* context)
|
||||
return ((rdpClientContext*) context)->thread;
|
||||
}
|
||||
|
||||
int freerdp_client_parse_command_line(rdpContext* context, int argc, char** argv)
|
||||
int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc, char** argv)
|
||||
{
|
||||
int status;
|
||||
rdpSettings* settings;
|
||||
|
||||
context->argc = argc;
|
||||
context->argv = argv;
|
||||
|
||||
if (context->argc < 1)
|
||||
if (argc < 1)
|
||||
return 0;
|
||||
|
||||
if (!context->argv)
|
||||
if (!argv)
|
||||
return -1;
|
||||
|
||||
settings = context->settings;
|
||||
|
||||
status = freerdp_client_parse_command_line_arguments(context->argc, context->argv, settings);
|
||||
status = freerdp_client_settings_parse_command_line_arguments(settings, argc, argv);
|
||||
|
||||
if (settings->ConnectionFile)
|
||||
{
|
||||
status = freerdp_client_parse_connection_file(context, settings->ConnectionFile);
|
||||
status = freerdp_client_settings_parse_connection_file(settings, settings->ConnectionFile);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int freerdp_client_parse_connection_file(rdpContext* context, const char* filename)
|
||||
int freerdp_client_settings_parse_connection_file(rdpSettings* settings, const char* filename)
|
||||
{
|
||||
rdpFile* file;
|
||||
|
||||
file = freerdp_client_rdp_file_new();
|
||||
freerdp_client_parse_rdp_file(file, filename);
|
||||
freerdp_client_populate_settings_from_rdp_file(file, context->settings);
|
||||
freerdp_client_populate_settings_from_rdp_file(file, settings);
|
||||
freerdp_client_rdp_file_free(file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_client_parse_connection_file_buffer(rdpContext* context, BYTE* buffer, size_t size)
|
||||
int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings, BYTE* buffer, size_t size)
|
||||
{
|
||||
rdpFile* file;
|
||||
int status = -1;
|
||||
@@ -144,7 +138,7 @@ int freerdp_client_parse_connection_file_buffer(rdpContext* context, BYTE* buffe
|
||||
file = freerdp_client_rdp_file_new();
|
||||
|
||||
if (freerdp_client_parse_rdp_file_buffer(file, buffer, size)
|
||||
&& freerdp_client_populate_settings_from_rdp_file(file, context->settings))
|
||||
&& freerdp_client_populate_settings_from_rdp_file(file, settings))
|
||||
{
|
||||
status = 0;
|
||||
}
|
||||
@@ -154,14 +148,14 @@ int freerdp_client_parse_connection_file_buffer(rdpContext* context, BYTE* buffe
|
||||
return status;
|
||||
}
|
||||
|
||||
int freerdp_client_write_connection_file(rdpContext* context, const char* filename, BOOL unicode)
|
||||
int freerdp_client_settings_write_connection_file(rdpSettings* settings, const char* filename, BOOL unicode)
|
||||
{
|
||||
rdpFile* file;
|
||||
int status = -1;
|
||||
|
||||
file = freerdp_client_rdp_file_new();
|
||||
|
||||
if (freerdp_client_populate_rdp_file_from_settings(file, context->settings))
|
||||
if (freerdp_client_populate_rdp_file_from_settings(file, settings))
|
||||
{
|
||||
if (freerdp_client_write_rdp_file(file, filename, unicode))
|
||||
{
|
||||
|
||||
@@ -1001,7 +1001,7 @@ BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags)
|
||||
return compatibility;
|
||||
}
|
||||
|
||||
int freerdp_client_command_line_status_print(int argc, char** argv, rdpSettings* settings, int status)
|
||||
int freerdp_client_settings_command_line_status_print(rdpSettings* settings, int status, int argc, char** argv)
|
||||
{
|
||||
COMMAND_LINE_ARGUMENT_A* arg;
|
||||
|
||||
@@ -1058,7 +1058,7 @@ int freerdp_client_command_line_status_print(int argc, char** argv, rdpSettings*
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettings* settings)
|
||||
int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, int argc, char** argv)
|
||||
{
|
||||
char* p;
|
||||
char* str;
|
||||
|
||||
@@ -960,7 +960,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
|
||||
|
||||
if (file->argc > 1)
|
||||
{
|
||||
freerdp_client_parse_command_line_arguments(file->argc, file->argv, settings);
|
||||
freerdp_client_settings_parse_command_line(settings, file->argc, file->argv);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -85,10 +85,10 @@ FREERDP_API int freerdp_client_stop(rdpContext* context);
|
||||
FREERDP_API freerdp* freerdp_client_get_instance(rdpContext* context);
|
||||
FREERDP_API HANDLE freerdp_client_get_thread(rdpContext* context);
|
||||
|
||||
FREERDP_API int freerdp_client_parse_command_line(rdpContext* context, int argc, char** argv);
|
||||
FREERDP_API int freerdp_client_parse_connection_file(rdpContext* context, const char* filename);
|
||||
FREERDP_API int freerdp_client_parse_connection_file_buffer(rdpContext* context, BYTE* buffer, size_t size);
|
||||
FREERDP_API int freerdp_client_write_connection_file(rdpContext* context, const char* filename, BOOL unicode);
|
||||
FREERDP_API int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc, char** argv);
|
||||
FREERDP_API int freerdp_client_settings_parse_connection_file(rdpSettings* settings, const char* filename);
|
||||
FREERDP_API int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings, BYTE* buffer, size_t size);
|
||||
FREERDP_API int freerdp_client_settings_write_connection_file(rdpSettings* settings, const char* filename, BOOL unicode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FREERDP_API int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettings* settings);
|
||||
FREERDP_API int freerdp_client_command_line_status_print(int argc, char** argv, rdpSettings* settings, int status);
|
||||
FREERDP_API int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, int argc, char** argv);
|
||||
FREERDP_API int freerdp_client_settings_command_line_status_print(rdpSettings* settings, int status, int argc, char** argv);
|
||||
FREERDP_API int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings);
|
||||
|
||||
FREERDP_API int freerdp_client_print_version(void);
|
||||
|
||||
Reference in New Issue
Block a user