~ubuntu-branches/ubuntu/raring/remmina/raring

« back to all changes in this revision

Viewing changes to remmina/src/remmina_init_dialog.c

  • Committer: Package Import Robot
  • Author(s): Luca Falavigna
  • Date: 2012-02-11 17:28:48 UTC
  • mfrom: (1.2.8)
  • Revision ID: package-import@ubuntu.com-20120211172848-rh3ffi7075qyobuq
Tags: 1.0.0-1
* New upstream release.
  - Compatible with FreeRDP 1.0 (Closes: #658363).
  - Ported to GTK3, this also fixes an incompatibility with
    GTK2 and recent Avahi with GTK3 support, which lead to
    crashes when scanning network services (Closes: #626499).
* debian/patches/libvncserver.patch:
  - Do not use convenience copy of libvncserver.
* debian/patches/g_thread_init.patch:
  - Do not use deprecated g_thread_init function.
* debian/patches/REMMINA_COMMAND_NONE.patch:
  - Removed, obsoleted by GApplication port.
* debian/clean:
  - Remove spurious files created at build-time.
* debian/compat:
  - Bump compatibility level to 9.
* debian/control:
  - Refresh build-dependencies to match new structure.
  - Drop remmina-dev package, no longer used.
  - Build packages once provided by remmina-plugins.
  - Provide remmina-common package.
  - Provide remmina-plugin-gnome package.
* debian/copyright:
  - Refresh copyright information.
* debian/docs:
  - Documentation is no longer accurate, do not ship it anymore.
* debian/remmina-dev.install:
  - Drop remmina-dev package, no longer used.
* debian/remmina-plugin-telepathy.install:
  - Adjust location for Remmina.client.
  - Disable D-BUS support for now.
* debian/rules:
  - Compile with -DWITH_APPINDICATOR=OFF.
  - Do not treat plugins as shared libraries.
* debian/watch:
  - Adjust watch file to match new download location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Remmina - The GTK+ Remote Desktop Client
 
3
 * Copyright (C) 2009-2011 Vic Lee
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, 
 
18
 * Boston, MA 02111-1307, USA.
 
19
 */
 
20
 
 
21
#include <gtk/gtk.h>
 
22
#include <glib/gi18n.h>
 
23
#include "remmina_widget_pool.h"
 
24
#include "remmina_init_dialog.h"
 
25
 
 
26
G_DEFINE_TYPE( RemminaInitDialog, remmina_init_dialog, GTK_TYPE_DIALOG)
 
27
 
 
28
static void remmina_init_dialog_class_init(RemminaInitDialogClass *klass)
 
29
{
 
30
}
 
31
 
 
32
static void remmina_init_dialog_destroy(RemminaInitDialog *dialog, gpointer data)
 
33
{
 
34
        g_free(dialog->title);
 
35
        g_free(dialog->status);
 
36
        g_free(dialog->username);
 
37
        g_free(dialog->domain);
 
38
        g_free(dialog->password);
 
39
        g_free(dialog->cacert);
 
40
        g_free(dialog->cacrl);
 
41
        g_free(dialog->clientcert);
 
42
        g_free(dialog->clientkey);
 
43
}
 
44
 
 
45
static void remmina_init_dialog_init(RemminaInitDialog *dialog)
 
46
{
 
47
        GtkWidget *hbox;
 
48
        GtkWidget *widget;
 
49
 
 
50
        dialog->image = NULL;
 
51
        dialog->content_vbox = NULL;
 
52
        dialog->status_label = NULL;
 
53
        dialog->mode = REMMINA_INIT_MODE_CONNECTING;
 
54
        dialog->title = NULL;
 
55
        dialog->status = NULL;
 
56
        dialog->username = NULL;
 
57
        dialog->domain = NULL;
 
58
        dialog->password = NULL;
 
59
        dialog->save_password = FALSE;
 
60
        dialog->cacert = NULL;
 
61
        dialog->cacrl = NULL;
 
62
        dialog->clientcert = NULL;
 
63
        dialog->clientkey = NULL;
 
64
 
 
65
        gtk_dialog_add_buttons(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
 
66
        gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1);
 
67
 
 
68
        gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
 
69
 
 
70
        gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS);
 
71
        gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
 
72
 
 
73
        /**** Create the dialog content from here ****/
 
74
 
 
75
        /* Create top-level hbox */
 
76
        hbox = gtk_hbox_new(FALSE, 4);
 
77
        gtk_widget_show(hbox);
 
78
        gtk_container_set_border_width(GTK_CONTAINER(hbox), 15);
 
79
        gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox, TRUE, TRUE, 0);
 
80
 
 
81
        /* Icon */
 
82
        widget = gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
 
83
        gtk_widget_show(widget);
 
84
        gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 4);
 
