Fix For PTREL-286 : Multi-User Architecture Change updated for review comments
[platform/core/telephony/tel-plugin-imc.git] / src / s_network.c
old mode 100755 (executable)
new mode 100644 (file)
index 68da560..aab77c9
@@ -36,6 +36,7 @@
 #include <storage.h>
 #include <util.h>
 #include <at.h>
+#include <tzplatform_config.h>
 
 #include "s_common.h"
 #include "s_network.h"
@@ -153,12 +154,15 @@ static void _insert_mcc_mnc_oper_list(TcorePlugin *p, CoreObject *o)
        gpointer key, value;
        GHashTable *result = NULL, *row = NULL;
        struct tcore_network_operator_info *noi = NULL;
+       const char *path = NULL;
        int count = 0;
 
        s = tcore_plugin_ref_server(p);
        strg = tcore_server_find_storage(s, "database");
 
-       handle = tcore_storage_create_handle(strg, "/opt/dbspace/.mcc_mnc_oper_list.db");
+       path = tzplatform_mkpath(TZ_SYS_DB, ".mcc_mnc_oper_list.db");
+
+       handle = tcore_storage_create_handle(strg, path);
        if (!handle) {
                dbg("fail to create database handle");
                return;
@@ -881,6 +885,7 @@ static void on_response_get_nitz_name(TcorePending *p, int data_len, const void
                                                break;
 
                                        case 5: /* Short NITZ name*/
+                                       case 3: /* Short Network Name (CPHS) */
                                                if ((pResp = tcore_at_tok_nth(tokens, 1))) {
                                                        if (strlen(pResp) > 0) {
                                                                net_name = tcore_at_tok_extract((const char *)pResp);
@@ -891,6 +896,7 @@ static void on_response_get_nitz_name(TcorePending *p, int data_len, const void
                                                break;
 
                                        case 6: /* Full NITZ name */
+                                       case 4: /* Long Network Name (CPHS) */
                                                if ((pResp = tcore_at_tok_nth(tokens, 1))) {
                                                        if (strlen(pResp) > 0) {
                                                                net_name = tcore_at_tok_extract((const char *)pResp);
@@ -905,6 +911,7 @@ static void on_response_get_nitz_name(TcorePending *p, int data_len, const void
                                        }
 
                                        g_free(net_name);
+                                       net_name = NULL;
                                }
 
                                tcore_at_tok_free(tokens);
@@ -1044,7 +1051,6 @@ static void on_response_get_serving_network(TcorePending *p, int data_len, const
        const TcoreATResponse *resp = data;
        UserRequest *ur;
        struct tresp_network_get_serving_network Tresp = {0};
-       char plmn[7] = {0};
        char *long_plmn_name = NULL;
        char *short_plmn_name = NULL;
        char *plmn_id = NULL;
@@ -1147,7 +1153,8 @@ static void on_response_get_serving_network(TcorePending *p, int data_len, const
                        tcore_at_tok_free(tokens);
                }
 
-               memcpy(Tresp.plmn, plmn, 7);
+               if(plmn_id)
+                       memcpy(Tresp.plmn, plmn_id, strlen(plmn_id));
                tcore_network_get_access_technology(o, &(Tresp.act));
                tcore_network_get_lac(o, &(Tresp.gsm.lac));
 
@@ -1160,7 +1167,8 @@ static void on_response_get_serving_network(TcorePending *p, int data_len, const
                        struct tnoti_network_change network_change;
 
                        memset(&network_change, 0, sizeof(struct tnoti_network_change));
-                       memcpy(network_change.plmn, plmn, 7);
+                       if(plmn_id)
+                               memcpy(network_change.plmn, plmn_id, strlen(plmn_id));
                        tcore_network_get_access_technology(o, &(network_change.act));
                        tcore_network_get_lac(o, &(network_change.gsm.lac));
 
@@ -1173,7 +1181,7 @@ static void on_response_get_serving_network(TcorePending *p, int data_len, const
                        if ((AT_COPS_MODE_DEREGISTER != network_mode) &&
                                (AT_COPS_MODE_SET_ONLY != network_mode)) {
                                /*Network identity noti*/
-                               memset(&noti, 0x0, sizeof(struct tnoti_network_change));
+                               memset(&noti, 0x0, sizeof(struct tnoti_network_identity));
                                if (long_plmn_name)
                                        memcpy(noti.full_name, long_plmn_name, MIN(32, strlen(long_plmn_name)));
                                if (short_plmn_name)
@@ -1262,23 +1270,32 @@ Note: <Act> is supporting from R7 and above Protocol Stack.
                        goto OUT;
                } else {
                        stat = atoi(pResp);
-                       if ((pResp = g_slist_nth_data(tokens, 1)))
-                               lac = atoi(pResp);
+                       if ((pResp = g_slist_nth_data(tokens, 1))) {
+                               pResp = util_removeQuotes(pResp);
+                               lac = strtol(pResp, NULL, 16);
+                               g_free(pResp);
+                       }
 
-                       if ((pResp = g_slist_nth_data(tokens, 2)))
-                               ci = atoi(pResp);
-                       else
+                       if ((pResp = g_slist_nth_data(tokens, 2))) {
+                               pResp = util_removeQuotes(pResp);
+                               ci = strtol(pResp, NULL, 16);
+                               g_free(pResp);
+                       } else {
                                dbg("No ci in +CGREG");
+                       }
 
                        if ((pResp = g_slist_nth_data(tokens, 3)))
                                AcT = atoi(pResp);
                        else
                                dbg("No AcT in +CGREG");
 
-                       if ((pResp = g_slist_nth_data(tokens, 4)))
-                               rac = atoi(pResp);
-                       else
+                       if ((pResp = g_slist_nth_data(tokens, 4))) {
+                               pResp = util_removeQuotes(pResp);
+                               rac = strtol(pResp, NULL, 16);
+                               g_free(pResp);
+                       } else {
                                dbg("No rac in +CGREG");
+                       }
                }
 
 
@@ -1443,13 +1460,19 @@ Note: <Act> is supporting from R7 and above Protocol Stack.
                        goto OUT;
                } else {
                        stat = atoi(pResp);
-                       if ((pResp = g_slist_nth_data(tokens, 1)))
-                               lac = atoi(pResp);
+                       if ((pResp = g_slist_nth_data(tokens, 1))) {
+                               pResp = util_removeQuotes(pResp);
+                               lac = strtol(pResp, NULL, 16);
+                               g_free(pResp);
+                       }
 
-                       if ((pResp = g_slist_nth_data(tokens, 2)))
-                               ci = atoi(pResp);
-                       else
+                       if ((pResp = g_slist_nth_data(tokens, 2))) {
+                               pResp = util_removeQuotes(pResp);
+                               ci = strtol(pResp, NULL, 16);
+                               g_free(pResp);
+                       } else {
                                dbg("No ci in +CREG");
+                       }
 
                        if ((pResp = g_slist_nth_data(tokens, 3)))
                                AcT = atoi(pResp);