~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to gnome/src/config/accountconfigdialog.c

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-01-07 14:51:16 UTC
  • mfrom: (4.3.5 sid)
  • Revision ID: package-import@ubuntu.com-20150107145116-yxnafinf4lrdvrmx
Tags: 1.4.1-0.1ubuntu1
* Merge with Debian, remaining changes:
 - Drop soprano, nepomuk build-dep
* Drop ubuntu patches, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
static GtkWidget *audio_port_min_spin_box;
101
101
static GtkWidget *audio_port_max_spin_box;
102
102
#ifdef SFL_VIDEO
 
103
static GtkWidget *enable_video_button;
103
104
static GtkWidget *video_port_min_spin_box;
104
105
static GtkWidget *video_port_max_spin_box;
105
106
#endif
145
146
                    gtk_toggle_button_get_active(widget) ? "true" : "false");
146
147
}
147
148
 
 
149
static void
 
150
user_agent_checkbox_cb(GtkToggleButton *widget, account_t *account)
 
151
{
 
152
    const gboolean is_active = gtk_toggle_button_get_active(widget);
 
153
    account_replace(account, CONFIG_ACCOUNT_HAS_CUSTOM_USERAGENT,
 
154
                    is_active ? "true" : "false");
 
155
    gtk_widget_set_sensitive(entry_user_agent, is_active);
 
156
}
 
157
 
148
158
/*
149
159
 * Display / Hide the password
150
160
 */
244
254
    return auto_answer_checkbox;
245
255
}
246
256
 
 
257
static GtkWidget*
 
258
create_user_agent_checkbox(const account_t *account)
 
259
{
 
260
    GtkWidget *user_agent_checkbox = gtk_check_button_new_with_mnemonic(_("_Use custom user-agent"));
 
261
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(user_agent_checkbox), account_has_custom_user_agent(account));
 
262
    g_signal_connect(user_agent_checkbox, "toggled", G_CALLBACK(user_agent_checkbox_cb), (gpointer) account);
 
263
    return user_agent_checkbox;
 
264
}
 
265
 
247
266
static void
248
267
alias_changed_cb(GtkEditable *editable, gpointer data)
249
268
{
250
269
    const gchar *alias = gtk_entry_get_text(GTK_ENTRY(editable));
251
270
    GtkDialog *dialog = GTK_DIALOG(data);
252
 
    gtk_dialog_set_response_sensitive(dialog, GTK_RESPONSE_APPLY, strlen(alias));
 
271
    gtk_dialog_set_response_sensitive(dialog, GTK_RESPONSE_APPLY, !!strlen(alias));
253
272
}
254
273
 
255
274
 
358
377
    gtk_grid_attach(GTK_GRID(grid), label, 0, row, 1, 1);
359
378
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
360
379
    entry_password = gtk_entry_new();
361
 
    gtk_entry_set_icon_from_stock(GTK_ENTRY(entry_password),
362
 
                                  GTK_ENTRY_ICON_PRIMARY,
363
 
                                  GTK_STOCK_DIALOG_AUTHENTICATION);
 
380
    gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry_password),
 
381
            GTK_ENTRY_ICON_PRIMARY, "dialog-password");
 
382
 
364
383
    gtk_entry_set_visibility(GTK_ENTRY(entry_password), FALSE);
365
384
    gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry_password);
366
385
    password = password ? password : "";
408
427
    gtk_entry_set_text(GTK_ENTRY(entry_user_agent), user_agent);
409
428
    gtk_grid_attach(GTK_GRID(grid), entry_user_agent, 1, row, 1, 1);
410
429
 
 
430
    gtk_widget_set_sensitive(entry_user_agent, account_has_custom_user_agent(account));
 
431
 
 
432
    row++;
 
433
    GtkWidget *user_agent_checkbox = create_user_agent_checkbox(account);
 
434
    gtk_grid_attach(GTK_GRID(grid), user_agent_checkbox, 0, row, 1, 1);
 
435
 
411
436
    row++;
412
437
    GtkWidget *auto_answer_checkbox = create_auto_answer_checkbox(account);
413
438
    gtk_grid_attach(GTK_GRID(grid), auto_answer_checkbox, 0, row, 1, 1);
704
729
    }
705
730
}
706
731
 
707
 
static void use_stun_cb(GtkWidget *widget, G_GNUC_UNUSED gpointer data)
 
732
static void
 
733
use_stun_cb(GtkWidget *widget, G_GNUC_UNUSED gpointer data)
708
734
{
709
735
    /* Widgets have not been created yet */
710
 
    if (!stun_server_label)
711
 
        return;
 
736
    g_return_if_fail(stun_server_label || stun_server_entry ||
 
737
                     same_as_local_radio_button ||
 
738
                     published_addr_radio_button || published_address_label ||
 
739
                     published_port_label || published_address_entry ||
 
740
                     published_port_spin_box);
712
741
 
713
742
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
714
743
        g_debug("Showing stun options, hiding Local/Published info");
814
843
    /* 2x1 */
815
844
    gtk_grid_attach(GTK_GRID(grid), hbox, 0, 1, 2, 1);
816
845
 
817
 
    GtkWidget *addButton = gtk_button_new_from_stock(GTK_STOCK_ADD);
 
846
    GtkWidget *addButton = gtk_button_new_with_label(_("Add"));
818
847
    g_signal_connect(addButton, "clicked", G_CALLBACK(add_credential_cb), credential_store);
819
848
    gtk_box_pack_start(GTK_BOX(hbox), addButton, FALSE, FALSE, 0);
820
849
 
821
 
    delete_cred_button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
 
850
    delete_cred_button = gtk_button_new_with_label(_("Remove"));
822
851
    g_signal_connect(delete_cred_button, "clicked", G_CALLBACK(delete_credential_cb), treeview_credential);
823
852
    gtk_box_pack_start(GTK_BOX(hbox), delete_cred_button, FALSE, FALSE, 0);
824
853
 
862
891
    OptionsData *options = g_new0(OptionsData, 1);
863
892
    options->account = account;
864
893
    options->client = client;
865
 
    GtkWidget *sip_tls_advanced_button = gtk_button_new_from_stock(GTK_STOCK_EDIT);
 
894
    GtkWidget *sip_tls_advanced_button = gtk_button_new_with_label(_("Edit"));
866
895
    gtk_grid_attach(GTK_GRID(grid), sip_tls_advanced_button, 2, 0, 1, 1);
867
896
    gtk_widget_set_sensitive(sip_tls_advanced_button, FALSE);
868
897
    g_signal_connect(G_OBJECT(sip_tls_advanced_button), "clicked",
885
914
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(key_exchange_combo), "SDES");
886
915
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(key_exchange_combo), _("Disabled"));
887
916
 
888
 
    zrtp_button = gtk_button_new_from_stock(GTK_STOCK_PREFERENCES);
 
917
    zrtp_button = gtk_button_new_with_label(_("Preferences"));
889
918
    g_signal_connect(G_OBJECT(zrtp_button), "clicked",
890
919
                     G_CALLBACK(show_advanced_zrtp_options_cb),
891
920
                     options);
923
952
    GtkWidget * ret = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
924
953
    gtk_container_set_border_width(GTK_CONTAINER(ret), 10);
925
954
 
926
 
    // Credentials frame
927
 
    GtkWidget * frame = create_credential_widget(account);
928
 
    gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
 
955
    GtkWidget *frame;
 
956
 
 
957
    if (!account_is_IP2IP(account)) {
 
958
        // Credentials frame
 
959
        frame = create_credential_widget(account);
 
960
        gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
 
961
    }
929
962
 
930
963
    // Security frame
931
964
    frame = create_security_widget(account, client);
1065
1098
    use_stun_check_box = gtk_check_button_new_with_mnemonic(_("Using STUN"));
1066
1099
    gtk_grid_attach(GTK_GRID(grid), use_stun_check_box, 0, 0, 1, 1);
1067
1100
    g_signal_connect(use_stun_check_box, "toggled", G_CALLBACK(use_stun_cb), NULL);
1068
 
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_stun_check_box),
1069
 
                                 utf8_case_equal(stun_enable, "true"));
1070
 
    gtk_widget_set_sensitive(use_stun_check_box, !utf8_case_equal(use_tls, "true"));
1071
1101
 
1072
1102
    stun_server_label = gtk_label_new_with_mnemonic(_("STUN server URL"));
1073
1103
    gtk_grid_attach(GTK_GRID(grid), stun_server_label, 0, 1, 1, 1);
1117
1147
    g_signal_connect(same_as_local_radio_button, "toggled", G_CALLBACK(same_as_local_cb), same_as_local_radio_button);
1118
1148
    g_signal_connect(published_addr_radio_button, "toggled", G_CALLBACK(set_published_addr_manually_cb), published_addr_radio_button);
1119
1149
 
 
1150
    /* Now that widgets have been initialized it's safe to invoke this signal */
 
1151
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_stun_check_box),
 
1152
                                 utf8_case_equal(stun_enable, "true"));
 
1153
    gtk_widget_set_sensitive(use_stun_check_box, !utf8_case_equal(use_tls, "true"));
 
1154
 
1120
1155
    set_published_addr_manually_cb(published_addr_radio_button, NULL);
1121
1156
 
1122
1157
    return frame;
1165
1200
 
1166
1201
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
1167
1202
 
1168
 
    GtkWidget *frame = create_registration_expire(account);
1169
 
    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
 
1203
    GtkWidget *frame;
 
1204
 
 
1205
    if (!account_is_IP2IP(account)) {
 
1206
        frame = create_registration_expire(account);
 
1207
        gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
 
1208
    }
1170
1209
 
1171
1210
    frame = create_network(account);
1172
1211
    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
1314
1353
    gtk_widget_show(videocodecs);
1315
1354
    gtk_container_add(GTK_CONTAINER (videocodecs), box);
1316
1355
 
 
1356
    /* Check button to enable/disable video for an account */
 
1357
    gpointer ptr = account_lookup(a, CONFIG_VIDEO_ENABLED);
 
1358
    enable_video_button = gtk_check_button_new_with_mnemonic(_("_Enable video"));
 
1359
    const gboolean video_enabled = g_strcmp0(ptr, "true") == 0;
 
1360
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enable_video_button), video_enabled);
 
1361
    gtk_box_pack_start(GTK_BOX(vbox), enable_video_button, FALSE, FALSE, 0);
 
1362
 
1317
1363
    gtk_widget_show_all(vbox);
1318
1364
 
1319
1365
    return vbox;
1338
1384
    gtk_widget_set_size_request(label, 350, -1);
1339
1385
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
1340
1386
 
1341
 
    GtkWidget *frame = create_network(account);
1342
 
    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
1343
 
 
1344
1387
    GtkWidget *auto_answer_checkbox = create_auto_answer_checkbox(account);
1345
1388
    gtk_box_pack_start(GTK_BOX(vbox), auto_answer_checkbox, FALSE, FALSE, 0);
1346
1389
 
1355
1398
 
1356
1399
static void update_account_from_basic_tab(account_t *account)
1357
1400
{
 
1401
    const gboolean IS_IP2IP = account_is_IP2IP(account);
 
1402
 
1358
1403
    // Update protocol in case it changed
1359
1404
    gchar *proto;
1360
1405
    if (protocol_combo)
1363
1408
        proto = g_strdup("SIP");
1364
1409
 
1365
1410
    if (g_strcmp0(proto, "SIP") == 0) {
1366
 
        account_replace(account, CONFIG_ACCOUNT_REGISTRATION_EXPIRE,
1367
 
                gtk_entry_get_text(GTK_ENTRY(expire_spin_box)));
1368
 
 
1369
 
        account_replace(account, CONFIG_ACCOUNT_ROUTESET,
1370
 
                gtk_entry_get_text(GTK_ENTRY(entry_route_set)));
 
1411
 
 
1412
        if (!IS_IP2IP) {
 
1413
            account_replace(account, CONFIG_ACCOUNT_REGISTRATION_EXPIRE,
 
1414
                    gtk_entry_get_text(GTK_ENTRY(expire_spin_box)));
 
1415
 
 
1416
            account_replace(account, CONFIG_ACCOUNT_ROUTESET,
 
1417
                    gtk_entry_get_text(GTK_ENTRY(entry_route_set)));
 
1418
        }
1371
1419
 
1372
1420
        gboolean v = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_stun_check_box));
1373
1421
        account_replace(account, CONFIG_STUN_ENABLE,
1391
1439
#endif
1392
1440
 
1393
1441
#ifdef SFL_PRESENCE
1394
 
        v = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(presence_check_box));
1395
 
        account_replace(account, CONFIG_PRESENCE_ENABLED, bool_to_string(v));
1396
 
        // TODO enable/disable the presence window view
 
1442
        if (!IS_IP2IP) {
 
1443
            v = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(presence_check_box));
 
1444
            account_replace(account, CONFIG_PRESENCE_ENABLED, bool_to_string(v));
 
1445
            // TODO enable/disable the presence window view
 
1446
        }
1397
1447
#endif
1398
1448
 
1399
1449
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(overrtp))) {
1430
1480
    }
1431
1481
 
1432
1482
    account_replace(account, CONFIG_ACCOUNT_USERAGENT,
1433
 
                    gtk_entry_get_text(GTK_ENTRY(entry_user_agent)));
1434
 
    account_replace(account, CONFIG_ACCOUNT_ALIAS, gtk_entry_get_text(GTK_ENTRY(entry_alias)));
1435
 
    account_replace(account, CONFIG_ACCOUNT_TYPE, proto);
1436
 
    account_replace(account, CONFIG_ACCOUNT_HOSTNAME, gtk_entry_get_text(GTK_ENTRY(entry_hostname)));
1437
 
    account_replace(account, CONFIG_ACCOUNT_USERNAME, gtk_entry_get_text(GTK_ENTRY(entry_username)));
1438
 
    account_replace(account, CONFIG_ACCOUNT_PASSWORD, gtk_entry_get_text(GTK_ENTRY(entry_password)));
1439
 
    account_replace(account, CONFIG_ACCOUNT_MAILBOX, gtk_entry_get_text(GTK_ENTRY(entry_mailbox)));
 
1483
            gtk_entry_get_text(GTK_ENTRY(entry_user_agent)));
 
1484
 
 
1485
    if (!IS_IP2IP) {
 
1486
        account_replace(account, CONFIG_ACCOUNT_ALIAS, gtk_entry_get_text(GTK_ENTRY(entry_alias)));
 
1487
        account_replace(account, CONFIG_ACCOUNT_TYPE, proto);
 
1488
        account_replace(account, CONFIG_ACCOUNT_HOSTNAME, gtk_entry_get_text(GTK_ENTRY(entry_hostname)));
 
1489
        account_replace(account, CONFIG_ACCOUNT_USERNAME, gtk_entry_get_text(GTK_ENTRY(entry_username)));
 
1490
        account_replace(account, CONFIG_ACCOUNT_PASSWORD, gtk_entry_get_text(GTK_ENTRY(entry_password)));
 
1491
        account_replace(account, CONFIG_ACCOUNT_MAILBOX, gtk_entry_get_text(GTK_ENTRY(entry_mailbox)));
 
1492
    }
 
1493
 
1440
1494
    g_free(proto);
1441
1495
}
1442
1496
 
1450
1504
        return;
1451
1505
 
1452
1506
    const gboolean IS_IP2IP = account_is_IP2IP(account);
1453
 
    if (!IS_IP2IP)
1454
 
        update_account_from_basic_tab(account);
 
1507
    update_account_from_basic_tab(account);
1455
1508
 
1456
1509
    if (account_is_SIP(account)) {
1457
1510
        if (IS_IP2IP ||
1478
1531
    const gboolean tone_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enable_tone));
1479
1532
    account_replace(account, CONFIG_RINGTONE_ENABLED, bool_to_string(tone_enabled));
1480
1533
 
 
1534
#ifdef SFL_VIDEO
 
1535
    const gboolean video_enabled =
 
1536
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enable_video_button));
 
1537
    account_replace(account, CONFIG_VIDEO_ENABLED, bool_to_string(video_enabled));
 
1538
#endif
 
1539
 
1481
1540
    gchar *ringtone_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_chooser));
1482
1541
    account_replace(account, CONFIG_RINGTONE_PATH, ringtone_path);
1483
1542
    g_free(ringtone_path);
1534
1593
 
1535
1594
    account_t *account = account_list_get_by_id(accountID);
1536
1595
    if (!account) {
1537
 
        g_error("Invalid account %s", accountID);
 
1596
        g_warning("Invalid account %s", accountID);
1538
1597
        return NULL;
1539
1598
    }
1540
1599
 
1557
1616
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), videocodecs_tab, gtk_label_new(_("Video")));
1558
1617
#endif
1559
1618
 
1560
 
    // Do not need advanced or security one for the IP2IP account
1561
 
    if (!IS_IP2IP) {
1562
 
        /* Advanced */
1563
 
        advanced_tab = create_advanced_tab(account);
1564
 
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advanced_tab, gtk_label_new(_("Advanced")));
1565
 
 
1566
 
        /* Security */
1567
 
        security_tab = create_security_tab(account, client);
1568
 
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), security_tab, gtk_label_new(_("Security")));
1569
 
    } else {
 
1619
    if (IS_IP2IP) {
1570
1620
        /* Custom tab for the IP to IP profile */
1571
1621
        GtkWidget *ip_tab = create_direct_ip_calls_tab(account);
1572
 
        gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook), ip_tab, gtk_label_new(_("Network")));
 
1622
        gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook), ip_tab, gtk_label_new(_("General")));
1573
1623
    }
1574
1624
 
 
1625
    /* Advanced */
 
1626
    advanced_tab = create_advanced_tab(account);
 
1627
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advanced_tab, gtk_label_new(_("Advanced")));
 
1628
 
 
1629
    /* Security */
 
1630
    security_tab = create_security_tab(account, client);
 
1631
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), security_tab, gtk_label_new(_("Security")));
 
1632
 
1575
1633
    // Emit signal to hide advanced and security tabs in case of IAX
1576
1634
    if (protocol_combo)
1577
1635
        g_signal_emit_by_name(protocol_combo, "changed", NULL);