85
        dialog->image = widget;
 
86
 
 
87
        /* Create vbox for other dialog content */
 
88
        widget = gtk_vbox_new(FALSE, 4);
 
89
        gtk_widget_show(widget);
 
90
        gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 4);
 
91
        dialog->content_vbox = widget;
 
92
 
 
93
        /* Entries */
 
94
        widget = gtk_label_new(dialog->title);
 
95
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
96
        gtk_widget_show(widget);
 
97
        gtk_box_pack_start(GTK_BOX(dialog->content_vbox), widget, TRUE, TRUE, 4);
 
98
        dialog->status_label = widget;
 
99
 
 
100
        g_signal_connect(G_OBJECT(dialog), "destroy", G_CALLBACK(remmina_init_dialog_destroy), NULL);
 
101
 
 
102
        remmina_widget_pool_register(GTK_WIDGET(dialog));
 
103
}
 
104
 
 
105
static void remmina_init_dialog_connecting(RemminaInitDialog *dialog)
 
106
{
 
107
        gtk_label_set_text(GTK_LABEL(dialog->status_label), (dialog->status ? dialog->status : dialog->title));
 
108
        gtk_image_set_from_stock(GTK_IMAGE(dialog->image), GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
 
109
        gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, FALSE);
 
110
 
 
111
        dialog->mode = REMMINA_INIT_MODE_CONNECTING;
 
112
}
 
113
 
 
114
GtkWidget* remmina_init_dialog_new(const gchar *title_format, ...)
 
115
{
 
116
        RemminaInitDialog *dialog;
 
117
        va_list args;
 
118
 
 
119
        dialog = REMMINA_INIT_DIALOG (g_object_new (REMMINA_TYPE_INIT_DIALOG, NULL));
 
120
 
 
121
        va_start (args, title_format);
 
122
        dialog->title = g_strdup_vprintf (title_format, args);
 
123
        va_end (args);
 
124
        gtk_window_set_title (GTK_WINDOW(dialog), dialog->title);
 
125
 
 
126
        remmina_init_dialog_connecting (dialog);
 
127
 
 
128
        return GTK_WIDGET (dialog);
 
129
}
 
130
 
 
131
void remmina_init_dialog_set_status(RemminaInitDialog *dialog, const gchar *status_format, ...)
 
132
{
 
133
        va_list args;
 
134
 
 
135
        if (status_format)
 
136
        {
 
137
                if (dialog->status)
 
138
                        g_free(dialog->status);
 
139
 
 
140
                va_start(args, status_format);
 
141
                dialog->status = g_strdup_vprintf(status_format, args);
 
142
                va_end(args);
 
143
 
 
144
                gtk_label_set_text(GTK_LABEL(dialog->status_label), dialog->status);
 
145
        }
 
146
}
 
147
 
 
148
void remmina_init_dialog_set_status_temp(RemminaInitDialog *dialog, const gchar *status_format, ...)
 
149
{
 
150
        gchar* s;
 
151
        va_list args;
 
152
 
 
153
        if (status_format)
 
154
        {
 
155
                va_start(args, status_format);
 
156
                s = g_strdup_vprintf(status_format, args);
 
157
                va_end(args);
 
158
 
 
159
                gtk_label_set_text(GTK_LABEL (dialog->status_label), s);
 
160
                g_free(s);
 
161
        }
 
162
}
 
163
 
 
164
gint remmina_init_dialog_authpwd(RemminaInitDialog *dialog, const gchar *label, gboolean allow_save)
 
