Commit 6cc31560 authored by Emmanuel Milou's avatar Emmanuel Milou

Date format + suspicious cases

parent af114d1b
......@@ -215,7 +215,6 @@ void
sflphone_hang_up()
{
call_t * selectedCall = call_get_selected(current_calls);
(void) time(&selectedCall->_stop);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -234,10 +233,12 @@ sflphone_hang_up()
case CALL_STATE_FAILURE:
dbus_hang_up (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
(void) time(&selectedCall->_stop);
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:
......
......@@ -604,8 +604,8 @@ update_call_tree (calltab_t* tab, call_t * c)
}
date = timestamp_get_call_date();
duration = process_call_duration(c);
description = g_strconcat( date , description , NULL);
description = g_strconcat( description, duration, NULL);
duration = g_strconcat( date , duration , NULL);
description = g_strconcat( description , duration, NULL);
}
//Resize it
if(pixbuf)
......@@ -648,7 +648,7 @@ update_call_tree_add (calltab_t* tab, call_t * c)
call_get_number(c),
call_get_name(c));
gtk_list_store_prepend (tab->store, &iter);
if( tab == current_calls )
......@@ -684,9 +684,6 @@ update_call_tree_add (calltab_t* tab, call_t * c)
g_warning("Should not happen!");
}
date = timestamp_get_call_date();
duration = process_call_duration(c);
//g_print("call duration = %s\n" , duration);
description = g_strconcat( date , description , NULL);
}
......
......@@ -107,11 +107,13 @@ call_state_cb (DBusGProxy *proxy,
if(c->state==CALL_STATE_CURRENT)
{
// peer hung up, the conversation was established, so _start has been initialized with the current time value
g_print("call state current\n");
(void) time(&c->_stop);
update_call_tree( history, c );
}
g_print("from dbus: "); stop_notification();
sflphone_hung_up (c);
update_call_tree( history, c );
}
else if ( strcmp(state, "UNHOLD") == 0 )
{
......
......@@ -19,6 +19,9 @@
#include <timestamp.h>
char* months[12] = {"january","february","march", "april", "may", "june", "july", "august", "september", "october", "november", "december"};
char* week_days[7] = {"Sun", "Mon", "Tue","Wed","Thu","Fri","Sat"};
gchar*
timestamp_get_call_date( void )
{
......@@ -28,14 +31,8 @@ timestamp_get_call_date( void )
lt = time(NULL);
ptr = localtime(&lt);
return (gchar*) asctime( ptr ) ;
}
struct tm*
what_time_is_it( void )
{
time_t lt = time(NULL);
return localtime(&lt);
return format( ptr ) ;
}
gchar*
......@@ -43,26 +40,49 @@ process_call_duration( call_t* c )
{
gchar * res;
g_print("Start = %i - Stop = %i - Call duration = %i\n", c->_start , c->_stop , (int)(c->_stop - c->_start));
if( c->_stop == 0 )
return g_markup_printf_escaped("<small>Missed call</small>");
int duration = c->_stop - c->_start;
if( duration / 60 == 0 )
{
if( duration < 10 )
res = g_markup_printf_escaped("\n00:0%i", duration);
res = g_markup_printf_escaped("00:0%i", duration);
else
res = g_markup_printf_escaped("\n00:%i", duration);
res = g_markup_printf_escaped("00:%i", duration);
}
else
{
if( duration%60 < 10 )
res = g_markup_printf_escaped("\n%i:0%i" , duration/60 , duration%60);
res = g_markup_printf_escaped("%i:0%i" , duration/60 , duration%60);
else
res = g_markup_printf_escaped("\n%i:%i" , duration/60 , duration%60);
res = g_markup_printf_escaped("%i:%i" , duration/60 , duration%60);
}
return res;
return g_markup_printf_escaped("<small>Duration:</small> %s", res);
}
gchar*
format( struct tm* ptr )
{
gchar *result;
gchar *hour, *min;
gchar *day_of_week, *month, *day_number;
hour = g_markup_printf_escaped("%i", ptr->tm_hour);
min = g_markup_printf_escaped("%i", ptr->tm_min);
day_of_week = g_markup_printf_escaped( "%i", ptr->tm_mday );
month = months[ptr->tm_mon];
day_number = week_days[ptr->tm_wday];
result = g_markup_printf_escaped( "\n%s %s %s %s:%s\n" , day_number, month , day_of_week , hour, min );
return result;
}
......
......@@ -30,11 +30,13 @@
#include <gtk/gtk.h>
#include <calllist.h>
#include <sflphone_const.h>
gchar* timestamp_get_call_date( void );
struct tm* what_time_is_it( void );
gchar* timestamp_get_call_date( void );
gchar* process_call_duration( call_t* c );
gchar* format( struct tm* ptr );
#endif
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