Initial refactoring merge 96/19096/1 accepted/tizen_generic accepted/tizen_ivi_panda accepted/tizen/generic/20140408.094847 accepted/tizen/ivi/20140410.192345 accepted/tizen/ivi/panda/20140408.203154 accepted/tizen/mobile/20140409.082610 submit/tizen/20140408.080552
authorDongchul Lim <dc7.lim@samsung.com>
Mon, 7 Apr 2014 10:52:18 +0000 (19:52 +0900)
committerDongchul Lim <dc7.lim@samsung.com>
Mon, 7 Apr 2014 10:52:34 +0000 (19:52 +0900)
Change-Id: I94046514307898cabf15b4758297d9c3f91ada29

AUTHORS [deleted file]
packaging/tel-plugin-nitz.spec
src/citylist.c
src/desc-nitz.c
src/time_update.c
src/time_update.h

diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644 (file)
index e69de29..0000000
index 38a07fd..bbe613a 100644 (file)
@@ -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}
index 68de04b..1e9b3c3 100644 (file)
@@ -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;
index db4ec9e..0aebedd 100644 (file)
 #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 =
index 39e5e5d..2d6ae70 100644 (file)
@@ -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
index 4736550..a05cb1a 100644 (file)
@@ -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