From 59eccac4e71ef5dff6f559b8c2983e32627620f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sat, 12 Oct 2013 21:07:12 -0400 Subject: [PATCH] libfreerdp-client: refactor and decouple rdpSettings* from client context --- client/DirectFB/dfreerdp.c | 2 +- client/Mac/cli/AppDelegate.m | 6 +++--- client/Sample/freerdp.c | 2 +- client/Windows/cli/wfreerdp.c | 4 ++-- client/X11/cli/xfreerdp.c | 4 ++-- client/common/client.c | 28 +++++++++++----------------- client/common/cmdline.c | 4 ++-- client/common/file.c | 2 +- include/freerdp/client.h | 8 ++++---- include/freerdp/client/cmdline.h | 4 ++-- 10 files changed, 29 insertions(+), 35 deletions(-) diff --git a/client/DirectFB/dfreerdp.c b/client/DirectFB/dfreerdp.c index 5ea5e5ee3..cc621480b 100644 --- a/client/DirectFB/dfreerdp.c +++ b/client/DirectFB/dfreerdp.c @@ -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); diff --git a/client/Mac/cli/AppDelegate.m b/client/Mac/cli/AppDelegate.m index c05213240..9c5636079 100644 --- a/client/Mac/cli/AppDelegate.m +++ b/client/Mac/cli/AppDelegate.m @@ -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; } diff --git a/client/Sample/freerdp.c b/client/Sample/freerdp.c index 87e4eb148..d5f89f7a2 100644 --- a/client/Sample/freerdp.c +++ b/client/Sample/freerdp.c @@ -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); diff --git a/client/Windows/cli/wfreerdp.c b/client/Windows/cli/wfreerdp.c index ac8d6f665..f19cc7ecc 100644 --- a/client/Windows/cli/wfreerdp.c +++ b/client/Windows/cli/wfreerdp.c @@ -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) { diff --git a/client/X11/cli/xfreerdp.c b/client/X11/cli/xfreerdp.c index 8e39158c2..3006ad50f 100644 --- a/client/X11/cli/xfreerdp.c +++ b/client/X11/cli/xfreerdp.c @@ -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) { diff --git a/client/common/client.c b/client/common/client.c index d560fa310..51973f4be 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -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)) { diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 202551d66..17f8c2446 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -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; diff --git a/client/common/file.c b/client/common/file.c index 769108e35..4511cf9d4 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -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; diff --git a/include/freerdp/client.h b/include/freerdp/client.h index 721ab935c..2878ffa2e 100644 --- a/include/freerdp/client.h +++ b/include/freerdp/client.h @@ -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 } diff --git a/include/freerdp/client/cmdline.h b/include/freerdp/client/cmdline.h index 8e4ab21ed..9020c8246 100644 --- a/include/freerdp/client/cmdline.h +++ b/include/freerdp/client/cmdline.h @@ -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);