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,
"redirectprinters") == 0) {
86 }
else if (g_strcmp0(key,
"redirectsmartcard") == 0) {
88 }
else if (g_strcmp0(key,
"redirectclipboard") == 0) {
90 }
else if (g_strcmp0(key,
"alternate shell") == 0) {
92 }
else if (g_strcmp0(key,
"shell working directory") == 0) {
94 }
else if (g_strcmp0(key,
"loadbalanceinfo") == 0) {
96 }
else if (g_strcmp0(key,
"gatewayhostname") == 0) {
98 }
else if (g_strcmp0(key,
"gatewayusagemethod") == 0) {
100 }
else if (g_strcmp0(key,
"gatewayaccesstoken") == 0) {
102 }
else if (g_strcmp0(key,
"authentication level") == 0) {
106 else if (g_strcmp0(key,
"client hostname") == 0) {
108 }
else if (g_strcmp0(key,
"domain") == 0) {
110 }
else if (g_strcmp0(key,
"username") == 0) {
112 }
else if (g_strcmp0(key,
"password") == 0) {
119 TRACE_CALL(__func__);
123 GError *error = NULL;
124 gsize bytes_read = 0;
126 guchar magic[2] = { 0 };
128 if (g_io_channel_set_encoding(channel, NULL, &error) != G_IO_STATUS_NORMAL) {
129 g_print(
"g_io_channel_set_encoding: %s\n", error->message);
134 if (g_io_channel_read_chars(channel, (gchar *)magic, 2, &bytes_read, &error) != G_IO_STATUS_NORMAL) {
135 g_print(
"g_io_channel_read_chars: %s\n", error->message);
139 if (magic[0] == 0xFF && magic[1] == 0xFE) {
141 }
else if (magic[0] == 0xFE && magic[1] == 0xFF) {
145 if (g_io_channel_seek_position(channel, 0, G_SEEK_SET, &error) != G_IO_STATUS_NORMAL) {
146 g_print(
"g_io_channel_seek: failed\n");
151 if (g_io_channel_set_encoding(channel, enc, &error) != G_IO_STATUS_NORMAL) {
152 g_print(
"g_io_channel_set_encoding: %s\n", error->message);
158 while (g_io_channel_read_line(channel, &line, NULL, &bytes_read, &error) == G_IO_STATUS_NORMAL) {
162 line[bytes_read] =
'\0';
163 p = strchr(line,
':');
187 TRACE_CALL(__func__);
189 GError *error = NULL;
192 channel = g_io_channel_new_file(from_file,
"r", &error);
194 if (channel == NULL) {
195 g_print(
"Failed to import %s: %s\n", from_file, error->message);
200 g_io_channel_shutdown(channel, TRUE, &error);
207 TRACE_CALL(__func__);
216 TRACE_CALL(__func__);
220 fprintf(fp,
"screen mode id:i:2\r\n");
223 if (w > 0 && h > 0) {
224 fprintf(fp,
"desktopwidth:i:%d\r\n", w);
225 fprintf(fp,
"desktopheight:i:%d\r\n", h);
230 fprintf(fp,
"compression:i:1\r\n");
231 fprintf(fp,
"keyboardhook:i:2\r\n");
232 fprintf(fp,
"displayconnectionbar:i:1\r\n");
233 fprintf(fp,
"disable wallpaper:i:1\r\n");
234 fprintf(fp,
"disable full window drag:i:1\r\n");
235 fprintf(fp,
"allow desktop composition:i:0\r\n");
236 fprintf(fp,
"allow font smoothing:i:0\r\n");
237 fprintf(fp,
"disable menu anims:i:1\r\n");
238 fprintf(fp,
"disable themes:i:0\r\n");
239 fprintf(fp,
"disable cursor setting:i:0\r\n");
240 fprintf(fp,
"bitmapcachepersistenable:i:1\r\n");
242 fprintf(fp,
"full address:s:%s\r\n", cs ? cs :
"");
244 fprintf(fp,
"audiomode:i:0\r\n");
246 fprintf(fp,
"audiomode:i:1\r\n");
248 fprintf(fp,
"audiomode:i:2\r\n");
250 fprintf(fp,
"audiocapturemode:i:0\r\n");
252 fprintf(fp,
"audiocapturemode:i:1\r\n");
254 fprintf(fp,
"audiocapturemode:i:1\r\n");
257 fprintf(fp,
"redirectcomports:i:0\r\n");
258 fprintf(fp,
"redirectsmartcards:i:0\r\n");
259 fprintf(fp,
"redirectclipboard:i:1\r\n");
260 fprintf(fp,
"redirectposdevices:i:0\r\n");
261 fprintf(fp,
"autoreconnection enabled:i:1\r\n");
262 fprintf(fp,
"authentication level:i:0\r\n");
263 fprintf(fp,
"prompt for credentials:i:1\r\n");
264 fprintf(fp,
"negotiate security layer:i:1\r\n");
265 fprintf(fp,
"remoteapplicationmode:i:0\r\n");
267 fprintf(fp,
"alternate shell:s:%s\r\n", cs ? cs :
"");
269 fprintf(fp,
"shell working directory:s:%s\r\n", cs ? cs :
"");
271 fprintf(fp,
"gatewayhostname:s:%s\r\n", cs ? cs :
"");
272 fprintf(fp,
"gatewayusagemethod:i:4\r\n");
273 fprintf(fp,
"gatewaycredentialssource:i:4\r\n");
274 fprintf(fp,
"gatewayprofileusagemethod:i:0\r\n");
275 fprintf(fp,
"precommand:s:\r\n");
276 fprintf(fp,
"promptcredentialonce:i:1\r\n");
277 fprintf(fp,
"drivestoredirect:s:\r\n");
284 TRACE_CALL(__func__);
289 p = strrchr(to_file,
'.');
291 if (p && (g_strcmp0(p + 1,
"rdp") == 0 || g_strcmp0(p + 1,
"RDP") == 0))
292 p = g_strdup(to_file);
294 p = g_strdup_printf(
"%s.rdp", to_file);
296 fp = g_fopen(p,
"w+");
299 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)
gboolean remmina_rdp_file_export_test(RemminaFilePlugin *plugin, RemminaFile *remminafile)
typedefG_BEGIN_DECLS struct _RemminaFile RemminaFile
static RemminaFile * remmina_rdp_file_import_channel(GIOChannel *channel)
gint(* file_get_int)(RemminaFile *remminafile, const gchar *setting, gint default_value)
static RemminaPluginService * remmina_plugin_service
gboolean remmina_rdp_file_import_test(RemminaFilePlugin *plugin, const gchar *from_file)
gboolean remmina_rdp_file_export(RemminaFilePlugin *plugin, RemminaFile *remminafile, const gchar *to_file)
static void remmina_rdp_file_import_field(RemminaFile *remminafile, const gchar *key, const gchar *value)
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)
RemminaFile * remmina_rdp_file_import(RemminaFilePlugin *plugin, const gchar *from_file)