libfreerdp-client: refactor and decouple rdpSettings* from client context

This commit is contained in:
Marc-André Moreau
2013-10-12 21:07:12 -04:00
parent b70ecbbf62
commit 59eccac4e7
10 changed files with 29 additions and 35 deletions

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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))
{

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
}

View File

@@ -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);