107
113
GHashTable * directIpCallsProperties = NULL;
115
gchar *current_username;
111
COLUMN_CREDENTIAL_REALM,
112
COLUMN_CREDENTIAL_USERNAME,
113
COLUMN_CREDENTIAL_PASSWORD,
114
COLUMN_CREDENTIAL_DATA,
115
COLUMN_CREDENTIAL_COUNT
120
COLUMN_CREDENTIAL_REALM,
121
COLUMN_CREDENTIAL_USERNAME,
122
COLUMN_CREDENTIAL_PASSWORD,
123
COLUMN_CREDENTIAL_DATA,
124
COLUMN_CREDENTIAL_COUNT
128
* The same window is used with different configurations
129
* so we need to reset some data to prevent side-effects
134
protocolComboBox = NULL;
135
entryHostname = NULL;
136
entryUsername = NULL;
137
entryPassword = NULL;
138
entryUseragent = NULL;
119
143
* Display / Hide the password
121
static void show_password_cb (GtkWidget *widget, gpointer data)
145
static void show_password_cb (GtkWidget *widget UNUSED, gpointer data)
123
gtk_entry_set_visibility (GTK_ENTRY (data), !gtk_entry_get_visibility (GTK_ENTRY (data)));
147
gtk_entry_set_visibility (GTK_ENTRY (data), !gtk_entry_get_visibility (GTK_ENTRY (data)));
126
150
/* Signal to protocolComboBox 'changed' */
127
void change_protocol_cb (account_t *currentAccount UNUSED) {
129
gchar *protocol = gtk_combo_box_get_active_text (GTK_COMBO_BOX (protocolComboBox));
131
// Only if tabs are not NULL
132
if(security_tab && advanced_tab) {
133
if (g_strcasecmp (protocol, "IAX") == 0) {
134
gtk_widget_hide (GTK_WIDGET(security_tab));
135
gtk_widget_hide (GTK_WIDGET(advanced_tab));
138
gtk_widget_show (GTK_WIDGET(security_tab));
139
gtk_widget_show (GTK_WIDGET(advanced_tab));
147
int res = dbus_is_iax2_enabled();
156
select_dtmf_type( void )
159
DEBUG("DTMF selection changed\n");
161
if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(overrtp) ) )
163
// dbus_set_audio_manager( ALSA );
164
DEBUG("Selected DTMF over RTP");
168
// dbus_set_audio_manager( PULSEAUDIO );
169
DEBUG("Selected DTMF over SIP");
174
static GPtrArray* getNewCredential (GHashTable * properties) {
180
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(credentialStore), &iter);
182
GPtrArray *credential_array = g_ptr_array_new ();
187
GHashTable * new_table;
189
gtk_tree_model_get (GTK_TREE_MODEL(credentialStore), &iter,
190
COLUMN_CREDENTIAL_REALM, &realm,
191
COLUMN_CREDENTIAL_USERNAME, &username,
192
COLUMN_CREDENTIAL_PASSWORD, &password,
195
g_hash_table_insert(properties, g_strdup(ACCOUNT_REALM), realm);
196
g_hash_table_insert(properties, g_strdup(ACCOUNT_AUTHENTICATION_USERNAME), username);
198
// Do not change the password if nothing has been changed by the user
199
if (g_strcasecmp (password, PW_HIDDEN) != 0)
200
g_hash_table_insert(properties, g_strdup(ACCOUNT_PASSWORD), password);
202
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(credentialStore), &iter);
205
gtk_tree_model_get (GTK_TREE_MODEL(credentialStore), &iter,
206
COLUMN_CREDENTIAL_REALM, &realm,
207
COLUMN_CREDENTIAL_USERNAME, &username,
208
COLUMN_CREDENTIAL_PASSWORD, &password,
211
DEBUG ("Row %d: %s %s %s", row_count, username, password, realm);
213
new_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
214
g_hash_table_insert(new_table, g_strdup(ACCOUNT_REALM), realm);
215
g_hash_table_insert(new_table, g_strdup(ACCOUNT_USERNAME), username);
216
g_hash_table_insert(new_table, g_strdup(ACCOUNT_PASSWORD), password);
218
g_ptr_array_add (credential_array, new_table);
222
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(credentialStore), &iter);
225
return credential_array;
228
static void update_credential_cb(GtkWidget *widget, gpointer data UNUSED)
231
gtk_tree_model_get_iter_from_string ((GtkTreeModel *) credentialStore, &iter, "0");
232
gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "column"));
233
// g_print ("set password to %s\n", (gchar *) gtk_entry_get_text(GTK_ENTRY(widget)));
234
gtk_list_store_set (GTK_LIST_STORE (credentialStore), &iter, column, (gchar *) gtk_entry_get_text(GTK_ENTRY(widget)), -1);
237
static GtkWidget* create_basic_tab (account_t **a) {
241
account_t *currentAccount;
242
GtkWidget * clearTextCheckbox;
243
#if GTK_CHECK_VERSION(2,16,0)
249
gchar *curAccountID = "";
250
gchar *curAccountEnabled = "true";
251
gchar *curAccountType = "SIP";
252
gchar *curAlias = "";
253
gchar *curUsername = "";
254
gchar *curRouteSet = "";
255
gchar *curHostname = "";
256
gchar *curPassword = "";
257
/* TODO: add curProxy, and add boxes for Proxy support */
258
gchar *curMailbox = "";
259
gchar *curUseragent = "";
265
// Load from SIP/IAX/Unknown ?
268
curAccountID = currentAccount->accountID;
269
curAccountType = g_hash_table_lookup(currentAccount->properties, ACCOUNT_TYPE);
270
DEBUG("Config: Current accountType %s", curAccountType);
271
curAccountEnabled = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ENABLED);
272
curAlias = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ALIAS);
273
curHostname = g_hash_table_lookup(currentAccount->properties, ACCOUNT_HOSTNAME);
274
curPassword = g_hash_table_lookup(currentAccount->properties, ACCOUNT_PASSWORD);
275
curUsername = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERNAME);
276
// curRouteSet = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ROUTE);
277
curMailbox = g_hash_table_lookup(currentAccount->properties, ACCOUNT_MAILBOX);
278
curUseragent = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERAGENT);
281
gnome_main_section_new (_("Account Parameters"), &frame);
282
gtk_widget_show(frame);
284
if(strcmp(curAccountType, "SIP") == 0) {
285
table = gtk_table_new (9, 2, FALSE/* homogeneous */);
287
else if(strcmp(curAccountType, "IAX") == 0) {
288
table = gtk_table_new (8, 2, FALSE);
291
gtk_table_set_row_spacings( GTK_TABLE(table), 10);
292
gtk_table_set_col_spacings( GTK_TABLE(table), 10);
293
gtk_widget_show (table);
294
gtk_container_add( GTK_CONTAINER( frame) , table );
296
label = gtk_label_new_with_mnemonic (_("_Alias"));
297
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
298
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
299
entryAlias = gtk_entry_new();
300
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryAlias);
301
gtk_entry_set_text(GTK_ENTRY(entryAlias), curAlias);
302
gtk_table_attach ( GTK_TABLE( table ), entryAlias, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
306
label = gtk_label_new_with_mnemonic (_("_Protocol"));
307
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
308
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
309
protocolComboBox = gtk_combo_box_new_text();
310
gtk_label_set_mnemonic_widget (GTK_LABEL (label), protocolComboBox);
311
gtk_combo_box_append_text(GTK_COMBO_BOX(protocolComboBox), "SIP");
312
if( is_iax_enabled() ) gtk_combo_box_append_text(GTK_COMBO_BOX(protocolComboBox), "IAX");
313
if(strcmp(curAccountType, "SIP") == 0)
315
gtk_combo_box_set_active(GTK_COMBO_BOX(protocolComboBox),0);
317
else if(strcmp(curAccountType, "IAX") == 0)
319
gtk_combo_box_set_active(GTK_COMBO_BOX(protocolComboBox),1);
323
DEBUG("Config: Error: Account protocol not valid");
324
/* Should never come here, add debug message. */
325
gtk_combo_box_append_text(GTK_COMBO_BOX(protocolComboBox), _("Unknown"));
326
gtk_combo_box_set_active(GTK_COMBO_BOX(protocolComboBox),2);
328
gtk_table_attach ( GTK_TABLE( table ), protocolComboBox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
330
/* Link signal 'changed' */
331
g_signal_connect (G_OBJECT (GTK_COMBO_BOX(protocolComboBox)), "changed",
332
G_CALLBACK (change_protocol_cb),
336
label = gtk_label_new_with_mnemonic (_("_Host name"));
337
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
338
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
339
entryHostname = gtk_entry_new();
340
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryHostname);
341
gtk_entry_set_text(GTK_ENTRY(entryHostname), curHostname);
342
gtk_table_attach ( GTK_TABLE( table ), entryHostname, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
345
label = gtk_label_new_with_mnemonic (_("_User name"));
346
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
347
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
348
#if GTK_CHECK_VERSION(2,16,0)
349
entryUsername = gtk_entry_new();
350
gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entryUsername), GTK_ENTRY_ICON_PRIMARY, gdk_pixbuf_new_from_file(ICONS_DIR "/stock_person.svg", NULL));
352
entryUsername = sexy_icon_entry_new();
353
image = gtk_image_new_from_file( ICONS_DIR "/stock_person.svg" );
354
sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(entryUsername), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) );
356
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryUsername);
357
gtk_entry_set_text(GTK_ENTRY(entryUsername), curUsername);
358
gtk_table_attach ( GTK_TABLE( table ), entryUsername, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
359
if(strcmp(curAccountType, "SIP") == 0) {
360
g_signal_connect(G_OBJECT (entryUsername), "changed", G_CALLBACK (update_credential_cb), NULL);
361
g_object_set_data (G_OBJECT (entryUsername), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_USERNAME));
364
// Route set can be update only for SIP account
365
// TODO: uncomment this code and implement route
367
if(strcmp(curAccountType, "SIP") == 0) {
369
label = gtk_label_new_with_mnemonic(_("_Route (optional)"));
370
gtk_table_attach(GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
371
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
372
entryRouteSet = gtk_entry_new();
373
gtk_label_set_mnemonic_widget(GTK_LABEL(label), entryRouteSet);
374
gtk_entry_set_text(GTK_ENTRY(entryRouteSet), curRouteSet);
375
gtk_table_attach (GTK_TABLE(table), entryRouteSet, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
380
label = gtk_label_new_with_mnemonic (_("_Password"));
381
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
382
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
383
#if GTK_CHECK_VERSION(2,16,0)
384
entryPassword = gtk_entry_new();
385
GtkSettings *settings = gtk_settings_get_default ();
386
//g_object_set (G_OBJECT (settings), "gtk-entry-password-hint-timeout", 600, NULL);
387
gtk_entry_set_icon_from_stock (GTK_ENTRY (entryPassword), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION);
389
entryPassword = sexy_icon_entry_new();
390
image = gtk_image_new_from_stock( GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR );
391
sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(entryPassword), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) );
393
gtk_entry_set_visibility(GTK_ENTRY(entryPassword), FALSE);
394
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryPassword);
395
gtk_entry_set_text(GTK_ENTRY(entryPassword), curPassword);
396
gtk_table_attach ( GTK_TABLE( table ), entryPassword, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
397
if(strcmp(curAccountType, "SIP") == 0) {
398
g_signal_connect (G_OBJECT (entryPassword), "changed", G_CALLBACK (update_credential_cb), NULL);
399
g_object_set_data (G_OBJECT (entryPassword), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_PASSWORD));
403
clearTextCheckbox = gtk_check_button_new_with_mnemonic (_("Show password"));
404
g_signal_connect (clearTextCheckbox, "toggled", G_CALLBACK (show_password_cb), entryPassword);
405
gtk_table_attach (GTK_TABLE (table), clearTextCheckbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
408
label = gtk_label_new_with_mnemonic (_("_Voicemail number"));
409
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
410
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
411
entryMailbox = gtk_entry_new();
412
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryMailbox);
413
gtk_entry_set_text(GTK_ENTRY(entryMailbox), curMailbox);
414
gtk_table_attach ( GTK_TABLE( table ), entryMailbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
417
label = gtk_label_new_with_mnemonic (_("_User-agent"));
418
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
419
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
420
entryUseragent = gtk_entry_new ();
421
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryUseragent);
422
gtk_entry_set_text (GTK_ENTRY (entryUseragent), curUseragent);
423
gtk_table_attach ( GTK_TABLE( table ), entryUseragent, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
425
gtk_widget_show_all( table );
426
gtk_container_set_border_width (GTK_CONTAINER(table), 10);
432
static void fill_treeview_with_credential (GtkListStore * credentialStore, account_t * account)
435
gtk_list_store_clear(credentialStore);
436
gtk_list_store_append (credentialStore, &iter);
438
/* This is the default, undeletable credential */
439
gchar * authentication_name = g_hash_table_lookup(account->properties, ACCOUNT_AUTHENTICATION_USERNAME);
440
gchar * realm = g_hash_table_lookup(account->properties, ACCOUNT_REALM);
441
if (realm == NULL || (g_strcmp0(realm, "") == 0)) {
442
realm = g_strdup("*");
445
if((authentication_name == NULL) || (g_strcmp0(authentication_name, "") == 0)) {
446
gtk_list_store_set(credentialStore, &iter,
447
COLUMN_CREDENTIAL_REALM, realm,
448
COLUMN_CREDENTIAL_USERNAME, gtk_entry_get_text(GTK_ENTRY(entryUsername)),
449
COLUMN_CREDENTIAL_PASSWORD, gtk_entry_get_text(GTK_ENTRY(entryPassword)),
450
COLUMN_CREDENTIAL_DATA, account,
453
gtk_list_store_set(credentialStore, &iter,
454
COLUMN_CREDENTIAL_REALM, g_hash_table_lookup(account->properties, ACCOUNT_REALM),
455
COLUMN_CREDENTIAL_USERNAME, g_hash_table_lookup(account->properties, ACCOUNT_AUTHENTICATION_USERNAME),
456
// COLUMN_CREDENTIAL_PASSWORD, gtk_entry_get_text(GTK_ENTRY(entryPassword)),
457
COLUMN_CREDENTIAL_PASSWORD, PW_HIDDEN,
458
COLUMN_CREDENTIAL_DATA, account,
460
g_signal_handlers_disconnect_by_func (G_OBJECT(entryUsername), G_CALLBACK(update_credential_cb), NULL);
463
if(account->credential_information == NULL) {
464
DEBUG("No credential defined");
469
for(i = 0; i < account->credential_information->len; i++)
471
GHashTable * element = g_ptr_array_index(account->credential_information, i);
472
gtk_list_store_append (credentialStore, &iter);
473
gtk_list_store_set(credentialStore, &iter,
474
COLUMN_CREDENTIAL_REALM, g_hash_table_lookup(element, ACCOUNT_REALM),
475
COLUMN_CREDENTIAL_USERNAME, g_hash_table_lookup(element, ACCOUNT_USERNAME),
476
COLUMN_CREDENTIAL_PASSWORD, g_hash_table_lookup(element, ACCOUNT_PASSWORD),
477
COLUMN_CREDENTIAL_DATA, element, // Pointer
482
static select_credential_cb(GtkTreeSelection *selection, GtkTreeModel *model)
486
if(gtk_tree_selection_get_selected (selection, NULL, &iter)) {
487
path = gtk_tree_model_get_path (model, &iter);
488
if(gtk_tree_path_get_indices (path)[0] == 0) {
489
gtk_widget_set_sensitive(GTK_WIDGET(deleteCredButton), FALSE);
491
gtk_widget_set_sensitive(GTK_WIDGET(deleteCredButton), TRUE);
496
static void add_credential_cb (GtkWidget *button, gpointer data)
499
GtkTreeModel *model = (GtkTreeModel *)data;
501
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
502
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
503
COLUMN_CREDENTIAL_REALM, "*",
504
COLUMN_CREDENTIAL_USERNAME, _("Authentication"),
505
COLUMN_CREDENTIAL_PASSWORD, _("Secret"),
509
static void delete_credential_cb(GtkWidget *button, gpointer data)
512
GtkTreeView *treeview = (GtkTreeView *)data;
513
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
514
GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview);
516
if (gtk_tree_selection_get_selected (selection, NULL, &iter))
519
path = gtk_tree_model_get_path (model, &iter);
520
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
522
gtk_tree_path_free (path);
527
static void cell_edited_cb(GtkCellRendererText *renderer, gchar *path_desc, gchar *text, gpointer data)
529
GtkTreeModel *model = (GtkTreeModel *)data;
530
GtkTreePath *path = gtk_tree_path_new_from_string (path_desc);
533
gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (renderer), "column"));
534
DEBUG("path desc in cell_edited_cb: %s\n", text);
536
if(g_strcasecmp(path_desc, "0") == 0) {
537
if(g_strcasecmp(text, gtk_entry_get_text (GTK_ENTRY(entryUsername))) != 0) {
538
g_signal_handlers_disconnect_by_func (G_OBJECT(entryUsername), G_CALLBACK(update_credential_cb), NULL);
541
if (column == COLUMN_CREDENTIAL_PASSWORD) {
542
gtk_entry_set_text (GTK_ENTRY (entryPassword), text);
547
gtk_tree_model_get_iter (model, &iter, path);
548
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, text, -1);
549
gtk_tree_path_free (path);
553
static void editing_started_cb (GtkCellRenderer *cell, GtkCellEditable * editable, const gchar * path, gpointer data) {
555
DEBUG("Editing started");
556
DEBUG("path desc in editing_started_cb: %s\n", path);
558
// If we are dealing the first row
559
if (g_strcasecmp (path, "0") == 0)
561
gtk_entry_set_text (GTK_ENTRY (editable), gtk_entry_get_text (GTK_ENTRY (entryPassword)));
565
static void show_advanced_zrtp_options_cb(GtkWidget *widget UNUSED, gpointer data)
568
DEBUG("Advanced options for SRTP");
569
if (g_strcasecmp(gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo)), (gchar *) "ZRTP") == 0) {
570
show_advanced_zrtp_options((GHashTable *) data);
573
show_advanced_sdes_options((GHashTable *) data);
578
static void show_advanced_tls_options_cb(GtkWidget *widget UNUSED, gpointer data)
580
DEBUG("Advanced options for TLS");
581
show_advanced_tls_options((GHashTable *) data);
584
static void key_exchange_changed_cb(GtkWidget *widget, gpointer data)
587
DEBUG("Key exchange changed %s", gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo)));
589
int isSdes = g_strcasecmp(gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo)), (gchar *) "SDES");
590
int isZrtp = g_strcasecmp(gtk_combo_box_get_active_text(GTK_COMBO_BOX(keyExchangeCombo)), (gchar *) "ZRTP");
592
if ((isSdes == 0) || (isZrtp == 0)) {
593
gtk_widget_set_sensitive(GTK_WIDGET(advancedZrtpButton), TRUE);
595
gtk_widget_set_sensitive(GTK_WIDGET(advancedZrtpButton), FALSE);
601
static void use_sip_tls_cb(GtkWidget *widget, gpointer data)
604
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
606
gtk_widget_set_sensitive(GTK_WIDGET(data), TRUE);
608
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useStunCheckBox), FALSE);
609
gtk_widget_set_sensitive(GTK_WIDGET(useStunCheckBox), FALSE);
610
gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), TRUE);
611
gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), TRUE);
612
gtk_widget_hide (stunServerLabel);
613
gtk_widget_hide (stunServerEntry);
617
if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton))) {
618
gtk_widget_show(publishedAddressEntry);
619
gtk_widget_show(publishedPortSpinBox);
620
gtk_widget_show(publishedAddressLabel);
621
gtk_widget_show(publishedPortLabel);
625
gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE);
626
gtk_widget_set_sensitive(GTK_WIDGET(useStunCheckBox), TRUE);
628
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useStunCheckBox))) {
629
gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), FALSE);
630
gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), FALSE);
631
gtk_widget_show(stunServerLabel);
632
gtk_widget_show(stunServerEntry);
633
gtk_widget_hide(publishedAddressEntry);
634
gtk_widget_hide(publishedPortSpinBox);
635
gtk_widget_hide(publishedAddressLabel);
636
gtk_widget_hide(publishedPortLabel);
639
gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), TRUE);
640
gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), TRUE);
641
gtk_widget_hide(stunServerLabel);
642
gtk_widget_hide(stunServerEntry);
648
static local_interface_changed_cb(GtkWidget * widget, gpointer data UNUSED) {
650
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(sameAsLocalRadioButton))) {
652
gchar *local_iface_name;
653
gchar *local_iface_addr;
654
local_iface_addr = g_malloc(36);
656
local_iface_name = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo));
657
// sflphone_get_interface_addr_from_name((char *)local_interface);
658
sflphone_get_interface_addr_from_name(local_iface_name, &local_iface_addr, 36);
660
gtk_entry_set_text(GTK_ENTRY(localAddressEntry), local_iface_addr);
661
gtk_entry_set_text (GTK_ENTRY(publishedAddressEntry), local_iface_addr);
663
// gchar * local_port = (gchar *) gtk_entry_get_text(GTK_ENTRY(localPortSpinBox));
664
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(publishedPortSpinBox), g_ascii_strtod(local_port, NULL));
665
g_free(local_iface_addr);
670
static set_published_addr_manually_cb(GtkWidget * widget, gpointer data UNUSED)
673
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
674
DEBUG("Config: Showing manual publishing options");
675
gtk_widget_show(publishedPortLabel);
676
gtk_widget_show(publishedPortSpinBox);
677
gtk_widget_show(publishedAddressLabel);
678
gtk_widget_show(publishedAddressEntry);
680
DEBUG("Config: Hiding manual publishing options");
681
gtk_widget_hide(publishedPortLabel);
682
gtk_widget_hide(publishedPortSpinBox);
683
gtk_widget_hide(publishedAddressLabel);
684
gtk_widget_hide(publishedAddressEntry);
688
static use_stun_cb(GtkWidget *widget, gpointer data UNUSED)
690
gchar *local_interface;
691
gchar *local_address;
693
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
695
DEBUG("Config: Showing stun options, hiding Local/Published info");
696
gtk_widget_show (stunServerLabel);
697
gtk_widget_show (stunServerEntry);
698
gtk_widget_set_sensitive (sameAsLocalRadioButton, FALSE);
699
gtk_widget_set_sensitive (publishedAddrRadioButton, FALSE);
701
gtk_widget_hide (publishedAddressLabel);
702
gtk_widget_hide (publishedPortLabel);
703
gtk_widget_hide (publishedAddressEntry);
704
gtk_widget_hide (publishedPortSpinBox);
708
DEBUG("Config: hiding stun options, showing Local/Published info");
710
gtk_widget_hide (stunServerLabel);
711
gtk_widget_hide (stunServerEntry);
712
gtk_widget_set_sensitive (sameAsLocalRadioButton, TRUE);
713
gtk_widget_set_sensitive (publishedAddrRadioButton, TRUE);
715
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton))) {
716
gtk_widget_show (publishedAddressLabel);
717
gtk_widget_show (publishedPortLabel);
718
gtk_widget_show (publishedAddressEntry);
719
gtk_widget_show (publishedPortSpinBox);
725
static same_as_local_cb(GtkWidget * widget, gpointer data UNUSED)
728
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
729
DEBUG("Same as local");
730
gchar * local_interface;
731
gchar * local_address;
733
local_interface = (gchar *) gtk_combo_box_get_active_text(GTK_COMBO_BOX(localAddressCombo));
734
// sflphone_get_interface_addr_from_name((char *)local_interface);
735
local_address = dbus_get_address_from_interface_name(local_interface);
737
gtk_entry_set_text(GTK_ENTRY(publishedAddressEntry), local_address);
739
gchar * local_port = (gchar *) gtk_entry_get_text(GTK_ENTRY(localPortSpinBox));
740
gtk_spin_button_set_value(GTK_SPIN_BUTTON(publishedPortSpinBox), g_ascii_strtod(local_port, NULL));
747
GtkWidget* create_credential_widget (account_t **a) {
749
GtkWidget *frame, *table, *scrolledWindowCredential, *addButton;
750
GtkCellRenderer * renderer;
751
GtkTreeViewColumn * treeViewColumn;
752
GtkTreeSelection * treeSelection;
754
/* Credentials tree view */
755
gnome_main_section_new_with_table (_("Credential"), &frame, &table, 1, 1);
756
gtk_container_set_border_width (GTK_CONTAINER(table), 10);
757
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
759
scrolledWindowCredential = gtk_scrolled_window_new (NULL, NULL);
760
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledWindowCredential), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
761
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledWindowCredential), GTK_SHADOW_IN);
762
gtk_table_attach_defaults (GTK_TABLE (table), scrolledWindowCredential, 0, 1, 0, 1);
764
credentialStore = gtk_list_store_new(COLUMN_CREDENTIAL_COUNT,
765
G_TYPE_STRING, // Realm
766
G_TYPE_STRING, // Username
767
G_TYPE_STRING, // Password
768
G_TYPE_POINTER // Pointer to the Objectc
771
treeViewCredential = gtk_tree_view_new_with_model(GTK_TREE_MODEL(credentialStore));
772
treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW (treeViewCredential));
773
g_signal_connect(G_OBJECT (treeSelection), "changed", G_CALLBACK (select_credential_cb), credentialStore);
775
renderer = gtk_cell_renderer_text_new();
776
g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL);
777
g_signal_connect(G_OBJECT (renderer), "edited", G_CALLBACK(cell_edited_cb), credentialStore);
778
g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_REALM));
779
treeViewColumn = gtk_tree_view_column_new_with_attributes ("Realm",
781
"markup", COLUMN_CREDENTIAL_REALM,
783
gtk_tree_view_append_column (GTK_TREE_VIEW(treeViewCredential), treeViewColumn);
785
renderer = gtk_cell_renderer_text_new();
786
g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL);
787
g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (cell_edited_cb), credentialStore);
788
g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_USERNAME));
789
treeViewColumn = gtk_tree_view_column_new_with_attributes (_("Authentication name"),
791
"markup", COLUMN_CREDENTIAL_USERNAME,
793
gtk_tree_view_append_column (GTK_TREE_VIEW(treeViewCredential), treeViewColumn);
795
renderer = gtk_cell_renderer_text_new();
796
g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL);
797
g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (cell_edited_cb), credentialStore);
798
g_signal_connect (renderer, "editing-started", G_CALLBACK (editing_started_cb), NULL);
799
g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_PASSWORD));
800
treeViewColumn = gtk_tree_view_column_new_with_attributes (_("Password"),
802
"markup", COLUMN_CREDENTIAL_PASSWORD,
804
gtk_tree_view_append_column (GTK_TREE_VIEW(treeViewCredential), treeViewColumn);
806
gtk_container_add(GTK_CONTAINER(scrolledWindowCredential), treeViewCredential);
808
fill_treeview_with_credential(credentialStore, *a);
810
/* Credential Buttons */
811
hbox = gtk_hbox_new(FALSE, 10);
812
gtk_table_attach_defaults(GTK_TABLE(table), hbox, 0, 3, 1, 2);
814
addButton = gtk_button_new_from_stock (GTK_STOCK_ADD);
815
g_signal_connect (addButton, "clicked", G_CALLBACK (add_credential_cb), credentialStore);
816
gtk_box_pack_start(GTK_BOX(hbox), addButton, FALSE, FALSE, 0);
818
deleteCredButton = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
819
g_signal_connect (deleteCredButton, "clicked", G_CALLBACK (delete_credential_cb), treeViewCredential);
820
gtk_box_pack_start(GTK_BOX(hbox), deleteCredButton, FALSE, FALSE, 0);
822
/* Dynamically resize the window to fit the scrolled window */
823
GtkRequisition requisitionTable;
824
GtkRequisition requisitionTreeView;
825
gtk_widget_size_request (GTK_WIDGET(treeViewCredential), &requisitionTreeView);
826
gtk_widget_size_request (GTK_WIDGET(table), &requisitionTable);
827
gtk_widget_set_size_request (GTK_WIDGET(scrolledWindowCredential), 400, 120);
828
// same_as_local_cb (sameAsLocalRadioButton, NULL);
829
// set_published_addr_manually_cb (publishedAddrRadioButton, NULL);
835
GtkWidget* create_security_widget (account_t **a) {
837
GtkWidget *frame, *table, *sipTlsAdvancedButton, *label;
838
gchar *curSRTPEnabled = NULL, *curKeyExchange = NULL, *curTLSEnabled = NULL;
840
// Load from SIP/IAX/Unknown ?
842
curKeyExchange = g_hash_table_lookup ((*a)->properties, ACCOUNT_KEY_EXCHANGE);
843
if (curKeyExchange == NULL) {
844
curKeyExchange = "none";
847
curSRTPEnabled = g_hash_table_lookup ((*a)->properties, ACCOUNT_SRTP_ENABLED);
848
if (curSRTPEnabled == NULL) {
849
curSRTPEnabled = "false";
852
curTLSEnabled = g_hash_table_lookup ((*a)->properties, TLS_ENABLE);
853
if (curTLSEnabled == NULL) {
854
curTLSEnabled = "false";
858
gnome_main_section_new_with_table (_("Security"), &frame, &table, 2, 3);
859
gtk_container_set_border_width (GTK_CONTAINER(table), 10);
860
gtk_table_set_row_spacings (GTK_TABLE(table), 10);
861
gtk_table_set_col_spacings (GTK_TABLE(table), 10);
864
sipTlsAdvancedButton = gtk_button_new_from_stock (GTK_STOCK_EDIT);
865
gtk_table_attach_defaults (GTK_TABLE (table), sipTlsAdvancedButton, 2, 3, 0, 1);
866
gtk_widget_set_sensitive (GTK_WIDGET (sipTlsAdvancedButton), FALSE);
867
g_signal_connect (G_OBJECT (sipTlsAdvancedButton), "clicked", G_CALLBACK (show_advanced_tls_options_cb), (*a)->properties);
869
useSipTlsCheckBox = gtk_check_button_new_with_mnemonic(_("Use TLS transport (sips)"));
870
g_signal_connect (useSipTlsCheckBox, "toggled", G_CALLBACK(use_sip_tls_cb), sipTlsAdvancedButton);
871
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useSipTlsCheckBox), (g_strcmp0(curTLSEnabled, "true") == 0) ? TRUE:FALSE);
872
gtk_table_attach_defaults(GTK_TABLE(table), useSipTlsCheckBox, 0, 2, 0, 1);
874
/* ZRTP subsection */
875
label = gtk_label_new_with_mnemonic (_("SRTP key exchange"));
876
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
877
keyExchangeCombo = gtk_combo_box_new_text();
878
gtk_label_set_mnemonic_widget (GTK_LABEL (label), keyExchangeCombo);
879
gtk_combo_box_append_text(GTK_COMBO_BOX(keyExchangeCombo), "ZRTP");
880
gtk_combo_box_append_text(GTK_COMBO_BOX(keyExchangeCombo), "SDES");
881
gtk_combo_box_append_text(GTK_COMBO_BOX(keyExchangeCombo), _("Disabled"));
883
advancedZrtpButton = gtk_button_new_from_stock(GTK_STOCK_PREFERENCES);
884
g_signal_connect(G_OBJECT(advancedZrtpButton), "clicked", G_CALLBACK(show_advanced_zrtp_options_cb), (*a)->properties);
886
if (g_strcmp0(curSRTPEnabled, "false") == 0)
888
gtk_combo_box_set_active(GTK_COMBO_BOX(keyExchangeCombo), 2);
889
gtk_widget_set_sensitive(GTK_WIDGET(advancedZrtpButton), FALSE);
891
if (strcmp(curKeyExchange, ZRTP) == 0) {
892
gtk_combo_box_set_active(GTK_COMBO_BOX(keyExchangeCombo),0);
894
else if (strcmp(curKeyExchange, SDES) == 0) {
895
gtk_combo_box_set_active(GTK_COMBO_BOX(keyExchangeCombo),1);
898
gtk_combo_box_set_active(GTK_COMBO_BOX(keyExchangeCombo), 2);
899
gtk_widget_set_sensitive(GTK_WIDGET(advancedZrtpButton), FALSE);
903
g_signal_connect (G_OBJECT (GTK_COMBO_BOX(keyExchangeCombo)), "changed", G_CALLBACK (key_exchange_changed_cb), *a);
905
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
906
gtk_table_attach_defaults(GTK_TABLE(table), keyExchangeCombo, 1, 2, 1, 2);
907
gtk_table_attach_defaults(GTK_TABLE(table), advancedZrtpButton, 2, 3, 1, 2);
909
gtk_widget_show_all(table);
151
void change_protocol_cb (account_t *currentAccount UNUSED)
154
gchar *protocol = gtk_combo_box_get_active_text (GTK_COMBO_BOX (protocolComboBox));
156
// Only if tabs are not NULL
157
if (security_tab && advanced_tab) {
158
if (g_strcasecmp (protocol, "IAX") == 0) {
159
gtk_widget_hide (GTK_WIDGET (security_tab));
160
gtk_widget_hide (GTK_WIDGET (advanced_tab));
162
gtk_widget_show (GTK_WIDGET (security_tab));
163
gtk_widget_show (GTK_WIDGET (advanced_tab));
169
is_iax_enabled (void)
171
int res = dbus_is_iax2_enabled();
181
select_dtmf_type (void)
184
DEBUG ("DTMF selection changed\n");
186
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (overrtp))) {
187
// dbus_set_audio_manager( ALSA );
188
DEBUG ("Selected DTMF over RTP");
191
// dbus_set_audio_manager( PULSEAUDIO );
192
DEBUG ("Selected DTMF over SIP");
197
static GPtrArray* getNewCredential (GHashTable * properties)
204
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (credentialStore), &iter);
206
GPtrArray *credential_array = g_ptr_array_new ();
211
GHashTable * new_table;
213
if (valid == FALSE) {
214
DEBUG ("Gtk tree model iter is not valid");
218
gtk_tree_model_get (GTK_TREE_MODEL (credentialStore), &iter,
219
COLUMN_CREDENTIAL_REALM, &realm,
220
COLUMN_CREDENTIAL_USERNAME, &username,
221
COLUMN_CREDENTIAL_PASSWORD, &password,
224
g_hash_table_insert (properties, g_strdup (ACCOUNT_REALM), realm);
226
// better use the current_username as it is the account username in the
227
// g_hash_table_insert(properties, g_strdup(ACCOUNT_AUTHENTICATION_USERNAME), username);
228
g_hash_table_insert (properties, g_strdup (ACCOUNT_AUTHENTICATION_USERNAME), current_username);
230
// Do not change the password if nothing has been changed by the user
231
if (g_strcasecmp (password, PW_HIDDEN) != 0)
232
g_hash_table_insert (properties, g_strdup (ACCOUNT_PASSWORD), password);
235
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (credentialStore), &iter);
238
gtk_tree_model_get (GTK_TREE_MODEL (credentialStore), &iter,
239
COLUMN_CREDENTIAL_REALM, &realm,
240
COLUMN_CREDENTIAL_USERNAME, &username,
241
COLUMN_CREDENTIAL_PASSWORD, &password,
244
DEBUG ("Row %d: %s %s %s", row_count, username, password, realm);
246
new_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
247
g_hash_table_insert (new_table, g_strdup (ACCOUNT_REALM), realm);
248
g_hash_table_insert (new_table, g_strdup (ACCOUNT_USERNAME), username);
249
g_hash_table_insert (new_table, g_strdup (ACCOUNT_PASSWORD), password);
251
g_ptr_array_add (credential_array, new_table);
255
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (credentialStore), &iter);
258
return credential_array;
261
static void update_credential_cb (GtkWidget *widget, gpointer data UNUSED)
265
if (credentialStore) {
266
if (gtk_tree_model_get_iter_from_string ( (GtkTreeModel *) credentialStore, &iter, "0")) {
267
gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "column"));
268
// g_print ("set password to %s\n", (gchar *) gtk_entry_get_text(GTK_ENTRY(widget)));
269
gtk_list_store_set (GTK_LIST_STORE (credentialStore), &iter, column, (gchar *) gtk_entry_get_text (GTK_ENTRY (widget)), -1);
275
static GtkWidget* create_basic_tab (account_t **a)
280
account_t *currentAccount;
281
GtkWidget * clearTextCheckbox;
282
#if GTK_CHECK_VERSION(2,16,0)
288
gchar *curAccountID = "";
289
gchar *curAccountEnabled = "true";
290
gchar *curAccountType = "SIP";
291
gchar *curAlias = "";
292
gchar *curUsername = "";
293
gchar *curHostname = "";
294
gchar *curPassword = "";
295
/* TODO: add curProxy, and add boxes for Proxy support */
296
gchar *curMailbox = "";
297
gchar *curUseragent = "";
303
DEBUG ("Config: Create basic account tab");
305
// Load from SIP/IAX/Unknown ?
306
if (currentAccount) {
307
curAccountID = currentAccount->accountID;
308
curAccountType = g_hash_table_lookup (currentAccount->properties, ACCOUNT_TYPE);
309
curAccountEnabled = g_hash_table_lookup (currentAccount->properties, ACCOUNT_ENABLED);
310
curAlias = g_hash_table_lookup (currentAccount->properties, ACCOUNT_ALIAS);
311
curHostname = g_hash_table_lookup (currentAccount->properties, ACCOUNT_HOSTNAME);
312
curPassword = g_hash_table_lookup (currentAccount->properties, ACCOUNT_PASSWORD);
313
curUsername = g_hash_table_lookup (currentAccount->properties, ACCOUNT_USERNAME);
314
// curRouteSet = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ROUTE);
315
curMailbox = g_hash_table_lookup (currentAccount->properties, ACCOUNT_MAILBOX);
316
curMailbox = curMailbox != NULL ? curMailbox : "";
317
curUseragent = g_hash_table_lookup (currentAccount->properties, ACCOUNT_USERAGENT);
320
gnome_main_section_new (_ ("Account Parameters"), &frame);
321
gtk_widget_show (frame);
323
if (strcmp (curAccountType, "SIP") == 0) {
324
table = gtk_table_new (9, 2, FALSE/* homogeneous */);
325
} else if (strcmp (curAccountType, "IAX") == 0) {
326
table = gtk_table_new (8, 2, FALSE);
329
gtk_table_set_row_spacings (GTK_TABLE (table), 10);
330
gtk_table_set_col_spacings (GTK_TABLE (table), 10);
331
gtk_widget_show (table);
332
gtk_container_add (GTK_CONTAINER (frame) , table);
334
label = gtk_label_new_with_mnemonic (_ ("_Alias"));
335
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
336
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
337
entryAlias = gtk_entry_new();
338
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryAlias);
339
gtk_entry_set_text (GTK_ENTRY (entryAlias), curAlias);
340
gtk_table_attach (GTK_TABLE (table), entryAlias, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
344
label = gtk_label_new_with_mnemonic (_ ("_Protocol"));
345
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
346
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
347
protocolComboBox = gtk_combo_box_new_text();
348
gtk_label_set_mnemonic_widget (GTK_LABEL (label), protocolComboBox);
349
gtk_combo_box_append_text (GTK_COMBO_BOX (protocolComboBox), "SIP");
351
if (is_iax_enabled()) gtk_combo_box_append_text (GTK_COMBO_BOX (protocolComboBox), "IAX");
353
if (strcmp (curAccountType, "SIP") == 0) {
354
gtk_combo_box_set_active (GTK_COMBO_BOX (protocolComboBox),0);
355
} else if (strcmp (curAccountType, "IAX") == 0) {
356
gtk_combo_box_set_active (GTK_COMBO_BOX (protocolComboBox),1);
358
DEBUG ("Config: Error: Account protocol not valid");
359
/* Should never come here, add debug message. */
360
gtk_combo_box_append_text (GTK_COMBO_BOX (protocolComboBox), _ ("Unknown"));
361
gtk_combo_box_set_active (GTK_COMBO_BOX (protocolComboBox),2);
364
gtk_table_attach (GTK_TABLE (table), protocolComboBox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
366
/* Link signal 'changed' */
367
g_signal_connect (G_OBJECT (GTK_COMBO_BOX (protocolComboBox)), "changed",
368
G_CALLBACK (change_protocol_cb),
372
label = gtk_label_new_with_mnemonic (_ ("_Host name"));
373
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
374
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
375
entryHostname = gtk_entry_new();
376
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryHostname);
377
gtk_entry_set_text (GTK_ENTRY (entryHostname), curHostname);
378
gtk_table_attach (GTK_TABLE (table), entryHostname, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
381
label = gtk_label_new_with_mnemonic (_ ("_User name"));
382
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
383
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
384
#if GTK_CHECK_VERSION(2,16,0)
385
entryUsername = gtk_entry_new();
386
gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entryUsername), GTK_ENTRY_ICON_PRIMARY, gdk_pixbuf_new_from_file (ICONS_DIR "/stock_person.svg", NULL));
388
entryUsername = sexy_icon_entry_new();
389
image = gtk_image_new_from_file (ICONS_DIR "/stock_person.svg");
390
sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (entryUsername), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image));
392
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryUsername);
393
gtk_entry_set_text (GTK_ENTRY (entryUsername), curUsername);
394
gtk_table_attach (GTK_TABLE (table), entryUsername, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
396
if (strcmp (curAccountType, "SIP") == 0) {
397
g_signal_connect (G_OBJECT (entryUsername), "changed", G_CALLBACK (update_credential_cb), NULL);
398
g_object_set_data (G_OBJECT (entryUsername), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_USERNAME));
402
label = gtk_label_new_with_mnemonic (_ ("_Password"));
403
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
404
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
405
#if GTK_CHECK_VERSION(2,16,0)
406
entryPassword = gtk_entry_new();
407
gtk_entry_set_icon_from_stock (GTK_ENTRY (entryPassword), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION);
409
entryPassword = sexy_icon_entry_new();
410
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR);
411
sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (entryPassword), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image));
413
gtk_entry_set_visibility (GTK_ENTRY (entryPassword), FALSE);
414
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryPassword);
415
gtk_entry_set_text (GTK_ENTRY (entryPassword), curPassword);
416
gtk_table_attach (GTK_TABLE (table), entryPassword, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
418
if (strcmp (curAccountType, "SIP") == 0) {
419
g_signal_connect (G_OBJECT (entryPassword), "changed", G_CALLBACK (update_credential_cb), NULL);
420
g_object_set_data (G_OBJECT (entryPassword), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_PASSWORD));
424
clearTextCheckbox = gtk_check_button_new_with_mnemonic (_ ("Show password"));
425
g_signal_connect (clearTextCheckbox, "toggled", G_CALLBACK (show_password_cb), entryPassword);
426
gtk_table_attach (GTK_TABLE (table), clearTextCheckbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
429
label = gtk_label_new_with_mnemonic (_ ("_Voicemail number"));
430
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
431
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
432
entryMailbox = gtk_entry_new();
433
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryMailbox);
434
gtk_entry_set_text (GTK_ENTRY (entryMailbox), curMailbox);
435
gtk_table_attach (GTK_TABLE (table), entryMailbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
438
label = gtk_label_new_with_mnemonic (_ ("_User-agent"));
439
gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
440
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
441
entryUseragent = gtk_entry_new ();
442
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryUseragent);
443
gtk_entry_set_text (GTK_ENTRY (entryUseragent), curUseragent);
444
gtk_table_attach (GTK_TABLE (table), entryUseragent, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
446
gtk_widget_show_all (table);
447
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
453
static void fill_treeview_with_credential (GtkListStore * credentialStore, account_t * account)
456
gtk_list_store_clear (credentialStore);
458
if (account->credential_information == NULL) {
459
DEBUG ("No credential defined");
465
for (i = 0; i < account->credential_information->len; i++) {
466
GHashTable * element = g_ptr_array_index (account->credential_information, i);
467
gtk_list_store_append (credentialStore, &iter);
468
gtk_list_store_set (credentialStore, &iter,
469
COLUMN_CREDENTIAL_REALM, g_hash_table_lookup (element, ACCOUNT_REALM),
470
COLUMN_CREDENTIAL_USERNAME, g_hash_table_lookup (element, ACCOUNT_USERNAME),
471
COLUMN_CREDENTIAL_PASSWORD, g_hash_table_lookup (element, ACCOUNT_PASSWORD),
472
COLUMN_CREDENTIAL_DATA, element, -1);
476
static void select_credential_cb (GtkTreeSelection *selection, GtkTreeModel *model)
481
if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
482
path = gtk_tree_model_get_path (model, &iter);
484
if (gtk_tree_path_get_indices (path) [0] == 0) {
485
gtk_widget_set_sensitive (GTK_WIDGET (deleteCredButton), FALSE);
487
gtk_widget_set_sensitive (GTK_WIDGET (deleteCredButton), TRUE);
492
static void add_credential_cb (GtkWidget *button UNUSED, gpointer data)
495
GtkTreeModel *model = (GtkTreeModel *) data;
497
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
498
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
499
COLUMN_CREDENTIAL_REALM, "*",
500
COLUMN_CREDENTIAL_USERNAME, _ ("Authentication"),
501
COLUMN_CREDENTIAL_PASSWORD, _ ("Secret"),
505
static void delete_credential_cb (GtkWidget *button UNUSED, gpointer data)
508
GtkTreeView *treeview = (GtkTreeView *) data;
509
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
510
GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview);
512
if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
514
path = gtk_tree_model_get_path (model, &iter);
515
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
517
gtk_tree_path_free (path);
522
static void cell_edited_cb (GtkCellRendererText *renderer, gchar *path_desc, gchar *text, gpointer data)
524
GtkTreeModel *model = (GtkTreeModel *) data;
525
GtkTreePath *path = gtk_tree_path_new_from_string (path_desc);
528
gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (renderer), "column"));
529
DEBUG ("path desc in cell_edited_cb: %s\n", text);
531
if (g_strcasecmp (path_desc, "0") == 0) {
532
if (g_strcasecmp (text, gtk_entry_get_text (GTK_ENTRY (entryUsername))) != 0) {
533
g_signal_handlers_disconnect_by_func (G_OBJECT (entryUsername), G_CALLBACK (update_credential_cb), NULL);
536
if (column == COLUMN_CREDENTIAL_PASSWORD) {
537
gtk_entry_set_text (GTK_ENTRY (entryPassword), text);
542
gtk_tree_model_get_iter (model, &iter, path);
543
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, text, -1);
544
gtk_tree_path_free (path);
548
static void editing_started_cb (GtkCellRenderer *cell UNUSED, GtkCellEditable * editable, const gchar * path, gpointer data UNUSED)
551
DEBUG ("Editing started");
552
DEBUG ("path desc in editing_started_cb: %s\n", path);
554
// If we are dealing the first row
555
if (g_strcasecmp (path, "0") == 0) {
556
gtk_entry_set_text (GTK_ENTRY (editable), gtk_entry_get_text (GTK_ENTRY (entryPassword)));
560
static void show_advanced_zrtp_options_cb (GtkWidget *widget UNUSED, gpointer data)
563
DEBUG ("Advanced options for SRTP");
565
if (g_strcasecmp (gtk_combo_box_get_active_text (GTK_COMBO_BOX (keyExchangeCombo)), (gchar *) "ZRTP") == 0) {
566
show_advanced_zrtp_options ( (GHashTable *) data);
568
show_advanced_sdes_options ( (GHashTable *) data);
573
static void show_advanced_tls_options_cb (GtkWidget *widget UNUSED, gpointer data)
575
DEBUG ("Advanced options for TLS");
576
show_advanced_tls_options ( (GHashTable *) data);
579
static void key_exchange_changed_cb (GtkWidget *widget UNUSED, gpointer data UNUSED)
582
DEBUG ("Key exchange changed %s", gtk_combo_box_get_active_text (GTK_COMBO_BOX (keyExchangeCombo)));
584
int isSdes = g_strcasecmp (gtk_combo_box_get_active_text (GTK_COMBO_BOX (keyExchangeCombo)), (gchar *) "SDES");
585
int isZrtp = g_strcasecmp (gtk_combo_box_get_active_text (GTK_COMBO_BOX (keyExchangeCombo)), (gchar *) "ZRTP");
587
if ( (isSdes == 0) || (isZrtp == 0)) {
588
gtk_widget_set_sensitive (GTK_WIDGET (advancedZrtpButton), TRUE);
590
gtk_widget_set_sensitive (GTK_WIDGET (advancedZrtpButton), FALSE);
596
static void use_sip_tls_cb (GtkWidget *widget, gpointer data)
599
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
600
DEBUG ("Using sips");
601
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
603
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (useStunCheckBox), FALSE);
604
gtk_widget_set_sensitive (GTK_WIDGET (useStunCheckBox), FALSE);
605
gtk_widget_set_sensitive (GTK_WIDGET (sameAsLocalRadioButton), TRUE);
606
gtk_widget_set_sensitive (GTK_WIDGET (publishedAddrRadioButton), TRUE);
607
gtk_widget_hide (stunServerLabel);
608
gtk_widget_hide (stunServerEntry);
612
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton))) {
613
gtk_widget_show (publishedAddressEntry);
614
gtk_widget_show (publishedPortSpinBox);
615
gtk_widget_show (publishedAddressLabel);
616
gtk_widget_show (publishedPortLabel);
620
gtk_widget_set_sensitive (GTK_WIDGET (data), FALSE);
621
gtk_widget_set_sensitive (GTK_WIDGET (useStunCheckBox), TRUE);
623
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (useStunCheckBox))) {
624
gtk_widget_set_sensitive (GTK_WIDGET (sameAsLocalRadioButton), FALSE);
625
gtk_widget_set_sensitive (GTK_WIDGET (publishedAddrRadioButton), FALSE);
626
gtk_widget_show (stunServerLabel);
627
gtk_widget_show (stunServerEntry);
628
gtk_widget_hide (publishedAddressEntry);
629
gtk_widget_hide (publishedPortSpinBox);
630
gtk_widget_hide (publishedAddressLabel);
631
gtk_widget_hide (publishedPortLabel);
633
gtk_widget_set_sensitive (GTK_WIDGET (sameAsLocalRadioButton), TRUE);
634
gtk_widget_set_sensitive (GTK_WIDGET (publishedAddrRadioButton), TRUE);
635
gtk_widget_hide (stunServerLabel);
636
gtk_widget_hide (stunServerEntry);
642
static void local_interface_changed_cb (GtkWidget * widget UNUSED, gpointer data UNUSED)
645
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton))) {
647
gchar *local_iface_name;
648
gchar *local_iface_addr;
649
local_iface_addr = g_malloc (36);
651
local_iface_name = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo));
652
sflphone_get_interface_addr_from_name (local_iface_name, &local_iface_addr, 36);
654
gtk_entry_set_text (GTK_ENTRY (localAddressEntry), local_iface_addr);
655
gtk_entry_set_text (GTK_ENTRY (publishedAddressEntry), local_iface_addr);
657
g_free (local_iface_addr);
662
static void set_published_addr_manually_cb (GtkWidget * widget, gpointer data UNUSED)
664
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
665
DEBUG ("Config: Showing manual publishing options");
666
gtk_widget_show (publishedPortLabel);
667
gtk_widget_show (publishedPortSpinBox);
668
gtk_widget_show (publishedAddressLabel);
669
gtk_widget_show (publishedAddressEntry);
671
DEBUG ("Config: Hiding manual publishing options");
672
gtk_widget_hide (publishedPortLabel);
673
gtk_widget_hide (publishedPortSpinBox);
674
gtk_widget_hide (publishedAddressLabel);
675
gtk_widget_hide (publishedAddressEntry);
679
static void use_stun_cb (GtkWidget *widget, gpointer data UNUSED)
681
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
683
DEBUG ("Config: Showing stun options, hiding Local/Published info");
684
gtk_widget_show (stunServerLabel);
685
gtk_widget_show (stunServerEntry);
686
gtk_widget_set_sensitive (sameAsLocalRadioButton, FALSE);
687
gtk_widget_set_sensitive (publishedAddrRadioButton, FALSE);
689
gtk_widget_hide (publishedAddressLabel);
690
gtk_widget_hide (publishedPortLabel);
691
gtk_widget_hide (publishedAddressEntry);
692
gtk_widget_hide (publishedPortSpinBox);
696
DEBUG ("Config: hiding stun options, showing Local/Published info");
698
gtk_widget_hide (stunServerLabel);
699
gtk_widget_hide (stunServerEntry);
700
gtk_widget_set_sensitive (sameAsLocalRadioButton, TRUE);
701
gtk_widget_set_sensitive (publishedAddrRadioButton, TRUE);
703
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton))) {
704
gtk_widget_show (publishedAddressLabel);
705
gtk_widget_show (publishedPortLabel);
706
gtk_widget_show (publishedAddressEntry);
707
gtk_widget_show (publishedPortSpinBox);
713
static void same_as_local_cb (GtkWidget * widget, gpointer data UNUSED)
716
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
717
DEBUG ("Same as local");
718
gchar * local_interface;
719
gchar * local_address;
721
local_interface = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo));
722
// sflphone_get_interface_addr_from_name((char *)local_interface);
723
local_address = dbus_get_address_from_interface_name (local_interface);
725
gtk_entry_set_text (GTK_ENTRY (publishedAddressEntry), local_address);
727
gchar * local_port = (gchar *) gtk_entry_get_text (GTK_ENTRY (localPortSpinBox));
728
gtk_spin_button_set_value (GTK_SPIN_BUTTON (publishedPortSpinBox), g_ascii_strtod (local_port, NULL));
735
GtkWidget* create_credential_widget (account_t **a)
738
GtkWidget *frame, *table, *scrolledWindowCredential, *addButton;
739
GtkCellRenderer * renderer;
740
GtkTreeViewColumn * treeViewColumn;
741
GtkTreeSelection * treeSelection;
743
/* Credentials tree view */
744
gnome_main_section_new_with_table (_ ("Credential"), &frame, &table, 1, 1);
745
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
746
gtk_table_set_row_spacings (GTK_TABLE (table), 10);
748
scrolledWindowCredential = gtk_scrolled_window_new (NULL, NULL);
749
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledWindowCredential), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
750
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledWindowCredential), GTK_SHADOW_IN);
751
gtk_table_attach_defaults (GTK_TABLE (table), scrolledWindowCredential, 0, 1, 0, 1);
753
credentialStore = gtk_list_store_new (COLUMN_CREDENTIAL_COUNT,
754
G_TYPE_STRING, // Realm
755
G_TYPE_STRING, // Username
756
G_TYPE_STRING, // Password
757
G_TYPE_POINTER // Pointer to the Objectc
760
treeViewCredential = gtk_tree_view_new_with_model (GTK_TREE_MODEL (credentialStore));
761
treeSelection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeViewCredential));
762
g_signal_connect (G_OBJECT (treeSelection), "changed", G_CALLBACK (select_credential_cb), credentialStore);
764
renderer = gtk_cell_renderer_text_new();
765
g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL);
766
g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (cell_edited_cb), credentialStore);
767
g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_REALM));
768
treeViewColumn = gtk_tree_view_column_new_with_attributes ("Realm",
770
"markup", COLUMN_CREDENTIAL_REALM,
772
gtk_tree_view_append_column (GTK_TREE_VIEW (treeViewCredential), treeViewColumn);
774
renderer = gtk_cell_renderer_text_new();
775
g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL);
776
g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (cell_edited_cb), credentialStore);
777
g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_USERNAME));
778
treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Authentication name"),
780
"markup", COLUMN_CREDENTIAL_USERNAME,
782
gtk_tree_view_append_column (GTK_TREE_VIEW (treeViewCredential), treeViewColumn);
784
renderer = gtk_cell_renderer_text_new();
785
g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL);
786
g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (cell_edited_cb), credentialStore);
787
g_signal_connect (renderer, "editing-started", G_CALLBACK (editing_started_cb), NULL);
788
g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_CREDENTIAL_PASSWORD));
789
treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Password"),
791
"markup", COLUMN_CREDENTIAL_PASSWORD,
793
gtk_tree_view_append_column (GTK_TREE_VIEW (treeViewCredential), treeViewColumn);
795
gtk_container_add (GTK_CONTAINER (scrolledWindowCredential), treeViewCredential);
797
DEBUG ("Credential pas ok");
798
fill_treeview_with_credential (credentialStore, *a);
799
DEBUG ("Credential ok");
801
/* Credential Buttons */
802
hbox = gtk_hbox_new (FALSE, 10);
803
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 0, 3, 1, 2);
805
addButton = gtk_button_new_from_stock (GTK_STOCK_ADD);
806
g_signal_connect (addButton, "clicked", G_CALLBACK (add_credential_cb), credentialStore);
807
gtk_box_pack_start (GTK_BOX (hbox), addButton, FALSE, FALSE, 0);
809
deleteCredButton = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
810
g_signal_connect (deleteCredButton, "clicked", G_CALLBACK (delete_credential_cb), treeViewCredential);
811
gtk_box_pack_start (GTK_BOX (hbox), deleteCredButton, FALSE, FALSE, 0);
813
/* Dynamically resize the window to fit the scrolled window */
814
GtkRequisition requisitionTable;
815
GtkRequisition requisitionTreeView;
816
gtk_widget_size_request (GTK_WIDGET (treeViewCredential), &requisitionTreeView);
817
gtk_widget_size_request (GTK_WIDGET (table), &requisitionTable);
818
gtk_widget_set_size_request (GTK_WIDGET (scrolledWindowCredential), 400, 120);
819
// same_as_local_cb (sameAsLocalRadioButton, NULL);
820
// set_published_addr_manually_cb (publishedAddrRadioButton, NULL);
826
GtkWidget* create_security_widget (account_t **a)
829
GtkWidget *frame, *table, *sipTlsAdvancedButton, *label;
830
gchar *curSRTPEnabled = NULL, *curKeyExchange = NULL, *curTLSEnabled = NULL;
832
// Load from SIP/IAX/Unknown ?
834
curKeyExchange = g_hash_table_lookup ( (*a)->properties, ACCOUNT_KEY_EXCHANGE);
836
if (curKeyExchange == NULL) {
837
curKeyExchange = "none";
840
curSRTPEnabled = g_hash_table_lookup ( (*a)->properties, ACCOUNT_SRTP_ENABLED);
842
if (curSRTPEnabled == NULL) {
843
curSRTPEnabled = "false";
846
curTLSEnabled = g_hash_table_lookup ( (*a)->properties, TLS_ENABLE);
848
if (curTLSEnabled == NULL) {
849
curTLSEnabled = "false";
853
gnome_main_section_new_with_table (_ ("Security"), &frame, &table, 2, 3);
854
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
855
gtk_table_set_row_spacings (GTK_TABLE (table), 10);
856
gtk_table_set_col_spacings (GTK_TABLE (table), 10);
859
sipTlsAdvancedButton = gtk_button_new_from_stock (GTK_STOCK_EDIT);
860
gtk_table_attach_defaults (GTK_TABLE (table), sipTlsAdvancedButton, 2, 3, 0, 1);
861
gtk_widget_set_sensitive (GTK_WIDGET (sipTlsAdvancedButton), FALSE);
862
g_signal_connect (G_OBJECT (sipTlsAdvancedButton), "clicked", G_CALLBACK (show_advanced_tls_options_cb), (*a)->properties);
864
useSipTlsCheckBox = gtk_check_button_new_with_mnemonic (_ ("Use TLS transport (sips)"));
865
g_signal_connect (useSipTlsCheckBox, "toggled", G_CALLBACK (use_sip_tls_cb), sipTlsAdvancedButton);
866
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (useSipTlsCheckBox), (g_strcmp0 (curTLSEnabled, "true") == 0) ? TRUE:FALSE);
867
gtk_table_attach_defaults (GTK_TABLE (table), useSipTlsCheckBox, 0, 2, 0, 1);
869
/* ZRTP subsection */
870
label = gtk_label_new_with_mnemonic (_ ("SRTP key exchange"));
871
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
872
keyExchangeCombo = gtk_combo_box_new_text();
873
gtk_label_set_mnemonic_widget (GTK_LABEL (label), keyExchangeCombo);
874
gtk_combo_box_append_text (GTK_COMBO_BOX (keyExchangeCombo), "ZRTP");
875
gtk_combo_box_append_text (GTK_COMBO_BOX (keyExchangeCombo), "SDES");
876
gtk_combo_box_append_text (GTK_COMBO_BOX (keyExchangeCombo), _ ("Disabled"));
878
advancedZrtpButton = gtk_button_new_from_stock (GTK_STOCK_PREFERENCES);
879
g_signal_connect (G_OBJECT (advancedZrtpButton), "clicked", G_CALLBACK (show_advanced_zrtp_options_cb), (*a)->properties);
881
if (g_strcmp0 (curSRTPEnabled, "false") == 0) {
882
gtk_combo_box_set_active (GTK_COMBO_BOX (keyExchangeCombo), 2);
883
gtk_widget_set_sensitive (GTK_WIDGET (advancedZrtpButton), FALSE);
885
if (strcmp (curKeyExchange, ZRTP) == 0) {
886
gtk_combo_box_set_active (GTK_COMBO_BOX (keyExchangeCombo),0);
887
} else if (strcmp (curKeyExchange, SDES) == 0) {
888
gtk_combo_box_set_active (GTK_COMBO_BOX (keyExchangeCombo),1);
890
gtk_combo_box_set_active (GTK_COMBO_BOX (keyExchangeCombo), 2);
891
gtk_widget_set_sensitive (GTK_WIDGET (advancedZrtpButton), FALSE);
895
g_signal_connect (G_OBJECT (GTK_COMBO_BOX (keyExchangeCombo)), "changed", G_CALLBACK (key_exchange_changed_cb), *a);
897
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);
898
gtk_table_attach_defaults (GTK_TABLE (table), keyExchangeCombo, 1, 2, 1, 2);
899
gtk_table_attach_defaults (GTK_TABLE (table), advancedZrtpButton, 2, 3, 1, 2);
901
gtk_widget_show_all (table);
915
907
GtkWidget * create_security_tab (account_t **a)
922
ret = gtk_vbox_new(FALSE, 10);
923
gtk_container_set_border_width(GTK_CONTAINER(ret), 10);
926
frame = create_credential_widget (a);
927
gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0);
930
frame = create_security_widget (a);
931
gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0);
933
gtk_widget_show_all(ret);
938
GtkWidget* create_registration_expire (account_t **a) {
912
ret = gtk_vbox_new (FALSE, 10);
913
gtk_container_set_border_width (GTK_CONTAINER (ret), 10);
916
frame = create_credential_widget (a);
917
gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0);
920
frame = create_security_widget (a);
921
gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0);
923
gtk_widget_show_all (ret);
928
GtkWidget* create_registration_expire (account_t **a)
940
931
GtkWidget *table, *frame, *label;
942
933
gchar *resolve_once=NULL, *account_expire=NULL;
945
resolve_once = g_hash_table_lookup ((*a)->properties, ACCOUNT_RESOLVE_ONCE);
946
account_expire = g_hash_table_lookup ((*a)->properties, ACCOUNT_REGISTRATION_EXPIRE);
936
resolve_once = g_hash_table_lookup ( (*a)->properties, ACCOUNT_RESOLVE_ONCE);
937
account_expire = g_hash_table_lookup ( (*a)->properties, ACCOUNT_REGISTRATION_EXPIRE);
949
gnome_main_section_new_with_table (_("Registration"), &frame, &table, 2, 3);
950
gtk_container_set_border_width (GTK_CONTAINER(table), 10);
951
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
953
label = gtk_label_new_with_mnemonic (_("Registration expire"));
940
gnome_main_section_new_with_table (_ ("Registration"), &frame, &table, 2, 3);
941
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
942
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
944
label = gtk_label_new_with_mnemonic (_ ("Registration expire"));
954
945
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);
955
946
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
956
947
expireSpinBox = gtk_spin_button_new_with_range (1, 65535, 1);
957
948
gtk_label_set_mnemonic_widget (GTK_LABEL (label), expireSpinBox);
958
949
gtk_spin_button_set_value (GTK_SPIN_BUTTON (expireSpinBox), g_ascii_strtod (account_expire, NULL));
959
950
gtk_table_attach_defaults (GTK_TABLE (table), expireSpinBox, 1, 2, 0, 1);
962
entryResolveNameOnlyOnce = gtk_check_button_new_with_mnemonic (_("_Comply with RFC 3263"));
953
entryResolveNameOnlyOnce = gtk_check_button_new_with_mnemonic (_ ("_Comply with RFC 3263"));
963
954
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entryResolveNameOnlyOnce),
964
g_strcasecmp (resolve_once,"false") == 0 ? TRUE: FALSE);
955
g_strcasecmp (resolve_once,"false") == 0 ? TRUE: FALSE);
965
956
gtk_table_attach_defaults (GTK_TABLE (table), entryResolveNameOnlyOnce, 0, 2, 1, 2);
966
gtk_widget_set_sensitive (GTK_WIDGET (entryResolveNameOnlyOnce ) , TRUE );
957
gtk_widget_set_sensitive (GTK_WIDGET (entryResolveNameOnlyOnce) , TRUE);
971
GtkWidget* create_network (account_t **a) {
962
GtkWidget* create_network (account_t **a)
973
965
GtkWidget *table, *frame, *label;
974
gchar *local_interface, *local_port;
966
gchar *local_interface = NULL;
967
gchar *local_port = NULL;
977
local_interface = g_hash_table_lookup ((*a)->properties, LOCAL_INTERFACE);
978
local_port = g_hash_table_lookup ((*a)->properties, LOCAL_PORT);
970
local_interface = g_hash_table_lookup ( (*a)->properties, LOCAL_INTERFACE);
971
local_port = g_hash_table_lookup ( (*a)->properties, LOCAL_PORT);
981
gnome_main_section_new_with_table (_("Network Interface"), &frame, &table, 2, 3);
982
gtk_container_set_border_width (GTK_CONTAINER(table), 10);
983
gtk_table_set_row_spacings( GTK_TABLE(table), 5);
974
gnome_main_section_new_with_table (_ ("Network Interface"), &frame, &table, 2, 3);
975
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
976
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
986
* Retreive the list of IP interface from the
979
* Retreive the list of IP interface from the
987
980
* the daemon and build the combo box.
990
GtkListStore * ipInterfaceListStore;
983
GtkListStore * ipInterfaceListStore;
991
984
GtkTreeIter iter;
993
ipInterfaceListStore = gtk_list_store_new( 1, G_TYPE_STRING );
994
label = gtk_label_new_with_mnemonic (_("Local address"));
995
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
996
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
986
ipInterfaceListStore = gtk_list_store_new (1, G_TYPE_STRING);
987
label = gtk_label_new_with_mnemonic (_ ("Local address"));
988
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
989
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
998
GtkTreeIter current_local_iface_iter = iter;
991
GtkTreeIter current_local_iface_iter = iter;
999
992
gchar ** iface_list = NULL;
1000
993
// iface_list = (gchar**) dbus_get_all_ip_interface();
1001
994
iface_list = (gchar**) dbus_get_all_ip_interface_by_name();
1002
995
gchar ** iface = NULL;
1004
// flag to determine if local_address is found
997
// flag to determine if local_address is found
1005
998
gboolean iface_found = FALSE;
1007
1000
gchar *local_iface_addr;
1008
gchar *local_iface_name;
1010
local_iface_addr= g_malloc(36);
1001
gchar *local_iface_name;
1003
local_iface_addr= g_malloc (36);
1012
1005
if (iface_list != NULL) {
1014
1007
// fill the iterface combo box
1015
for (iface = iface_list; *iface; iface++) {
1016
DEBUG("Interface %s", *iface);
1017
gtk_list_store_append(ipInterfaceListStore, &iter );
1018
gtk_list_store_set(ipInterfaceListStore, &iter, 0, *iface, -1 );
1020
// set the current local address
1021
if (!iface_found && (g_strcmp0(*iface, local_interface) == 0)) {
1022
DEBUG("Setting active local address combo box");
1023
current_local_iface_iter = iter;
1029
DEBUG("Did not find local ip address, take fisrt in the list");
1030
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ipInterfaceListStore), ¤t_local_iface_iter);
1008
for (iface = iface_list; *iface; iface++) {
1009
DEBUG ("Interface %s", *iface);
1010
gtk_list_store_append (ipInterfaceListStore, &iter);
1011
gtk_list_store_set (ipInterfaceListStore, &iter, 0, *iface, -1);
1013
// set the current local address
1014
if (!iface_found && (g_strcmp0 (*iface, local_interface) == 0)) {
1015
DEBUG ("Setting active local address combo box");
1016
current_local_iface_iter = iter;
1022
DEBUG ("Did not find local ip address, take fisrt in the list");
1023
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ipInterfaceListStore), ¤t_local_iface_iter);
1036
localAddressCombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ipInterfaceListStore));
1029
localAddressCombo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (ipInterfaceListStore));
1037
1030
gtk_label_set_mnemonic_widget (GTK_LABEL (label), localAddressCombo);
1038
gtk_table_attach ( GTK_TABLE( table ), localAddressCombo, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1039
g_object_unref(G_OBJECT(ipInterfaceListStore));
1031
gtk_table_attach (GTK_TABLE (table), localAddressCombo, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1032
g_object_unref (G_OBJECT (ipInterfaceListStore));
1042
1035
GtkCellRenderer * ipInterfaceCellRenderer;
1043
1036
ipInterfaceCellRenderer = gtk_cell_renderer_text_new();
1045
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(localAddressCombo), ipInterfaceCellRenderer, TRUE);
1046
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(localAddressCombo), ipInterfaceCellRenderer, "text", 0, NULL);
1047
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(localAddressCombo), ¤t_local_iface_iter);
1038
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (localAddressCombo), ipInterfaceCellRenderer, TRUE);
1039
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (localAddressCombo), ipInterfaceCellRenderer, "text", 0, NULL);
1040
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (localAddressCombo), ¤t_local_iface_iter);
1050
1043
// Fill the text entry with the ip address of local interface selected
1051
1044
localAddressEntry = gtk_entry_new();
1052
1045
local_iface_name = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (localAddressCombo));
1053
sflphone_get_interface_addr_from_name(local_iface_name, &local_iface_addr, 36);
1054
gtk_entry_set_text(GTK_ENTRY(localAddressEntry), local_iface_addr);
1055
gtk_widget_set_sensitive(localAddressEntry, FALSE);
1056
gtk_table_attach ( GTK_TABLE( table ), localAddressEntry, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1058
g_free(local_iface_addr);
1046
sflphone_get_interface_addr_from_name (local_iface_name, &local_iface_addr, 36);
1047
gtk_entry_set_text (GTK_ENTRY (localAddressEntry), local_iface_addr);
1048
gtk_widget_set_sensitive (localAddressEntry, FALSE);
1049
gtk_table_attach (GTK_TABLE (table), localAddressEntry, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1051
g_free (local_iface_addr);
1060
1053
// Local port widget
1061
label = gtk_label_new_with_mnemonic (_("Local port"));
1062
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
1063
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
1064
localPortSpinBox = gtk_spin_button_new_with_range(1, 65535, 1);
1054
label = gtk_label_new_with_mnemonic (_ ("Local port"));
1055
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);
1056
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1057
localPortSpinBox = gtk_spin_button_new_with_range (1, 65535, 1);
1065
1058
gtk_label_set_mnemonic_widget (GTK_LABEL (label), localPortSpinBox);
1066
gtk_spin_button_set_value(GTK_SPIN_BUTTON(localPortSpinBox), g_ascii_strtod(local_port, NULL));
1068
gtk_table_attach_defaults(GTK_TABLE(table), localPortSpinBox, 1, 2, 1, 2);
1073
GtkWidget* create_published_address (account_t **a) {
1075
GtkWidget *table, *frame, *label;
1076
gchar *use_tls, *published_address, *published_port, *local_address, *stun_enable, *stun_server, *published_sameas_local;
1078
// Get the user configuration
1081
use_tls = g_hash_table_lookup ((*a)->properties, TLS_ENABLE);
1082
published_sameas_local = g_hash_table_lookup ((*a)->properties, PUBLISHED_SAMEAS_LOCAL);
1084
if (g_strcasecmp (published_sameas_local, "true") == 0) {
1085
published_address = dbus_get_address_from_interface_name (g_hash_table_lookup ((*a)->properties, LOCAL_INTERFACE));
1086
published_port = g_hash_table_lookup ((*a)->properties, LOCAL_PORT);
1089
published_address = g_hash_table_lookup ((*a)->properties, PUBLISHED_ADDRESS);
1090
published_port = g_hash_table_lookup ((*a)->properties, PUBLISHED_PORT);
1093
stun_enable = g_hash_table_lookup ((*a)->properties, ACCOUNT_SIP_STUN_ENABLED);
1094
stun_server = g_hash_table_lookup ((*a)->properties, ACCOUNT_SIP_STUN_SERVER);
1095
published_sameas_local = g_hash_table_lookup ((*a)->properties, PUBLISHED_SAMEAS_LOCAL);
1098
gnome_main_section_new_with_table (_("Published address"), &frame, &table, 2, 3);
1099
gtk_container_set_border_width (GTK_CONTAINER(table), 10);
1100
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
1102
useStunCheckBox = gtk_check_button_new_with_mnemonic(_("Using STUN"));
1103
gtk_table_attach_defaults(GTK_TABLE(table), useStunCheckBox, 0, 1, 0, 1);
1104
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(useStunCheckBox),
1105
g_strcasecmp(stun_enable, "true") == 0 ? TRUE: FALSE);
1106
gtk_widget_set_sensitive (GTK_WIDGET(useStunCheckBox),
1107
g_strcasecmp(use_tls,"true") == 0 ? FALSE: TRUE);
1109
stunServerLabel = gtk_label_new_with_mnemonic (_("STUN server URL"));
1110
gtk_table_attach_defaults(GTK_TABLE(table), stunServerLabel, 0, 1, 1, 2);
1111
gtk_misc_set_alignment(GTK_MISC (stunServerLabel), 0, 0.5);
1112
stunServerEntry = gtk_entry_new();
1113
gtk_label_set_mnemonic_widget (GTK_LABEL (stunServerLabel), stunServerEntry);
1114
gtk_entry_set_text(GTK_ENTRY(stunServerEntry), stun_server);
1115
gtk_table_attach_defaults(GTK_TABLE(table), stunServerEntry, 1, 2, 1, 2);
1117
sameAsLocalRadioButton = gtk_radio_button_new_with_mnemonic_from_widget(NULL, _("Same as local parameters"));
1118
gtk_table_attach_defaults(GTK_TABLE(table), sameAsLocalRadioButton, 0, 2, 3, 4);
1120
publishedAddrRadioButton = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(sameAsLocalRadioButton), _("Set published address and port:"));
1121
gtk_table_attach_defaults(GTK_TABLE(table), publishedAddrRadioButton, 0, 2, 4, 5);
1123
if (g_strcasecmp (published_sameas_local, "true") == 0) {
1124
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton), TRUE);
1125
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton), FALSE);
1127
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton), FALSE);
1128
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton), TRUE);
1131
publishedAddressLabel = gtk_label_new_with_mnemonic (_("Published address"));
1132
gtk_table_attach_defaults( GTK_TABLE(table), publishedAddressLabel, 0, 1, 5, 6);
1133
gtk_misc_set_alignment(GTK_MISC (publishedAddressLabel), 0, 0.5);
1134
publishedAddressEntry = gtk_entry_new();
1135
gtk_label_set_mnemonic_widget (GTK_LABEL (publishedAddressLabel), publishedAddressEntry);
1137
gtk_entry_set_text(GTK_ENTRY(publishedAddressEntry), published_address);
1138
gtk_table_attach_defaults( GTK_TABLE(table), publishedAddressEntry, 1, 2, 5, 6);
1140
publishedPortLabel = gtk_label_new_with_mnemonic(_("Published port"));
1141
gtk_table_attach_defaults(GTK_TABLE(table), publishedPortLabel, 0, 1, 6, 7);
1142
gtk_misc_set_alignment(GTK_MISC (publishedPortLabel), 0, 0.5);
1143
publishedPortSpinBox = gtk_spin_button_new_with_range(1, 65535, 1);
1144
gtk_label_set_mnemonic_widget(GTK_LABEL (publishedPortLabel), publishedPortSpinBox);
1145
gtk_spin_button_set_value(GTK_SPIN_BUTTON(publishedPortSpinBox), g_ascii_strtod(published_port, NULL));
1147
gtk_table_attach_defaults(GTK_TABLE(table), publishedPortSpinBox, 1, 2, 6, 7);
1149
// This will trigger a signal, and the above two
1150
// widgets need to be instanciated before that.
1151
g_signal_connect(localAddressCombo, "changed", G_CALLBACK(local_interface_changed_cb), localAddressCombo);
1153
g_signal_connect(useStunCheckBox, "toggled", G_CALLBACK(use_stun_cb), useStunCheckBox);
1155
g_signal_connect(sameAsLocalRadioButton, "toggled", G_CALLBACK(same_as_local_cb), sameAsLocalRadioButton);
1156
g_signal_connect(publishedAddrRadioButton, "toggled", G_CALLBACK(set_published_addr_manually_cb), publishedAddrRadioButton);
1158
set_published_addr_manually_cb(publishedAddrRadioButton, NULL);
1163
GtkWidget* create_advanced_tab (account_t **a) {
1165
// Build the advanced tab, to appear on the account configuration panel
1166
DEBUG("Config: Build advanced tab")
1168
GtkWidget *ret, *frame;
1170
ret = gtk_vbox_new (FALSE, 10);
1171
gtk_container_set_border_width (GTK_CONTAINER(ret), 10);
1173
frame = create_registration_expire (a);
1174
gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0);
1176
frame = create_network (a);
1177
gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0);
1179
frame = create_published_address (a);
1180
gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0);
1182
gtk_widget_show_all (ret);
1184
use_stun_cb (GTK_WIDGET (useStunCheckBox), NULL);
1186
set_published_addr_manually_cb(GTK_WIDGET (publishedAddrRadioButton), NULL);
1191
GtkWidget* create_codecs_configuration (account_t **a) {
1194
GtkWidget *ret, *codecs, *dtmf, *box, *frame, *sipinfo, *table;
1195
account_t *currentAccount = *a;
1196
gchar *currentDtmfType = "";
1197
gboolean dtmf_are_rtp = TRUE;
1200
ret = gtk_vbox_new(FALSE, 10);
1201
gtk_container_set_border_width(GTK_CONTAINER(ret), 10);
1203
box = codecs_box (a);
1205
// Box for the codecs
1206
gnome_main_section_new (_("Codecs"), &codecs);
1207
gtk_box_pack_start (GTK_BOX(ret), codecs, FALSE, FALSE, 0);
1208
gtk_widget_set_size_request (GTK_WIDGET (codecs), -1, 200);
1209
gtk_widget_show (codecs);
1210
gtk_container_add (GTK_CONTAINER (codecs) , box);
1212
// Add DTMF type selection for SIP account only
1213
p = g_hash_table_lookup(currentAccount->properties, g_strdup(ACCOUNT_TYPE));
1214
if(g_strcmp0(p, "SIP") == 0) {
1217
gnome_main_section_new_with_table (_("DTMF"), &dtmf, &table, 1, 2);
1218
gtk_box_pack_start (GTK_BOX(ret), dtmf, FALSE, FALSE, 0);
1219
gtk_widget_show (dtmf);
1222
currentDtmfType = g_hash_table_lookup (currentAccount->properties, g_strdup(ACCOUNT_DTMF_TYPE));
1223
if (g_strcasecmp(currentDtmfType, OVERRTP) != 0) {
1059
gtk_spin_button_set_value (GTK_SPIN_BUTTON (localPortSpinBox), g_ascii_strtod (local_port, NULL));
1061
gtk_table_attach_defaults (GTK_TABLE (table), localPortSpinBox, 1, 2, 1, 2);
1066
GtkWidget* create_published_address (account_t **a)
1069
GtkWidget *table, *frame;
1070
gchar *use_tls =NULL;
1071
gchar *published_address = NULL;
1072
gchar *published_port = NULL;
1073
gchar *stun_enable = NULL;
1074
gchar *stun_server = NULL;
1075
gchar *published_sameas_local = NULL;
1077
// Get the user configuration
1080
use_tls = g_hash_table_lookup ( (*a)->properties, TLS_ENABLE);
1081
published_sameas_local = g_hash_table_lookup ( (*a)->properties, PUBLISHED_SAMEAS_LOCAL);
1083
if (g_strcasecmp (published_sameas_local, "true") == 0) {
1084
published_address = dbus_get_address_from_interface_name (g_hash_table_lookup ( (*a)->properties, LOCAL_INTERFACE));
1085
published_port = g_hash_table_lookup ( (*a)->properties, LOCAL_PORT);
1087
published_address = g_hash_table_lookup ( (*a)->properties, PUBLISHED_ADDRESS);
1088
published_port = g_hash_table_lookup ( (*a)->properties, PUBLISHED_PORT);
1091
stun_enable = g_hash_table_lookup ( (*a)->properties, ACCOUNT_SIP_STUN_ENABLED);
1092
stun_server = g_hash_table_lookup ( (*a)->properties, ACCOUNT_SIP_STUN_SERVER);
1093
published_sameas_local = g_hash_table_lookup ( (*a)->properties, PUBLISHED_SAMEAS_LOCAL);
1096
gnome_main_section_new_with_table (_ ("Published address"), &frame, &table, 2, 3);
1097
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
1098
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
1100
useStunCheckBox = gtk_check_button_new_with_mnemonic (_ ("Using STUN"));
1101
gtk_table_attach_defaults (GTK_TABLE (table), useStunCheckBox, 0, 1, 0, 1);
1102
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (useStunCheckBox),
1103
g_strcasecmp (stun_enable, "true") == 0 ? TRUE: FALSE);
1104
gtk_widget_set_sensitive (GTK_WIDGET (useStunCheckBox),
1105
g_strcasecmp (use_tls,"true") == 0 ? FALSE: TRUE);
1107
stunServerLabel = gtk_label_new_with_mnemonic (_ ("STUN server URL"));
1108
gtk_table_attach_defaults (GTK_TABLE (table), stunServerLabel, 0, 1, 1, 2);
1109
gtk_misc_set_alignment (GTK_MISC (stunServerLabel), 0, 0.5);
1110
stunServerEntry = gtk_entry_new();
1111
gtk_label_set_mnemonic_widget (GTK_LABEL (stunServerLabel), stunServerEntry);
1112
gtk_entry_set_text (GTK_ENTRY (stunServerEntry), stun_server);
1113
gtk_table_attach_defaults (GTK_TABLE (table), stunServerEntry, 1, 2, 1, 2);
1115
sameAsLocalRadioButton = gtk_radio_button_new_with_mnemonic_from_widget (NULL, _ ("Same as local parameters"));
1116
gtk_table_attach_defaults (GTK_TABLE (table), sameAsLocalRadioButton, 0, 2, 3, 4);
1118
publishedAddrRadioButton = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (sameAsLocalRadioButton), _ ("Set published address and port:"));
1119
gtk_table_attach_defaults (GTK_TABLE (table), publishedAddrRadioButton, 0, 2, 4, 5);
1121
if (g_strcasecmp (published_sameas_local, "true") == 0) {
1122
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton), TRUE);
1123
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton), FALSE);
1125
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sameAsLocalRadioButton), FALSE);
1126
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (publishedAddrRadioButton), TRUE);
1129
publishedAddressLabel = gtk_label_new_with_mnemonic (_ ("Published address"));
1130
gtk_table_attach_defaults (GTK_TABLE (table), publishedAddressLabel, 0, 1, 5, 6);
1131
gtk_misc_set_alignment (GTK_MISC (publishedAddressLabel), 0, 0.5);
1132
publishedAddressEntry = gtk_entry_new();
1133
gtk_label_set_mnemonic_widget (GTK_LABEL (publishedAddressLabel), publishedAddressEntry);
1135
gtk_entry_set_text (GTK_ENTRY (publishedAddressEntry), published_address);
1136
gtk_table_attach_defaults (GTK_TABLE (table), publishedAddressEntry, 1, 2, 5, 6);
1138
publishedPortLabel = gtk_label_new_with_mnemonic (_ ("Published port"));
1139
gtk_table_attach_defaults (GTK_TABLE (table), publishedPortLabel, 0, 1, 6, 7);
1140
gtk_misc_set_alignment (GTK_MISC (publishedPortLabel), 0, 0.5);
1141
publishedPortSpinBox = gtk_spin_button_new_with_range (1, 65535, 1);
1142
gtk_label_set_mnemonic_widget (GTK_LABEL (publishedPortLabel), publishedPortSpinBox);
1143
gtk_spin_button_set_value (GTK_SPIN_BUTTON (publishedPortSpinBox), g_ascii_strtod (published_port, NULL));
1145
gtk_table_attach_defaults (GTK_TABLE (table), publishedPortSpinBox, 1, 2, 6, 7);
1147
// This will trigger a signal, and the above two
1148
// widgets need to be instanciated before that.
1149
g_signal_connect (localAddressCombo, "changed", G_CALLBACK (local_interface_changed_cb), localAddressCombo);
1151
g_signal_connect (useStunCheckBox, "toggled", G_CALLBACK (use_stun_cb), useStunCheckBox);
1153
g_signal_connect (sameAsLocalRadioButton, "toggled", G_CALLBACK (same_as_local_cb), sameAsLocalRadioButton);
1154
g_signal_connect (publishedAddrRadioButton, "toggled", G_CALLBACK (set_published_addr_manually_cb), publishedAddrRadioButton);
1156
set_published_addr_manually_cb (publishedAddrRadioButton, NULL);
1161
GtkWidget* create_advanced_tab (account_t **a)
1164
// Build the advanced tab, to appear on the account configuration panel
1165
DEBUG ("Config: Build advanced tab");
1167
GtkWidget *ret, *frame;
1169
ret = gtk_vbox_new (FALSE, 10);
1170
gtk_container_set_border_width (GTK_CONTAINER (ret), 10);
1172
frame = create_registration_expire (a);
1173
gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0);
1175
frame = create_network (a);
1176
gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0);
1178
frame = create_published_address (a);
1179
gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0);
1181
gtk_widget_show_all (ret);
1183
use_stun_cb (GTK_WIDGET (useStunCheckBox), NULL);
1185
set_published_addr_manually_cb (GTK_WIDGET (publishedAddrRadioButton), NULL);
1190
void ringtone_enabled (GtkWidget *widget UNUSED, gpointer fileChooser, const gchar *accountID UNUSED)
1192
gboolean isEnabled = gtk_widget_get_sensitive (GTK_WIDGET (fileChooser));
1195
gtk_widget_set_sensitive (GTK_WIDGET (fileChooser), FALSE);
1197
gtk_widget_set_sensitive (GTK_WIDGET (fileChooser), TRUE);
1202
GtkWidget* create_codecs_configuration (account_t **a)
1206
GtkWidget *ret, *codecs, *dtmf, *box, *frame, *sipinfo, *table;
1207
account_t *currentAccount = *a;
1208
gchar *currentDtmfType = "";
1209
gboolean dtmf_are_rtp = TRUE;
1212
ret = gtk_vbox_new (FALSE, 10);
1213
gtk_container_set_border_width (GTK_CONTAINER (ret), 10);
1215
box = codecs_box (a);
1217
// Box for the codecs
1218
gnome_main_section_new (_ ("Codecs"), &codecs);
1219
gtk_box_pack_start (GTK_BOX (ret), codecs, FALSE, FALSE, 0);
1220
gtk_widget_set_size_request (GTK_WIDGET (codecs), -1, 200);
1221
gtk_widget_show (codecs);
1222
gtk_container_add (GTK_CONTAINER (codecs) , box);
1224
// Add DTMF type selection for SIP account only
1225
p = g_hash_table_lookup (currentAccount->properties, g_strdup (ACCOUNT_TYPE));
1227
if (g_strcmp0 (p, "SIP") == 0) {
1230
gnome_main_section_new_with_table (_ ("DTMF"), &dtmf, &table, 1, 2);
1231
gtk_box_pack_start (GTK_BOX (ret), dtmf, FALSE, FALSE, 0);
1232
gtk_widget_show (dtmf);
1235
currentDtmfType = g_hash_table_lookup (currentAccount->properties, g_strdup (ACCOUNT_DTMF_TYPE));
1237
if (g_strcasecmp (currentDtmfType, OVERRTP) != 0) {
1224
1238
dtmf_are_rtp = FALSE;
1227
overrtp = gtk_radio_button_new_with_label( NULL, _("RTP") );
1228
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(overrtp), dtmf_are_rtp);
1229
gtk_table_attach ( GTK_TABLE( table ), overrtp, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1231
sipinfo = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(overrtp), _("SIP"));
1232
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(sipinfo), !dtmf_are_rtp);
1233
g_signal_connect(G_OBJECT(sipinfo), "clicked", G_CALLBACK(select_dtmf_type), NULL);
1234
gtk_table_attach ( GTK_TABLE( table ), sipinfo, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1237
gtk_widget_show_all(ret);
1241
overrtp = gtk_radio_button_new_with_label (NULL, _ ("RTP"));
1242
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (overrtp), dtmf_are_rtp);
1243
gtk_table_attach (GTK_TABLE (table), overrtp, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1245
sipinfo = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (overrtp), _ ("SIP"));
1246
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sipinfo), !dtmf_are_rtp);
1247
g_signal_connect (G_OBJECT (sipinfo), "clicked", G_CALLBACK (select_dtmf_type), NULL);
1248
gtk_table_attach (GTK_TABLE (table), sipinfo, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1251
// Box for the ringtones
1252
gnome_main_section_new_with_table (_ ("Ringtones"), &frame, &table, 1, 2);
1253
gtk_box_pack_start (GTK_BOX (ret), frame, FALSE, FALSE, 0);
1255
fileChooser = gtk_file_chooser_button_new (_ ("Choose a ringtone"), GTK_FILE_CHOOSER_ACTION_OPEN);
1257
p = g_hash_table_lookup (currentAccount->properties, g_strdup (CONFIG_RINGTONE_ENABLED));
1258
gboolean ringtoneEnabled = (g_strcmp0 (p, "true") == 0) ? TRUE : FALSE;
1260
enableTone = gtk_check_button_new_with_mnemonic (_ ("_Enable ringtones"));
1261
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enableTone), ringtoneEnabled);
1262
g_signal_connect (G_OBJECT (enableTone) , "clicked" , G_CALLBACK (ringtone_enabled), fileChooser);
1263
gtk_table_attach (GTK_TABLE (table), enableTone, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1265
// file chooser button
1266
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fileChooser) , g_get_home_dir());
1267
p = g_hash_table_lookup (currentAccount->properties, g_strdup (CONFIG_RINGTONE_PATH));
1268
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fileChooser) , p);
1269
gtk_widget_set_sensitive (GTK_WIDGET (fileChooser), ringtoneEnabled);
1271
GtkFileFilter *filter = gtk_file_filter_new();
1272
gtk_file_filter_set_name (filter , _ ("Audio Files"));
1273
gtk_file_filter_add_pattern (filter , "*.wav");
1274
gtk_file_filter_add_pattern (filter , "*.ul");
1275
gtk_file_filter_add_pattern (filter , "*.au");
1276
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fileChooser) , filter);
1277
gtk_table_attach (GTK_TABLE (table), fileChooser, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
1281
gtk_widget_show_all (ret);
1243
void show_account_window (account_t * a) {
1287
void show_account_window (account_t * a)
1245
1290
GtkWidget * notebook;
1246
GtkWidget *tab, *codecs_tab, *ip_tab;
1291
GtkWidget *tab, *codecs_tab, *ip_tab;
1248
1293
account_t *currentAccount;
1250
// In case the published address is same than local,
1251
// we must resolve published address from interface name
1299
// In case the published address is same than local,
1300
// we must resolve published address from interface name
1252
1301
gchar * local_interface;
1253
1302
gchar * published_address;
1257
1306
if (currentAccount == NULL) {
1258
currentAccount = g_new0(account_t, 1);
1259
currentAccount->properties = dbus_account_details(NULL);
1260
currentAccount->accountID = "new";
1261
sflphone_fill_codec_list_per_account (¤tAccount);
1262
DEBUG("Config: Account is NULL. Will fetch default values");
1307
currentAccount = g_new0 (account_t, 1);
1308
currentAccount->properties = dbus_account_details (NULL);
1309
currentAccount->accountID = "new";
1310
sflphone_fill_codec_list_per_account (¤tAccount);
1311
DEBUG ("Config: Account is NULL. Will fetch default values");
1265
dialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Account settings"),
1266
GTK_WINDOW(get_main_window()),
1267
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
1269
GTK_RESPONSE_CANCEL,
1271
GTK_RESPONSE_ACCEPT,
1274
gtk_dialog_set_has_separator(dialog, FALSE);
1275
gtk_container_set_border_width (GTK_CONTAINER(dialog), 0);
1314
dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_ ("Account settings"),
1315
GTK_WINDOW (get_main_window()),
1316
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
1318
GTK_RESPONSE_CANCEL,
1320
GTK_RESPONSE_ACCEPT,
1323
gtk_dialog_set_has_separator (dialog, FALSE);
1324
gtk_container_set_border_width (GTK_CONTAINER (dialog), 0);
1277
1326
notebook = gtk_notebook_new();
1278
gtk_box_pack_start(GTK_BOX (dialog->vbox), notebook, TRUE, TRUE, 0);
1279
gtk_container_set_border_width(GTK_CONTAINER(notebook), 10);
1280
gtk_widget_show(notebook);
1327
gtk_box_pack_start (GTK_BOX (dialog->vbox), notebook, TRUE, TRUE, 0);
1328
gtk_container_set_border_width (GTK_CONTAINER (notebook), 10);
1329
gtk_widget_show (notebook);
1282
1331
// We do not need the global settings for the IP2IP account
1283
1332
if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) {
1285
/* General Settings */
1286
tab = create_basic_tab(¤tAccount);
1288
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new(_("Basic")));
1289
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab);
1334
/* General Settings */
1335
tab = create_basic_tab (¤tAccount);
1337
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new (_ ("Basic")));
1338
gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab);
1294
1344
codecs_tab = create_codecs_configuration (¤tAccount);
1295
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), codecs_tab, gtk_label_new(_("Codecs")));
1296
gtk_notebook_page_num (GTK_NOTEBOOK (notebook), codecs_tab);
1345
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), codecs_tab, gtk_label_new (_ ("Codecs")));
1346
gtk_notebook_page_num (GTK_NOTEBOOK (notebook), codecs_tab);
1298
1348
// Get current protocol for this account protocol
1299
1349
gchar *currentProtocol = "SIP";
1300
currentProtocol = (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(protocolComboBox));
1351
if (protocolComboBox)
1352
currentProtocol = (gchar *) gtk_combo_box_get_active_text (GTK_COMBO_BOX (protocolComboBox));
1302
1354
// Do not need advanced or security one for the IP2IP account
1303
1355
if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) {
1306
advanced_tab = create_advanced_tab(¤tAccount);
1307
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advanced_tab, gtk_label_new(_("Advanced")));
1308
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), advanced_tab);
1311
security_tab = create_security_tab (¤tAccount);
1312
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), security_tab, gtk_label_new(_("Security")));
1313
gtk_notebook_page_num(GTK_NOTEBOOK(notebook),security_tab);
1318
/* Custom tab for the IP to IP profile */
1319
ip_tab = create_direct_ip_calls_tab (¤tAccount);
1320
gtk_notebook_prepend_page (GTK_NOTEBOOK (notebook), ip_tab, gtk_label_new(_("Network")));
1321
gtk_notebook_page_num (GTK_NOTEBOOK (notebook), ip_tab);
1358
advanced_tab = create_advanced_tab (¤tAccount);
1359
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), advanced_tab, gtk_label_new (_ ("Advanced")));
1360
gtk_notebook_page_num (GTK_NOTEBOOK (notebook), advanced_tab);
1363
security_tab = create_security_tab (¤tAccount);
1364
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), security_tab, gtk_label_new (_ ("Security")));
1365
gtk_notebook_page_num (GTK_NOTEBOOK (notebook),security_tab);
1369
/* Custom tab for the IP to IP profile */
1370
ip_tab = create_direct_ip_calls_tab (¤tAccount);
1371
gtk_notebook_prepend_page (GTK_NOTEBOOK (notebook), ip_tab, gtk_label_new (_ ("Network")));
1372
gtk_notebook_page_num (GTK_NOTEBOOK (notebook), ip_tab);
1324
1375
// Emit signal to hide advanced and security tabs in case of IAX
1325
g_signal_emit_by_name (GTK_WIDGET(protocolComboBox), "changed", NULL);
1376
if (protocolComboBox)
1377
g_signal_emit_by_name (GTK_WIDGET (protocolComboBox), "changed", NULL);
1327
1379
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook) , 0);