165
{
 
166
        GtkWidget *table;
 
167
        GtkWidget *password_entry;
 
168
        GtkWidget *save_password_check;
 
169
        GtkWidget *widget;
 
170
        gint ret;
 
171
        gchar *s;
 
172
 
 
173
        gtk_label_set_text(GTK_LABEL(dialog->status_label), (dialog->status ? dialog->status : dialog->title));
 
174
 
 
175
        /* Create table */
 
176
        table = gtk_table_new(2, 2, FALSE);
 
177
        gtk_widget_show(table);
 
178
        gtk_table_set_row_spacings(GTK_TABLE(table), 8);
 
179
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
 
180
 
 
181
        /* Icon */
 
182
        gtk_image_set_from_stock(GTK_IMAGE(dialog->image), GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG);
 
183
 
 
184
        /* Entries */
 
185
        widget = gtk_label_new(label);
 
186
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
187
        gtk_widget_show(widget);
 
188
        gtk_table_attach(GTK_TABLE(table), widget, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
 
189
 
 
190
        password_entry = gtk_entry_new();
 
191
        gtk_widget_show(password_entry);
 
192
        gtk_table_attach_defaults(GTK_TABLE(table), password_entry, 1, 2, 0, 1);
 
193
        gtk_entry_set_max_length(GTK_ENTRY(password_entry), 100);
 
194
        gtk_entry_set_visibility(GTK_ENTRY(password_entry), FALSE);
 
195
        gtk_entry_set_activates_default(GTK_ENTRY(password_entry), TRUE);
 
196
 
 
197
        s = g_strdup_printf(_("Save %s"), label);
 
198
        save_password_check = gtk_check_button_new_with_label(s);
 
199
        g_free(s);
 
200
        gtk_widget_show(save_password_check);
 
201
        gtk_table_attach_defaults(GTK_TABLE(table), save_password_check, 0, 2, 1, 2);
 
202
        if (allow_save)
 
203
        {
 
204
                if (dialog->save_password)
 
205
                        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(save_password_check), TRUE);
 
206
        }
 
207
        else
 
208
        {
 
209
                gtk_widget_set_sensitive(save_password_check, FALSE);
 
210
        }
 
211
 
 
212
        /* Pack it into the dialog */
 
213
        gtk_box_pack_start(GTK_BOX(dialog->content_vbox), table, TRUE, TRUE, 4);
 
214
 
 
215
        gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, TRUE);
 
216
 
 
217
        gtk_widget_grab_focus(password_entry);
 
218
 
 
219
        dialog->mode = REMMINA_INIT_MODE_AUTHPWD;
 
220
 
 
221
        /* Now run it */
 
222
        ret = gtk_dialog_run(GTK_DIALOG(dialog));
 
223
 
 
224
        if (ret == GTK_RESPONSE_OK)
 
225
        {
 
226
                dialog->password = g_strdup(gtk_entry_get_text(GTK_ENTRY(password_entry)));
 
227
                dialog->save_password = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(save_password_check));
 
228
        }
 
229
 
 
230
        gtk_container_remove(GTK_CONTAINER(dialog->content_vbox), table);
 
231
 
 
232
        remmina_init_dialog_connecting(dialog);
 
233
 
 
234
        return ret;
 
235
}
 
236
 
 
237
gint remmina_init_dialog_authuserpwd(RemminaInitDialog *dialog, gboolean want_domain, const gchar *default_username,
 
238
                const gchar *default_domain, gboolean allow_save)
 
239
{
 
240
        GtkWidget *table;
 
241
        GtkWidget *username_entry;
 
242
        GtkWidget *password_entry;
 
243
        GtkWidget *domain_entry = NULL;
 
244
        GtkWidget *save_password_check;
 
245
        GtkWidget *widget;
 
246
        gint ret;
 
247
 
 
248
        gtk_label_set_text(GTK_LABEL(dialog->status_label), (dialog->status ? dialog->status : dialog->title));
 
249
 
 
250
        /* Create table */
 
251
        table = gtk_table_new(4, 2, FALSE);
 
252
        gtk_widget_show(table);
 
253
        gtk_table_set_row_spacings(GTK_TABLE(table), 8);
 
254
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
 
255
 
 
256
        /* Icon */
 
257
        gtk_image_set_from_stock(GTK_IMAGE(dialog->image), GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG);
 
258
 
 
259
        /* Entries */
 
260
        widget = gtk_label_new(_("User name"));
 
261
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
262
        gtk_widget_show(widget);
 
263
        gtk_table_attach(GTK_TABLE(table), widget, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
 
264
 
 
265
        username_entry = gtk_entry_new();
 
266
        gtk_widget_show(username_entry);
 
267
        gtk_table_attach_defaults(GTK_TABLE(table), username_entry, 1, 2, 0, 1);
 
268
        gtk_entry_set_max_length(GTK_ENTRY(username_entry), 100);
 
269
        if (default_username && default_username[0] != '\0')
 
270
        {
 
271
                gtk_entry_set_text(GTK_ENTRY(username_entry), default_username);
 
272
        }
 
273
 
 
274
        widget = gtk_label_new(_("Password"));
 
275
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
276
        gtk_widget_show(widget);
 
277
        gtk_table_attach(GTK_TABLE(table), widget, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
 
278
 
 
279
        password_entry = gtk_entry_new();
 
280
        gtk_widget_show(password_entry);
 
281
        gtk_table_attach_defaults(GTK_TABLE(table), password_entry, 1, 2, 1, 2);
 
282
        gtk_entry_set_max_length(GTK_ENTRY(password_entry), 100);
 
283
        gtk_entry_set_visibility(GTK_ENTRY(password_entry), FALSE);
 
284
        gtk_entry_set_activates_default(GTK_ENTRY(password_entry), TRUE);
 
285
 
 
286
        save_password_check = gtk_check_button_new_with_label(_("Save password"));
 
287
        gtk_widget_show(save_password_check);
 
288
        gtk_table_attach_defaults(GTK_TABLE(table), save_password_check, 0, 2, 2, 3);
 
289
        if (allow_save)
 
290
        {
 
291
                if (dialog->save_password)
 
292
                        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(save_password_check), TRUE);
 
293
        }
 
294
        else
 
295
        {
 
296
                gtk_widget_set_sensitive(save_password_check, FALSE);
 
297
        }
 
298
 
 
299
        if (want_domain)
 
300
        {
 
301
                widget = gtk_label_new(_("Domain"));
 
302
                gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
303
                gtk_widget_show(widget);
 
304
                gtk_table_attach(GTK_TABLE(table), widget, 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
 
305
 
 
306
                domain_entry = gtk_entry_new();
 
307
                gtk_widget_show(domain_entry);
 
308
                gtk_table_attach_defaults(GTK_TABLE(table), domain_entry, 1, 2, 3, 4);
 
309
                gtk_entry_set_max_length(GTK_ENTRY(domain_entry), 100);
 
310
                if (default_domain && default_domain[0] != '\0')
 
311
                {
 
312
                        gtk_entry_set_text(GTK_ENTRY(domain_entry), default_domain);
 
313
                }
 
314
        }
 
315
 
 
316
        /* Pack it into the dialog */
 
317
        gtk_box_pack_start(GTK_BOX(dialog->content_vbox), table, TRUE, TRUE, 4);
 
318
 
 
319
        gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, TRUE);
 
320
 
 
321
        if (default_username && default_username[0] != '\0')
 
322
        {
 
323
                gtk_widget_grab_focus(password_entry);
 
324
        }
 
325
        else
 
326
        {
 
327
                gtk_widget_grab_focus(username_entry);
 
328
        }
 
329
 
 
330
        dialog->mode = REMMINA_INIT_MODE_AUTHUSERPWD;
 
331
 
 
332
        /* Now run it */
 
333
        ret = gtk_dialog_run(GTK_DIALOG(dialog));
 
334
        if (ret == GTK_RESPONSE_OK)
 
335
        {
 
336
                dialog->username = g_strdup(gtk_entry_get_text(GTK_ENTRY(username_entry)));
 
337
                dialog->password = g_strdup(gtk_entry_get_text(GTK_ENTRY(password_entry)));
 
338
                dialog->save_password = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(save_password_check));
 
339
 
 
340
                if (want_domain)
 
341
                        dialog->domain = g_strdup(gtk_entry_get_text(GTK_ENTRY(domain_entry)));
 
342
        }
 
343
 
 
344
        gtk_container_remove(GTK_CONTAINER(dialog->content_vbox), table);
 
345
 
 
346
        remmina_init_dialog_connecting(dialog);
 
347
 
 
348
        return ret;
 
349
}
 
350
 
 
351
gint remmina_init_dialog_certificate(RemminaInitDialog* dialog, const gchar* subject, const gchar* issuer, const gchar* fingerprint)
 
352
{
 
353
        gint status;
 
354
        GtkWidget* table;
 
355
        GtkWidget* widget;
 
356
 
 
357
        gtk_label_set_text(GTK_LABEL(dialog->status_label), "Certificate Details:");
 
358
 
 
359
        /* Create table */
 
360
        table = gtk_table_new(5, 2, FALSE);
 
361
        gtk_widget_show(table);
 
362
        gtk_table_set_row_spacings(GTK_TABLE(table), 8);
 
363
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
 
364
 
 
365
        /* Icon */
 
366
        gtk_image_set_from_stock(GTK_IMAGE(dialog->image), GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG);
 
367
 
 
368
        /* Entries */
 
369
        widget = gtk_label_new(_("Subject:"));
 
370
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
371
        gtk_widget_show(widget);
 
372
        gtk_table_attach(GTK_TABLE(table), widget, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
 
373
 
 
374
        widget = gtk_label_new(subject);
 
375
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
376
        gtk_widget_show(widget);
 
377
        gtk_table_attach(GTK_TABLE(table), widget, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
 
378
 
 
379
        widget = gtk_label_new(_("Issuer:"));
 
380
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
381
        gtk_widget_show(widget);
 
382
        gtk_table_attach(GTK_TABLE(table), widget, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
 
383
 
 
384
        widget = gtk_label_new(issuer);
 
385
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
386
        gtk_widget_show(widget);
 
387
        gtk_table_attach(GTK_TABLE(table), widget, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
 
388
 
 
389
        widget = gtk_label_new(_("Fingerprint:"));
 
390
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
391
        gtk_widget_show(widget);
 
392
        gtk_table_attach(GTK_TABLE(table), widget, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
 
393
 
 
394
        widget = gtk_label_new(fingerprint);
 
395
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
396
        gtk_widget_show(widget);
 
397
        gtk_table_attach(GTK_TABLE(table), widget, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
 
398
 
 
399
        widget = gtk_label_new(_("Accept Certificate?"));
 
400
        gtk_misc_set_alignment(GTK_MISC(widget), 1.0, 0.5);
 
401
        gtk_widget_show(widget);
 
402
        gtk_table_attach(GTK_TABLE(table), widget, 0, 2, 3, 4, GTK_FILL, 0, 0, 0);
 
403
 
 
404
        /* Pack it into the dialog */
 
405
        gtk_box_pack_start(GTK_BOX(dialog->content_vbox), table, TRUE, TRUE, 4);
 
406
 
 
407
        gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, TRUE);
 
408
 
 
409
        dialog->mode = REMMINA_INIT_MODE_CERTIFICATE;
 
410
 
 
411
        /* Now run it */
 
412
        status = gtk_dialog_run(GTK_DIALOG(dialog));
 
413
 
 
414
        if (status == GTK_RESPONSE_OK)
 
415
        {
 
416
 
 
417
        }
 
418
 
 
419
        gtk_container_remove(GTK_CONTAINER(dialog->content_vbox), table);
 
420
 
 
421
        return status;
 
422
}
 
423
 
 
424
static GtkWidget* remmina_init_dialog_create_file_button(GtkTable *table, const gchar *label, gint row, const gchar *filename)
 
425
{
 
426
        GtkWidget *widget;
 
427
        gchar *pkidir;
 
428
 
 
429
        widget = gtk_label_new(label);
 
430
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
431
        gtk_widget_show(widget);
 
432
        gtk_table_attach(table, widget, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);
 
433
 
 
434
        widget = gtk_file_chooser_button_new(label, GTK_FILE_CHOOSER_ACTION_OPEN);
 
435
        gtk_file_chooser_button_set_width_chars(GTK_FILE_CHOOSER_BUTTON(widget), 25);
 
436
        gtk_widget_show(widget);
 
437
        gtk_table_attach_defaults(table, widget, 1, 2, row, row + 1);
 
438
        if (filename && filename[0] != '\0')
 
439
        {
 
440
                gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(widget), filename);
 
441
        }
 
442
        else
 
443
        {
 
444
                pkidir = g_strdup_printf("%s/.pki", g_get_home_dir());
 
445
                if (g_file_test(pkidir, G_FILE_TEST_IS_DIR))
 
446
                {
 
447
                        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(widget), pkidir);
 
448
                }
 
449
                g_free(pkidir);
 
450
        }
 
451
 
 
452
        return widget;
 
453
}
 
454
 
 
455
gint remmina_init_dialog_authx509(RemminaInitDialog *dialog, const gchar *cacert, const gchar *cacrl, const gchar *clientcert,
 
456
                const gchar *clientkey)
 
457
{
 
458
        GtkWidget *table;
 
459
        GtkWidget *cacert_button;
 
460
        GtkWidget *cacrl_button;
 
461
        GtkWidget *clientcert_button;
 
462
        GtkWidget *clientkey_button;
 
463
        gint ret;
 
464
 
 
465
        gtk_label_set_text(GTK_LABEL(dialog->status_label), (dialog->status ? dialog->status : dialog->title));
 
466
 
 
467
        /* Create table */
 
468
        table = gtk_table_new(4, 2, FALSE);
 
469
        gtk_widget_show(table);
 
470
        gtk_table_set_row_spacings(GTK_TABLE(table), 8);
 
471
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
 
472
 
 
473
        /* Icon */
 
474
        gtk_image_set_from_stock(GTK_IMAGE(dialog->image), GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG);
 
475
 
 
476
        /* Buttons for choosing the certificates */
 
477
        cacert_button = remmina_init_dialog_create_file_button(GTK_TABLE(table), _("CA certificate"), 0, cacert);
 
478
        cacrl_button = remmina_init_dialog_create_file_button(GTK_TABLE(table), _("CA CRL"), 1, cacrl);
 
479
        clientcert_button = remmina_init_dialog_create_file_button(GTK_TABLE(table), _("Client certificate"), 2, clientcert);
 
480
        clientkey_button = remmina_init_dialog_create_file_button(GTK_TABLE(table), _("Client key"), 3, clientkey);
 
481
 
 
482
        /* Pack it into the dialog */
 
483
        gtk_box_pack_start(GTK_BOX(dialog->content_vbox), table, TRUE, TRUE, 4);
 
484
 
 
485
        gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, TRUE);
 
486
 
 
487
        dialog->mode = REMMINA_INIT_MODE_AUTHX509;
 
488
 
 
489
        /* Now run it */
 
490
        ret = gtk_dialog_run(GTK_DIALOG(dialog));
 
491
        if (ret == GTK_RESPONSE_OK)
 
492
        {
 
493
                dialog->cacert = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(cacert_button));
 
494
                dialog->cacrl = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(cacrl_button));
 
495
                dialog->clientcert = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(clientcert_button));
 
496
                dialog->clientkey = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(clientkey_button));
 
