Commit 314f4084 authored by Emmanuel Milou's avatar Emmanuel Milou

Improve ergonomy when switching between history, main tab and address book

parent e47a6eae
......@@ -28,7 +28,7 @@ sflphone_gtk_SOURCES = \
menus.c \
calltab.c \
calltree.c \
historyfilter.c \
searchfilter.c \
actions.c \
configwindow.c \
accountlist.c \
......@@ -43,7 +43,7 @@ sflphone_gtk_SOURCES = \
noinst_HEADERS = actions.h dbus.h sflnotify.h mainwindow.h calllist.h dialpad.h audioconf.h codeclist.h assistant.h \
callmanager-glue.h errors.h sflphone_const.h configurationmanager-glue.h instance-glue.h menus.h calltab.h calltree.h configwindow.h \
accountlist.h accountwindow.h marshaller.h sliders.h $(STATUSICON_HEADER) timestamp.h historyfilter.c reqaccount.h addressbook-config.h
accountlist.h accountwindow.h marshaller.h sliders.h $(STATUSICON_HEADER) timestamp.h searchfilter.h reqaccount.h addressbook-config.h
EXTRA_DIST = marshaller.list
......
......@@ -25,7 +25,7 @@
#include <menus.h>
#include <statusicon.h>
#include <calltab.h>
#include <historyfilter.h>
#include <searchfilter.h>
#include <contactlist/eds.h>
#include <gtk/gtk.h>
......@@ -37,7 +37,7 @@
guint voice_mails;
void
void
sflphone_notify_voice_mail ( const gchar* accountID , guint count )
{
gchar *id;
......@@ -66,82 +66,82 @@ sflphone_notify_voice_mail ( const gchar* accountID , guint count )
if( account_list_get_size() > 0 )
{
account_t* acc = account_list_get_by_id( id );
if( acc != NULL )
if( acc != NULL )
notify_voice_mails( count , acc );
}
}
void
void
status_bar_display_account( call_t* c)
{
gchar* msg;
account_t* acc;
if(c->accountID != NULL){
acc = account_list_get_by_id(c->accountID);
msg = g_markup_printf_escaped(_("%s account- %s") ,
(gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE),
(gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS));
statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT);
g_free(msg);
}
acc = account_list_get_by_id(c->accountID);
msg = g_markup_printf_escaped(_("%s account- %s") ,
(gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE),
(gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS));
statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT);
g_free(msg);
}
}
gboolean
gboolean
sflphone_quit ()
{
gboolean quit = FALSE;
guint count = call_list_get_size(current_calls);
if(count > 0){
quit = main_window_ask_quit();
}
else{
quit = TRUE;
}
if (quit)
{
dbus_unregister(getpid());
dbus_clean ();
//call_list_clean(); TODO
//account_list_clean()
gtk_main_quit ();
}
return quit;
gboolean quit = FALSE;
guint count = call_list_get_size(current_calls);
if(count > 0){
quit = main_window_ask_quit();
}
else{
quit = TRUE;
}
if (quit)
{
dbus_unregister(getpid());
dbus_clean ();
//call_list_clean(); TODO
//account_list_clean()
gtk_main_quit ();
}
return quit;
}
void
void
sflphone_hold(call_t * c )
{
c->state = CALL_STATE_HOLD;
update_call_tree(current_calls,c);
update_menus();
c->state = CALL_STATE_HOLD;
update_call_tree(current_calls,c);
update_menus();
}
void
void
sflphone_ringing(call_t * c )
{
c->state = CALL_STATE_RINGING;
update_call_tree(current_calls,c);
update_menus();
c->state = CALL_STATE_RINGING;
update_call_tree(current_calls,c);
update_menus();
}
void
void
sflphone_hung_up( call_t * c)
{
call_list_remove( current_calls, c->callID);
update_call_tree_remove(current_calls, c);
c->state = CALL_STATE_DIALING;
update_menus();
call_list_remove( current_calls, c->callID);
update_call_tree_remove(current_calls, c);
c->state = CALL_STATE_DIALING;
update_menus();
#if GTK_CHECK_VERSION(2,10,0)
status_tray_icon_blink( FALSE );
status_tray_icon_blink( FALSE );
#endif
statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
}
/** Internal to actions: Fill account list */
void
void
sflphone_fill_account_list(gboolean toolbarInitialized)
{
......@@ -149,526 +149,526 @@ sflphone_fill_account_list(gboolean toolbarInitialized)
gchar** accountID;
unsigned int i;
account_list_clear ( );
account_list_clear ( );
array = (gchar **)dbus_account_list();
array = (gchar **)dbus_account_list();
if(array)
{
for (accountID = array; *accountID; accountID++)
{
account_t * a = g_new0(account_t,1);
a->accountID = g_strdup(*accountID);
account_list_add(a);
}
g_strfreev (array);
for (accountID = array; *accountID; accountID++)
{
account_t * a = g_new0(account_t,1);
a->accountID = g_strdup(*accountID);
account_list_add(a);
}
g_strfreev (array);
}
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);
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 )
break;
a->properties = details;
gchar * status = g_hash_table_lookup(details, "Status");
if(strcmp(status, "REGISTERED") == 0)
{
a->state = ACCOUNT_STATE_REGISTERED;
}
else if(strcmp(status, "UNREGISTERED") == 0)
{
a->state = ACCOUNT_STATE_UNREGISTERED;
}
else if(strcmp(status, "TRYING") == 0)
{
a->state = ACCOUNT_STATE_TRYING;
}
else if(strcmp(status, "ERROR") == 0)
{
a->state = ACCOUNT_STATE_ERROR;
}
else if(strcmp( status , "ERROR_AUTH") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_AUTH;
}
else if(strcmp( status , "ERROR_NETWORK") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_NETWORK;
}
else if(strcmp( status , "ERROR_HOST") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_HOST;
}
else if(strcmp( status , "ERROR_CONF_STUN") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_CONF_STUN;
}
else if(strcmp( status , "ERROR_EXIST_STUN") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_EXIST_STUN;
}
else
{
a->state = ACCOUNT_STATE_INVALID;
}
}
// Prevent update being called when toolbar is not yet initialized
if(toolbarInitialized)
toolbar_update_buttons();
a->properties = details;
gchar * status = g_hash_table_lookup(details, "Status");
if(strcmp(status, "REGISTERED") == 0)
{
a->state = ACCOUNT_STATE_REGISTERED;
}
else if(strcmp(status, "UNREGISTERED") == 0)
{
a->state = ACCOUNT_STATE_UNREGISTERED;
}
else if(strcmp(status, "TRYING") == 0)
{
a->state = ACCOUNT_STATE_TRYING;
}
else if(strcmp(status, "ERROR") == 0)
{
a->state = ACCOUNT_STATE_ERROR;
}
else if(strcmp( status , "ERROR_AUTH") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_AUTH;
}
else if(strcmp( status , "ERROR_NETWORK") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_NETWORK;
}
else if(strcmp( status , "ERROR_HOST") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_HOST;
}
else if(strcmp( status , "ERROR_CONF_STUN") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_CONF_STUN;
}
else if(strcmp( status , "ERROR_EXIST_STUN") == 0 )
{
a->state = ACCOUNT_STATE_ERROR_EXIST_STUN;
}
else
{
a->state = ACCOUNT_STATE_INVALID;
}
}
// Prevent update being called when toolbar is not yet initialized
if(toolbarInitialized)
toolbar_update_buttons();
}
gboolean sflphone_init()
{
if(!dbus_connect ()){
main_window_error_message(_("Unable to connect to the SFLphone server.\nMake sure the daemon is running."));
return FALSE;
}
else
{
dbus_register(getpid(), "Gtk+ Client");
if(!dbus_connect ()){
main_window_error_message(_("Unable to connect to the SFLphone server.\nMake sure the daemon is running."));
return FALSE;
}
else
{
dbus_register(getpid(), "Gtk+ Client");
current_calls = calltab_init();
history = calltab_init();
contacts = calltab_init();
if(SHOW_SEARCHBAR) histfilter = create_filter(GTK_TREE_MODEL(history->store));
init();
account_list_init ();
codec_list_init();
sflphone_fill_account_list(FALSE);
sflphone_fill_codec_list();
sflphone_set_current_account();
return TRUE;
}
history = calltab_init();
contacts = calltab_init();
if(SHOW_SEARCHBAR) histfilter = create_filter(GTK_TREE_MODEL(history->store));
init();
account_list_init ();
codec_list_init();
sflphone_fill_account_list(FALSE);
sflphone_fill_codec_list();
sflphone_set_current_account();
return TRUE;
}
}
void
void
sflphone_hang_up()
{
call_t * selectedCall = call_get_selected(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_DIALING:
dbus_hang_up (selectedCall);
break;
case CALL_STATE_RINGING:
dbus_hang_up (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
selectedCall->_stop = 0;
break;
case CALL_STATE_CURRENT:
case CALL_STATE_HOLD:
case CALL_STATE_BUSY:
call_t * selectedCall = call_get_selected(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_DIALING:
dbus_hang_up (selectedCall);
break;
case CALL_STATE_RINGING:
dbus_hang_up (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
selectedCall->_stop = 0;
break;
case CALL_STATE_CURRENT:
case CALL_STATE_HOLD:
case CALL_STATE_BUSY:
case CALL_STATE_RECORD:
dbus_hang_up (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
(void) time(&selectedCall->_stop);
break;
case CALL_STATE_FAILURE:
dbus_hang_up (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
selectedCall->_stop = 0;
break;
case CALL_STATE_INCOMING:
dbus_refuse (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
selectedCall->_stop = 0;
g_print("from sflphone_hang_up : "); stop_notification();
break;
case CALL_STATE_TRANSFERT:
dbus_hang_up (selectedCall);
(void) time(&selectedCall->_stop);
break;
default:
g_warning("Should not happen in sflphone_hang_up()!");
break;
}
}
update_call_tree( history , selectedCall );
dbus_hang_up (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
(void) time(&selectedCall->_stop);
break;
case CALL_STATE_FAILURE:
dbus_hang_up (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
selectedCall->_stop = 0;
break;
case CALL_STATE_INCOMING:
dbus_refuse (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
selectedCall->_stop = 0;
g_print("from sflphone_hang_up : "); stop_notification();
break;
case CALL_STATE_TRANSFERT:
dbus_hang_up (selectedCall);
(void) time(&selectedCall->_stop);
break;
default:
g_warning("Should not happen in sflphone_hang_up()!");
break;
}
}
update_call_tree( history , selectedCall );
}
void
void
sflphone_pick_up()
{
call_t * selectedCall = call_get_selected(active_calltree);
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_DIALING:
sflphone_place_call (selectedCall);
break;
case CALL_STATE_INCOMING:
selectedCall->history_state = INCOMING;
update_call_tree( history , selectedCall );
dbus_accept (selectedCall);
g_print("from sflphone_pick_up : "); stop_notification();
break;
case CALL_STATE_HOLD:
sflphone_new_call();
break;
case CALL_STATE_TRANSFERT:
dbus_transfert (selectedCall);
(void) time(&selectedCall->_stop);
break;
case CALL_STATE_CURRENT:
case CALL_STATE_RECORD:
sflphone_new_call();
break;
case CALL_STATE_RINGING:
sflphone_new_call();
break;
default:
g_warning("Should not happen in sflphone_pick_up()!");
break;
}
}
call_t * selectedCall = call_get_selected(active_calltree);
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_DIALING:
sflphone_place_call (selectedCall);
break;
case CALL_STATE_INCOMING:
selectedCall->history_state = INCOMING;
update_call_tree( history , selectedCall );
dbus_accept (selectedCall);
g_print("from sflphone_pick_up : "); stop_notification();
break;
case CALL_STATE_HOLD:
sflphone_new_call();
break;
case CALL_STATE_TRANSFERT:
dbus_transfert (selectedCall);
(void) time(&selectedCall->_stop);
break;
case CALL_STATE_CURRENT:
case CALL_STATE_RECORD:
sflphone_new_call();
break;
case CALL_STATE_RINGING:
sflphone_new_call();
break;
default:
g_warning("Should not happen in sflphone_pick_up()!");
break;
}
}
}
void
void
sflphone_on_hold ()
{
call_t * selectedCall = call_get_selected(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_CURRENT:
dbus_hold (selectedCall);
break;
case CALL_STATE_RECORD:
dbus_hold (selectedCall);
break;
default:
g_warning("Should not happen in sflphone_on_hold!");
break;
}
}
call_t * selectedCall = call_get_selected(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_CURRENT:
dbus_hold (selectedCall);
break;
case CALL_STATE_RECORD:
dbus_hold (selectedCall);
break;
default:
g_warning("Should not happen in sflphone_on_hold!");
break;
}
}
}
void
void
sflphone_off_hold ()
{
call_t * selectedCall = call_get_selected(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_HOLD:
dbus_unhold (selectedCall);
break;
default:
g_warning("Should not happen in sflphone_off_hold ()!");
break;
}
}
call_t * selectedCall = call_get_selected(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_HOLD:
dbus_unhold (selectedCall);
break;
default:
g_warning("Should not happen in sflphone_off_hold ()!");
break;
}
}
}
void
void
sflphone_fail( call_t * c )
{
c->state = CALL_STATE_FAILURE;
update_call_tree(current_calls,c);
update_menus();
c->state = CALL_STATE_FAILURE;
update_call_tree(current_calls,c);
update_menus();
}
void
void
sflphone_busy( call_t * c )
{
c->state = CALL_STATE_BUSY;
update_call_tree(current_calls, c);
update_menus();
c->state = CALL_STATE_BUSY;
update_call_tree(current_calls, c);
update_menus();
}
void
void
sflphone_current( call_t * c )
{
if( c->state != CALL_STATE_HOLD )
(void) time(&c->_start);
c->state = CALL_STATE_CURRENT;
update_call_tree(current_calls,c);
update_menus();
if( c->state != CALL_STATE_HOLD )
(void) time(&c->_start);
c->state = CALL_STATE_CURRENT;
update_call_tree(current_calls,c);
update_menus();