From: Dongchul Lim Date: Mon, 7 Apr 2014 10:52:18 +0000 (+0900) Subject: Initial refactoring merge X-Git-Tag: submit/tizen/20140408.080552^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01e6a847a2db0f118655307956292b595a5e02db;p=platform%2Fcore%2Ftelephony%2Ftel-plugin-nitz.git Initial refactoring merge Change-Id: I94046514307898cabf15b4758297d9c3f91ada29 --- diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index e69de29..0000000 diff --git a/packaging/tel-plugin-nitz.spec b/packaging/tel-plugin-nitz.spec index 38a07fd..bbe613a 100644 --- a/packaging/tel-plugin-nitz.spec +++ b/packaging/tel-plugin-nitz.spec @@ -1,6 +1,7 @@ -%define major 0 -%define minor 1 -%define patchlevel 19 +%define major 3 +%define minor 0 +%define patchlevel 1 + Name: tel-plugin-nitz Summary: nitz plugin for telephony Version: %{major}.%{minor}.%{patchlevel} diff --git a/src/citylist.c b/src/citylist.c index 68de04b..1e9b3c3 100644 --- a/src/citylist.c +++ b/src/citylist.c @@ -669,7 +669,7 @@ static NITZ_MCC_TZFILE_MAP *nitz_find_tzinfo_by_mcc(int mcc) { NITZ_MCC_TZFILE_MAP *t = NULL; - if (mcc < 0) + if (mcc <= 0) return NULL; t = nitz_table_mcc_tzfile; diff --git a/src/desc-nitz.c b/src/desc-nitz.c index db4ec9e..0aebedd 100644 --- a/src/desc-nitz.c +++ b/src/desc-nitz.c @@ -35,19 +35,17 @@ #define PLUGIN_VERSION 1 #endif -static enum tcore_hook_return on_hook_network_timeinfo(Server *s, - CoreObject *source, - enum tcore_notification_command command, - unsigned int data_len, void *data, void *user_data) +static TcoreHookReturn on_hook_network_timeinfo(TcorePlugin *source, + TcoreNotification command, + guint data_len, void *data, void *user_data) { - struct tnoti_network_timeinfo *timeinfo = data; + TelNetworkNitzInfoNoti *timeinfo = data; gboolean flag_auto_update = FALSE; - filelog("NITZ !! (time(NULL) = %u)", (unsigned int)time(NULL)); - dbg("+- %04d-%02d-%02d %02d:%02d:%02d wday=%d", + filelog("NITZ !! (time(NULL) = %u)", (guint)time(NULL)); + dbg("+- %04d-%02d-%02d %02d:%02d:%02d", timeinfo->year, timeinfo->month, timeinfo->day, - timeinfo->hour, timeinfo->minute, timeinfo->second, - timeinfo->wday); + timeinfo->hour, timeinfo->minute, timeinfo->second); dbg("+- GMT-offset:%d, DST-offset:%d, is_dst:%d", timeinfo->gmtoff, timeinfo->dstoff, timeinfo->isdst); @@ -61,32 +59,81 @@ static enum tcore_hook_return on_hook_network_timeinfo(Server *s, return TCORE_HOOK_RETURN_CONTINUE; } +static TcoreHookReturn on_hook_modem_plugin_added(Server *s, + TcoreServerNotification command, + guint data_len, void *data, void *user_data) +{ + TcorePlugin *modem_plugin; + + modem_plugin = (TcorePlugin *)data; + tcore_check_return_value_assert(NULL != modem_plugin, TCORE_HOOK_RETURN_STOP_PROPAGATION); + + tcore_plugin_add_notification_hook(modem_plugin, TCORE_NOTIFICATION_NETWORK_TIMEINFO, + on_hook_network_timeinfo, NULL); + + return TCORE_HOOK_RETURN_CONTINUE; +} + +static TcoreHookReturn on_hook_modem_plugin_removed(Server *s, + TcoreServerNotification command, + guint data_len, void *data, void *user_data) +{ + TcorePlugin *modem_plugin; + + modem_plugin = (TcorePlugin *)data; + tcore_check_return_value_assert(NULL != modem_plugin, TCORE_HOOK_RETURN_STOP_PROPAGATION); + + tcore_plugin_remove_notification_hook(modem_plugin, TCORE_NOTIFICATION_NETWORK_TIMEINFO, + on_hook_network_timeinfo); + + return TCORE_HOOK_RETURN_CONTINUE; +} + static gboolean on_load() { dbg("Load!!!"); - return TRUE; } -static gboolean on_init(TcorePlugin *p) +static gboolean on_init(TcorePlugin *plugin) { Server *s; + GSList *list = NULL; + TcorePlugin *modem_plugin; - dbg("Init!!!"); + tcore_check_return_value_assert(NULL != plugin, FALSE); - s = tcore_plugin_ref_server(p); - if (s == NULL) - return FALSE; + dbg("Init!!!"); - tcore_server_add_notification_hook(s, TNOTI_NETWORK_TIMEINFO, + s = tcore_plugin_ref_server(plugin); + list = tcore_server_get_modem_plugin_list(s); + while (list) { /* Process for pre-loaded Modem Plug-in */ + modem_plugin = list->data; + if ( NULL != modem_plugin) + tcore_plugin_add_notification_hook(modem_plugin, TCORE_NOTIFICATION_NETWORK_TIMEINFO, on_hook_network_timeinfo, NULL); - + list = g_slist_next(list); + } + g_slist_free(list); + + /* Register for post-loaded Modem Plug-ins */ + tcore_server_add_notification_hook(s, TCORE_SERVER_NOTIFICATION_ADDED_MODEM_PLUGIN, + on_hook_modem_plugin_added, NULL); + tcore_server_add_notification_hook(s, TCORE_SERVER_NOTIFICATION_REMOVED_MODEM_PLUGIN, + on_hook_modem_plugin_removed, NULL); return TRUE; } -static void on_unload(TcorePlugin *p) +static void on_unload(TcorePlugin *plugin) { + Server *s; + + tcore_check_return_assert(NULL != plugin); dbg("Unload"); + + s = tcore_plugin_ref_server(plugin); + tcore_server_remove_notification_hook(s, on_hook_modem_plugin_added); + tcore_server_remove_notification_hook(s, on_hook_modem_plugin_removed); } EXPORT_API struct tcore_plugin_define_desc plugin_define_desc = diff --git a/src/time_update.c b/src/time_update.c index 39e5e5d..2d6ae70 100644 --- a/src/time_update.c +++ b/src/time_update.c @@ -77,8 +77,7 @@ long nitz_get_uptime() return 0; } -static gboolean update_time(const struct tnoti_network_timeinfo *ti, - gboolean mode_auto) +static gboolean update_time(const TelNetworkNitzInfoNoti *ti, gboolean mode_auto) { struct tm tm_time; time_t tt_gmt_nitz; @@ -91,7 +90,6 @@ static gboolean update_time(const struct tnoti_network_timeinfo *ti, tm_time.tm_sec = ti->second; tm_time.tm_min = ti->minute; tm_time.tm_hour = ti->hour; - tm_time.tm_wday = ti->wday; tm_time.tm_isdst = ti->dstoff; tt_gmt_nitz = timegm(&tm_time); @@ -121,8 +119,7 @@ static gboolean update_time(const struct tnoti_network_timeinfo *ti, return TRUE; } -static gboolean update_timezone(const struct tnoti_network_timeinfo *ti, - gboolean mode_auto) +static gboolean update_timezone(const TelNetworkNitzInfoNoti *ti, gboolean mode_auto) { int mcc; char mcc_str[4]; @@ -133,7 +130,7 @@ static gboolean update_timezone(const struct tnoti_network_timeinfo *ti, mcc = atoi(mcc_str); dbg("MCC: [%d]", mcc); - if (mcc >= 0) { + if (mcc > 0) { m = nitz_find_tzinfo(mcc, ti->gmtoff, ti->dstoff, ti->isdst); if (m) { dbg("Country: [%s] (ISO 3166)", m->country); @@ -148,8 +145,7 @@ static gboolean update_timezone(const struct tnoti_network_timeinfo *ti, return ret; } -gboolean nitz_time_update(const struct tnoti_network_timeinfo *time_info, - gboolean mode_auto) +gboolean nitz_time_update(const TelNetworkNitzInfoNoti *time_info, gboolean mode_auto) { if (time_info->year == 0 && time_info->month == 0 diff --git a/src/time_update.h b/src/time_update.h index 4736550..a05cb1a 100644 --- a/src/time_update.h +++ b/src/time_update.h @@ -21,6 +21,6 @@ int nitz_apply_tzfile(const char *tzfilename, gboolean mode_auto); long nitz_get_uptime(); -gboolean nitz_time_update(const struct tnoti_network_timeinfo *time_info, gboolean mode_auto); +gboolean nitz_time_update(const TelNetworkNitzInfoNoti *time_info, gboolean mode_auto); #endif