497
        }
 
498
 
 
499
        gtk_container_remove(GTK_CONTAINER(dialog->content_vbox), table);
 
500
 
 
501
        remmina_init_dialog_connecting(dialog);
 
502
 
 
503
        return ret;
 
504
}
 
505
 
 
506
static gint remmina_init_dialog_serverkey_confirm(RemminaInitDialog *dialog, const gchar *serverkey, const gchar *prompt)
 
507
{
 
508
        GtkWidget *vbox;
 
509
        GtkWidget *widget;
 
510
        gint ret;
 
511
 
 
512
        gtk_label_set_text(GTK_LABEL(dialog->status_label), (dialog->status ? dialog->status : dialog->title));
 
513
 
 
514
        /* Create vbox */
 
515
        vbox = gtk_vbox_new(FALSE, 4);
 
516
        gtk_widget_show(vbox);
 
517
 
 
518
        /* Icon */
 
519
        gtk_image_set_from_stock(GTK_IMAGE(dialog->image), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
 
520
 
 
521
        /* Entries */
 
522
        widget = gtk_label_new(prompt);
 
523
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
524
        gtk_widget_show(widget);
 
525
        gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 4);
 
526
 
 
527
        widget = gtk_label_new(serverkey);
 
528
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
529
        gtk_widget_show(widget);
 
530
        gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 4);
 
531
 
 
532
        widget = gtk_label_new(_("Do you trust the new public key?"));
 
533
        gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
 
534
        gtk_widget_show(widget);
 
535
        gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 4);
 
536
 
 
537
        /* Pack it into the dialog */
 
538
        gtk_box_pack_start(GTK_BOX(dialog->content_vbox), vbox, TRUE, TRUE, 4);
 
539
 
 
540
        gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, TRUE);
 
541
 
 
542
        dialog->mode = REMMINA_INIT_MODE_SERVERKEY_CONFIRM;
 
543
 
 
544
        /* Now run it */
 
545
        ret = gtk_dialog_run(GTK_DIALOG(dialog));
 
546
        gtk_container_remove(GTK_CONTAINER(dialog->content_vbox), vbox);
 
547
        remmina_init_dialog_connecting(dialog);
 
548
 
 
549
        return ret;
 
550
}
 
551
 
 
552
gint remmina_init_dialog_serverkey_unknown(RemminaInitDialog *dialog, const gchar *serverkey)
 
553
{
 
554
        return remmina_init_dialog_serverkey_confirm(dialog, serverkey,
 
555
                        _("The server is unknown. The public key fingerprint is:"));
 
556
}
 
557
 
 
558
gint remmina_init_dialog_serverkey_changed(RemminaInitDialog *dialog, const gchar *serverkey)
 
559
{
 
560
        return remmina_init_dialog_serverkey_confirm(dialog, serverkey,
 
561
                        _("WARNING: The server has changed its public key. This means either you are under attack,\n"
 
562
                                        "or the administrator has changed the key. The new public key fingerprint is:"));
 
563
}
 
564