Skip to content
Snippets Groups Projects
Commit cba9b332 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3611] Update account authentication name on username change

parent cd92d21f
Branches
Tags
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
* Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com> * Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com>
* Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -106,6 +107,9 @@ GtkWidget * overrtp; ...@@ -106,6 +107,9 @@ GtkWidget * overrtp;
GHashTable * directIpCallsProperties = NULL; GHashTable * directIpCallsProperties = NULL;
gchar *current_username;
// Credentials // Credentials
enum { enum {
COLUMN_CREDENTIAL_REALM, COLUMN_CREDENTIAL_REALM,
...@@ -193,12 +197,17 @@ static GPtrArray* getNewCredential (GHashTable * properties) { ...@@ -193,12 +197,17 @@ static GPtrArray* getNewCredential (GHashTable * properties) {
-1); -1);
g_hash_table_insert(properties, g_strdup(ACCOUNT_REALM), realm); g_hash_table_insert(properties, g_strdup(ACCOUNT_REALM), realm);
g_hash_table_insert(properties, g_strdup(ACCOUNT_AUTHENTICATION_USERNAME), username);
// better use the current_username as it is the account username in the
// g_hash_table_insert(properties, g_strdup(ACCOUNT_AUTHENTICATION_USERNAME), username);
g_hash_table_insert(properties, g_strdup(ACCOUNT_AUTHENTICATION_USERNAME), current_username);
// Do not change the password if nothing has been changed by the user // Do not change the password if nothing has been changed by the user
if (g_strcasecmp (password, PW_HIDDEN) != 0) if (g_strcasecmp (password, PW_HIDDEN) != 0)
g_hash_table_insert(properties, g_strdup(ACCOUNT_PASSWORD), password); g_hash_table_insert(properties, g_strdup(ACCOUNT_PASSWORD), password);
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(credentialStore), &iter); valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(credentialStore), &iter);
while (valid) { while (valid) {
...@@ -1252,9 +1261,6 @@ void show_account_window (account_t * a) { ...@@ -1252,9 +1261,6 @@ void show_account_window (account_t * a) {
gchar * local_interface; gchar * local_interface;
gchar * published_address; gchar * published_address;
gchar *previous_username, *current_username;
gboolean username_changed = FALSE;
currentAccount = a; currentAccount = a;
if (currentAccount == NULL) { if (currentAccount == NULL) {
...@@ -1351,15 +1357,9 @@ void show_account_window (account_t * a) { ...@@ -1351,15 +1357,9 @@ void show_account_window (account_t * a) {
gchar *key = g_strdup(ACCOUNT_USERNAME); gchar *key = g_strdup(ACCOUNT_USERNAME);
// Get username at loadtime to determine if it changed. If so, update authentication name accordingly
// if(g_hash_table_lookup_extended(currentAccount->properties, g_strdup(ACCOUNT_USERNAME), NULL, previous_username))
// If accept button is // If accept button is
if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) { if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) {
previous_username = (gchar *)g_hash_table_lookup(currentAccount->properties, g_strdup(ACCOUNT_USERNAME));
DEBUG("------------------------------ USERNAME BEFORE %s", previous_username);
g_hash_table_replace(currentAccount->properties, g_hash_table_replace(currentAccount->properties,
g_strdup(ACCOUNT_ALIAS), g_strdup(ACCOUNT_ALIAS),
g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryAlias)))); g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryAlias))));
...@@ -1379,16 +1379,10 @@ void show_account_window (account_t * a) { ...@@ -1379,16 +1379,10 @@ void show_account_window (account_t * a) {
g_strdup(ACCOUNT_MAILBOX), g_strdup(ACCOUNT_MAILBOX),
g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryMailbox)))); g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryMailbox))));
// Variable used to update credentials
current_username = (gchar *)g_hash_table_lookup(currentAccount->properties, g_strdup(ACCOUNT_USERNAME)); current_username = (gchar *)g_hash_table_lookup(currentAccount->properties, g_strdup(ACCOUNT_USERNAME));
DEBUG("------------------------------ USERNAME AFTER %s", current_username);
}
if(strcmp(previous_username, current_username) != 0)
username_changed = TRUE;
if(username_changed)
DEBUG("--------------------------------- CHANGED");
}
if (proto && strcmp (proto, "SIP") == 0) { if (proto && strcmp (proto, "SIP") == 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment