diff --git a/sflphone-gtk/src/SFLnotify.c b/sflphone-gtk/src/SFLnotify.c index 58a1a77f680f093ff8000fcf2c8e711afa3e4759..932627f6d4d61246c0d1df02d14b3a76329565ec 100644 --- a/sflphone-gtk/src/SFLnotify.c +++ b/sflphone-gtk/src/SFLnotify.c @@ -112,7 +112,7 @@ notify_voice_mails( guint count , account_t* acc ) } void -notify_switch_account( account_t* acc ) +notify_current_account( account_t* acc ) { // the account is different from NULL GdkPixbuf *pixbuf; @@ -124,7 +124,7 @@ notify_switch_account( account_t* acc ) g_hash_table_lookup( acc->properties , ACCOUNT_TYPE) , g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS)); - title = g_markup_printf_escaped(_("Switching account")); + title = g_markup_printf_escaped(_("Current account")); pixbuf = gdk_pixbuf_new_from_file(ICON_DIR "/sflphone.png", NULL); diff --git a/sflphone-gtk/src/SFLnotify.h b/sflphone-gtk/src/SFLnotify.h index 1f80d3207d34f9f90a3e82579f204e07d72dcf27..eb343332cd9a12753ef869fba26c0928ba6edd37 100644 --- a/sflphone-gtk/src/SFLnotify.h +++ b/sflphone-gtk/src/SFLnotify.h @@ -42,7 +42,7 @@ void notify_incoming_call( call_t* c); void notify_voice_mails( guint count , account_t* acc ); -void notify_switch_account( account_t* acc ); +void notify_current_account( account_t* acc ); void notify_no_accounts( ); void notify_no_registered_accounts( ); /* diff --git a/sflphone-gtk/src/accountlist.c b/sflphone-gtk/src/accountlist.c index 2e3197b163cfb602d71daf9bd2e43e58647655e8..e423420bad0c86040b7630f35f8882aa31a5d50f 100644 --- a/sflphone-gtk/src/accountlist.c +++ b/sflphone-gtk/src/accountlist.c @@ -129,7 +129,10 @@ account_list_get_nth ( guint n ) account_t* account_list_get_current( ) { - return account_list_get_by_id( __CURRENT_ACCOUNT_ID ); + if( __CURRENT_ACCOUNT_ID != NULL ) + return account_list_get_by_id( __CURRENT_ACCOUNT_ID ); + else + return NULL; } void diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c index 2de7fe6775d665e6b283a37c6b1c030c947febe8..cc522921e5e068417627eac375c04ad01d4da6d1 100644 --- a/sflphone-gtk/src/actions.c +++ b/sflphone-gtk/src/actions.c @@ -570,41 +570,48 @@ sflphone_place_call ( call_t * c ) { if(c->state == CALL_STATE_DIALING) { - account_t * current = account_list_get_current(); - if( current ) + if( account_list_get_size() == 0 ) + notify_no_accounts(); + else if( account_list_get_by_state( ACCOUNT_STATE_REGISTERED ) == NULL ) + notify_no_registered_accounts(); + else { - if(g_strcasecmp(g_hash_table_lookup( current->properties, "Status"),"REGISTERED")==0) - { - // OK, everything alright - the call is made with the current account - c -> accountID = current -> accountID; - status_bar_display_account(c); - dbus_place_call(c); + account_t * current = account_list_get_current(); + if( current ) + { + if(g_strcasecmp(g_hash_table_lookup( current->properties, "Status"),"REGISTERED")==0) + { + // OK, everything alright - the call is made with the current account + c -> accountID = current -> accountID; + status_bar_display_account(c); + dbus_place_call(c); + } + else + { + // No current accounts have been setup. + // So we place a call with the first registered account + // And we change the current account + current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED ); + c -> accountID = current -> accountID; + dbus_place_call(c); + notify_current_account( current ); + status_bar_display_account(c); + account_list_set_current_id( c-> accountID ); + } } else { - // the current account (ie the first in the list) isn't registered - // So we try the next one. If it is registered, place a call with - int pos; - for( pos = 1 ; pos < account_list_get_size() ; pos++ ){ - current = account_list_get_nth(pos); - if( current ){ - if( g_strcasecmp(g_hash_table_lookup( current->properties, "Status"),"REGISTERED")==0 ){ - notify_switch_account( current ); - //main_warning_error_message(_("Switch account.")); - c -> accountID = current -> accountID; - status_bar_display_account(c); - dbus_place_call(c); - break; - } - } - } - notify_no_registered_accounts(); + // No current accounts have been setup. + // So we place a call with the first registered account + // and we change the current account + current = account_list_get_by_state( ACCOUNT_STATE_REGISTERED ); + c -> accountID = current -> accountID; + dbus_place_call(c); + notify_current_account( current ); + status_bar_display_account(c); + account_list_set_current_id( c-> accountID ); } } - else{ - notify_no_accounts(); - main_window_error_message(_("There is no accounts to make this call with.")); - } } } @@ -612,7 +619,7 @@ sflphone_place_call ( call_t * c ) void sflphone_set_current_account() { - if( account_list_get_size > 0 ) + if( account_list_get_size() > 0 ) account_list_set_current_pos( 0 ); }