Skip to content
Snippets Groups Projects
Commit 56dce982 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Call duration

Format duration display
Display the duration in all cases??
parent 3330ab60
Branches
Tags
No related merge requests found
...@@ -216,7 +216,6 @@ sflphone_hang_up() ...@@ -216,7 +216,6 @@ sflphone_hang_up()
{ {
call_t * selectedCall = call_get_selected(current_calls); call_t * selectedCall = call_get_selected(current_calls);
(void) time(&selectedCall->_stop); (void) time(&selectedCall->_stop);
update_call_tree( history , selectedCall );
if(selectedCall) if(selectedCall)
{ {
switch(selectedCall->state) switch(selectedCall->state)
...@@ -224,9 +223,13 @@ sflphone_hang_up() ...@@ -224,9 +223,13 @@ sflphone_hang_up()
case CALL_STATE_DIALING: case CALL_STATE_DIALING:
dbus_hang_up (selectedCall); dbus_hang_up (selectedCall);
break; 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_CURRENT:
case CALL_STATE_HOLD: case CALL_STATE_HOLD:
case CALL_STATE_RINGING:
case CALL_STATE_BUSY: case CALL_STATE_BUSY:
case CALL_STATE_FAILURE: case CALL_STATE_FAILURE:
dbus_hang_up (selectedCall); dbus_hang_up (selectedCall);
...@@ -245,6 +248,7 @@ sflphone_hang_up() ...@@ -245,6 +248,7 @@ sflphone_hang_up()
break; break;
} }
} }
update_call_tree( history , selectedCall );
} }
...@@ -469,6 +473,9 @@ sflphone_new_call() ...@@ -469,6 +473,9 @@ sflphone_new_call()
c->to = g_strdup(""); c->to = g_strdup("");
c->_start = 0;
c->_stop = 0;
call_list_add(current_calls,c); call_list_add(current_calls,c);
update_call_tree_add(current_calls,c); update_call_tree_add(current_calls,c);
update_menus(); update_menus();
...@@ -495,6 +502,8 @@ sflphone_keypad( guint keyval, gchar * key) ...@@ -495,6 +502,8 @@ sflphone_keypad( guint keyval, gchar * key)
{ {
case 65307: /* ESCAPE */ case 65307: /* ESCAPE */
dbus_hang_up(c); dbus_hang_up(c);
(void) time(&c->_stop);
update_call_tree( history , c );
break; break;
default: default:
// To play the dtmf when calling mail box for instance // To play the dtmf when calling mail box for instance
...@@ -564,6 +573,8 @@ sflphone_keypad( guint keyval, gchar * key) ...@@ -564,6 +573,8 @@ sflphone_keypad( guint keyval, gchar * key)
{ {
case 65307: /* ESCAPE */ case 65307: /* ESCAPE */
dbus_hang_up(c); dbus_hang_up(c);
c->_stop = 0;
update_call_tree( history , c );
break; break;
} }
break; break;
......
...@@ -169,6 +169,8 @@ call_mailbox( GtkWidget* widget , gpointer data ) ...@@ -169,6 +169,8 @@ call_mailbox( GtkWidget* widget , gpointer data )
mailboxCall->callID = g_new0(gchar, 30); mailboxCall->callID = g_new0(gchar, 30);
g_sprintf(mailboxCall->callID, "%d", rand()); g_sprintf(mailboxCall->callID, "%d", rand());
mailboxCall->accountID = g_strdup(current->accountID); mailboxCall->accountID = g_strdup(current->accountID);
mailboxCall->_start = 0;
mailboxCall->_stop = 0;
g_print("TO : %s\n" , mailboxCall->to); g_print("TO : %s\n" , mailboxCall->to);
call_list_add( current_calls , mailboxCall ); call_list_add( current_calls , mailboxCall );
update_call_tree_add( current_calls , mailboxCall ); update_call_tree_add( current_calls , mailboxCall );
...@@ -426,6 +428,7 @@ create_call_tree (calltab_t* tab) ...@@ -426,6 +428,7 @@ create_call_tree (calltab_t* tab)
tab->store = gtk_list_store_new (3, tab->store = gtk_list_store_new (3,
GDK_TYPE_PIXBUF,// Icon GDK_TYPE_PIXBUF,// Icon
G_TYPE_STRING, // Description G_TYPE_STRING, // Description
G_TYPE_POINTER // Pointer to the Object G_TYPE_POINTER // Pointer to the Object
); );
......
...@@ -104,6 +104,12 @@ call_state_cb (DBusGProxy *proxy, ...@@ -104,6 +104,12 @@ call_state_cb (DBusGProxy *proxy,
{ {
if ( strcmp(state, "HUNGUP") == 0 ) if ( strcmp(state, "HUNGUP") == 0 )
{ {
if(c->state==CALL_STATE_CURRENT)
{
// peer hung up, the conversation was established, so _start has been initialized with the current time value
(void) time(&c->_stop);
update_call_tree( history, c );
}
g_print("from dbus: "); stop_notification(); g_print("from dbus: "); stop_notification();
sflphone_hung_up (c); sflphone_hung_up (c);
} }
......
...@@ -42,16 +42,22 @@ what_time_is_it( void ) ...@@ -42,16 +42,22 @@ what_time_is_it( void )
process_call_duration( call_t* c ) process_call_duration( call_t* c )
{ {
gchar * res; gchar * res;
g_print("Call duration = %i\n", (int)c->_stop - c->_start); g_print("Start = %i - Stop = %i - Call duration = %i\n", c->_start , c->_stop , (int)(c->_stop - c->_start));
int duration = c->_stop - c->_start; int duration = c->_stop - c->_start;
if( duration / 60 == 0 ) if( duration / 60 == 0 )
{ {
res = g_markup_printf_escaped("\n00:%i", duration); if( duration < 10 )
res = g_markup_printf_escaped("\t00:0%i", duration);
else
res = g_markup_printf_escaped("\t00:%i", duration);
} }
else else
{ {
res = g_markup_printf_escaped("\n%i:%i" , duration/60 , duration%60); if( duration%60 < 10 )
res = g_markup_printf_escaped("\t%i:0%i" , duration/60 , duration%60);
else
res = g_markup_printf_escaped("\t%i:%i" , duration/60 , duration%60);
} }
return res; return res;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment