diff --git a/gnome/src/accountlist.c b/gnome/src/accountlist.c index 6d8423219e02c4c1e5d4d1fe14f2ca4a46b0097d..b908915138cad1dfa9a72b4c0c8b8ef185be046b 100644 --- a/gnome/src/accountlist.c +++ b/gnome/src/accountlist.c @@ -45,7 +45,7 @@ static guint account_list_get_position(account_t *account) for (guint i = 0; i < size; i++) { account_t *tmp = account_list_get_nth(i); - if (utf8_case_cmp(tmp->accountID, account->accountID) == 0) + if (utf8_case_equal(tmp->accountID, account->accountID)) return i; } @@ -263,9 +263,9 @@ 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) + if (account_mailbox && !utf8_case_equal(account_mailbox, "")) return TRUE; } @@ -294,10 +294,26 @@ gboolean current_account_has_new_message(void) return current && current->_messages_number > 0; } -gboolean is_IP2IP(const account_t *account) +gboolean account_is_IP2IP(const account_t *account) { g_assert(account); - return utf8_case_cmp(account->accountID, IP2IP) == 0; + return utf8_case_equal(account->accountID, IP2IP_PROFILE); +} + +static gboolean is_type(const account_t *account, const gchar *type) +{ + const gchar *account_type = account_lookup(account, ACCOUNT_TYPE); + return g_strcmp0(account_type, type) == 0; +} + +gboolean account_is_SIP(const account_t *account) +{ + return is_type(account, "SIP"); +} + +gboolean account_is_IAX(const account_t *account) +{ + return is_type(account, "IAX"); } account_t *create_default_account() @@ -321,3 +337,19 @@ 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)); +} + +void account_insert(account_t *account, const gchar *key, const gchar *value) +{ + g_hash_table_insert(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); +} diff --git a/gnome/src/accountlist.h b/gnome/src/accountlist.h index 57df391081c53bca4833b62e046ccbbe557dcc89..8665e570b1ddfab4519de8157fc01cb33897c897 100644 --- a/gnome/src/accountlist.h +++ b/gnome/src/accountlist.h @@ -183,10 +183,16 @@ void current_account_set_message_number (guint nb); gboolean current_account_has_new_message (void); -gboolean is_IP2IP(const account_t *account); +gboolean account_is_IP2IP(const account_t *account); +gboolean account_is_SIP(const account_t *account); +gboolean account_is_IAX(const account_t *account); account_t *create_default_account(); void initialize_credential_information(account_t *account); +void account_replace(account_t *account, const gchar *key, const gchar *value); +void account_insert(account_t *account, const gchar *key, const gchar *value); +gpointer account_lookup(const account_t *account, gconstpointer key); + #endif diff --git a/gnome/src/actions.c b/gnome/src/actions.c index 8ac4fa49d52d18fe1d2588fdafdd4bcd32866393..fb385e924b89e61acb7a0173e98d0ff23fda31ad 100644 --- a/gnome/src/actions.c +++ b/gnome/src/actions.c @@ -103,7 +103,7 @@ sflphone_notify_voice_mail(const gchar* accountID , guint count) static gboolean is_direct_call(callable_obj_t * c) { - if (utf8_case_cmp(c->_accountID, "empty") == 0) { + if (utf8_case_equal(c->_accountID, "empty")) { if (!g_str_has_prefix(c->_peer_number, "sip:")) { gchar * new_number = g_strconcat("sip:", c->_peer_number, NULL); g_free(c->_peer_number); @@ -819,7 +819,7 @@ static int place_registered_call(callable_obj_t * c) } gpointer status = g_hash_table_lookup(current->properties, "Status"); - if (status && utf8_case_cmp(status, "REGISTERED") == 0) { + if (utf8_case_equal(status, "REGISTERED")) { /* The call is made with the current account */ // free memory for previous account id and get a new one g_free(c->_accountID); diff --git a/gnome/src/callable_obj.c b/gnome/src/callable_obj.c index 562745a9b22681aed2d9c5b8eecbe6fe48d271af..545773077313fafe8aaf7e0aa6e0d4250a9846a9 100644 --- a/gnome/src/callable_obj.c +++ b/gnome/src/callable_obj.c @@ -147,15 +147,15 @@ callable_obj_t *create_new_call_from_details(const gchar *call_id, GHashTable *d const gchar * const display_name = g_hash_table_lookup(details, "DISPLAY_NAME"); const gchar * const state_str = g_hash_table_lookup(details, "CALL_STATE"); - if (utf8_case_cmp(state_str, "CURRENT") == 0) + if (utf8_case_equal(state_str, "CURRENT")) state = CALL_STATE_CURRENT; - else if (utf8_case_cmp(state_str, "RINGING") == 0) + else if (utf8_case_equal(state_str, "RINGING")) state = CALL_STATE_RINGING; - else if (utf8_case_cmp(state_str, "INCOMING") == 0) + else if (utf8_case_equal(state_str, "INCOMING")) state = CALL_STATE_INCOMING; - else if (utf8_case_cmp(state_str, "HOLD") == 0) + else if (utf8_case_equal(state_str, "HOLD")) state = CALL_STATE_HOLD; - else if (utf8_case_cmp(state_str, "BUSY") == 0) + else if (utf8_case_equal(state_str, "BUSY")) state = CALL_STATE_BUSY; else state = CALL_STATE_FAILURE; diff --git a/gnome/src/conference_obj.c b/gnome/src/conference_obj.c index f91617458266d8171cd8e405610f45b15bd4d85b..84ecb0348f8b8c9af9233814771d725d1cda4d65 100644 --- a/gnome/src/conference_obj.c +++ b/gnome/src/conference_obj.c @@ -81,17 +81,17 @@ conference_obj_t *create_new_conference_from_details(const gchar *conf_id, GHash gchar *state_str = g_hash_table_lookup(details, "CONF_STATE"); - if (utf8_case_cmp(state_str, "ACTIVE_ATTACHED") == 0) + if (utf8_case_equal(state_str, "ACTIVE_ATTACHED")) new_conf->_state = CONFERENCE_STATE_ACTIVE_ATTACHED; - else if (utf8_case_cmp(state_str, "ACTIVE_ATTACHED_REC") == 0) + else if (utf8_case_equal(state_str, "ACTIVE_ATTACHED_REC")) new_conf->_state = CONFERENCE_STATE_ACTIVE_ATTACHED_RECORD; - else if (utf8_case_cmp(state_str, "ACTIVE_DETACHED") == 0) + else if (utf8_case_equal(state_str, "ACTIVE_DETACHED")) new_conf->_state = CONFERENCE_STATE_ACTIVE_DETACHED; - else if (utf8_case_cmp(state_str, "ACTIVE_DETACHED_REC") == 0) + else if (utf8_case_equal(state_str, "ACTIVE_DETACHED_REC")) new_conf->_state = CONFERENCE_STATE_ACTIVE_DETACHED_RECORD; - else if (utf8_case_cmp(state_str, "HOLD") == 0) + else if (utf8_case_equal(state_str, "HOLD")) new_conf->_state = CONFERENCE_STATE_HOLD; - else if (utf8_case_cmp(state_str, "HOLD_REC") == 0) + else if (utf8_case_equal(state_str, "HOLD_REC")) new_conf->_state = CONFERENCE_STATE_HOLD_RECORD; return new_conf; diff --git a/gnome/src/config/accountconfigdialog.c b/gnome/src/config/accountconfigdialog.c index c284e73712a605813a3b0e94d8eb92444c594a67..a70e7c502505b6fa16e14fb3ae9a1c495ad60038 100644 --- a/gnome/src/config/accountconfigdialog.c +++ b/gnome/src/config/accountconfigdialog.c @@ -131,7 +131,7 @@ void change_protocol_cb() // Only if tabs are not NULL if (security_tab && advanced_tab) { - if (utf8_case_cmp(protocol, "IAX") == 0) { + if (utf8_case_equal(protocol, "IAX")) { gtk_widget_hide(security_tab); gtk_widget_hide(advanced_tab); } else { @@ -198,11 +198,8 @@ static void update_credential_cb(GtkWidget *widget, gpointer data UNUSED) static GtkWidget* create_basic_tab(const account_t *account) { g_assert(account); - - const gchar *account_type = g_hash_table_lookup(account->properties, - ACCOUNT_TYPE); gchar *password = NULL; - if (g_strcmp0(account_type, "SIP") == 0) { + if (account_is_SIP(account)) { /* get password from credentials list */ if (account->credential_information) { GHashTable * element = g_ptr_array_index(account->credential_information, 0); @@ -216,12 +213,12 @@ static GtkWidget* create_basic_tab(const account_t *account) GtkWidget *table = NULL; - if (g_strcmp0(account_type, "SIP") == 0) + if (account_is_SIP(account)) table = gtk_table_new(9, 2, FALSE/* homogeneous */); - else if (g_strcmp0(account_type, "IAX") == 0) + else if (account_is_IAX(account)) table = gtk_table_new(8, 2, FALSE); else { - ERROR("Unknown account type \"%s\"", account_type); + ERROR("Unknown account type"); return NULL; } @@ -254,9 +251,9 @@ static GtkWidget* create_basic_tab(const account_t *account) if (dbus_is_iax2_enabled()) gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(protocol_combo), "IAX"); - if (g_strcmp0(account_type, "SIP") == 0) + if (account_is_SIP(account)) gtk_combo_box_set_active(GTK_COMBO_BOX(protocol_combo), 0); - else if (g_strcmp0(account_type, "IAX") == 0) + else if (account_is_IAX(account)) gtk_combo_box_set_active(GTK_COMBO_BOX(protocol_combo), 1); else { DEBUG("Config: Error: Account protocol not valid"); @@ -301,7 +298,7 @@ static GtkWidget* create_basic_tab(const account_t *account) gtk_table_attach(GTK_TABLE(table), entry_username, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - if (g_strcmp0(account_type, "SIP") == 0) { + if (account_is_SIP(account)) { g_signal_connect(G_OBJECT(entry_username), "changed", G_CALLBACK(update_credential_cb), NULL); g_object_set_data(G_OBJECT(entry_username), "column", @@ -324,7 +321,7 @@ static GtkWidget* create_basic_tab(const account_t *account) gtk_table_attach(GTK_TABLE(table), entry_password, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - if (g_strcmp0(account_type, "SIP") == 0) { + if (account_is_SIP(account)) { g_signal_connect(G_OBJECT(entry_password), "changed", G_CALLBACK(update_credential_cb), NULL); g_object_set_data(G_OBJECT(entry_password), "column", GINT_TO_POINTER(COLUMN_CREDENTIAL_PASSWORD)); } @@ -436,8 +433,8 @@ cell_edited_cb(GtkCellRendererText *renderer, gchar *path_desc, gchar *text, gint column = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(renderer), "column")); DEBUG("path desc in cell_edited_cb: %s\n", text); - if ((utf8_case_cmp(path_desc, "0") == 0) && - utf8_case_cmp(text, gtk_entry_get_text(GTK_ENTRY(entry_username))) != 0) + if ((utf8_case_equal(path_desc, "0")) && + !utf8_case_equal(text, gtk_entry_get_text(GTK_ENTRY(entry_username)))) g_signal_handlers_disconnect_by_func(G_OBJECT(entry_username), G_CALLBACK(update_credential_cb), NULL); @@ -456,18 +453,19 @@ editing_started_cb(GtkCellRenderer *cell UNUSED, GtkCellEditable * editable, DEBUG("path desc in editing_started_cb: %s\n", path); // If we are dealing the first row - if (utf8_case_cmp(path, "0") == 0) + if (utf8_case_equal(path, "0")) gtk_entry_set_text(GTK_ENTRY(editable), gtk_entry_get_text(GTK_ENTRY(entry_password))); } 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); + if (utf8_case_equal(proto, "ZRTP")) + show_advanced_zrtp_options(account); else - show_advanced_sdes_options((GHashTable *) data); + show_advanced_sdes_options(account); g_free(proto); } @@ -476,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 @@ -486,8 +485,8 @@ key_exchange_changed_cb(GtkWidget *widget UNUSED, gpointer data UNUSED) DEBUG("Key exchange changed %s", active_text); gboolean sensitive = FALSE; - sensitive |= utf8_case_cmp(active_text, "SDES") == 0; - sensitive |= utf8_case_cmp(active_text, "ZRTP") == 0; + sensitive |= utf8_case_equal(active_text, "SDES"); + sensitive |= utf8_case_equal(active_text, "ZRTP"); g_free(active_text); gtk_widget_set_sensitive(zrtp_button, sensitive); } @@ -755,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); @@ -775,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); @@ -923,11 +922,10 @@ GtkWidget* create_published_address(const account_t *account) // Get the user configuration if (account) { - use_tls = g_hash_table_lookup(account->properties, TLS_ENABLE); published_sameas_local = g_hash_table_lookup(account->properties, PUBLISHED_SAMEAS_LOCAL); - if (utf8_case_cmp(published_sameas_local, "true") == 0) { + if (utf8_case_equal(published_sameas_local, "true")) { published_address = dbus_get_address_from_interface_name(g_hash_table_lookup(account->properties, LOCAL_INTERFACE)); published_port = g_hash_table_lookup(account->properties, LOCAL_PORT); } else { @@ -948,8 +946,8 @@ GtkWidget* create_published_address(const account_t *account) gtk_table_attach_defaults(GTK_TABLE(table), use_stun_check_box, 0, 1, 0, 1); g_signal_connect(use_stun_check_box, "toggled", G_CALLBACK(use_stun_cb), NULL); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_stun_check_box), - utf8_case_cmp(stun_enable, "true") == 0); - gtk_widget_set_sensitive(use_stun_check_box, utf8_case_cmp(use_tls, "true") != 0); + utf8_case_equal(stun_enable, "true")); + gtk_widget_set_sensitive(use_stun_check_box, !utf8_case_equal(use_tls, "true")); stun_server_label = gtk_label_new_with_mnemonic(_("STUN server URL")); gtk_table_attach_defaults(GTK_TABLE(table), stun_server_label, 0, 1, 1, 2); @@ -965,7 +963,7 @@ GtkWidget* create_published_address(const account_t *account) published_addr_radio_button = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(same_as_local_radio_button), _("Set published address and port:")); gtk_table_attach_defaults(GTK_TABLE(table), published_addr_radio_button, 0, 2, 4, 5); - if (utf8_case_cmp(published_sameas_local, "true") == 0) { + if (utf8_case_equal(published_sameas_local, "true")) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(same_as_local_radio_button), TRUE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(published_addr_radio_button), FALSE); } else { @@ -1053,11 +1051,9 @@ create_audiocodecs_configuration(const account_t *account) gtk_container_add(GTK_CONTAINER(audiocodecs), box); // Add DTMF type selection for SIP account only - gpointer p = g_hash_table_lookup(account->properties, ACCOUNT_TYPE); - GtkWidget *table; - if (g_strcmp0(p, "SIP") == 0) { + if (account_is_SIP(account)) { // Box for dtmf GtkWidget *dtmf; gnome_main_section_new_with_table(_("DTMF"), &dtmf, &table, 1, 2); @@ -1066,7 +1062,7 @@ create_audiocodecs_configuration(const account_t *account) overrtp = gtk_radio_button_new_with_label(NULL, _("RTP")); const gchar * const dtmf_type = g_hash_table_lookup(account->properties, ACCOUNT_DTMF_TYPE); - const gboolean dtmf_are_rtp = !utf8_case_cmp(dtmf_type, OVERRTP); + const gboolean dtmf_are_rtp = utf8_case_equal(dtmf_type, OVERRTP); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(overrtp), dtmf_are_rtp); gtk_table_attach(GTK_TABLE(table), overrtp, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); @@ -1083,17 +1079,17 @@ create_audiocodecs_configuration(const account_t *account) file_chooser = gtk_file_chooser_button_new(_("Choose a ringtone"), GTK_FILE_CHOOSER_ACTION_OPEN); - p = g_hash_table_lookup(account->properties, CONFIG_RINGTONE_ENABLED); + gpointer ptr = g_hash_table_lookup(account->properties, CONFIG_RINGTONE_ENABLED); enable_tone = gtk_check_button_new_with_mnemonic(_("_Enable ringtones")); - const gboolean ringtone_enabled = g_strcmp0(p, "true") == 0; + const gboolean ringtone_enabled = g_strcmp0(ptr, "true") == 0; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enable_tone), ringtone_enabled); g_signal_connect(G_OBJECT(enable_tone) , "clicked", G_CALLBACK(ringtone_enabled_cb), file_chooser); gtk_table_attach(GTK_TABLE(table), enable_tone, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); // file chooser button gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(file_chooser) , g_get_home_dir()); - p = g_hash_table_lookup(account->properties, CONFIG_RINGTONE_PATH); - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(file_chooser) , p); + ptr = g_hash_table_lookup(account->properties, CONFIG_RINGTONE_PATH); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(file_chooser) , ptr); gtk_widget_set_sensitive(file_chooser, ringtone_enabled); GtkFileFilter *filter = gtk_file_filter_new(); @@ -1139,9 +1135,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_equal(key_exchange, "ZRTP")) { + account_replace(account, ACCOUNT_SRTP_ENABLED, "true"); + account_replace(account, ACCOUNT_KEY_EXCHANGE, ZRTP); + } else if (utf8_case_equal(key_exchange, "SDES")) { + 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) @@ -1166,7 +1258,7 @@ void show_account_window(account_t *account) gtk_widget_show(notebook); // We do not need the global settings for the IP2IP account - if (!is_IP2IP(account)) { + if (!account_is_IP2IP(account)) { /* General Settings */ GtkWidget *basic_tab = create_basic_tab(account); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), basic_tab, gtk_label_new(_("Basic"))); @@ -1178,16 +1270,15 @@ 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 current_protocol = g_strdup("SIP"); // Do not need advanced or security one for the IP2IP account - if (!is_IP2IP(account)) { + if (!account_is_IP2IP(account)) { /* Advanced */ advanced_tab = create_advanced_tab(account); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advanced_tab, gtk_label_new(_("Advanced"))); @@ -1214,136 +1305,17 @@ 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 (!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 (!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) + if (utf8_case_equal(account->accountID, "new")) dbus_add_account(account); else dbus_set_account_details(account); @@ -1352,7 +1324,7 @@ void show_account_window(account_t *account) /* Set new credentials if any */ DEBUG("Config: Setting credentials"); - if (!is_IP2IP(account)) { + if (!account_is_IP2IP(account)) { DEBUG("Config: Get new credentials"); account->credential_information = get_new_credential(); @@ -1366,6 +1338,5 @@ void show_account_window(account_t *account) gtk_widget_destroy(dialog); g_free(current_protocol); - g_free(proto); } diff --git a/gnome/src/config/accountlistconfigdialog.c b/gnome/src/config/accountlistconfigdialog.c index 6562b6050d90e0e10414a4f65649de92ef3f9df1..31de47d48c02e6528c5bda9dd6ba43d523fa60cf 100644 --- a/gnome/src/config/accountlistconfigdialog.c +++ b/gnome/src/config/accountlistconfigdialog.c @@ -104,7 +104,7 @@ static void account_store_fill(GtkTreeIter *iter, account_t *a) g_hash_table_lookup(a->properties, ACCOUNT_ALIAS), COLUMN_ACCOUNT_TYPE, type, COLUMN_ACCOUNT_STATUS, account_state_name(a->state), - COLUMN_ACCOUNT_ACTIVE, !utf8_case_cmp(enabled, "true"), + COLUMN_ACCOUNT_ACTIVE, utf8_case_equal(enabled, "true"), COLUMN_ACCOUNT_DATA, a, -1); } @@ -168,7 +168,7 @@ select_account_cb(GtkTreeSelection *selection, GtkTreeModel *model) gtk_widget_set_sensitive(edit_button, TRUE); - if (!is_IP2IP(selected_account)) { + if (!account_is_IP2IP(selected_account)) { gtk_widget_set_sensitive(move_up_button, TRUE); gtk_widget_set_sensitive(move_down_button, TRUE); gtk_widget_set_sensitive(delete_button, TRUE); @@ -208,7 +208,7 @@ enable_account_cb(GtkCellRendererToggle *rend UNUSED, gchar* path, gpointer data) { // The IP2IP profile can't be disabled - if (utf8_case_cmp(path, "0") == 0) + if (utf8_case_equal(path, "0")) return; // Get pointer on object @@ -259,7 +259,7 @@ account_move(gboolean move_up, gpointer data) // The first real account in the list can't move up because of the IP2IP account // It can still move down though - if (utf8_case_cmp(path, "1") == 0 && move_up) + if (utf8_case_equal(path, "1") && move_up) return; GtkTreePath *tree_path = gtk_tree_path_new_from_string(path); @@ -350,7 +350,7 @@ highlight_ip_profile(GtkTreeViewColumn *col UNUSED, GtkCellRenderer *rend, if (current != NULL) { // Make the first line appear differently - if (is_IP2IP(current)) { + if (account_is_IP2IP(current)) { g_object_set(G_OBJECT(rend), "weight", PANGO_WEIGHT_THIN, "style", PANGO_STYLE_ITALIC, "stretch", PANGO_STRETCH_ULTRA_EXPANDED, "scale", 0.95, NULL); @@ -365,7 +365,7 @@ highlight_ip_profile(GtkTreeViewColumn *col UNUSED, GtkCellRenderer *rend, static const gchar* state_color(account_t *a) { - if (!is_IP2IP(a)) + if (!account_is_IP2IP(a)) if (a->state == ACCOUNT_STATE_REGISTERED) return "Dark Green"; else diff --git a/gnome/src/config/addressbook-config.c b/gnome/src/config/addressbook-config.c index fd12fc8672196ab13d9fcd1318ae7f60cf3c1e3b..3eb74d378f9db063988bbffe9c3dc1ff3959b0f2 100644 --- a/gnome/src/config/addressbook-config.c +++ b/gnome/src/config/addressbook-config.c @@ -444,14 +444,14 @@ addressbook_display(AddressBook_Config *settings, const gchar *field) { gboolean display; - if (utf8_case_cmp(field, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO) == 0) - display = (settings->display_contact_photo == 1) ? TRUE : FALSE; - else if (utf8_case_cmp(field, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS) == 0) - display = (settings->search_phone_business == 1) ? TRUE : FALSE; - else if (utf8_case_cmp(field, ADDRESSBOOK_DISPLAY_PHONE_HOME) == 0) - display = (settings->search_phone_home == 1) ? TRUE : FALSE; - else if (utf8_case_cmp(field, ADDRESSBOOK_DISPLAY_PHONE_MOBILE) == 0) - display = (settings->search_phone_mobile == 1) ? TRUE : FALSE; + if (utf8_case_equal(field, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO)) + display = settings->display_contact_photo == 1; + else if (utf8_case_equal(field, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS)) + display = settings->search_phone_business == 1; + else if (utf8_case_equal(field, ADDRESSBOOK_DISPLAY_PHONE_HOME)) + display = settings->search_phone_home == 1; + else if (utf8_case_equal(field, ADDRESSBOOK_DISPLAY_PHONE_MOBILE)) + display = settings->search_phone_mobile == 1; else display = FALSE; diff --git a/gnome/src/config/assistant.c b/gnome/src/config/assistant.c index 202767eb2494e390f4ed84f0c633d37945073300..bc74e9cf2c4122655ce2a14d17f8f1ebf06247a0 100644 --- a/gnome/src/config/assistant.c +++ b/gnome/src/config/assistant.c @@ -145,26 +145,25 @@ static void sip_apply_callback(void) } if (account_type == _SIP) { - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ALIAS), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->sip_alias)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ENABLED), g_strdup("true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_MAILBOX), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->sip_voicemail)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_TYPE), g_strdup("SIP")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_HOSTNAME), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->sip_server)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_PASSWORD), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->sip_password)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_USERNAME), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->sip_username)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SIP_STUN_ENABLED), g_strdup((gchar *)(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->enable)) ? "true":"false"))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SIP_STUN_SERVER), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->addr)))); + account_insert(current, ACCOUNT_ALIAS, gtk_entry_get_text(GTK_ENTRY(wiz->sip_alias))); + account_insert(current, ACCOUNT_ENABLED, "true"); + account_insert(current, ACCOUNT_MAILBOX, gtk_entry_get_text(GTK_ENTRY(wiz->sip_voicemail))); + account_insert(current, ACCOUNT_TYPE, "SIP"); + account_insert(current, ACCOUNT_HOSTNAME, gtk_entry_get_text(GTK_ENTRY(wiz->sip_server))); + account_insert(current, ACCOUNT_PASSWORD, gtk_entry_get_text(GTK_ENTRY(wiz->sip_password))); + account_insert(current, ACCOUNT_USERNAME, gtk_entry_get_text(GTK_ENTRY(wiz->sip_username))); + account_insert(current, ACCOUNT_SIP_STUN_ENABLED, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->enable)) ? "true" : "false"); + account_insert(current, ACCOUNT_SIP_STUN_SERVER, gtk_entry_get_text(GTK_ENTRY(wiz->addr))); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wiz->zrtp_enable)) == TRUE) { - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_SRTP_ENABLED), g_strdup((gchar *) "true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_KEY_EXCHANGE), g_strdup((gchar *) ZRTP)); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ZRTP_DISPLAY_SAS), g_strdup((gchar *) "true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ZRTP_NOT_SUPP_WARNING), g_strdup((gchar *) "true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ZRTP_HELLO_HASH), g_strdup((gchar *) "true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_DISPLAY_SAS_ONCE), g_strdup((gchar *) "false")); + account_insert(current, ACCOUNT_SRTP_ENABLED, "true"); + account_insert(current, ACCOUNT_KEY_EXCHANGE, ZRTP); + account_insert(current, ACCOUNT_ZRTP_DISPLAY_SAS, "true"); + account_insert(current, ACCOUNT_ZRTP_NOT_SUPP_WARNING, "true"); + account_insert(current, ACCOUNT_ZRTP_HELLO_HASH, "true"); + account_insert(current, ACCOUNT_DISPLAY_SAS_ONCE, "false"); } - // Add default interface info gchar ** iface_list = NULL; iface_list = (gchar**) dbus_get_all_ip_interface_by_name(); @@ -174,9 +173,8 @@ static void sip_apply_callback(void) iface = iface_list; DEBUG("Selected interface %s", *iface); - g_hash_table_insert(current->properties, g_strdup(LOCAL_INTERFACE), g_strdup((gchar *) *iface)); - - g_hash_table_insert(current->properties, g_strdup(PUBLISHED_ADDRESS), g_strdup((gchar *) *iface)); + account_insert(current, LOCAL_INTERFACE, *iface); + account_insert(current, PUBLISHED_ADDRESS, *iface); dbus_add_account(current); getMessageSummary(gtk_entry_get_text(GTK_ENTRY(wiz->sip_alias)), @@ -196,20 +194,19 @@ static void sip_apply_callback(void) static void iax_apply_callback(void) { if (account_type == _IAX) { - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ALIAS), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->iax_alias)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_ENABLED), g_strdup("true")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_MAILBOX), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->iax_voicemail)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_TYPE), g_strdup("IAX")); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_USERNAME), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->iax_username)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_HOSTNAME), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->iax_server)))); - g_hash_table_insert(current->properties, g_strdup(ACCOUNT_PASSWORD), g_strdup((gchar *) gtk_entry_get_text(GTK_ENTRY(wiz->iax_password)))); + account_insert(current, ACCOUNT_ALIAS, gtk_entry_get_text(GTK_ENTRY(wiz->iax_alias))); + account_insert(current, ACCOUNT_ENABLED, "true"); + account_insert(current, ACCOUNT_MAILBOX, gtk_entry_get_text(GTK_ENTRY(wiz->iax_voicemail))); + account_insert(current, ACCOUNT_TYPE, "IAX"); + account_insert(current, ACCOUNT_USERNAME, gtk_entry_get_text(GTK_ENTRY(wiz->iax_username))); + account_insert(current, ACCOUNT_HOSTNAME, gtk_entry_get_text(GTK_ENTRY(wiz->iax_server))); + account_insert(current, ACCOUNT_PASSWORD, gtk_entry_get_text(GTK_ENTRY(wiz->iax_password))); dbus_add_account(current); getMessageSummary(gtk_entry_get_text(GTK_ENTRY(wiz->iax_alias)), gtk_entry_get_text(GTK_ENTRY(wiz->iax_server)), gtk_entry_get_text(GTK_ENTRY(wiz->iax_username)), - FALSE - ) ; + FALSE); gtk_label_set_text(GTK_LABEL(wiz->label_summary), message); } @@ -228,17 +225,13 @@ void build_wizard(void) return ; wiz = (struct _wizard*) g_malloc(sizeof(struct _wizard)); - current = g_new0(account_t, 1); - current->properties = NULL; - current->properties = dbus_get_account_details(NULL); + current = create_default_account(); if (current->properties == NULL) { DEBUG("Failed to get default values. Creating from scratch"); current->properties = g_hash_table_new(NULL, g_str_equal); } - current->accountID = g_strdup("new"); - wiz->assistant = gtk_assistant_new(); gtk_window_set_title(GTK_WINDOW(wiz->assistant), _("SFLphone account creation wizard")); diff --git a/gnome/src/config/audioconf.c b/gnome/src/config/audioconf.c index 4289c8f7a5c633daa06130917695956fd8b49e8a..9159586cfe00b65d0b2097f4408aa1eec44887f8 100644 --- a/gnome/src/config/audioconf.c +++ b/gnome/src/config/audioconf.c @@ -273,7 +273,7 @@ select_active_input_audio_device() void update_device_widget(gchar *pluginName) { - if (utf8_case_cmp(pluginName, "default") == 0) { + if (utf8_case_equal(pluginName, "default")) { gtk_widget_set_sensitive(output, FALSE); gtk_widget_set_sensitive(input, FALSE); gtk_widget_set_sensitive(ringtone, FALSE); @@ -316,7 +316,7 @@ select_active_output_audio_plugin() do { gtk_tree_model_get(model, &iter, 0, &pluginname, -1); - if (utf8_case_cmp(tmp, pluginname) == 0) { + if (utf8_case_equal(tmp, pluginname)) { // Set current iteration the active one gtk_combo_box_set_active_iter(GTK_COMBO_BOX(plugin), &iter); return; @@ -423,11 +423,11 @@ codec_active_toggled(GtkCellRendererToggle *renderer UNUSED, gchar *path, gpoint codec_t* codec; - if ((utf8_case_cmp(name,"speex") == 0) && (utf8_case_cmp(srate,"8 kHz") == 0)) + if (utf8_case_equal(name,"speex") && utf8_case_equal(srate,"8 kHz")) codec = codec_list_get_by_payload((gconstpointer) 110, acc->codecs); - else if ((utf8_case_cmp(name,"speex") ==0) && (utf8_case_cmp(srate,"16 kHz") ==0)) + else if (utf8_case_equal(name,"speex") && utf8_case_equal(srate,"16 kHz")) codec = codec_list_get_by_payload((gconstpointer) 111, acc->codecs); - else if ((utf8_case_cmp(name,"speex") ==0) && (utf8_case_cmp(srate,"32 kHz") ==0)) + else if (utf8_case_equal(name,"speex") && utf8_case_equal(srate, "32 kHz")) codec = codec_list_get_by_payload((gconstpointer) 112, acc->codecs); else codec = codec_list_get_by_name((gconstpointer) name, acc->codecs); diff --git a/gnome/src/config/hooks-config.c b/gnome/src/config/hooks-config.c index 5a161344ac29d414e0b4fb593b12ed6600de1b29..2ff4dc500346fc4cf39a6248acbd2e68dbb8f821 100644 --- a/gnome/src/config/hooks-config.c +++ b/gnome/src/config/hooks-config.c @@ -157,7 +157,7 @@ GtkWidget* create_hooks_settings() gtk_table_attach(GTK_TABLE(table), info_bar, 0, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 10, 10); widg = gtk_check_button_new_with_mnemonic(_("Trigger on specific _SIP header")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), (utf8_case_cmp(_urlhook_config->sip_enabled, "true") ==0) ?TRUE:FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), utf8_case_equal(_urlhook_config->sip_enabled, "true")); g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(sip_enabled_cb), NULL); gtk_table_attach(GTK_TABLE(table), widg, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); @@ -166,7 +166,7 @@ GtkWidget* create_hooks_settings() gtk_table_attach(GTK_TABLE(table), field, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); widg = gtk_check_button_new_with_mnemonic(_("Trigger on _IAX2 URL")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), (utf8_case_cmp(_urlhook_config->iax2_enabled, "true") ==0) ?TRUE:FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), utf8_case_equal(_urlhook_config->iax2_enabled, "true")); g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(iax2_enabled_cb), NULL); gtk_table_attach(GTK_TABLE(table), widg, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); @@ -183,7 +183,7 @@ GtkWidget* create_hooks_settings() gtk_widget_show(frame); widg = gtk_check_button_new_with_mnemonic(_("_Prefix dialed numbers with")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), (utf8_case_cmp(_urlhook_config->phone_number_enabled, "true") ==0) ?TRUE:FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widg), utf8_case_equal(_urlhook_config->phone_number_enabled, "true")); g_signal_connect(G_OBJECT(widg) , "clicked" , G_CALLBACK(phone_number_enabled_cb), NULL); gtk_table_attach(GTK_TABLE(table), widg, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); diff --git a/gnome/src/config/tlsadvanceddialog.c b/gnome/src/config/tlsadvanceddialog.c index 232c3a8d8938483cc8080ebb03828d792cb5f1eb..7c77eba19ae67b3268fbc1f8b515fa0899b8a135 100644 --- a/gnome/src/config/tlsadvanceddialog.c +++ b/gnome/src/config/tlsadvanceddialog.c @@ -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")); @@ -251,71 +258,53 @@ void show_advanced_tls_options(GHashTable * properties) GtkWidget * verifyCertificateServer; verifyCertificateServer = gtk_check_button_new_with_mnemonic(_("Verify incoming certificates, as a server")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(verifyCertificateServer), - utf8_case_cmp(verify_server,"true") == 0); + utf8_case_equal(verify_server, "true")); gtk_table_attach(GTK_TABLE(table), verifyCertificateServer, 0, 1, 11, 12, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GtkWidget * verifyCertificateClient; verifyCertificateClient = gtk_check_button_new_with_mnemonic(_("Verify certificates from answer, as a client")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(verifyCertificateClient), - utf8_case_cmp(verify_client,"true") == 0); + utf8_case_equal(verify_client, "true")); gtk_table_attach(GTK_TABLE(table), verifyCertificateClient, 0, 1, 12, 13, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GtkWidget * requireCertificate; requireCertificate = gtk_check_button_new_with_mnemonic(_("Require certificate for incoming tls connections")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(requireCertificate), - utf8_case_cmp(require_client_certificate,"true") == 0); + utf8_case_equal(require_client_certificate,"true")); gtk_table_attach(GTK_TABLE(table), requireCertificate, 0, 1, 13, 14, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); 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)); diff --git a/gnome/src/config/tlsadvanceddialog.h b/gnome/src/config/tlsadvanceddialog.h index 35d45d7eee4787c0b0d90a48e2704696d36b5cea..73a40ea6da7838d77ab680cf82019552eab7bc8f 100644 --- a/gnome/src/config/tlsadvanceddialog.h +++ b/gnome/src/config/tlsadvanceddialog.h @@ -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 diff --git a/gnome/src/config/zrtpadvanceddialog.c b/gnome/src/config/zrtpadvanceddialog.c index efb80d976356707b01d34d83fe143c9a1792b761..8b1090655239eb32a19fac11c086d45babc3a6ad 100644 --- a/gnome/src/config/zrtpadvanceddialog.c +++ b/gnome/src/config/zrtpadvanceddialog.c @@ -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_equal(account_lookup(account, ACCOUNT_ZRTP_HELLO_HASH), "true"); + curSasConfirm = utf8_case_equal(account_lookup(account, ACCOUNT_ZRTP_DISPLAY_SAS), "true"); + curZrtpNotSuppOther = utf8_case_equal(account_lookup(account, ACCOUNT_ZRTP_NOT_SUPP_WARNING), "true"); + curDisplaySasOnce = utf8_case_equal(account_lookup(account, ACCOUNT_DISPLAY_SAS_ONCE), "true"); } GtkDialog *securityDialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("ZRTP Options"), @@ -56,13 +57,11 @@ 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 */); + 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); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(securityDialog)), tableZrtp, FALSE, FALSE, 0); @@ -71,70 +70,63 @@ void show_advanced_zrtp_options(GHashTable * properties) GtkWidget *enableHelloHash = gtk_check_button_new_with_mnemonic(_("Send Hello Hash in S_DP")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enableHelloHash), curHelloEnabled); gtk_table_attach(GTK_TABLE(tableZrtp), enableHelloHash, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive(GTK_WIDGET(enableHelloHash) , TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(enableHelloHash), TRUE); GtkWidget *enableSASConfirm = gtk_check_button_new_with_mnemonic(_("Ask User to Confirm SAS")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enableSASConfirm), curSasConfirm); gtk_table_attach(GTK_TABLE(tableZrtp), enableSASConfirm, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive(GTK_WIDGET(enableSASConfirm) , TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(enableSASConfirm), TRUE); GtkWidget *enableZrtpNotSuppOther = gtk_check_button_new_with_mnemonic(_("_Warn if ZRTP not supported")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enableZrtpNotSuppOther), curZrtpNotSuppOther); gtk_table_attach(GTK_TABLE(tableZrtp), enableZrtpNotSuppOther, 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive(GTK_WIDGET(enableZrtpNotSuppOther) , TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(enableZrtpNotSuppOther), TRUE); GtkWidget *displaySasOnce = gtk_check_button_new_with_mnemonic(_("Display SAS once for hold events")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(displaySasOnce), curDisplaySasOnce); gtk_table_attach(GTK_TABLE(tableZrtp), displaySasOnce, 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive(GTK_WIDGET(displaySasOnce) , TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(displaySasOnce), TRUE); gtk_widget_show_all(tableZrtp); 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_equal(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); - GtkWidget *sdesTable = gtk_table_new(1, 2 , FALSE/* homogeneous */); + GtkWidget *sdesTable = gtk_table_new(1, 2, FALSE /* homogeneous */); gtk_table_set_row_spacings(GTK_TABLE(sdesTable), 10); gtk_table_set_col_spacings(GTK_TABLE(sdesTable), 10); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(securityDialog)), sdesTable, FALSE, FALSE, 0); @@ -143,16 +135,15 @@ void show_advanced_sdes_options(GHashTable * properties) GtkWidget *enableRtpFallback = gtk_check_button_new_with_mnemonic(_("Fallback on RTP on SDES failure")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enableRtpFallback), rtpFallback); gtk_table_attach(GTK_TABLE(sdesTable), enableRtpFallback, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_set_sensitive(GTK_WIDGET(enableRtpFallback) , TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(enableRtpFallback), TRUE); gtk_widget_show_all(sdesTable); 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)); diff --git a/gnome/src/config/zrtpadvanceddialog.h b/gnome/src/config/zrtpadvanceddialog.h index 0a98ddb96089001c66f0df3cdf15e3b20de00fb0..ddc09114beb8d4fbb2455139c981618bf4e324af 100644 --- a/gnome/src/config/zrtpadvanceddialog.h +++ b/gnome/src/config/zrtpadvanceddialog.h @@ -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 diff --git a/gnome/src/contacts/calltab.c b/gnome/src/contacts/calltab.c index 7ff8c1ccc55d40b487c31cfbadb6c90db0458201..af12e642742b7216ac5d10706cd2a0c022e2d53f 100644 --- a/gnome/src/contacts/calltab.c +++ b/gnome/src/contacts/calltab.c @@ -98,9 +98,9 @@ calltab_create_searchbar(calltab_t* tab) { g_assert(tab); - if (utf8_case_cmp(tab->_name, HISTORY) == 0) + if (utf8_case_equal(tab->_name, HISTORY)) tab->searchbar = history_searchbar_new(); - else if (utf8_case_cmp(tab->_name, CONTACTS) == 0) + else if (utf8_case_equal(tab->_name, CONTACTS)) tab->searchbar = contacts_searchbar_new(); else ERROR("Current calls tab does not need a searchbar\n"); diff --git a/gnome/src/contacts/calltree.c b/gnome/src/contacts/calltree.c index 87521d6ca73641d0a080c7fb1f96633f67450b69..b945561888aa39ec0bcda383086b20f084fe9df1 100644 --- a/gnome/src/contacts/calltree.c +++ b/gnome/src/contacts/calltree.c @@ -292,7 +292,7 @@ row_single_click(GtkTreeView *tree_view UNUSED, void * data UNUSED) case SRTP_STATE_ZRTP_SAS_UNCONFIRMED: selectedCall->_srtp_state = SRTP_STATE_ZRTP_SAS_CONFIRMED; - if (utf8_case_cmp(displaySasOnce, "true") == 0) + if (utf8_case_equal(displaySasOnce, "true")) selectedCall->_zrtp_confirmed = TRUE; dbus_confirm_sas(selectedCall); @@ -595,26 +595,21 @@ calltree_update_call_recursive(calltab_t* tab, callable_obj_t * c, GtkTreeIter * gchar* srtp_enabled = NULL; gboolean display_sas = TRUE; - account_t* account_details=NULL; + account_t* account = NULL; int nbChild = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), parent); if (c) { - account_details = account_list_get_by_id(c->_accountID); - - if (account_details != NULL) { - srtp_enabled = g_hash_table_lookup(account_details->properties, ACCOUNT_SRTP_ENABLED); + account = account_list_get_by_id(c->_accountID); - if (utf8_case_cmp(g_hash_table_lookup(account_details->properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) - display_sas = FALSE; + if (account != NULL) { + srtp_enabled = account_lookup(account, ACCOUNT_SRTP_ENABLED); + display_sas = utf8_case_equal(account_lookup(account, ACCOUNT_ZRTP_DISPLAY_SAS), "true"); } else { GHashTable * properties = sflphone_get_ip2ip_properties(); - if (properties != NULL) { srtp_enabled = g_hash_table_lookup(properties, ACCOUNT_SRTP_ENABLED); - - if (utf8_case_cmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) - display_sas = FALSE; + display_sas = utf8_case_equal(g_hash_table_lookup(properties, ACCOUNT_ZRTP_DISPLAY_SAS), "true"); } } } @@ -699,12 +694,12 @@ calltree_update_call_recursive(calltab_t* tab, callable_obj_t * c, GtkTreeIter * pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_certified.svg", NULL); break; case SRTP_STATE_UNLOCKED: - if (utf8_case_cmp(srtp_enabled,"true") == 0) + if (utf8_case_equal(srtp_enabled, "true")) pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL); break; default: WARN("Update calltree srtp state #%d- Should not happen!", c->_srtp_state); - if (utf8_case_cmp(srtp_enabled, "true") == 0) + if (utf8_case_equal(srtp_enabled, "true")) pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL); } @@ -812,7 +807,7 @@ void calltree_add_call(calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) WARN("Update calltree add - Should not happen!"); } - if (srtp_enabled && utf8_case_cmp(srtp_enabled, "true") == 0) + if (srtp_enabled && utf8_case_equal(srtp_enabled, "true")) pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/secure_off.svg", NULL); } else if (tab == contacts_tab) @@ -973,7 +968,7 @@ void calltree_add_conference_to_current_calls(conference_obj_t* conf) else srtp_enabled = g_hash_table_lookup(account_details->properties, ACCOUNT_SRTP_ENABLED); - if (utf8_case_cmp(srtp_enabled, "true") == 0) { + if (utf8_case_equal(srtp_enabled, "true")) { DEBUG("Calltree: SRTP enabled for participant %s", call_id); conf->_conf_srtp_enabled = TRUE; break; diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c index f8863da0fe9586b45fc64e96f708642c0abefce4..e68d4455913946ad8e25d0c6b42cac8a2b828a77 100644 --- a/gnome/src/dbus/dbus.c +++ b/gnome/src/dbus/dbus.c @@ -238,7 +238,7 @@ process_nonexisting_call_state_change(const gchar *callID, const gchar *state) GHashTable *call_details = dbus_get_call_details(callID); callable_obj_t *new_call = create_new_call_from_details(callID, call_details); - if (utf8_case_cmp(g_hash_table_lookup(call_details, "CALL_TYPE"), INCOMING_STRING) == 0) + if (utf8_case_equal(g_hash_table_lookup(call_details, "CALL_TYPE"), INCOMING_STRING)) new_call->_history_state = g_strdup(INCOMING_STRING); else new_call->_history_state = g_strdup(OUTGOING_STRING); diff --git a/gnome/src/mainwindow.c b/gnome/src/mainwindow.c index ce8d3b8140d6807af5bccca9f8029777eec3279b..9b079d739650c89ed326e95d7d4b9303b3af8ed1 100644 --- a/gnome/src/mainwindow.c +++ b/gnome/src/mainwindow.c @@ -402,22 +402,22 @@ main_window_zrtp_not_supported(callable_obj_t * c) { gchar* warning_enabled = ""; - account_t *account_details = account_list_get_by_id(c->_accountID); + account_t *account = account_list_get_by_id(c->_accountID); - if (account_details != NULL) { - warning_enabled = g_hash_table_lookup(account_details->properties, - ACCOUNT_ZRTP_NOT_SUPP_WARNING); + if (account != NULL) { + warning_enabled = account_lookup(account, + ACCOUNT_ZRTP_NOT_SUPP_WARNING); DEBUG("Warning Enabled %s", warning_enabled); } else { DEBUG("Account is null callID %s", c->_callID); GHashTable * properties = sflphone_get_ip2ip_properties(); if (properties) - warning_enabled = g_hash_table_lookup (properties, - ACCOUNT_ZRTP_NOT_SUPP_WARNING); + warning_enabled = g_hash_table_lookup(properties, + ACCOUNT_ZRTP_NOT_SUPP_WARNING); } - if (utf8_case_cmp(warning_enabled, "true") == 0) { + if (utf8_case_equal(warning_enabled, "true")) { PidginMiniDialog *mini_dialog; gchar *desc = g_markup_printf_escaped( _("ZRTP is not supported by peer %s\n"), c->_peer_number); diff --git a/gnome/src/sflnotify.c b/gnome/src/sflnotify.c index 773946eb06d8efb8277905de9b364bacad6cbbc4..7f8c19a9c1d0644b89ae61153a8840b70a2199f0 100644 --- a/gnome/src/sflnotify.c +++ b/gnome/src/sflnotify.c @@ -90,7 +90,7 @@ notify_incoming_message(const gchar *callID, const gchar *msg) create_new_gnome_notification(title, (gchar *)msg, NOTIFY_URGENCY_CRITICAL, - (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + utf8_case_equal(__TIMEOUT_MODE, "default") ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } @@ -113,7 +113,7 @@ notify_incoming_call(callable_obj_t* c) create_new_gnome_notification(title, callerid, NOTIFY_URGENCY_CRITICAL, - (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + utf8_case_equal(__TIMEOUT_MODE, "default") ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } @@ -185,7 +185,7 @@ notify_secure_on(callable_obj_t* c) create_new_gnome_notification(title, callerid, NOTIFY_URGENCY_CRITICAL, - (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + utf8_case_equal(__TIMEOUT_MODE, "default") ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } @@ -198,7 +198,7 @@ notify_zrtp_not_supported(callable_obj_t* c) create_new_gnome_notification(title, callerid, NOTIFY_URGENCY_CRITICAL, - (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + utf8_case_equal(__TIMEOUT_MODE, "default") ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } @@ -211,7 +211,7 @@ notify_zrtp_negotiation_failed(callable_obj_t* c) create_new_gnome_notification(title, callerid, NOTIFY_URGENCY_CRITICAL, - (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + utf8_case_equal(__TIMEOUT_MODE, "default") ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } @@ -224,6 +224,6 @@ notify_secure_off(callable_obj_t* c) create_new_gnome_notification(title, callerid, NOTIFY_URGENCY_CRITICAL, - (utf8_case_cmp(__TIMEOUT_MODE, "default") == 0) ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); + utf8_case_equal(__TIMEOUT_MODE, "default") ? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER); #endif } diff --git a/gnome/src/sflphone_const.h b/gnome/src/sflphone_const.h index f31f377c6dd0f8a4818337138ec92e7e77a4fd50..62e2887a86e6617a32b38504ecf61dcfdcc47ee0 100644 --- a/gnome/src/sflphone_const.h +++ b/gnome/src/sflphone_const.h @@ -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" diff --git a/gnome/src/str_utils.c b/gnome/src/str_utils.c index cfa2a1e6dc925c387c6b6a8e54787bce35511f5a..2bbff79e159340e71fd2f65e888802d2d6cc8167 100644 --- a/gnome/src/str_utils.c +++ b/gnome/src/str_utils.c @@ -32,8 +32,6 @@ gint utf8_case_cmp(const gchar *a, const gchar *b) { - g_assert(a); - g_assert(b); gchar *l = g_utf8_casefold(a, -1); gchar *r = g_utf8_casefold(b, -1); gint result = g_utf8_collate(l, r); @@ -41,3 +39,14 @@ gint utf8_case_cmp(const gchar *a, const gchar *b) g_free(r); return result; } + +gboolean utf8_case_equal(const gchar *a, const gchar *b) +{ + if (a == NULL) { + if (b == NULL) + return TRUE; + else + return FALSE; + } else + return utf8_case_cmp(a, b) == 0; +} diff --git a/gnome/src/str_utils.h b/gnome/src/str_utils.h index b2b4bddb56655337552f51e17ce454fff7ea2245..bc9f7cc2780bc1e6f2410f699c3fe8e5d5c9e217 100644 --- a/gnome/src/str_utils.h +++ b/gnome/src/str_utils.h @@ -33,6 +33,10 @@ #include <glib.h> +/* Case independent, local independent string comparison test */ gint utf8_case_cmp(const gchar *a, const gchar *b); +/* Case independent, local independent string equality test, NULL-safe */ +gint utf8_case_equal(const gchar *a, const gchar *b); + #endif /* STR_UTILS_H_ */ diff --git a/gnome/src/uimanager.c b/gnome/src/uimanager.c index 04ee1f5d369b77f8a771135306f4805cad15da72..25a45352eb320f218dae3bfb50d7b45990c07bce 100644 --- a/gnome/src/uimanager.c +++ b/gnome/src/uimanager.c @@ -1237,8 +1237,8 @@ add_registered_accounts_to_menu(GtkWidget *menu) account_t *acc = account_list_get_nth(i); // Display only the registered accounts - if (utf8_case_cmp(account_state_name(acc->state), account_state_name( - ACCOUNT_STATE_REGISTERED)) == 0) { + if (utf8_case_equal(account_state_name(acc->state), + account_state_name(ACCOUNT_STATE_REGISTERED))) { gchar *alias = g_strconcat(g_hash_table_lookup(acc->properties, ACCOUNT_ALIAS), " - ", g_hash_table_lookup(acc->properties, ACCOUNT_TYPE), @@ -1251,7 +1251,7 @@ add_registered_accounts_to_menu(GtkWidget *menu) if (current) { gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items), - utf8_case_cmp(acc->accountID, current->accountID) == 0); + utf8_case_equal(acc->accountID, current->accountID)); } g_signal_connect(G_OBJECT(menu_items), "activate", diff --git a/gnome/tests/Makefile.am b/gnome/tests/Makefile.am index 4cd128b8019fdfd7f8f201b933b2f47d0e0cb287..62f04b0892f2ad01b5760ed3b7adbdfbcd424229 100644 --- a/gnome/tests/Makefile.am +++ b/gnome/tests/Makefile.am @@ -3,14 +3,32 @@ include ../globals.mak 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/dbus/libdbus.la \ - $(top_builddir)/src/config/libconfig.la +SFLPHONE_LIBS= $(top_builddir)/src/contacts/libcontacts.la \ + $(top_builddir)/src/config/libconfig.la \ + $(top_builddir)/src/dbus/libdbus.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@ ########################################################### diff --git a/gnome/tests/check_global.c b/gnome/tests/check_global.c index d1e6eb37692073e024b2142459984ef361f179cc..09ead1053e987e9b6ffc3d24b8d3d4d96ad9e56d 100644 --- a/gnome/tests/check_global.c +++ b/gnome/tests/check_global.c @@ -48,15 +48,15 @@ account_t* create_test_account(gchar *alias) test->properties = g_hash_table_new(NULL, g_str_equal); // Populate the properties - g_hash_table_replace(test->properties, ACCOUNT_ENABLED, "1"); - g_hash_table_replace(test->properties, ACCOUNT_ALIAS, alias); - g_hash_table_replace(test->properties, ACCOUNT_TYPE, "SIP"); - g_hash_table_replace(test->properties, ACCOUNT_HOSTNAME, "sflphone.org"); - g_hash_table_replace(test->properties, ACCOUNT_USERNAME, "1260"); - g_hash_table_replace(test->properties, ACCOUNT_PASSWORD, "NIPAgmLo"); - g_hash_table_replace(test->properties, ACCOUNT_MAILBOX, ""); - g_hash_table_replace(test->properties, ACCOUNT_SIP_STUN_SERVER, ""); - g_hash_table_replace(test->properties, ACCOUNT_SIP_STUN_ENABLED, "0"); + account_replace(test, ACCOUNT_ENABLED, "1"); + account_replace(test, ACCOUNT_ALIAS, alias); + account_replace(test, ACCOUNT_TYPE, "SIP"); + account_replace(test, ACCOUNT_HOSTNAME, "sflphone.org"); + account_replace(test, ACCOUNT_USERNAME, "1260"); + account_replace(test, ACCOUNT_PASSWORD, "NIPAgmLo"); + account_replace(test, ACCOUNT_MAILBOX, ""); + account_replace(test, ACCOUNT_SIP_STUN_SERVER, ""); + account_replace(test, ACCOUNT_SIP_STUN_ENABLED, "0"); return test; } @@ -79,7 +79,7 @@ START_TEST(test_ordered_list) account_list_init(); account_list_add(test); account_list_add(test); - fail_unless(utf8_case_cmp(account_list_get_ordered_list(), list) == 0, "ERROR - BAD ACCOUNT LIST SERIALIZING"); + fail_unless(utf8_case_equal(account_list_get_ordered_list(), list), "ERROR - BAD ACCOUNT LIST SERIALIZING"); g_free(list); } END_TEST @@ -92,7 +92,7 @@ START_TEST(test_get_by_id) account_list_init(); account_list_add(test); tmp = account_list_get_by_id(test->accountID); - fail_unless(utf8_case_cmp(tmp->accountID, test->accountID) == 0, "ERROR - ACCOUNTLIST_GET_BY_ID"); + fail_unless(utf8_case_equal(tmp->accountID, test->accountID), "ERROR - ACCOUNTLIST_GET_BY_ID"); } END_TEST @@ -110,8 +110,8 @@ START_TEST(test_get_current_account) // The current account must be the first we add if (current) { - fail_unless(utf8_case_cmp(g_hash_table_lookup(current->properties, ACCOUNT_ALIAS) , - g_hash_table_lookup(test->properties, ACCOUNT_ALIAS)) == 0, + fail_unless(utf8_case_equal(account_lookup(current, ACCOUNT_ALIAS), + account_lookup(test, ACCOUNT_ALIAS)), "ERROR - BAD CURRENT ACCOUNT"); } @@ -122,8 +122,8 @@ START_TEST(test_get_current_account) // The current account must be the first we add if (current) { - fail_unless(utf8_case_cmp(g_hash_table_lookup(current->properties, ACCOUNT_ALIAS) , - g_hash_table_lookup(test2->properties, ACCOUNT_ALIAS)) == 0, + fail_unless(utf8_case_equal(account_lookup(current, ACCOUNT_ALIAS), + account_lookup(test2, ACCOUNT_ALIAS)), "ERROR - BAD CURRENT ACCOUNT"); } }