Commit 56dce982 authored by Emmanuel Milou's avatar Emmanuel Milou

Call duration

Format duration display
Display the duration in all cases??
parent 3330ab60
......@@ -216,7 +216,6 @@ sflphone_hang_up()
{
call_t * selectedCall = call_get_selected(current_calls);
(void) time(&selectedCall->_stop);
update_call_tree( history , selectedCall );
if(selectedCall)
{
switch(selectedCall->state)
......@@ -224,9 +223,13 @@ sflphone_hang_up()
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_RINGING:
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
dbus_hang_up (selectedCall);
......@@ -245,6 +248,7 @@ sflphone_hang_up()
break;
}
}
update_call_tree( history , selectedCall );
}
......@@ -469,6 +473,9 @@ sflphone_new_call()
c->to = g_strdup("");
c->_start = 0;
c->_stop = 0;
call_list_add(current_calls,c);
update_call_tree_add(current_calls,c);
update_menus();
......@@ -495,6 +502,8 @@ sflphone_keypad( guint keyval, gchar * key)
{
case 65307: /* ESCAPE */
dbus_hang_up(c);
(void) time(&c->_stop);
update_call_tree( history , c );
break;
default:
// To play the dtmf when calling mail box for instance
......@@ -563,8 +572,10 @@ sflphone_keypad( guint keyval, gchar * key)
switch (keyval)
{
case 65307: /* ESCAPE */
dbus_hang_up(c);
break;
dbus_hang_up(c);
c->_stop = 0;
update_call_tree( history , c );
break;
}
break;
default:
......
......@@ -169,6 +169,8 @@ call_mailbox( GtkWidget* widget , gpointer data )
mailboxCall->callID = g_new0(gchar, 30);
g_sprintf(mailboxCall->callID, "%d", rand());
mailboxCall->accountID = g_strdup(current->accountID);
mailboxCall->_start = 0;
mailboxCall->_stop = 0;
g_print("TO : %s\n" , mailboxCall->to);
call_list_add( current_calls , mailboxCall );
update_call_tree_add( current_calls , mailboxCall );
......@@ -426,6 +428,7 @@ create_call_tree (calltab_t* tab)
tab->store = gtk_list_store_new (3,
GDK_TYPE_PIXBUF,// Icon
G_TYPE_STRING, // Description
G_TYPE_POINTER // Pointer to the Object
);
......
......@@ -104,6 +104,12 @@ call_state_cb (DBusGProxy *proxy,
{
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();
sflphone_hung_up (c);
}
......
......@@ -42,16 +42,22 @@ what_time_is_it( void )
process_call_duration( call_t* c )
{
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;
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
{
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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment