Commit 3330ab60 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Add call duration

parent b910e7de
......@@ -215,6 +215,8 @@ void
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)
......@@ -341,6 +343,7 @@ sflphone_current( call_t * c )
c->state = CALL_STATE_CURRENT;
update_call_tree(current_calls,c);
update_menus();
(void) time(&c->_start);
}
void
......
......@@ -79,6 +79,10 @@ typedef struct {
call_state_t state;
/** The history state */
history_state_t history_state;
time_t _start;
time_t _stop;
} call_t;
typedef struct {
......
......@@ -533,7 +533,8 @@ update_call_tree (calltab_t* tab, call_t * c)
{
// Existing call in the list
gchar * description;
gchar * length="";
gchar * date="";
gchar * duration="";
if(c->state == CALL_STATE_TRANSFERT)
{
description = g_markup_printf_escaped("<b>%s</b>\n"
......@@ -598,8 +599,10 @@ update_call_tree (calltab_t* tab, call_t * c)
g_print("No history state\n");
break;
}
length = timestamp_get_call_time();
description = g_strconcat( length , description , NULL);
date = timestamp_get_call_date();
duration = process_call_duration(c);
description = g_strconcat( date , description , NULL);
description = g_strconcat( description, duration, NULL);
}
//Resize it
if(pixbuf)
......@@ -635,9 +638,10 @@ update_call_tree_add (calltab_t* tab, call_t * c)
GtkTreeSelection* sel;
// New call in the list
gchar * markup;
gchar * description;
gchar * date="";
markup = g_markup_printf_escaped("<b>%s</b> <i>%s</i>",
gchar * duration="";
description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>",
call_get_number(c),
call_get_name(c));
......@@ -676,8 +680,11 @@ update_call_tree_add (calltab_t* tab, call_t * c)
default:
g_warning("Should not happen!");
}
date = timestamp_get_call_time();
markup = g_strconcat( date , markup , NULL);
date = timestamp_get_call_date();
duration = process_call_duration(c);
//g_print("call duration = %s\n" , duration);
description = g_strconcat( date , description , NULL);
}
//Resize it
......@@ -690,7 +697,7 @@ update_call_tree_add (calltab_t* tab, call_t * c)
}
gtk_list_store_set(tab->store, &iter,
0, pixbuf, // Icon
1, markup, // Description
1, description, // Description
2, c, // Pointer
-1);
......
......@@ -20,7 +20,7 @@
#include <timestamp.h>
gchar*
timestamp_get_call_time( void )
timestamp_get_call_date( void )
{
struct tm* ptr;
time_t lt;
......@@ -30,3 +30,48 @@ timestamp_get_call_time( void )
return (gchar*) asctime( ptr ) ;
}
struct tm*
what_time_is_it( void )
{
time_t lt = time(NULL);
return localtime(&lt);
}
gchar*
process_call_duration( call_t* c )
{
gchar * res;
g_print("Call duration = %i\n", (int)c->_stop - c->_start);
int duration = c->_stop - c->_start;
if( duration / 60 == 0 )
{
res = g_markup_printf_escaped("\n00:%i", duration);
}
else
{
res = g_markup_printf_escaped("\n%i:%i" , duration/60 , duration%60);
}
return res;
}
......@@ -29,6 +29,12 @@
#include <time.h>
#include <gtk/gtk.h>
gchar* timestamp_get_call_time( void );
#include <calllist.h>
gchar* timestamp_get_call_date( void );
struct tm* what_time_is_it( void );
gchar* process_call_duration( call_t* c );
#endif
Supports Markdown
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