46 ext = strrchr(from_file,
'.');
53 if (g_strcmp0(ext,
"RDP") == 0)
56 if (g_strcmp0(ext,
"rdp") == 0)
65 if (g_strcmp0(key,
"desktopwidth") == 0) {
67 }
else if (g_strcmp0(key,
"desktopheight") == 0) {
69 }
else if (g_strcmp0(key,
"session bpp") == 0) {
71 }
else if (g_strcmp0(key,
"keyboardhook") == 0) {
73 }
else if (g_strcmp0(key,
"full address") == 0) {
75 }
else if (g_strcmp0(key,
"audiomode") == 0) {
76 switch (atoi(value)) {
84 }
else if (g_strcmp0(key,
"microphone") == 0) {
86 }
else if (g_strcmp0(key,
"redirectprinters") == 0) {
88 }
else if (g_strcmp0(key,
"redirectsmartcard") == 0) {
90 }
else if (g_strcmp0(key,
"redirectclipboard") == 0) {
92 }
else if (g_strcmp0(key,
"alternate shell") == 0) {
94 }
else if (g_strcmp0(key,
"shell working directory") == 0) {
96 }
else if (g_strcmp0(key,
"loadbalanceinfo") == 0) {
98 }
else if (g_strcmp0(key,
"gatewayhostname") == 0) {
100 }
else if (g_strcmp0(key,
"gatewayusagemethod") == 0) {
102 }
else if (g_strcmp0(key,
"gatewayaccesstoken") == 0) {
104 }
else if (g_strcmp0(key,
"authentication level") == 0) {
108 else if (g_strcmp0(key,
"client hostname") == 0) {
110 }
else if (g_strcmp0(key,
"domain") == 0) {
112 }
else if (g_strcmp0(key,
"username") == 0) {
114 }
else if (g_strcmp0(key,
"password") == 0) {
121 TRACE_CALL(__func__);
125 GError* error = NULL;
126 gsize bytes_read = 0;
128 guchar magic[2] = { 0 };
130 if (g_io_channel_set_encoding(channel, NULL, &error) != G_IO_STATUS_NORMAL) {
131 g_print(
"g_io_channel_set_encoding: %s\n", error->message);
136 if (g_io_channel_read_chars(channel, (gchar*)magic, 2, &bytes_read, &error) != G_IO_STATUS_NORMAL) {
137 g_print(
"g_io_channel_read_chars: %s\n", error->message);
141 if (magic[0] == 0xFF && magic[1] == 0xFE) {
143 }
else if (magic[0] == 0xFE && magic[1] == 0xFF) {
147 if (g_io_channel_seek_position(channel, 0, G_SEEK_SET, &error) != G_IO_STATUS_NORMAL) {
148 g_print(
"g_io_channel_seek: failed\n");
153 if (g_io_channel_set_encoding(channel, enc, &error) != G_IO_STATUS_NORMAL) {
154 g_print(
"g_io_channel_set_encoding: %s\n", error->message);
160 while (g_io_channel_read_line(channel, &line, NULL, &bytes_read, &error) == G_IO_STATUS_NORMAL) {
164 line[bytes_read] =
'\0';
165 p = strchr(line,
':');
189 TRACE_CALL(__func__);
191 GError* error = NULL;
194 channel = g_io_channel_new_file(from_file,
"r", &error);
196 if (channel == NULL) {
197 g_print(
"Failed to import %s: %s\n", from_file, error->message);
202 g_io_channel_shutdown(channel, TRUE, &error);
209 TRACE_CALL(__func__);
218 TRACE_CALL(__func__);
222 fprintf(fp,
"screen mode id:i:2\r\n");
225 if ( w > 0 && h > 0 ) {
226 fprintf(fp,
"desktopwidth:i:%d\r\n", w);
227 fprintf(fp,
"desktopheight:i:%d\r\n", h);
232 fprintf(fp,
"compression:i:1\r\n");
233 fprintf(fp,
"keyboardhook:i:2\r\n");
234 fprintf(fp,
"displayconnectionbar:i:1\r\n");
235 fprintf(fp,
"disable wallpaper:i:1\r\n");
236 fprintf(fp,
"disable full window drag:i:1\r\n");
237 fprintf(fp,
"allow desktop composition:i:0\r\n");
238 fprintf(fp,
"allow font smoothing:i:0\r\n");
239 fprintf(fp,
"disable menu anims:i:1\r\n");
240 fprintf(fp,
"disable themes:i:0\r\n");
241 fprintf(fp,
"disable cursor setting:i:0\r\n");
242 fprintf(fp,
"bitmapcachepersistenable:i:1\r\n");
244 fprintf(fp,
"full address:s:%s\r\n", cs ? cs :
"" );
246 fprintf(fp,
"audiomode:i:0\r\n");
248 fprintf(fp,
"audiomode:i:1\r\n");
250 fprintf(fp,
"audiomode:i:2\r\n");
254 fprintf(fp,
"redirectcomports:i:0\r\n");
255 fprintf(fp,
"redirectsmartcards:i:0\r\n");
256 fprintf(fp,
"redirectclipboard:i:1\r\n");
257 fprintf(fp,
"redirectposdevices:i:0\r\n");
258 fprintf(fp,
"autoreconnection enabled:i:1\r\n");
259 fprintf(fp,
"authentication level:i:0\r\n");
260 fprintf(fp,
"prompt for credentials:i:1\r\n");
261 fprintf(fp,
"negotiate security layer:i:1\r\n");
262 fprintf(fp,
"remoteapplicationmode:i:0\r\n");
264 fprintf(fp,
"alternate shell:s:%s\r\n", cs ? cs :
"");
266 fprintf(fp,
"shell working directory:s:%s\r\n", cs ? cs :
"");
267 fprintf(fp,
"gatewayhostname:s:\r\n");
268 fprintf(fp,
"gatewayusagemethod:i:4\r\n");
269 fprintf(fp,
"gatewaycredentialssource:i:4\r\n");
270 fprintf(fp,
"gatewayprofileusagemethod:i:0\r\n");
271 fprintf(fp,
"precommand:s:\r\n");
272 fprintf(fp,
"promptcredentialonce:i:1\r\n");
273 fprintf(fp,
"drivestoredirect:s:\r\n");
280 TRACE_CALL(__func__);
285 p = strrchr(to_file,
'.');
287 if (p && (g_strcmp0(p + 1,
"rdp") == 0 || g_strcmp0(p + 1,
"RDP") == 0)) {
288 p = g_strdup(to_file);
290 p = g_strdup_printf(
"%s.rdp", to_file);
293 fp = g_fopen(p,
"w+");
296 g_print(
"Failed to export %s\n", p);
gboolean remmina_rdp_file_export_channel(RemminaFile *remminafile, FILE *fp)
void(* file_set_int)(RemminaFile *remminafile, const gchar *setting, gint value)
typedefG_BEGIN_DECLS struct _RemminaFile RemminaFile
static RemminaFile * remmina_rdp_file_import_channel(GIOChannel *channel)
gboolean remmina_rdp_file_export(RemminaFile *remminafile, const gchar *to_file)
gint(* file_get_int)(RemminaFile *remminafile, const gchar *setting, gint default_value)
gboolean remmina_rdp_file_export_test(RemminaFile *remminafile)
RemminaFile * remmina_rdp_file_import(const gchar *from_file)
static RemminaPluginService * remmina_plugin_service
static void remmina_rdp_file_import_field(RemminaFile *remminafile, const gchar *key, const gchar *value)
gboolean remmina_rdp_file_import_test(const gchar *from_file)
void(* file_set_string)(RemminaFile *remminafile, const gchar *setting, const gchar *value)
const gchar *(* file_get_string)(RemminaFile *remminafile, const gchar *setting)
RemminaFile *(* file_new)(void)