From: Gustavo Sverzut Barbieri Date: Tue, 10 Jul 2012 23:37:54 +0000 (-0300) Subject: ofono parses start time. X-Git-Tag: accepted/2.0alpha/20121205.174825~188 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a3d91ccf52ba58bc6ffd9b1ecbee0f2513f9ca9;hp=c8440309ae90682a6809b24e88d527b376f61c3e;p=profile%2Fivi%2Flemolo.git ofono parses start time. time is relative to loop time, which should be monotonic. --- diff --git a/configure.ac b/configure.ac index 81e236d..a0fdd2f 100644 --- a/configure.ac +++ b/configure.ac @@ -15,6 +15,7 @@ COMPILER_FLAGS AC_LANG_C +AC_USE_SYSTEM_EXTENSIONS AC_PROG_CC AM_PROG_CC_C_O AC_C___ATTRIBUTE__ diff --git a/dialer/ofono.c b/dialer/ofono.c index caba729..26c6df4 100644 --- a/dialer/ofono.c +++ b/dialer/ofono.c @@ -6,6 +6,8 @@ #include "ofono.h" #include "log.h" +#include + typedef struct _OFono_Modem OFono_Modem; typedef struct _OFono_Bus_Object OFono_Bus_Object; @@ -341,6 +343,7 @@ struct _OFono_Call const char *line_id; const char *incoming_line; const char *name; + double start_time; OFono_Call_State state; Eina_Bool multiparty : 1; Eina_Bool emergency : 1; @@ -372,6 +375,8 @@ static OFono_Call *_call_new(const char *path) c->base.path = eina_stringshare_add(path); EINA_SAFETY_ON_NULL_GOTO(c->base.path, error_path); + c->start_time = -1.0; + return c; error_path: @@ -434,6 +439,8 @@ static void _call_property_update(OFono_Call *c, const char *key, state = _call_state_parse(str); DBG("%s State %s (%d)", c->base.path, str, state); c->state = state; + if ((state == OFONO_CALL_STATE_ACTIVE) && (c->start_time < 0.0)) + c->start_time = ecore_loop_time_get(); } else if (strcmp(key, "Name") == 0) { const char *str; dbus_message_iter_get_basic(value, &str); @@ -449,6 +456,22 @@ static void _call_property_update(OFono_Call *c, const char *key, dbus_message_iter_get_basic(value, &v); DBG("%s Emergency %d", c->base.path, v); c->emergency = v; + } else if (strcmp(key, "StartTime") == 0) { + const char *end, *ts = NULL; + struct tm tm; + dbus_message_iter_get_basic(value, &ts); + memset(&tm, 0, sizeof(tm)); + end = strptime(ts, "%Y-%m-%dT%H:%M:%S%z", &tm); + if ((end) && (*end != '\0')) + ERR("Failed to parse StartTime=%s", ts); + else { + time_t st = mktime(&tm); + time_t ut = time(NULL); + double lt = ecore_loop_time_get(); + c->start_time = st - ut + lt; + DBG("%s StartTime %f (%s)", c->base.path, c->start_time, + ts); + } } else DBG("%s %s (unused property)", c->base.path, key); } @@ -786,6 +809,12 @@ const char *ofono_call_line_id_get(const OFono_Call *c) return c->line_id; } +double ofono_call_start_time_get(const OFono_Call *c) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(c, -1.0); + return c->start_time; +} + static void _ofono_calls_get_reply(void *data, DBusMessage *msg, DBusError *err) { diff --git a/dialer/ofono.h b/dialer/ofono.h index 47ae702..8002e1e 100644 --- a/dialer/ofono.h +++ b/dialer/ofono.h @@ -79,6 +79,7 @@ OFono_Pending *ofono_call_answer(OFono_Call *c, OFono_Simple_Cb cb, OFono_Call_State ofono_call_state_get(const OFono_Call *c); const char *ofono_call_name_get(const OFono_Call *c); const char *ofono_call_line_id_get(const OFono_Call *c); +double ofono_call_start_time_get(const OFono_Call *c); #define ofono_call_state_valid_check(c) \ (ofono_call_state_get(c) != OFONO_CALL_STATE_DISCONNECTED)