Skip to content
Snippets Groups Projects
Commit 8be3aa43 authored by Pierre-Luc Beaudoin's avatar Pierre-Luc Beaudoin
Browse files

Add account

parent c402fc49
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,8 @@ typedef enum ...@@ -62,7 +62,8 @@ typedef enum
*/ */
typedef struct { typedef struct {
gchar * accountID; gchar * accountID;
account_state_t state; GHashTable * properties; account_state_t state;
GHashTable * properties;
} account_t; } account_t;
/** This function initialize the account list. */ /** This function initialize the account list. */
......
...@@ -80,17 +80,23 @@ show_account_window (account_t * a) ...@@ -80,17 +80,23 @@ show_account_window (account_t * a)
currentAccount = a; currentAccount = a;
// Current settings // Default settings
gchar * curAccountType = NULL; gchar * curAccountID = "";
gchar * curUserPart = NULL; gchar * curAccountEnabled = "TRUE";
gchar * curHostPart = NULL; gchar * curAccountType = "SIP";
gchar * curPassword = NULL; gchar * curUserPart = "";
gchar * curUsername = NULL; gchar * curHostPart = "";
gchar * curFullName = NULL; gchar * curPassword = "";
gchar * curUsername = "";
gchar * curFullName = "";
/* TODO: add curProxy, and add boxes for Proxy support */ /* TODO: add curProxy, and add boxes for Proxy support */
// Load from SIP/IAX/Unknown ? // Load from SIP/IAX/Unknown ?
if(a)
{
curAccountID = a->accountID;
curAccountType = g_hash_table_lookup(currentAccount->properties, ACCOUNT_TYPE); curAccountType = g_hash_table_lookup(currentAccount->properties, ACCOUNT_TYPE);
curAccountEnabled = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ENABLED);
if (strcmp(curAccountType, "IAX") == 0) { if (strcmp(curAccountType, "IAX") == 0) {
curHostPart = g_hash_table_lookup(currentAccount->properties, ACCOUNT_IAX_HOST); curHostPart = g_hash_table_lookup(currentAccount->properties, ACCOUNT_IAX_HOST);
...@@ -105,9 +111,12 @@ show_account_window (account_t * a) ...@@ -105,9 +111,12 @@ show_account_window (account_t * a)
curFullName = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_FULL_NAME); curFullName = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_FULL_NAME);
curUserPart = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_USER_PART); curUserPart = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_USER_PART);
} }
else { }
// Default values... else
curAccountType = "SIP"; {
currentAccount = g_new0(account_t, 1);
currentAccount->properties = g_hash_table_new(NULL, g_str_equal);
curAccountID = "test";
} }
dialog = GTK_DIALOG(gtk_dialog_new_with_buttons ("Account settings", dialog = GTK_DIALOG(gtk_dialog_new_with_buttons ("Account settings",
...@@ -132,14 +141,14 @@ show_account_window (account_t * a) ...@@ -132,14 +141,14 @@ show_account_window (account_t * a)
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5); gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
entryID = gtk_entry_new(); entryID = gtk_entry_new();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryID); gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryID);
gtk_entry_set_text(GTK_ENTRY(entryID), a->accountID); gtk_entry_set_text(GTK_ENTRY(entryID), curAccountID);
gtk_widget_set_sensitive( GTK_WIDGET(entryID), FALSE); gtk_widget_set_sensitive( GTK_WIDGET(entryID), FALSE);
gtk_table_attach ( GTK_TABLE( table ), entryID, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_table_attach ( GTK_TABLE( table ), entryID, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
#endif #endif
entryEnabled = gtk_check_button_new_with_mnemonic("_Enabled"); entryEnabled = gtk_check_button_new_with_mnemonic("_Enabled");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(entryEnabled), gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(entryEnabled),
strcmp(g_hash_table_lookup(currentAccount->properties, ACCOUNT_ENABLED),"TRUE") == 0 ? TRUE: FALSE); strcmp(curAccountEnabled,"TRUE") == 0 ? TRUE: FALSE);
gtk_table_attach ( GTK_TABLE( table ), entryEnabled, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_table_attach ( GTK_TABLE( table ), entryEnabled, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
//entryRegister = gtk_check_button_new_with_mnemonic("_Register on startup "); //entryRegister = gtk_check_button_new_with_mnemonic("_Register on startup ");
...@@ -249,6 +258,10 @@ show_account_window (account_t * a) ...@@ -249,6 +258,10 @@ show_account_window (account_t * a)
{ {
gchar* proto = (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(entryProtocol)); gchar* proto = (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(entryProtocol));
g_hash_table_replace(currentAccount->properties,
g_strdup("AccountID"),
g_strdup(curAccountID));
g_hash_table_replace(currentAccount->properties, g_hash_table_replace(currentAccount->properties,
g_strdup(ACCOUNT_ENABLED), g_strdup(ACCOUNT_ENABLED),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryEnabled)) ? "TRUE": "FALSE")); g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryEnabled)) ? "TRUE": "FALSE"));
...@@ -259,6 +272,10 @@ show_account_window (account_t * a) ...@@ -259,6 +272,10 @@ show_account_window (account_t * a)
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(entryName)))); g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryName))));
g_hash_table_replace(currentAccount->properties,
g_strdup(ACCOUNT_TYPE),
g_strdup(proto));
if (strcmp(proto, "SIP") == 0) { /* Protocol = SIP */ if (strcmp(proto, "SIP") == 0) { /* Protocol = SIP */
g_hash_table_replace(currentAccount->properties, g_hash_table_replace(currentAccount->properties,
...@@ -295,7 +312,7 @@ show_account_window (account_t * a) ...@@ -295,7 +312,7 @@ show_account_window (account_t * a)
} }
dbus_set_account_details(currentAccount); dbus_add_account(currentAccount);
} }
gtk_widget_destroy (GTK_WIDGET(dialog)); gtk_widget_destroy (GTK_WIDGET(dialog));
......
...@@ -76,7 +76,7 @@ delete_account( GtkWidget *widget, gpointer data ) ...@@ -76,7 +76,7 @@ delete_account( GtkWidget *widget, gpointer data )
} }
/** /**
* Delete an account * Edit an account
*/ */
static void static void
edit_account( GtkWidget *widget, gpointer data ) edit_account( GtkWidget *widget, gpointer data )
...@@ -88,6 +88,17 @@ edit_account( GtkWidget *widget, gpointer data ) ...@@ -88,6 +88,17 @@ edit_account( GtkWidget *widget, gpointer data )
} }
} }
/**
* Add an account
*/
static void
add_account( GtkWidget *widget, gpointer data )
{
show_account_window(NULL);
fill_account_list ();
}
/* Call back when the user click on an account in the list */ /* Call back when the user click on an account in the list */
static void static void
select_account(GtkTreeSelection *sel, GtkTreeModel *model) select_account(GtkTreeSelection *sel, GtkTreeModel *model)
...@@ -198,12 +209,10 @@ create_accounts_tab() ...@@ -198,12 +209,10 @@ create_accounts_tab()
gtk_widget_show (bbox); gtk_widget_show (bbox);
addButton = gtk_button_new_from_stock (GTK_STOCK_ADD); addButton = gtk_button_new_from_stock (GTK_STOCK_ADD);
/*g_signal_connect_swapped(G_OBJECT(addButton), "clicked", g_signal_connect_swapped(G_OBJECT(addButton), "clicked",
G_CALLBACK(config_module), _gtkWindow);*/ G_CALLBACK(add_account), NULL);
gtk_box_pack_start(GTK_BOX(bbox), addButton, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(bbox), addButton, FALSE, FALSE, 0);
gtk_widget_show(addButton); gtk_widget_show(addButton);
/* TODO Set to TRUE when AddAccount is implemented */
gtk_widget_set_sensitive( GTK_WIDGET(addButton), FALSE);
editButton = gtk_button_new_from_stock (GTK_STOCK_EDIT); editButton = gtk_button_new_from_stock (GTK_STOCK_EDIT);
g_signal_connect_swapped(G_OBJECT(editButton), "clicked", g_signal_connect_swapped(G_OBJECT(editButton), "clicked",
......
...@@ -141,6 +141,7 @@ accounts_changed_cb (DBusGProxy *proxy, ...@@ -141,6 +141,7 @@ accounts_changed_cb (DBusGProxy *proxy,
void * foo ) void * foo )
{ {
g_print ("Accounts changed\n"); g_print ("Accounts changed\n");
// TODO reload list
} }
gboolean gboolean
...@@ -459,6 +460,27 @@ dbus_set_account_details(account_t *a) ...@@ -459,6 +460,27 @@ dbus_set_account_details(account_t *a)
} }
} }
void
dbus_add_account(account_t *a)
{
GError *error = NULL;
org_sflphone_SFLphone_ConfigurationManager_add_account (
configurationManagerProxy,
a->properties,
&error);
if (error)
{
g_printerr ("Failed to call add_account() on ConfigurationManager: %s\n",
error->message);
g_error_free (error);
}
else
{
g_print ("DBus called add_account() on ConfigurationManager\n");
}
}
void void
dbus_set_volume(const gchar * device, gdouble value) dbus_set_volume(const gchar * device, gdouble value)
{ {
......
...@@ -45,6 +45,7 @@ void dbus_place_call (const call_t * c); ...@@ -45,6 +45,7 @@ void dbus_place_call (const call_t * c);
gchar ** dbus_account_list(); gchar ** dbus_account_list();
GHashTable * dbus_account_details(gchar * accountID); GHashTable * dbus_account_details(gchar * accountID);
void dbus_set_account_details(account_t *a); void dbus_set_account_details(account_t *a);
void dbus_add_account(account_t *a);
void dbus_remove_account(gchar * accountID); void dbus_remove_account(gchar * accountID);
void dbus_set_volume(const gchar * device, gdouble value); void dbus_set_volume(const gchar * device, gdouble value);
gdouble dbus_get_volume(const gchar * device); gdouble dbus_get_volume(const gchar * device);
......
...@@ -49,7 +49,8 @@ void ...@@ -49,7 +49,8 @@ void
ConfigurationManager::addAccount( const std::map< ::DBus::String, ::DBus::String >& details ) ConfigurationManager::addAccount( const std::map< ::DBus::String, ::DBus::String >& details )
{ {
_debug("ConfigurationManager::addAccount received\n"); _debug("ConfigurationManager::addAccount received\n");
std::string accountID = (*details.find("AccountID")).second;
Manager::instance().setAccountDetails(accountID, details);
} }
......
...@@ -1709,11 +1709,12 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID, ...@@ -1709,11 +1709,12 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
setConfig(accountID, IAX_USER, (*details.find(IAX_USER)).second); setConfig(accountID, IAX_USER, (*details.find(IAX_USER)).second);
setConfig(accountID, IAX_PASS, (*details.find(IAX_PASS)).second); setConfig(accountID, IAX_PASS, (*details.find(IAX_PASS)).second);
} else { } else {
_debug("Unknown account type in setAccountDetails(): %s", accountType.c_str()); _debug("Unknown account type in setAccountDetails(): %s\n", accountType.c_str());
} }
saveConfig(); saveConfig();
unloadAccountMap();
loadAccountMap();
/** @todo Then, reset the VoIP link with the new information */ /** @todo Then, reset the VoIP link with the new information */
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment