Skip to content
Snippets Groups Projects
Commit 53d51ead authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #9490: gnome: isolate code that modifies accounts

parent 50b7d8c2
Branches
No related tags found
No related merge requests found
......@@ -263,7 +263,7 @@ gboolean current_account_has_mailbox(void)
account_t *current = account_list_get_current();
if (current) {
gchar * account_mailbox = g_hash_table_lookup(current->properties, ACCOUNT_MAILBOX);
gchar * account_mailbox = account_lookup(current, ACCOUNT_MAILBOX);
if (account_mailbox && utf8_case_cmp(account_mailbox, "") != 0)
return TRUE;
......@@ -297,13 +297,12 @@ gboolean current_account_has_new_message(void)
gboolean account_is_IP2IP(const account_t *account)
{
g_assert(account);
return utf8_case_cmp(account->accountID, IP2IP) == 0;
return utf8_case_cmp(account->accountID, IP2IP_PROFILE) == 0;
}
static gboolean is_type(const account_t *account, const gchar *type)
{
const gchar *account_type = g_hash_table_lookup(account->properties,
ACCOUNT_TYPE);
const gchar *account_type = account_lookup(account, ACCOUNT_TYPE);
return g_strcmp0(account_type, type) == 0;
}
......@@ -338,3 +337,14 @@ void initialize_credential_information(account_t *account)
g_ptr_array_add(account->credential_information, new_table);
}
}
void account_replace(account_t *account, const gchar *key, const gchar *value)
{
g_hash_table_replace(account->properties, g_strdup(key), g_strdup(value));
}
gpointer account_lookup(const account_t *account, gconstpointer key)
{
g_assert(account->properties);
return g_hash_table_lookup(account->properties, key);
}
......@@ -191,4 +191,7 @@ account_t *create_default_account();
void initialize_credential_information(account_t *account);
void account_replace(account_t *account, const gchar *key, const gchar *value);
gpointer account_lookup(const account_t *account, gconstpointer key);
#endif
......@@ -459,12 +459,13 @@ editing_started_cb(GtkCellRenderer *cell UNUSED, GtkCellEditable * editable,
static void show_advanced_zrtp_options_cb(GtkWidget *widget UNUSED, gpointer data)
{
account_t *account = (account_t *) data;
gchar *proto = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(key_exchange_combo));
if (utf8_case_cmp(proto, "ZRTP") == 0)
show_advanced_zrtp_options((GHashTable *) data);
show_advanced_zrtp_options(account);
else
show_advanced_sdes_options((GHashTable *) data);
show_advanced_sdes_options(account);
g_free(proto);
}
......@@ -473,7 +474,8 @@ static void show_advanced_zrtp_options_cb(GtkWidget *widget UNUSED, gpointer dat
static void
show_advanced_tls_options_cb(GtkWidget *widget UNUSED, gpointer data)
{
show_advanced_tls_options((GHashTable *) data);
account_t *account = (account_t *) data;
show_advanced_tls_options(account);
}
static void
......@@ -752,7 +754,7 @@ create_security_widget(const account_t *account)
gtk_widget_set_sensitive(sip_tls_advanced_button, FALSE);
g_signal_connect(G_OBJECT(sip_tls_advanced_button), "clicked",
G_CALLBACK(show_advanced_tls_options_cb),
(gpointer) account->properties);
(gpointer) account);
use_sip_tls_check_box = gtk_check_button_new_with_mnemonic(_("Use TLS transport(sips)"));
g_signal_connect(use_sip_tls_check_box, "toggled", G_CALLBACK(use_sip_tls_cb), sip_tls_advanced_button);
......@@ -772,7 +774,7 @@ create_security_widget(const account_t *account)
zrtp_button = gtk_button_new_from_stock(GTK_STOCK_PREFERENCES);
g_signal_connect(G_OBJECT(zrtp_button), "clicked",
G_CALLBACK(show_advanced_zrtp_options_cb),
account->properties);
(gpointer) account);
if (g_strcmp0(curSRTPEnabled, "false") == 0) {
gtk_combo_box_set_active(GTK_COMBO_BOX(key_exchange_combo), 2);
......@@ -1134,9 +1136,105 @@ static GtkWidget* create_direct_ip_calls_tab(const account_t *account)
return vbox;
}
static gchar *bool_to_string(gboolean v)
static const gchar *bool_to_string(gboolean v)
{
return v ? g_strdup("true") : g_strdup("false");
return v ? "true" : "false";
}
static void update_account_from_basic_tab(account_t *account)
{
// Update protocol in case it changed
gchar *proto;
if (protocol_combo)
proto = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(protocol_combo));
else
proto = g_strdup("SIP");
if (g_strcmp0(proto, "SIP") == 0) {
if (!account_is_IP2IP(account)) {
account_replace(account, ACCOUNT_REGISTRATION_EXPIRE,
gtk_entry_get_text(GTK_ENTRY(expire_spin_box)));
account_replace(account, ACCOUNT_ROUTE,
gtk_entry_get_text(GTK_ENTRY(entry_route_set)));
account_replace(account, ACCOUNT_USERAGENT,
gtk_entry_get_text(GTK_ENTRY(entry_user_agent)));
gboolean v = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_stun_check_box));
account_replace(account, ACCOUNT_SIP_STUN_ENABLED,
bool_to_string(v));
account_replace(account, ACCOUNT_SIP_STUN_SERVER,
gtk_entry_get_text(GTK_ENTRY(stun_server_entry)));
v = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(same_as_local_radio_button));
account_replace(account, PUBLISHED_SAMEAS_LOCAL, bool_to_string(v));
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(same_as_local_radio_button))) {
account_replace(account, PUBLISHED_PORT,
gtk_entry_get_text(GTK_ENTRY(published_port_spin_box)));
account_replace(account, PUBLISHED_ADDRESS,
gtk_entry_get_text(GTK_ENTRY(published_address_entry)));
} else {
account_replace(account, PUBLISHED_PORT,
gtk_entry_get_text(GTK_ENTRY(local_port_spin_box)));
gchar *local_interface = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(local_address_combo));
gchar *published_address = dbus_get_address_from_interface_name(local_interface);
g_free(local_interface);
account_replace(account, PUBLISHED_ADDRESS, published_address);
}
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(overrtp))) {
DEBUG("Config: Set dtmf over rtp");
account_replace(account, ACCOUNT_DTMF_TYPE, OVERRTP);
} else {
DEBUG("Config: Set dtmf over sip");
account_replace(account, ACCOUNT_DTMF_TYPE, SIPINFO);
}
gchar* key_exchange = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(key_exchange_combo));
if (utf8_case_cmp(key_exchange, "ZRTP") == 0) {
account_replace(account, ACCOUNT_SRTP_ENABLED, "true");
account_replace(account, ACCOUNT_KEY_EXCHANGE, ZRTP);
} else if (utf8_case_cmp(key_exchange, "SDES") == 0) {
account_replace(account, ACCOUNT_SRTP_ENABLED, "true");
account_replace(account, ACCOUNT_KEY_EXCHANGE, SDES);
} else {
account_replace(account, ACCOUNT_SRTP_ENABLED, "false");
account_replace(account, ACCOUNT_KEY_EXCHANGE, "");
}
g_free(key_exchange);
const gboolean tls_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_sip_tls_check_box));
account_replace(account, TLS_ENABLE, bool_to_string(tls_enabled));
const gboolean tone_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enable_tone));
account_replace(account, CONFIG_RINGTONE_ENABLED, bool_to_string(tone_enabled));
account_replace(account, CONFIG_RINGTONE_PATH,
gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_chooser)));
gchar *address_combo_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(local_address_combo));
account_replace(account, LOCAL_INTERFACE, address_combo_text);
g_free(address_combo_text);
account_replace(account, LOCAL_PORT,
gtk_entry_get_text(GTK_ENTRY(local_port_spin_box)));
}
account_replace(account, ACCOUNT_ALIAS, gtk_entry_get_text(GTK_ENTRY(entry_alias)));
account_replace(account, ACCOUNT_TYPE, proto);
account_replace(account, ACCOUNT_HOSTNAME, gtk_entry_get_text(GTK_ENTRY(entry_hostname)));
account_replace(account, ACCOUNT_USERNAME, gtk_entry_get_text(GTK_ENTRY(entry_username)));
account_replace(account, ACCOUNT_PASSWORD, gtk_entry_get_text(GTK_ENTRY(entry_password)));
account_replace(account, ACCOUNT_MAILBOX, gtk_entry_get_text(GTK_ENTRY(entry_mailbox)));
g_free(proto);
}
void show_account_window(account_t *account)
......@@ -1173,9 +1271,8 @@ void show_account_window(account_t *account)
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), audiocodecs_tab, gtk_label_new(_("Audio")));
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), audiocodecs_tab);
// Get current protocol for this account protocol
// Get current protocol for this account
gchar *current_protocol;
if (protocol_combo)
current_protocol = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(protocol_combo));
else
......@@ -1209,133 +1306,14 @@ void show_account_window(account_t *account)
/* Run dialog */
gint response = gtk_dialog_run(GTK_DIALOG(dialog));
// Update protocol in case it changed
gchar *proto;
if (protocol_combo)
proto = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(protocol_combo));
else
proto = g_strdup("SIP");
// If cancel button is pressed
if (response == GTK_RESPONSE_CANCEL) {
gtk_widget_destroy(dialog);
g_free(proto);
return;
}
if (!account_is_IP2IP(account)) {
g_hash_table_replace(account->properties,
g_strdup(ACCOUNT_ALIAS),
g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_alias))));
g_hash_table_replace(account->properties,
g_strdup(ACCOUNT_TYPE),
g_strdup(proto));
g_hash_table_replace(account->properties,
g_strdup(ACCOUNT_HOSTNAME),
g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_hostname))));
g_hash_table_replace(account->properties,
g_strdup(ACCOUNT_USERNAME),
g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_username))));
g_hash_table_replace(account->properties,
g_strdup(ACCOUNT_PASSWORD),
g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_password))));
g_hash_table_replace(account->properties,
g_strdup(ACCOUNT_MAILBOX),
g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_mailbox))));
}
if (g_strcmp0(proto, "SIP") == 0) {
if (!account_is_IP2IP(account)) {
g_hash_table_replace(account->properties,
g_strdup(ACCOUNT_REGISTRATION_EXPIRE),
g_strdup(gtk_entry_get_text(GTK_ENTRY(expire_spin_box))));
g_hash_table_replace(account->properties,
g_strdup(ACCOUNT_ROUTE),
g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_route_set))));
g_hash_table_replace(account->properties,
g_strdup(ACCOUNT_USERAGENT),
g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_user_agent))));
gboolean v = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_stun_check_box));
g_hash_table_replace(account->properties, g_strdup(ACCOUNT_SIP_STUN_ENABLED),
bool_to_string(v));
g_hash_table_replace(account->properties, g_strdup(ACCOUNT_SIP_STUN_SERVER),
g_strdup(gtk_entry_get_text(GTK_ENTRY(stun_server_entry))));
v = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(same_as_local_radio_button));
g_hash_table_replace(account->properties, g_strdup(PUBLISHED_SAMEAS_LOCAL),
bool_to_string(v));
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(same_as_local_radio_button))) {
g_hash_table_replace(account->properties,
g_strdup(PUBLISHED_PORT),
g_strdup(gtk_entry_get_text(GTK_ENTRY(published_port_spin_box))));
g_hash_table_replace(account->properties,
g_strdup(PUBLISHED_ADDRESS),
g_strdup(gtk_entry_get_text(GTK_ENTRY(published_address_entry))));
} else {
g_hash_table_replace(account->properties,
g_strdup(PUBLISHED_PORT),
g_strdup(gtk_entry_get_text(GTK_ENTRY(local_port_spin_box))));
gchar *local_interface = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(local_address_combo));
gchar *published_address = dbus_get_address_from_interface_name(local_interface);
g_free(local_interface);
g_hash_table_replace(account->properties,
g_strdup(PUBLISHED_ADDRESS),
published_address);
}
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(overrtp))) {
DEBUG("Config: Set dtmf over rtp");
g_hash_table_replace(account->properties, g_strdup(ACCOUNT_DTMF_TYPE), g_strdup(OVERRTP));
} else {
DEBUG("Config: Set dtmf over sip");
g_hash_table_replace(account->properties, g_strdup(ACCOUNT_DTMF_TYPE), g_strdup(SIPINFO));
}
gchar* key_exchange = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(key_exchange_combo));
if (utf8_case_cmp(key_exchange, "ZRTP") == 0) {
g_hash_table_replace(account->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("true"));
g_hash_table_replace(account->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup(ZRTP));
} else if (utf8_case_cmp(key_exchange, "SDES") == 0) {
g_hash_table_replace(account->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("true"));
g_hash_table_replace(account->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup(SDES));
} else {
g_hash_table_replace(account->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup("false"));
g_hash_table_replace(account->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup(""));
}
g_free(key_exchange);
const gboolean tls_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_sip_tls_check_box));
g_hash_table_replace(account->properties, g_strdup(TLS_ENABLE),
bool_to_string(tls_enabled));
const gboolean tone_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enable_tone));
g_hash_table_replace(account->properties,
g_strdup(CONFIG_RINGTONE_ENABLED),
bool_to_string(tone_enabled));
g_hash_table_replace(account->properties,
g_strdup(CONFIG_RINGTONE_PATH),
g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_chooser))));
g_hash_table_replace(account->properties,
g_strdup(LOCAL_INTERFACE),
gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(local_address_combo)));
g_hash_table_replace(account->properties,
g_strdup(LOCAL_PORT),
g_strdup(gtk_entry_get_text(GTK_ENTRY(local_port_spin_box))));
}
if (!account_is_IP2IP(account))
update_account_from_basic_tab(account);
/** @todo Verify if it's the best condition to check */
if (utf8_case_cmp(account->accountID, "new") == 0)
......@@ -1361,6 +1339,5 @@ void show_account_window(account_t *account)
gtk_widget_destroy(dialog);
g_free(current_protocol);
g_free(proto);
}
......@@ -31,13 +31,26 @@
#include "tlsadvanceddialog.h"
#include "str_utils.h"
#include "sflphone_const.h"
#include "mainwindow.h"
#include "utils.h"
#include <dbus.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <math.h>
void show_advanced_tls_options(GHashTable * properties)
static
const gchar *toggle_to_string(GtkWidget *toggle)
{
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)) ? "true" : "false";
}
static
const gchar *get_filename(GtkWidget *chooser)
{
return gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
}
void show_advanced_tls_options(account_t *account)
{
GtkDialog *tlsDialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("Advanced options for TLS"),
GTK_WINDOW(get_main_window()),
......@@ -72,7 +85,6 @@ void show_advanced_tls_options(GHashTable * properties)
gtk_label_set_markup(GTK_LABEL(label), description);
gtk_table_attach(GTK_TABLE(table), label, 0, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gchar * account_id = NULL;
gchar * tls_listener_port = NULL;
gchar * tls_ca_list_file = NULL;
gchar * tls_certificate_file = NULL;
......@@ -87,23 +99,20 @@ void show_advanced_tls_options(GHashTable * properties)
gchar * negotiation_timeout_sec = NULL;
gchar * negotiation_timeout_msec = NULL;
if (properties != NULL) {
account_id = g_hash_table_lookup(properties, ACCOUNT_ID);
tls_listener_port = g_hash_table_lookup(properties, TLS_LISTENER_PORT);
tls_ca_list_file = g_hash_table_lookup(properties, TLS_CA_LIST_FILE);
tls_certificate_file = g_hash_table_lookup(properties, TLS_CERTIFICATE_FILE);
tls_private_key_file = g_hash_table_lookup(properties, TLS_PRIVATE_KEY_FILE);
tls_password = g_hash_table_lookup(properties, TLS_PASSWORD);
tls_method = g_hash_table_lookup(properties, TLS_METHOD);
tls_ciphers = g_hash_table_lookup(properties, TLS_CIPHERS);
tls_server_name = g_hash_table_lookup(properties, TLS_SERVER_NAME);
verify_server = g_hash_table_lookup(properties, TLS_VERIFY_SERVER);
verify_client = g_hash_table_lookup(properties, TLS_VERIFY_CLIENT);
require_client_certificate = g_hash_table_lookup(properties, TLS_REQUIRE_CLIENT_CERTIFICATE);
negotiation_timeout_sec = g_hash_table_lookup(properties, TLS_NEGOTIATION_TIMEOUT_SEC);
negotiation_timeout_msec = g_hash_table_lookup(properties, TLS_NEGOTIATION_TIMEOUT_MSEC);
if (account->properties != NULL) {
tls_listener_port = account_lookup(account, TLS_LISTENER_PORT);
tls_ca_list_file = account_lookup(account, TLS_CA_LIST_FILE);
tls_certificate_file = account_lookup(account, TLS_CERTIFICATE_FILE);
tls_private_key_file = account_lookup(account, TLS_PRIVATE_KEY_FILE);
tls_password = account_lookup(account, TLS_PASSWORD);
tls_method = account_lookup(account, TLS_METHOD);
tls_ciphers = account_lookup(account, TLS_CIPHERS);
tls_server_name = account_lookup(account, TLS_SERVER_NAME);
verify_server = account_lookup(account, TLS_VERIFY_SERVER);
verify_client = account_lookup(account, TLS_VERIFY_CLIENT);
require_client_certificate = account_lookup(account, TLS_REQUIRE_CLIENT_CERTIFICATE);
negotiation_timeout_sec = account_lookup(account, TLS_NEGOTIATION_TIMEOUT_SEC);
negotiation_timeout_msec = account_lookup(account, TLS_NEGOTIATION_TIMEOUT_MSEC);
}
......@@ -117,9 +126,8 @@ void show_advanced_tls_options(GHashTable * properties)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(tlsListenerPort), g_ascii_strtod(tls_listener_port, NULL));
gtk_box_pack_start(GTK_BOX(hbox), tlsListenerPort, TRUE, TRUE, 0);
if (g_strcmp0(account_id, IP2IP_PROFILE) != 0) {
if (!account_is_IP2IP(account))
gtk_widget_set_sensitive(tlsListenerPort, FALSE);
}
label = gtk_label_new(_("Certificate of Authority list"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
......@@ -127,13 +135,12 @@ void show_advanced_tls_options(GHashTable * properties)
GtkWidget * caListFileChooser = gtk_file_chooser_button_new(_("Choose a CA list file (optional)"), GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_table_attach(GTK_TABLE(table), caListFileChooser, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
if (!tls_ca_list_file || !*tls_ca_list_file) {
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(caListFileChooser));
} else {
if (tls_ca_list_file && *tls_ca_list_file) {
GFile *file = g_file_new_for_path(tls_ca_list_file);
gtk_file_chooser_set_file(GTK_FILE_CHOOSER(caListFileChooser), file, NULL);
g_object_unref(file);
} else {
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(caListFileChooser));
}
label = gtk_label_new(_("Public endpoint certificate file"));
......@@ -269,53 +276,35 @@ void show_advanced_tls_options(GHashTable * properties)
gtk_widget_show_all(ret);
if (gtk_dialog_run(GTK_DIALOG(tlsDialog)) == GTK_RESPONSE_ACCEPT) {
g_hash_table_replace(properties,
g_strdup(TLS_LISTENER_PORT),
g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(tlsListenerPort))));
g_hash_table_replace(properties,
g_strdup(TLS_CA_LIST_FILE), g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(caListFileChooser))));
account_replace(account, TLS_LISTENER_PORT,
gtk_entry_get_text(GTK_ENTRY(tlsListenerPort)));
account_replace(account, TLS_CA_LIST_FILE, get_filename(caListFileChooser));
g_hash_table_replace(properties,
g_strdup(TLS_CERTIFICATE_FILE), g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(certificateFileChooser))));
account_replace(account, TLS_CERTIFICATE_FILE,
get_filename(certificateFileChooser));
g_hash_table_replace(properties,
g_strdup(TLS_PRIVATE_KEY_FILE), g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(privateKeyFileChooser))));
account_replace(account, TLS_PRIVATE_KEY_FILE,
get_filename(privateKeyFileChooser));
g_hash_table_replace(properties,
g_strdup(TLS_PASSWORD),
g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(privateKeyPasswordEntry))));
account_replace(account, TLS_PASSWORD, gtk_entry_get_text(GTK_ENTRY(privateKeyPasswordEntry)));
g_hash_table_replace(properties,
g_strdup(TLS_METHOD),
g_strdup((gchar *) gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(tlsProtocolMethodCombo))));
gchar *tls_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(tlsProtocolMethodCombo));
account_replace(account, TLS_METHOD, tls_text);
g_free(tls_text);
g_hash_table_replace(properties,
g_strdup(TLS_CIPHERS),
g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(cipherListEntry))));
account_replace(account, TLS_CIPHERS, gtk_entry_get_text(GTK_ENTRY(cipherListEntry)));
g_hash_table_replace(properties,
g_strdup(TLS_SERVER_NAME),
g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(serverNameInstance))));
account_replace(account, TLS_SERVER_NAME, gtk_entry_get_text(GTK_ENTRY(serverNameInstance)));
g_hash_table_replace(properties,
g_strdup(TLS_VERIFY_SERVER),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(verifyCertificateServer)) ? "true": "false"));
account_replace(account, TLS_VERIFY_SERVER, toggle_to_string(verifyCertificateServer));
g_hash_table_replace(properties,
g_strdup(TLS_VERIFY_CLIENT),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(verifyCertificateClient)) ? "true": "false"));
account_replace(account, TLS_VERIFY_CLIENT, toggle_to_string(verifyCertificateClient));
g_hash_table_replace(properties,
g_strdup(TLS_REQUIRE_CLIENT_CERTIFICATE),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(requireCertificate)) ? "true": "false"));
account_replace(account, TLS_REQUIRE_CLIENT_CERTIFICATE, toggle_to_string(requireCertificate));
g_hash_table_replace(properties,
g_strdup(TLS_NEGOTIATION_TIMEOUT_SEC),
g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(tlsTimeOutSec))));
account_replace(account, TLS_NEGOTIATION_TIMEOUT_SEC, gtk_entry_get_text(GTK_ENTRY(tlsTimeOutSec)));
g_hash_table_replace(properties,
g_strdup(TLS_NEGOTIATION_TIMEOUT_MSEC),
g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(tlsTimeOutMSec))));
account_replace(account, TLS_NEGOTIATION_TIMEOUT_MSEC, gtk_entry_get_text(GTK_ENTRY(tlsTimeOutMSec)));
}
gtk_widget_destroy(GTK_WIDGET(tlsDialog));
......
......@@ -28,19 +28,16 @@
* as that of the covered work.
*/
#ifndef __SFL_TLS_ADVANCED_DIALOG__
#define __SFL_TLS_ADVANCED_DIALOG__
#ifndef TLS_ADVANCED_DIALOG_
#define TLS_ADVANCED_DIALOG_
/** @file tlsadvanceddialog.h
* @brief Display the advanced options window for tls
*/
#include <glib.h>
#include <mainwindow.h>
#include "accountlist.h"
/**
* Display the advanced options window for zrtp
*/
void show_advanced_tls_options (GHashTable * properties);
void show_advanced_tls_options(account_t *account);
#endif
......@@ -31,22 +31,23 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "str_utils.h"
#include <zrtpadvanceddialog.h>
#include "mainwindow.h"
#include "zrtpadvanceddialog.h"
#include "sflphone_const.h"
#include "utils.h"
void show_advanced_zrtp_options(GHashTable * properties)
void show_advanced_zrtp_options(account_t *account)
{
gboolean curSasConfirm = TRUE;
gboolean curHelloEnabled = TRUE;
gboolean curZrtpNotSuppOther = TRUE;
gboolean curDisplaySasOnce = FALSE;
if (properties != NULL) {
curHelloEnabled = !utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_HELLO_HASH), "true");
curSasConfirm = !utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_DISPLAY_SAS), "true");
curZrtpNotSuppOther = !utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_NOT_SUPP_WARNING), "true");
curDisplaySasOnce = !utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_DISPLAY_SAS_ONCE), "true");
if (account != NULL) {
curHelloEnabled = !utf8_case_cmp(account_lookup(account, ACCOUNT_ZRTP_HELLO_HASH), "true");
curSasConfirm = !utf8_case_cmp(account_lookup(account, ACCOUNT_ZRTP_DISPLAY_SAS), "true");
curZrtpNotSuppOther = !utf8_case_cmp(account_lookup(account, ACCOUNT_ZRTP_NOT_SUPP_WARNING), "true");
curDisplaySasOnce = !utf8_case_cmp(account_lookup(account, ACCOUNT_DISPLAY_SAS_ONCE), "true");
}
GtkDialog *securityDialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("ZRTP Options"),
......@@ -56,12 +57,10 @@ void show_advanced_zrtp_options(GHashTable * properties)
GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE,
GTK_RESPONSE_ACCEPT,
NULL)
);
NULL));
gtk_window_set_resizable(GTK_WINDOW(securityDialog), FALSE);
gtk_container_set_border_width(GTK_CONTAINER(securityDialog), 0);
GtkWidget *tableZrtp = gtk_table_new(4, 2, FALSE /* homogeneous */);
gtk_table_set_row_spacings(GTK_TABLE(tableZrtp), 10);
gtk_table_set_col_spacings(GTK_TABLE(tableZrtp), 10);
......@@ -93,43 +92,36 @@ void show_advanced_zrtp_options(GHashTable * properties)
gtk_container_set_border_width(GTK_CONTAINER(tableZrtp), 10);
if (gtk_dialog_run(GTK_DIALOG(securityDialog)) == GTK_RESPONSE_ACCEPT) {
g_hash_table_replace(properties,
g_strdup(ACCOUNT_ZRTP_DISPLAY_SAS),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableSASConfirm)) ? "true": "false"));
account_replace(account, ACCOUNT_ZRTP_DISPLAY_SAS,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableSASConfirm)) ? "true": "false");
g_hash_table_replace(properties,
g_strdup(ACCOUNT_DISPLAY_SAS_ONCE),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(displaySasOnce)) ? "true": "false"));
account_replace(account, ACCOUNT_DISPLAY_SAS_ONCE,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(displaySasOnce)) ? "true": "false");
g_hash_table_replace(properties,
g_strdup(ACCOUNT_ZRTP_HELLO_HASH),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableHelloHash)) ? "true": "false"));
account_replace(account, ACCOUNT_ZRTP_HELLO_HASH,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableHelloHash)) ? "true": "false");
g_hash_table_replace(properties,
g_strdup(ACCOUNT_ZRTP_NOT_SUPP_WARNING),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableZrtpNotSuppOther)) ? "true": "false"));
account_replace(account, ACCOUNT_ZRTP_NOT_SUPP_WARNING,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableZrtpNotSuppOther)) ? "true": "false");
}
gtk_widget_destroy(GTK_WIDGET(securityDialog));
}
void show_advanced_sdes_options(GHashTable * properties)
void show_advanced_sdes_options(account_t *account)
{
gboolean rtpFallback = FALSE;
if (properties != NULL) {
rtpFallback = !utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_SRTP_RTP_FALLBACK), "true");
}
if (account != NULL)
rtpFallback = !utf8_case_cmp(account_lookup(account, ACCOUNT_SRTP_RTP_FALLBACK), "true");
GtkDialog *securityDialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("SDES Options"),
GTK_WINDOW(get_main_window()),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE,
GTK_RESPONSE_ACCEPT,
NULL));
GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE,
GTK_RESPONSE_ACCEPT, NULL));
gtk_window_set_resizable(GTK_WINDOW(securityDialog), FALSE);
gtk_container_set_border_width(GTK_CONTAINER(securityDialog), 0);
......@@ -150,9 +142,8 @@ void show_advanced_sdes_options(GHashTable * properties)
gtk_container_set_border_width(GTK_CONTAINER(sdesTable), 10);
if (gtk_dialog_run(GTK_DIALOG(securityDialog)) == GTK_RESPONSE_ACCEPT) {
g_hash_table_replace(properties,
g_strdup(ACCOUNT_SRTP_RTP_FALLBACK),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableRtpFallback)) ? "true": "false"));
account_replace(account, ACCOUNT_SRTP_RTP_FALLBACK,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enableRtpFallback)) ? "true": "false");
}
gtk_widget_destroy(GTK_WIDGET(securityDialog));
......
......@@ -34,14 +34,13 @@
* @brief Display the advanced options window for zrtp
*/
#include <glib.h>
#include <mainwindow.h>
#include "accountlist.h"
/**
* Display the advanced options window for zrtp
*/
void show_advanced_zrtp_options (GHashTable * properties);
void show_advanced_zrtp_options (account_t *account);
void show_advanced_sdes_options (GHashTable * properties);
void show_advanced_sdes_options (account_t *account);
#endif
......@@ -51,8 +51,6 @@
#define c_(COMMENT,STRING) gettext(STRING)
#define n_(SING,PLUR,COUNT) ngettext(SING,PLUR,COUNT)
#define IP2IP "IP2IP"
#define IP2IP_PROFILE "IP2IP"
#define ACCOUNT_ID "Account.id"
......
......@@ -4,13 +4,31 @@ TESTS = check_global check_contacts check_config check_dbus
check_PROGRAMS = check_global check_contacts check_config check_dbus
SFLPHONE_LIBS= $(top_builddir)/src/contacts/libcontacts.la \
$(top_builddir)/src/config/libconfig.la \
$(top_builddir)/src/dbus/libdbus.la \
$(top_builddir)/src/config/libconfig.la
$(top_builddir)/src/widget/libwidget.la \
$(top_builddir)/src/icons/libicons.la
###########################################################
check_global_SOURCES = check_global.c $(top_srcdir)/src/accountlist.c $(top_srcdir)/src/logger.c $(top_srcdir)/src/str_utils.c
check_global_CFLAGS = @CHECK_CFLAGS@ @GTK_CFLAGS@ @GLIB_CFLAGS@ @DBUSGLIB_CFLAGS@ @GCONF_CFLAGS@
check_global_SOURCES = check_global.c $(top_srcdir)/src/codeclist.c \
$(top_srcdir)/src/eel-gconf-extensions.c \
$(top_srcdir)/src/statusicon.c \
$(top_srcdir)/src/dialpad.c \
$(top_srcdir)/src/actions.c \
$(top_srcdir)/src/uimanager.c \
$(top_srcdir)/src/shortcuts.c \
$(top_srcdir)/src/reqaccount.c \
$(top_srcdir)/src/sflnotify.c \
$(top_srcdir)/src/imwindow.c \
$(top_srcdir)/src/callable_obj.c \
$(top_srcdir)/src/conference_obj.c \
$(top_srcdir)/src/mainwindow.c \
$(top_srcdir)/src/sliders.c \
$(top_srcdir)/src/accountlist.c \
$(top_srcdir)/src/logger.c \
$(top_srcdir)/src/str_utils.c
check_global_CFLAGS = @CHECK_CFLAGS@ @GTK_CFLAGS@ @GLIB_CFLAGS@ @DBUSGLIB_CFLAGS@ @GCONF_CFLAGS@ @WEBKIT_CFLAGS@
check_global_LDADD = $(SFLPHONE_LIBS) @CHECK_LIBS@ @GLIB_LIBS@ @GTK_LIBS@ @DBUSGLIB_LIBS@ @GCONF_LIBS@
###########################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment