From 6ebdd55bf93f65b5099916581a1fa702ea3f28a2 Mon Sep 17 00:00:00 2001 From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Date: Tue, 22 Apr 2008 16:59:55 -0400 Subject: [PATCH] Save and use the new mailbox number in case --- sflphone-gtk/src/accountlist.c | 15 +++++++++++++++ sflphone-gtk/src/accountlist.h | 5 +++++ sflphone-gtk/src/accountwindow.c | 2 ++ sflphone-gtk/src/calltree.c | 10 +++++----- sflphone-gtk/src/configwindow.c | 3 +++ 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/sflphone-gtk/src/accountlist.c b/sflphone-gtk/src/accountlist.c index a075d57990..bbf398b190 100644 --- a/sflphone-gtk/src/accountlist.c +++ b/sflphone-gtk/src/accountlist.c @@ -138,6 +138,7 @@ account_list_get_current( ) void account_list_set_current_id(const gchar * accountID) { + g_print("set current id = %d\n" , accountID); __CURRENT_ACCOUNT_ID = g_strdup(accountID); } @@ -208,3 +209,17 @@ account_list_move_down(guint index) } account_list_set_current_pos( 0 ); } + +guint +account_list_get_registered_accounts( void ) +{ + guint res = 0; + int i; + for(i=0;i<account_list_get_size();i++) + { + if( account_list_get_nth( i ) -> state == ( ACCOUNT_STATE_REGISTERED )) + res ++; + } + g_print(" %d registered accounts \n" , res ); + return res; +} diff --git a/sflphone-gtk/src/accountlist.h b/sflphone-gtk/src/accountlist.h index e71ec3d9b9..70756bfad1 100644 --- a/sflphone-gtk/src/accountlist.h +++ b/sflphone-gtk/src/accountlist.h @@ -94,6 +94,11 @@ void account_list_remove (const gchar * accountID); */ account_t * account_list_get_by_state ( account_state_t state); +/** + * @return guint The number of registered accounts in the list + */ +guint account_list_get_registered_accounts( ); + /** * Return the number of accounts in the list * @return guint The number of accounts in the list diff --git a/sflphone-gtk/src/accountwindow.c b/sflphone-gtk/src/accountwindow.c index 73edaac47a..87767fd4a7 100644 --- a/sflphone-gtk/src/accountwindow.c +++ b/sflphone-gtk/src/accountwindow.c @@ -388,9 +388,11 @@ show_account_window (account_t * a) /** @todo Verify if it's the best condition to check */ if (currentAccount->accountID == NULL) { dbus_add_account(currentAccount); + account_list_set_current_id( currentAccount->accountID); } else { dbus_set_account_details(currentAccount); + account_list_set_current_id( currentAccount->accountID); } } gtk_widget_destroy (GTK_WIDGET(dialog)); diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c index 2b02150fb3..bc7e82f95a 100644 --- a/sflphone-gtk/src/calltree.c +++ b/sflphone-gtk/src/calltree.c @@ -164,9 +164,8 @@ call_mailbox( GtkWidget* widget , gpointer data ) mailboxCall->callID = g_new0(gchar, 30); g_sprintf(mailboxCall->callID, "%d", rand()); //mailboxCall->to = g_strdup(current->mailbox_number); - mailboxCall->to = g_strdup("888"); + mailboxCall->to = g_strdup(g_hash_table_lookup(current->properties, ACCOUNT_MAILBOX)); mailboxCall->accountID = g_strdup(current->accountID); - printf("call : from : %s to %s\n", mailboxCall->from, mailboxCall->to); call_list_add( current_calls , mailboxCall ); update_call_tree_add( current_calls , mailboxCall ); update_menus(); @@ -181,6 +180,7 @@ toolbar_update_buttons () gtk_widget_set_sensitive( GTK_WIDGET(hangupButton), FALSE); gtk_widget_set_sensitive( GTK_WIDGET(holdButton), FALSE); gtk_widget_set_sensitive( GTK_WIDGET(transfertButton), FALSE); + gtk_widget_set_sensitive( GTK_WIDGET(mailboxButton) , TRUE ); gtk_widget_set_sensitive( GTK_WIDGET(unholdButton), FALSE); g_object_ref(holdButton); g_object_ref(unholdButton); @@ -262,6 +262,7 @@ toolbar_update_buttons () else { gtk_widget_set_sensitive( GTK_WIDGET(callButton), FALSE); + gtk_widget_set_sensitive( GTK_WIDGET(mailboxButton), FALSE); } } } @@ -388,11 +389,10 @@ create_toolbar (){ history_shown = FALSE; active_calltree = current_calls; - //image = gtk_image_new_from_file( ICONS_DIR "/stock_mail-unread.svg"); mailboxButton = gtk_toggle_tool_button_new_from_stock( GTK_STOCK_HOME ); - //gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(mailboxButton), image); + if( account_list_get_size() ==0 ) gtk_widget_set_state( GTK_WIDGET(mailboxButton), GTK_STATE_INSENSITIVE ); gtk_widget_set_tooltip_text(GTK_WIDGET(mailboxButton), _("Mail Box")); - gtk_tool_button_set_label(GTK_TOOL_BUTTON(transfertButton), _("Mail Box")); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(mailboxButton), _("Mail Box")); g_signal_connect (G_OBJECT (mailboxButton), "toggled", G_CALLBACK (call_mailbox), NULL); gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(mailboxButton), -1); diff --git a/sflphone-gtk/src/configwindow.c b/sflphone-gtk/src/configwindow.c index 13de7c8099..06713faf1a 100644 --- a/sflphone-gtk/src/configwindow.c +++ b/sflphone-gtk/src/configwindow.c @@ -1371,5 +1371,8 @@ show_accounts_window( void ) dialogOpen=FALSE; gtk_widget_destroy(GTK_WIDGET(dialog)); + if( account_list_get_size() >0 && account_list_get_current()==NULL ) + account_list_set_current_pos(0); + toolbar_update_buttons(); } -- GitLab