2012-10-14 11:43:10 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* FreeRDP Client Common
|
|
|
|
*
|
|
|
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2013-06-14 01:52:24 +04:00
|
|
|
#include <freerdp/client.h>
|
2013-06-14 00:18:19 +04:00
|
|
|
|
2013-06-14 05:34:46 +04:00
|
|
|
#include <freerdp/client/file.h>
|
|
|
|
#include <freerdp/client/cmdline.h>
|
|
|
|
|
2013-06-14 01:52:24 +04:00
|
|
|
freerdp* freerdp_client_get_instance(rdpContext* context)
|
2013-06-14 00:18:19 +04:00
|
|
|
{
|
2013-06-14 01:52:24 +04:00
|
|
|
return context->instance;
|
2013-06-14 00:18:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-14 01:52:24 +04:00
|
|
|
BOOL freerdp_client_get_param_bool(rdpContext* context, int id)
|
2013-06-14 00:18:19 +04:00
|
|
|
{
|
2013-06-14 01:52:24 +04:00
|
|
|
rdpSettings* settings = context->settings;
|
|
|
|
return freerdp_get_param_bool(settings, id);
|
2013-06-14 00:18:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-14 01:52:24 +04:00
|
|
|
int freerdp_client_set_param_bool(rdpContext* context, int id, BOOL param)
|
2013-06-14 00:18:19 +04:00
|
|
|
{
|
2013-06-14 01:52:24 +04:00
|
|
|
rdpSettings* settings = context->settings;
|
|
|
|
return freerdp_set_param_bool(settings, id, param);
|
2013-06-14 00:18:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-14 01:52:24 +04:00
|
|
|
UINT32 freerdp_client_get_param_uint32(rdpContext* context, int id)
|
2013-06-14 00:18:19 +04:00
|
|
|
{
|
2013-06-14 01:52:24 +04:00
|
|
|
rdpSettings* settings = context->settings;
|
|
|
|
return freerdp_get_param_uint32(settings, id);
|
2013-06-14 00:18:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-14 01:52:24 +04:00
|
|
|
int freerdp_client_set_param_uint32(rdpContext* context, int id, UINT32 param)
|
2013-06-14 00:18:19 +04:00
|
|
|
{
|
2013-06-14 01:52:24 +04:00
|
|
|
rdpSettings* settings = context->settings;
|
|
|
|
return freerdp_set_param_uint32(settings, id, param);
|
2013-06-14 00:18:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-14 01:52:24 +04:00
|
|
|
UINT64 freerdp_client_get_param_uint64(rdpContext* context, int id)
|
2013-06-14 00:18:19 +04:00
|
|
|
{
|
2013-06-14 01:52:24 +04:00
|
|
|
rdpSettings* settings = context->settings;
|
|
|
|
return freerdp_get_param_uint64(settings, id);
|
2013-06-14 00:18:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-14 01:52:24 +04:00
|
|
|
int freerdp_client_set_param_uint64(rdpContext* context, int id, UINT64 param)
|
2013-06-14 00:18:19 +04:00
|
|
|
{
|
2013-06-14 01:52:24 +04:00
|
|
|
rdpSettings* settings = context->settings;
|
|
|
|
return freerdp_set_param_uint64(settings, id, param);
|
2013-06-14 00:18:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-14 01:52:24 +04:00
|
|
|
char* freerdp_client_get_param_string(rdpContext* context, int id)
|
2013-06-14 00:18:19 +04:00
|
|
|
{
|
2013-06-14 01:52:24 +04:00
|
|
|
rdpSettings* settings = context->settings;
|
|
|
|
return freerdp_get_param_string(settings, id);
|
2013-06-14 00:18:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-14 01:52:24 +04:00
|
|
|
int freerdp_client_set_param_string(rdpContext* context, int id, char* param)
|
2013-06-14 00:18:19 +04:00
|
|
|
{
|
2013-06-14 01:52:24 +04:00
|
|
|
rdpSettings* settings = context->settings;
|
|
|
|
return freerdp_set_param_string(settings, id, param);
|
2013-06-14 00:18:19 +04:00
|
|
|
}
|
|
|
|
|
2013-06-14 05:34:46 +04:00
|
|
|
/* Common API */
|
|
|
|
|
|
|
|
int freerdp_client_parse_command_line(rdpContext* context, int argc, char** argv)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
rdpSettings* settings;
|
|
|
|
|
|
|
|
context->argc = argc;
|
|
|
|
context->argv = argv;
|
|
|
|
|
|
|
|
if (context->argc < 1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!context->argv)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
settings = context->settings;
|
|
|
|
|
|
|
|
status = freerdp_client_parse_command_line_arguments(context->argc, context->argv, settings);
|
|
|
|
|
|
|
|
if (settings->ConnectionFile)
|
|
|
|
{
|
|
|
|
rdpFile* file = freerdp_client_rdp_file_new();
|
|
|
|
freerdp_client_parse_rdp_file(file, settings->ConnectionFile);
|
|
|
|
freerdp_client_populate_settings_from_rdp_file(file, settings);
|
|
|
|
freerdp_client_rdp_file_free(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_client_parse_connection_file(rdpContext* context, 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_rdp_file_free(file);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int freerdp_client_parse_connection_file_buffer(rdpContext* context, BYTE* buffer, size_t size)
|
|
|
|
{
|
|
|
|
rdpFile* file;
|
2013-06-14 00:18:19 +04:00
|
|
|
|
2013-06-14 05:34:46 +04:00
|
|
|
file = freerdp_client_rdp_file_new();
|
|
|
|
freerdp_client_parse_rdp_file_buffer(file, buffer, size);
|
|
|
|
freerdp_client_populate_settings_from_rdp_file(file, context->settings);
|
|
|
|
freerdp_client_rdp_file_free(file);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|