Commit cb57b888 authored by Alexandre Savard's avatar Alexandre Savard

#5966: Account config synchronization fix (for stun)

parent a7c1b747
......@@ -243,16 +243,18 @@ void sflphone_fill_account_list (void)
for (i = 0; i < account_list_get_size(); i++) {
account_t * a = account_list_get_nth (i);
GHashTable * details = (GHashTable *) dbus_account_details (a->accountID);
if (details == NULL)
if(a == NULL) {
ERROR("SFLphone: Error: Could not find account %d in list", i);
break;
}
a->properties = details;
GHashTable * details = (GHashTable *) dbus_get_account_details (a->accountID);
if (details == NULL) {
ERROR("SFLphone: Error: Could not fetch detais for account %s", a->accountID);
break;
}
/* As this function might be called numberous time, we should free the
* previously allocated space to avoid memory leaks.
*/
a->properties = details;
/* Fill the actual array of credentials */
int number_of_credential = dbus_get_number_of_credential (a->accountID);
......
......@@ -684,6 +684,9 @@ static void set_published_addr_manually_cb (GtkWidget * widget, gpointer data UN
static void use_stun_cb (GtkWidget *widget, gpointer data UNUSED)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
DEBUG ("Config: Showing stun options, hiding Local/Published info");
......@@ -713,6 +716,8 @@ static void use_stun_cb (GtkWidget *widget, gpointer data UNUSED)
gtk_widget_show (publishedPortSpinBox);
}
}
DEBUG("DONE");
}
......@@ -1105,11 +1110,13 @@ GtkWidget* create_published_address (account_t **a)
useStunCheckBox = gtk_check_button_new_with_mnemonic (_ ("Using STUN"));
gtk_table_attach_defaults (GTK_TABLE (table), useStunCheckBox, 0, 1, 0, 1);
g_signal_connect (useStunCheckBox, "toggled", G_CALLBACK (use_stun_cb), a);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (useStunCheckBox),
g_strcasecmp (stun_enable, "true") == 0 ? TRUE: FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (useStunCheckBox),
g_strcasecmp (use_tls,"true") == 0 ? FALSE: TRUE);
stunServerLabel = gtk_label_new_with_mnemonic (_ ("STUN server URL"));
gtk_table_attach_defaults (GTK_TABLE (table), stunServerLabel, 0, 1, 1, 2);
gtk_misc_set_alignment (GTK_MISC (stunServerLabel), 0, 0.5);
......@@ -1154,7 +1161,6 @@ GtkWidget* create_published_address (account_t **a)
// widgets need to be instanciated before that.
g_signal_connect (localAddressCombo, "changed", G_CALLBACK (local_interface_changed_cb), localAddressCombo);
g_signal_connect (useStunCheckBox, "toggled", G_CALLBACK (use_stun_cb), useStunCheckBox);
g_signal_connect (sameAsLocalRadioButton, "toggled", G_CALLBACK (same_as_local_cb), sameAsLocalRadioButton);
g_signal_connect (publishedAddrRadioButton, "toggled", G_CALLBACK (set_published_addr_manually_cb), publishedAddrRadioButton);
......@@ -1310,9 +1316,9 @@ void show_account_window (account_t * a)
currentAccount = a;
if (currentAccount == NULL) {
DEBUG ("Config: Account is NULL. Will fetch default values");
DEBUG ("Config: Fetching default values for new account");
currentAccount = g_new0 (account_t, 1);
currentAccount->properties = dbus_account_details (NULL);
currentAccount->properties = dbus_get_account_details (NULL);
currentAccount->accountID = "new";
sflphone_fill_codec_list_per_account (&currentAccount);
}
......
......@@ -67,10 +67,12 @@ enum {
*/
static void delete_account_cb (void)
{
if (selectedAccount != NULL) {
dbus_remove_account (selectedAccount->accountID);
if(selectedAccount == NULL) {
ERROR("Config: Error: No selected account in delete action");
return;
}
dbus_remove_account (selectedAccount->accountID);
}
......@@ -79,10 +81,12 @@ static void delete_account_cb (void)
*/
static void edit_account_cb (void)
{
if (selectedAccount != NULL) {
show_account_window (selectedAccount);
if(selectedAccount == NULL) {
ERROR("Config: Error: No selected account in edit action");
return;
}
show_account_window (selectedAccount);
}
/**
......@@ -101,7 +105,7 @@ void account_list_config_dialog_fill()
{
if (accountListDialog == NULL) {
DEBUG ("Dialog is not opened");
ERROR("Config: Error: Dialog is not opened");
return;
}
......@@ -111,30 +115,37 @@ void account_list_config_dialog_fill()
// IP2IP account must be first
account_t *a = account_list_get_by_id ("IP2IP");
if(a == NULL) {
ERROR("Config: Error: Could not find IP2IP account");
return;
}
if (a) {
gtk_list_store_append (accountStore, &iter);
gtk_list_store_append (accountStore, &iter);
DEBUG ("Filling accounts: Account is enabled :%s", g_hash_table_lookup (a->properties, ACCOUNT_ENABLED));
DEBUG ("Config: Filling accounts: Account is enabled :%s", g_hash_table_lookup (a->properties, ACCOUNT_ENABLED));
gtk_list_store_set (accountStore, &iter,
gtk_list_store_set (accountStore, &iter,
COLUMN_ACCOUNT_ALIAS, g_hash_table_lookup (a->properties, ACCOUNT_ALIAS), // Name
COLUMN_ACCOUNT_TYPE, g_hash_table_lookup (a->properties, ACCOUNT_TYPE), // Protocol
COLUMN_ACCOUNT_STATUS, account_state_name (a->state), // Status
COLUMN_ACCOUNT_ACTIVE, (g_strcasecmp (g_hash_table_lookup (a->properties, ACCOUNT_ENABLED),"true") == 0) ? TRUE:FALSE, // Enable/Disable
COLUMN_ACCOUNT_DATA, a, // Pointer
-1);
}
unsigned int i;
for (i = 0; i < account_list_get_size(); i++) {
a = account_list_get_nth (i);
if (a && g_strcmp0 (a->accountID, "IP2IP") != 0) {
if(a==NULL) {
ERROR("Config: Error: Account %d is NULL while parsing the list", i);
return;
}
// we dont wnat to process account twice
if (g_strcmp0 (a->accountID, "IP2IP") != 0) {
gtk_list_store_append (accountStore, &iter);
DEBUG ("Filling accounts: Account is enabled :%s", g_hash_table_lookup (a->properties, ACCOUNT_ENABLED));
DEBUG ("Config: Filling accounts: Account is enabled :%s", g_hash_table_lookup (a->properties, ACCOUNT_ENABLED));
gtk_list_store_set (accountStore, &iter,
COLUMN_ACCOUNT_ALIAS, g_hash_table_lookup (a->properties, ACCOUNT_ALIAS), // Name
......@@ -145,11 +156,8 @@ void account_list_config_dialog_fill()
-1);
}
}
}
/**
* Call back when the user click on an account in the list
*/
......
......@@ -242,7 +242,7 @@ void build_wizard (void)
wiz = (struct _wizard*) g_malloc (sizeof (struct _wizard));
current = g_new0 (account_t, 1);
current->properties = NULL;
current->properties = dbus_account_details (NULL);
current->properties = dbus_get_account_details (NULL);
if (current->properties == NULL) {
DEBUG ("Failed to get default values. Creating from scratch");
......
......@@ -926,7 +926,7 @@ dbus_account_list()
}
GHashTable*
dbus_account_details (gchar * accountID)
dbus_get_account_details (gchar * accountID)
{
GError *error = NULL;
GHashTable * details;
......
......@@ -118,7 +118,7 @@ gchar ** dbus_account_list();
* @param accountID The unique of the account
* @return GHashTable* The details of the account
*/
GHashTable * dbus_account_details (gchar * accountID);
GHashTable * dbus_get_account_details (gchar * accountID);
/**
* ConfigurationManager - Set the details of a specific account
......
......@@ -3830,27 +3830,33 @@ void ManagerImpl::setAccountDetails (const std::string& accountID,
const std::map<std::string, std::string>& details)
{
_debug ("Manager: Set account details %s", accountID.c_str());
_debug ("Manager: Set account details for %s", accountID.c_str());
Account* account;
if (! (account = getAccount (accountID))) {
_warn ("Manager: Cannot setAccountDetails on a non-existing accountID %s.", accountID.c_str());
Account* account = getAccount(accountID);
if (account == NULL) {
_error ("Manager: Error: Could not find account %s", accountID.c_str());
return;
}
account->setAccountDetails (details);
// Serialize configuration to disk once it is done
saveConfig();
if (account->isEnabled())
if (account->isEnabled()) {
account->registerVoIPLink();
else
}
else {
account->unregisterVoIPLink();
}
// Update account details to the client side
if (_dbus)
_dbus->getConfigurationManager()->accountsChanged();
if (_dbus) {
_error("Manager: Error: Dbus not initialized");
return;
}
_dbus->getConfigurationManager()->accountsChanged();
}
......
......@@ -719,15 +719,15 @@ void SIPAccount::setAccountDetails (const std::map<std::string, std::string>& de
setDisplayName (displayName);
setServiceRoute (routeset);
setLocalInterface (localInterface);
setPublishedSameasLocal ( (publishedSameasLocal.compare ("true") == 0) ? true : false);
setPublishedSameasLocal (publishedSameasLocal == "true");
setPublishedAddress (publishedAddress);
setLocalPort (atoi (localPort.data()));
setPublishedPort (atoi (publishedPort.data()));
setStunServer (stunServer);
setStunEnabled ( (stunEnable == "true"));
setStunEnabled (stunEnable == "true");
setDtmfType ( (dtmfType == "overrtp") ? OVERRTP : SIPINFO);
setResolveOnce ( (resolveOnce.compare ("true") ==0) ? true : false);
setResolveOnce (resolveOnce == "true");
setRegistrationExpire (registrationExpire);
// sip credential
......@@ -746,13 +746,12 @@ void SIPAccount::setAccountDetails (const std::map<std::string, std::string>& de
find_in_map (ZRTP_HELLO_HASH, zrtpHelloHash)
find_in_map (SRTP_KEY_EXCHANGE, srtpKeyExchange)
setSrtpEnable ( (srtpEnable.compare ("true") == 0) ? true : false);
setSrtpFallback ( (srtpRtpFallback.compare ("true") == 0) ? true : false);
setZrtpDisplaySas ( (zrtpDisplaySas.compare ("true") == 0) ? true : false);
setZrtpDiaplaySasOnce ( (zrtpDisplaySasOnce.compare ("true") == 0) ? true : false);
setZrtpNotSuppWarning ( (zrtpNotSuppWarning.compare ("true") == 0) ? true : false);
setZrtpHelloHash ( (zrtpHelloHash.compare ("true") == 0) ? true : false);
// sipaccount->setSrtpKeyExchange((srtpKeyExchange.compare("true") == 0) ? true : false);
setSrtpEnable (srtpEnable == "true");
setSrtpFallback (srtpRtpFallback == "true");
setZrtpDisplaySas (zrtpDisplaySas == "true");
setZrtpDiaplaySasOnce (zrtpDisplaySasOnce == "true");
setZrtpNotSuppWarning (zrtpNotSuppWarning == "true");
setZrtpHelloHash (zrtpHelloHash == "true");
setSrtpKeyExchange (srtpKeyExchange);
// TLS settings
......@@ -787,9 +786,9 @@ void SIPAccount::setAccountDetails (const std::map<std::string, std::string>& de
setTlsMethod (tlsMethod);
setTlsCiphers (tlsCiphers);
setTlsServerName (tlsServerName);
setTlsVerifyServer (tlsVerifyServer.compare ("true") ? true : false);
setTlsVerifyClient (tlsVerifyServer.compare ("true") ? true : false);
setTlsRequireClientCertificate (tlsRequireClientCertificate.compare ("true") ? true : false);
setTlsVerifyServer (tlsVerifyServer == "true");
setTlsVerifyClient (tlsVerifyServer == "true");
setTlsRequireClientCertificate (tlsRequireClientCertificate == "true");
setTlsNegotiationTimeoutSec (tlsNegotiationTimeoutSec);
setTlsNegotiationTimeoutMsec (tlsNegotiationTimeoutMsec);
......
......@@ -359,12 +359,16 @@ class SIPAccount : public Account
}
/**
* @return bool Tells if current transport for that
* account is set to OTHER.
*/
* @return bool Tells if current transport for that
* account is set to OTHER.
*/
inline bool isStunEnabled (void) {
return (_transportType == PJSIP_TRANSPORT_START_OTHER) ? true: false;
return _stunEnabled;
}
/**
* Set wether or not stun is enabled for this account
*/
inline void setStunEnabled (bool enabl) {
_stunEnabled = enabl;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment