2
* Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc.
3
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
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 3 of the License, or
8
* (at your option) any later version.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
19
* Additional permission under GNU GPL version 3 section 7:
21
* If you modify this program, or any covered work, by linking or
22
* combining it with the OpenSSL project's OpenSSL library (or a
23
* modified version of that library), containing parts covered by the
24
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
25
* grants you additional permission to convey the resulting work.
26
* Corresponding Source for a non-source form of such a combination
27
* shall include the source code for the parts of OpenSSL used as well
28
* as that of the covered work.
34
#include "assistant.h"
37
#include "reqaccount.h"
39
#define SFLPHONE_ORG_SERVER "sip.sflphone.org"
42
static int account_type;
43
static int use_sflphone_org = 1;
44
static account_t* current;
45
static char message[1024];
49
static gint forward_page_func(gint current_page , gpointer data);
54
static GtkWidget* create_vbox(GtkAssistantPageType type, const gchar *title, const gchar *section);
55
void prefill_sip(void) ;
57
void set_account_type(GtkWidget* widget , gpointer data UNUSED)
59
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
65
static void show_password_cb(GtkWidget *widget UNUSED, gpointer data)
67
gtk_entry_set_visibility(GTK_ENTRY(data), !gtk_entry_get_visibility(GTK_ENTRY(data)));
72
* Fills string message with the final message of account registration
73
* with alias, server and username specified.
75
void getMessageSummary(const gchar * alias, const gchar * server, const gchar * username, const gboolean zrtp)
78
sprintf(message, _("This assistant is now finished."));
79
strcat(message, "\n");
80
strcat(message, _("You can at any time check your registration state or modify your accounts parameters in the Options/Accounts window."));
81
strcat(message, "\n\n");
83
strcat(message, _("Alias"));
84
snprintf(var, sizeof(var), " : %s\n", alias);
87
strcat(message, _("Server"));
88
snprintf(var, sizeof(var), " : %s\n", server);
91
strcat(message, _("Username"));
92
snprintf(var, sizeof(var), " : %s\n", username);
95
strcat(message, _("Security: "));
98
strcat(message, _("SRTP/ZRTP draft-zimmermann"));
100
strcat(message, _("None"));
103
void set_sflphone_org(GtkWidget* widget , gpointer data UNUSED)
105
use_sflphone_org = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ?1:0) ;
111
* Callback when the close button of the dialog is clicked
112
* Action : close the assistant widget and get back to sflphone main window
114
static void close_callback(void)
116
gtk_widget_destroy(wiz->assistant);
120
status_bar_display_account();
124
* Callback when the cancel button of the dialog is clicked
125
* Action : close the assistant widget and get back to sflphone main window
127
static void cancel_callback(void)
129
gtk_widget_destroy(wiz->assistant);
133
status_bar_display_account();
137
* Callback when the button apply is clicked
138
* Action : Set the account parameters with the entries values and called dbus_add_account
140
static void sip_apply_callback(void)
142
if (use_sflphone_org) {
147
if (account_type == _SIP) {
148
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ALIAS), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->sip_alias))));
149
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ENABLED), g_strdup("true"));
150
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_MAILBOX), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->sip_voicemail))));
151
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_TYPE), g_strdup("SIP"));
152
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_HOSTNAME), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->sip_server))));
153
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_PASSWORD), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->sip_password))));
154
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_USERNAME), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->sip_username))));
155
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SIP_STUN_ENABLED), g_strdup((gchar *)(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->enable)) ? "true":"false")));
156
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SIP_STUN_SERVER), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->addr))));
158
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->zrtp_enable)) == TRUE) {
159
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup((gchar *) "true"));
160
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup((gchar *) ZRTP));
161
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ZRTP_DISPLAY_SAS), g_strdup((gchar *) "true"));
162
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ZRTP_NOT_SUPP_WARNING), g_strdup((gchar *) "true"));
163
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ZRTP_HELLO_HASH), g_strdup((gchar *) "true"));
164
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_DISPLAY_SAS_ONCE), g_strdup((gchar *) "false"));
168
// Add default interface info
169
gchar ** iface_list = NULL;
170
iface_list = (gchar**) dbus_get_all_ip_interface_by_name();
171
gchar ** iface = NULL;
173
// select the first interface available
175
DEBUG("Selected interface %s", *iface);
177
g_hash_table_insert(current->properties, g_strdup(LOCAL_INTERFACE), g_strdup((gchar *) *iface));
179
g_hash_table_insert(current->properties, g_strdup(PUBLISHED_ADDRESS), g_strdup((gchar *) *iface));
181
dbus_add_account(current);
182
getMessageSummary(gtk_entry_get_text(GTK_ENTRY(wiz->sip_alias)),
183
gtk_entry_get_text(GTK_ENTRY(wiz->sip_server)),
184
gtk_entry_get_text(GTK_ENTRY(wiz->sip_username)),
185
(gboolean)(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->zrtp_enable)))
188
gtk_label_set_text(GTK_LABEL(wiz->label_summary), message);
193
* Callback when the button apply is clicked
194
* Action : Set the account parameters with the entries values and called dbus_add_account
196
static void iax_apply_callback(void)
198
if (account_type == _IAX) {
199
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ALIAS), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->iax_alias))));
200
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ENABLED), g_strdup("true"));
201
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_MAILBOX), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->iax_voicemail))));
202
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_TYPE), g_strdup("IAX"));
203
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_USERNAME), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->iax_username))));
204
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_HOSTNAME), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->iax_server))));
205
g_hash_table_insert(current->properties, g_strdup(ACCOUNT_PASSWORD), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->iax_password))));
207
dbus_add_account(current);
208
getMessageSummary(gtk_entry_get_text(GTK_ENTRY(wiz->iax_alias)),
209
gtk_entry_get_text(GTK_ENTRY(wiz->iax_server)),
210
gtk_entry_get_text(GTK_ENTRY(wiz->iax_username)),
214
gtk_label_set_text(GTK_LABEL(wiz->label_summary), message);
218
void enable_stun(GtkWidget* widget)
220
gtk_widget_set_sensitive(GTK_WIDGET(wiz->addr), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
223
void build_wizard(void)
225
use_sflphone_org = 1;
230
wiz = (struct _wizard*) g_malloc(sizeof(struct _wizard));
231
current = g_new0(account_t, 1);
232
current->properties = NULL;
233
current->properties = dbus_get_account_details(NULL);
235
if (current->properties == NULL) {
236
DEBUG("Failed to get default values. Creating from scratch");
237
current->properties = g_hash_table_new(NULL, g_str_equal);
240
current->accountID = g_strdup("new");
242
wiz->assistant = gtk_assistant_new();
244
gtk_window_set_title(GTK_WINDOW(wiz->assistant), _("SFLphone account creation wizard"));
245
gtk_window_set_position(GTK_WINDOW(wiz->assistant), GTK_WIN_POS_CENTER);
246
gtk_window_set_default_size(GTK_WINDOW(wiz->assistant), 200 , 200);
249
build_sfl_or_account();
250
build_select_account();
251
build_sip_account_configuration();
252
build_nat_settings();
253
build_iax_account_configuration();
254
build_email_configuration();
257
g_signal_connect(G_OBJECT(wiz->assistant), "close" , G_CALLBACK(close_callback), NULL);
259
g_signal_connect(G_OBJECT(wiz->assistant), "cancel" , G_CALLBACK(cancel_callback), NULL);
261
gtk_widget_show_all(wiz->assistant);
263
gtk_assistant_set_forward_page_func(GTK_ASSISTANT(wiz->assistant), (GtkAssistantPageFunc) forward_page_func , NULL , NULL);
264
gtk_assistant_update_buttons_state(GTK_ASSISTANT(wiz->assistant));
267
GtkWidget* build_intro()
271
wiz->intro = create_vbox(GTK_ASSISTANT_PAGE_INTRO , "SFLphone GNOME client" , _("Welcome to the Account creation wizard of SFLphone!"));
272
label = gtk_label_new(_("This installation wizard will help you configure an account.")) ;
273
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
274
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
275
gtk_widget_set_size_request(GTK_WIDGET(label), 380, -1);
276
gtk_box_pack_start(GTK_BOX(wiz->intro), label, FALSE, TRUE, 0);
278
gtk_assistant_set_page_complete(GTK_ASSISTANT(wiz->assistant), wiz->intro, TRUE);
282
GtkWidget* build_select_account()
287
wiz->protocols = create_vbox(GTK_ASSISTANT_PAGE_CONTENT , _("VoIP Protocols") , _("Select an account type"));
289
sip = gtk_radio_button_new_with_label(NULL, _("SIP (Session Initiation Protocol)"));
290
gtk_box_pack_start(GTK_BOX(wiz->protocols) , sip , TRUE, TRUE, 0);
291
iax = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sip), _("IAX2 (InterAsterix Exchange)"));
292
gtk_box_pack_start(GTK_BOX(wiz->protocols) , iax , TRUE, TRUE, 0);
294
g_signal_connect(G_OBJECT(sip) , "clicked" , G_CALLBACK(set_account_type) , NULL);
296
gtk_assistant_set_page_complete(GTK_ASSISTANT(wiz->assistant), wiz->protocols, TRUE);
297
return wiz->protocols;
301
GtkWidget* build_sfl_or_account()
306
wiz->sflphone_org = create_vbox(GTK_ASSISTANT_PAGE_CONTENT , _("Account") , _("Please select one of the following options"));
308
sfl = gtk_radio_button_new_with_label(NULL, _("Create a free SIP/IAX2 account on sflphone.org \n(For testing purpose only)"));
309
gtk_box_pack_start(GTK_BOX(wiz->sflphone_org) , sfl , TRUE, TRUE, 0);
310
cus = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sfl), _("Register an existing SIP or IAX2 account"));
311
gtk_box_pack_start(GTK_BOX(wiz->sflphone_org) , cus , TRUE, TRUE, 0);
312
g_signal_connect(G_OBJECT(sfl) , "clicked" , G_CALLBACK(set_sflphone_org) , NULL);
314
return wiz->sflphone_org;
318
GtkWidget* build_sip_account_configuration(void)
322
GtkWidget * clearTextCheckbox;
324
wiz->sip_account = create_vbox(GTK_ASSISTANT_PAGE_CONTENT , _("SIP account settings") , _("Please fill the following information"));
326
table = gtk_table_new(7, 2 , FALSE/* homogeneous */);
327
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
328
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
329
gtk_box_pack_start(GTK_BOX(wiz->sip_account) , table , TRUE, TRUE, 0);
332
label = gtk_label_new_with_mnemonic(_("_Alias"));
333
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
334
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
335
wiz->sip_alias = gtk_entry_new();
336
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->sip_alias);
337
gtk_table_attach(GTK_TABLE(table), wiz->sip_alias, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
340
label = gtk_label_new_with_mnemonic(_("_Host name"));
341
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
342
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
343
wiz->sip_server = gtk_entry_new();
344
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->sip_server);
345
gtk_table_attach(GTK_TABLE(table), wiz->sip_server, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
348
label = gtk_label_new_with_mnemonic(_("_User name"));
349
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
350
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
351
wiz->sip_username = gtk_entry_new();
352
gtk_entry_set_icon_from_pixbuf(GTK_ENTRY(wiz->sip_username), GTK_ENTRY_ICON_PRIMARY, gdk_pixbuf_new_from_file(ICONS_DIR "/stock_person.svg", NULL));
353
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->sip_username);
354
gtk_table_attach(GTK_TABLE(table), wiz->sip_username, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
358
label = gtk_label_new_with_mnemonic(_("_Password"));
359
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
360
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
361
wiz->sip_password = gtk_entry_new();
362
gtk_entry_set_icon_from_stock(GTK_ENTRY(wiz->sip_password), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION);
363
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->sip_password);
364
gtk_entry_set_visibility(GTK_ENTRY(wiz->sip_password), FALSE);
365
gtk_table_attach(GTK_TABLE(table), wiz->sip_password, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
367
clearTextCheckbox = gtk_check_button_new_with_mnemonic(_("Show password"));
368
g_signal_connect(clearTextCheckbox, "toggled", G_CALLBACK(show_password_cb), wiz->sip_password);
369
gtk_table_attach(GTK_TABLE(table), clearTextCheckbox, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
371
// voicemail number field
372
label = gtk_label_new_with_mnemonic(_("_Voicemail number"));
373
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
374
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
375
wiz->sip_voicemail = gtk_entry_new();
376
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->sip_voicemail);
377
gtk_table_attach(GTK_TABLE(table), wiz->sip_voicemail, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
380
wiz->zrtp_enable = gtk_check_button_new_with_mnemonic(_("Secure communications with _ZRTP"));
381
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wiz->zrtp_enable), FALSE);
382
gtk_table_attach(GTK_TABLE(table), wiz->zrtp_enable, 0, 1, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
383
gtk_widget_set_sensitive(GTK_WIDGET(wiz->zrtp_enable) , TRUE);
385
//gtk_assistant_set_page_complete(GTK_ASSISTANT(wiz->assistant), wiz->sip_account, TRUE);
386
return wiz->sip_account;
389
GtkWidget* build_email_configuration(void)
394
wiz->email = create_vbox(GTK_ASSISTANT_PAGE_CONTENT , _("Optional email address") , _("This email address will be used to send your voicemail messages."));
396
table = gtk_table_new(4, 2 , FALSE/* homogeneous */);
397
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
398
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
399
gtk_box_pack_start(GTK_BOX(wiz->email) , table , TRUE, TRUE, 0);
402
label = gtk_label_new_with_mnemonic(_("_Email address"));
403
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
404
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
405
wiz->mailbox = gtk_entry_new();
406
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->mailbox);
407
gtk_table_attach(GTK_TABLE(table), wiz->mailbox, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
410
wiz->zrtp_enable = gtk_check_button_new_with_mnemonic(_("Secure communications with _ZRTP"));
411
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wiz->zrtp_enable), FALSE);
412
gtk_table_attach(GTK_TABLE(table), wiz->zrtp_enable, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
413
gtk_widget_set_sensitive(GTK_WIDGET(wiz->zrtp_enable) , TRUE);
418
GtkWidget* build_iax_account_configuration(void)
422
GtkWidget * clearTextCheckbox;
424
wiz->iax_account = create_vbox(GTK_ASSISTANT_PAGE_CONFIRM , _("IAX2 account settings") , _("Please fill the following information"));
426
table = gtk_table_new(6, 2 , FALSE/* homogeneous */);
427
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
428
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
429
gtk_box_pack_start(GTK_BOX(wiz->iax_account) , table , TRUE, TRUE, 0);
432
label = gtk_label_new_with_mnemonic(_("_Alias"));
433
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
434
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
435
wiz->iax_alias = gtk_entry_new();
436
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->iax_alias);
437
gtk_table_attach(GTK_TABLE(table), wiz->iax_alias, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
440
label = gtk_label_new_with_mnemonic(_("_Host name"));
441
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
442
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
443
wiz->iax_server = gtk_entry_new();
444
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->iax_server);
445
gtk_table_attach(GTK_TABLE(table), wiz->iax_server, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
448
label = gtk_label_new_with_mnemonic(_("_User name"));
449
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
450
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
451
wiz->iax_username = gtk_entry_new();
452
gtk_entry_set_icon_from_pixbuf(GTK_ENTRY(wiz->iax_username), GTK_ENTRY_ICON_PRIMARY, gdk_pixbuf_new_from_file(ICONS_DIR "/stock_person.svg", NULL));
453
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->iax_username);
454
gtk_table_attach(GTK_TABLE(table), wiz->iax_username, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
457
label = gtk_label_new_with_mnemonic(_("_Password"));
458
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
459
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
460
wiz->iax_password = gtk_entry_new();
461
gtk_entry_set_icon_from_stock(GTK_ENTRY(wiz->iax_password), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION);
462
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->iax_password);
463
gtk_entry_set_visibility(GTK_ENTRY(wiz->iax_password), FALSE);
464
gtk_table_attach(GTK_TABLE(table), wiz->iax_password, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
466
clearTextCheckbox = gtk_check_button_new_with_mnemonic(_("Show password"));
467
g_signal_connect(clearTextCheckbox, "toggled", G_CALLBACK(show_password_cb), wiz->iax_password);
468
gtk_table_attach(GTK_TABLE(table), clearTextCheckbox, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
470
// voicemail number field
471
label = gtk_label_new_with_mnemonic(_("_Voicemail number"));
472
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
473
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
474
wiz->iax_voicemail = gtk_entry_new();
475
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->iax_voicemail);
476
gtk_table_attach(GTK_TABLE(table), wiz->iax_voicemail, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
478
current -> state = ACCOUNT_STATE_UNREGISTERED;
480
g_signal_connect(G_OBJECT(wiz->assistant) , "apply" , G_CALLBACK(iax_apply_callback), NULL);
482
return wiz->iax_account;
485
GtkWidget* build_nat_settings(void)
490
wiz->nat = create_vbox(GTK_ASSISTANT_PAGE_CONFIRM , _("Network Address Translation (NAT)") , _("You should probably enable this if you are behind a firewall."));
493
table = gtk_table_new(2, 2 , FALSE/* homogeneous */);
494
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
495
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
496
gtk_box_pack_start(GTK_BOX(wiz->nat), table , TRUE, TRUE, 0);
499
wiz->enable = gtk_check_button_new_with_mnemonic(_("E_nable STUN"));
500
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wiz->enable), FALSE);
501
gtk_table_attach(GTK_TABLE(table), wiz->enable, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
502
gtk_widget_set_sensitive(GTK_WIDGET(wiz->enable) , TRUE);
503
g_signal_connect(G_OBJECT(GTK_TOGGLE_BUTTON(wiz->enable)) , "toggled" , G_CALLBACK(enable_stun), NULL);
506
label = gtk_label_new_with_mnemonic(_("_STUN server"));
507
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
508
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
509
wiz->addr = gtk_entry_new();
510
gtk_label_set_mnemonic_widget(GTK_LABEL(label), wiz->addr);
511
gtk_table_attach(GTK_TABLE(table), wiz->addr, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
512
gtk_widget_set_sensitive(GTK_WIDGET(wiz->addr), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->enable)));
514
g_signal_connect(G_OBJECT(wiz->assistant) , "apply" , G_CALLBACK(sip_apply_callback), NULL);
519
GtkWidget* build_summary()
521
wiz->summary = create_vbox(GTK_ASSISTANT_PAGE_SUMMARY , _("Account Registration") , _("Congratulations!"));
524
wiz->label_summary = gtk_label_new(message) ;
525
gtk_label_set_selectable(GTK_LABEL(wiz->label_summary), TRUE);
526
gtk_misc_set_alignment(GTK_MISC(wiz->label_summary), 0, 0);
527
gtk_label_set_line_wrap(GTK_LABEL(wiz->label_summary), TRUE);
528
//gtk_widget_set_size_request(GTK_WIDGET(wiz->label_summary), 380, -1);
529
gtk_box_pack_start(GTK_BOX(wiz->summary), wiz->label_summary, FALSE, TRUE, 0);
534
GtkWidget* build_registration_error()
537
wiz->reg_failed = create_vbox(GTK_ASSISTANT_PAGE_SUMMARY , "Account Registration" , "Registration error");
539
label = gtk_label_new(" Please correct the information.") ;
540
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
541
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
542
gtk_widget_set_size_request(GTK_WIDGET(label), 380, -1);
543
gtk_box_pack_start(GTK_BOX(wiz->reg_failed), label, FALSE, TRUE, 0);
545
return wiz->reg_failed;
548
void set_sip_infos_sentivite(gboolean b)
550
gtk_widget_set_sensitive(GTK_WIDGET(wiz->sip_alias), b);
551
gtk_widget_set_sensitive(GTK_WIDGET(wiz->sip_server), b);
552
gtk_widget_set_sensitive(GTK_WIDGET(wiz->sip_username), b);
553
gtk_widget_set_sensitive(GTK_WIDGET(wiz->sip_password), b);
556
void prefill_sip(void)
558
if (use_sflphone_org == 1) {
561
email = (char *) gtk_entry_get_text(GTK_ENTRY(wiz->mailbox));
562
rest_account ra = get_rest_account(SFLPHONE_ORG_SERVER,email);
565
set_sip_infos_sentivite(FALSE);
566
strcpy(alias,ra.user);
568
strcat(alias,"sip.sflphone.org");
569
gtk_entry_set_text(GTK_ENTRY(wiz->sip_alias),alias);
570
gtk_entry_set_text(GTK_ENTRY(wiz->sip_server), SFLPHONE_ORG_SERVER);
571
gtk_entry_set_text(GTK_ENTRY(wiz->sip_username), ra.user);
572
gtk_entry_set_text(GTK_ENTRY(wiz->sip_password), ra.passwd);
588
static gint forward_page_func(gint current_page , gpointer data UNUSED)
592
switch (current_page) {
594
next_page = PAGE_SFL;
598
if (use_sflphone_org) {
599
next_page = PAGE_EMAIL;
601
next_page = PAGE_TYPE;
606
if (account_type == _SIP) {
607
set_sip_infos_sentivite(TRUE);
608
next_page = PAGE_SIP;
610
next_page = PAGE_IAX;
614
next_page = PAGE_STUN;
617
next_page = PAGE_STUN;
620
next_page = PAGE_SUMMARY;
623
next_page = PAGE_SUMMARY;
626
next_page = PAGE_SUMMARY;
636
static GtkWidget* create_vbox(GtkAssistantPageType type, const gchar *title, const gchar *section)
642
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
643
gtk_container_set_border_width(GTK_CONTAINER(vbox), 24);
645
gtk_assistant_append_page(GTK_ASSISTANT(wiz->assistant), vbox);
646
gtk_assistant_set_page_type(GTK_ASSISTANT(wiz->assistant), vbox, type);
647
str = g_strdup_printf(" %s", title);
648
gtk_assistant_set_page_title(GTK_ASSISTANT(wiz->assistant), vbox, str);
652
gtk_assistant_set_page_complete(GTK_ASSISTANT(wiz->assistant), vbox, TRUE);
656
http://developer.gnome.org/gtk3/stable/GtkAssistant.html#gtk-assistant-set-page-header-image
657
wiz->logo = gdk_pixbuf_new_from_file(LOGO, NULL);
658
gtk_assistant_set_page_header_image(GTK_ASSISTANT(wiz->assistant),vbox, wiz->logo);
659
g_object_unref(wiz->logo);
663
label = gtk_label_new(NULL);
664
str = g_strdup_printf("<b>%s</b>\n", section);
665
gtk_label_set_markup(GTK_LABEL(label), str);
667
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
668
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);