NVM: Remove unused static function and duplicated declarations
[platform/core/telephony/tel-plugin-imc.git] / src / s_sms.c
index 25bea45..5b5ca30 100644 (file)
@@ -467,7 +467,7 @@ static gboolean on_event_sms_incom_msg(CoreObject *o, const void *event_info, vo
        if(tokens)
                tcore_at_tok_free(tokens);
 
-       free(bytePDU);
+       g_free(bytePDU);
 
        return TRUE;
 }
@@ -559,7 +559,7 @@ static gboolean on_event_sms_cb_incom_msg(CoreObject *o, const void *event_info,
 
                                memcpy(cbMsgInfo.cbMsg.msgData, (char*)byte_pdu, cbMsgInfo.cbMsg.length);
                                rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SMS_CB_INCOM_MSG, sizeof(struct tnoti_sms_cellBroadcast_msg), &cbMsgInfo);
-                               free(byte_pdu);
+                               g_free(byte_pdu);
                        } else {
                                dbg("Invalid Message Length");
                        }
@@ -780,7 +780,7 @@ static void on_response_class2_read_msg(TcorePending *pending, int data_len, con
 
        rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(tcore_pending_ref_core_object(pending))), tcore_pending_ref_core_object(pending), TNOTI_SMS_INCOM_MSG, sizeof(struct tnoti_sms_umts_msg), &gsmMsgInfo);
 
-       free(bytePDU);
+       g_free(bytePDU);
 
        dbg("Exit");
        return;
@@ -914,7 +914,7 @@ static void on_response_read_msg(TcorePending *pending, int data_len, const void
                                                resp_read_msg.result = SMS_INVALID_PARAMETER_FORMAT;
                                        }
                                }
-                               free(byte_pdu);
+                               g_free(byte_pdu);
                        }else {
                                dbg("NULL PDU");
                        }
@@ -1103,6 +1103,7 @@ static void on_response_get_sca(TcorePending *pending, int data_len, const void
        UserRequest *user_req = NULL;
 
        GSList *tokens = NULL;
+       const char *sca_tok_addr;
        char *gslist_line = NULL, *sca_addr = NULL, *sca_toa = NULL;
 
        dbg("Entry");
@@ -1118,9 +1119,10 @@ static void on_response_get_sca(TcorePending *pending, int data_len, const void
                        gslist_line = (char *)at_response->lines->data;
 
                        tokens = tcore_at_tok_new(gslist_line);
-                       sca_addr = g_slist_nth_data(tokens, 0);
+                       sca_tok_addr = g_slist_nth_data(tokens, 0);
                        sca_toa = g_slist_nth_data(tokens, 1);
 
+                       sca_addr = tcore_at_tok_extract(sca_tok_addr);
                        if ((NULL != sca_addr)
                                && (NULL != sca_toa)) {
                                dbg("sca_addr: [%s]. sca_toa: [%s]", sca_addr, sca_toa);
@@ -1152,8 +1154,8 @@ static void on_response_get_sca(TcorePending *pending, int data_len, const void
 
        tcore_user_request_send_response(user_req, TRESP_SMS_GET_SCA, sizeof(respGetSca), &respGetSca);
 
-       if(tokens)
-               tcore_at_tok_free(tokens);
+       tcore_at_tok_free(tokens);
+       g_free(sca_addr);
 
        dbg("Exit");
        return;
@@ -1238,6 +1240,8 @@ static void on_response_get_cb_config(TcorePending *p, int data_len, const void
                                                cb_mid_str = util_removeQuotes(pResp);
                                                cb_tokens = tcore_at_tok_new((const char *) cb_mid_str);
 
+                                               g_free(cb_mid_str);
+
                                                num_cb_tokens = g_slist_length(cb_tokens);
                                                dbg("num_cb_tokens = %d", num_cb_tokens);
 
@@ -1503,8 +1507,8 @@ static void on_response_get_sms_params(TcorePending *pending, int data_len, cons
                                for (i = 0; i < (int) respGetParams.paramsInfo.tpSvcCntrAddr.dialNumLen; i++)
                                        dbg("SCAddr = %d [%02x]", i, respGetParams.paramsInfo.tpSvcCntrAddr.diallingNum[i]);
 
-                               free(recordData);
-                               free(hexData);
+                               g_free(recordData);
+                               g_free(hexData);
                        } else {
                                dbg("No response");
                        }
@@ -1732,8 +1736,8 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void *
                                                                }
                                                        } else {
                                                                dbg("INVALID FCP received - DEbug!");
-                                                               free(hexData);
-                                                               free(recordData);
+                                                               g_free(hexData);
+                                                               g_free(recordData);
                                                                tcore_at_tok_free(tokens);
                                                                return;
                                                        }
@@ -1750,8 +1754,8 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void *
                                                                dbg("Getting FileID=[0x%x]", file_id);
                                                        } else {
                                                                dbg("INVALID FCP received - DEbug!");
-                                                               free(hexData);
-                                                               free(recordData);
+                                                               g_free(hexData);
+                                                               g_free(recordData);
                                                                tcore_at_tok_free(tokens);
                                                                return;
                                                        }
@@ -1830,8 +1834,8 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void *
                                                                }
                                                        } else {
                                                                dbg("INVALID FCP received[0x%x] - DEbug!", *ptr_data);
-                                                               free(hexData);
-                                                               free(recordData);
+                                                               g_free(hexData);
+                                                               g_free(recordData);
                                                                tcore_at_tok_free(tokens);
                                                                return;
                                                        }
@@ -1853,8 +1857,8 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void *
                                                                ptr_data = ptr_data + 2;
                                                        } else {
                                                                dbg("INVALID FCP received - DEbug!");
-                                                               free(hexData);
-                                                               free(recordData);
+                                                               g_free(hexData);
+                                                               g_free(recordData);
                                                                tcore_at_tok_free(tokens);
                                                                return;
                                                        }
@@ -1880,8 +1884,8 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void *
                                                        }
                                                } else {
                                                        dbg("INVALID FCP received - DEbug!");
-                                                       free(hexData);
-                                                       free(recordData);
+                                                       g_free(hexData);
+                                                       g_free(recordData);
                                                        tcore_at_tok_free(tokens);
                                                        return;
                                                }
@@ -1980,8 +1984,8 @@ static void on_response_get_paramcnt(TcorePending *p, int data_len, const void *
                                        smsp_record_len = tcore_plugin_ref_property(plugin, "SMSPRECORDLEN");
                                        memcpy(smsp_record_len, &record_len, sizeof(int));
 
-                                       free(recordData);
-                                       free(hexData);
+                                       g_free(recordData);
+                                       g_free(hexData);
                                } else {
                                        /*2. SIM access fail case*/
                                        dbg("SIM access fail");
@@ -2102,7 +2106,7 @@ static void _response_get_efsms_data(TcorePending *p, int data_len, const void *
 
                                //free memory we own
                                g_free(cmd_str);
-                               free(encoded_data);
+                               g_free(encoded_data);
                                util_sms_free_memory(atreq);
                                util_sms_free_memory(pending);
 
@@ -2120,7 +2124,7 @@ static void _response_get_efsms_data(TcorePending *p, int data_len, const void *
                        tcore_hal_send_request(hal, pending);
 
                        g_free(cmd_str);
-                       free(encoded_data);
+                       g_free(encoded_data);
                }
        }
 
@@ -2976,6 +2980,7 @@ static TReturn set_sms_params(CoreObject *obj, UserRequest *ur)
        char *encoded_data = NULL;
        unsigned char *temp_data = NULL;
        int SMSPRecordLen = 0;
+       int *smsp_record_len;
 
        TcoreHal *hal = NULL;
        TcoreATRequest *atreq = NULL;
@@ -2998,7 +3003,11 @@ static TReturn set_sms_params(CoreObject *obj, UserRequest *ur)
        }
 
        //EFsmsp file size is 28 +Y bytes (Y is alpha id size)
-       SMSPRecordLen = 28 + setSmsParams->params.alphaIdLen;
+       smsp_record_len = tcore_plugin_ref_property(tcore_object_ref_plugin(obj), "SMSPRECORDLEN");
+       SMSPRecordLen = *smsp_record_len;
+       if (SMSPRecordLen < nDefaultSMSPWithoutAlphaId)
+               return FALSE;
+
        temp_data = calloc(SMSPRecordLen,1);
        encoded_data = calloc(SMSPRecordLen*2 + 1,1);
 
@@ -3130,15 +3139,15 @@ gboolean s_sms_init(TcorePlugin *cp, CoreObject *co_sms)
        tcore_sms_override_ops(co_sms, &sms_ops);
 
        /* Registering for SMS notifications */
-       tcore_object_override_callback(co_sms, "\e+CMTI", on_event_class2_sms_incom_msg, NULL);
-       tcore_object_override_callback(co_sms, "\e+CMT", on_event_sms_incom_msg, NULL);
+       tcore_object_override_callback(co_sms, "+CMTI:", on_event_class2_sms_incom_msg, NULL);
+       tcore_object_override_callback(co_sms, "\e+CMT:", on_event_sms_incom_msg, NULL);
 
        tcore_object_override_callback(co_sms, "\e+CDS", on_event_sms_incom_msg, NULL);
        tcore_object_override_callback(co_sms, "+XSMSMMSTAT", on_event_sms_memory_status, NULL);
        tcore_object_override_callback(co_sms, "+CMS", on_event_sms_memory_status, NULL);
 
-       tcore_object_override_callback(co_sms, "\e+CBMI", on_event_sms_cb_incom_msg, NULL);
-       tcore_object_override_callback(co_sms, "\e+CBM", on_event_sms_cb_incom_msg, NULL);
+       tcore_object_override_callback(co_sms, "+CBMI:", on_event_sms_cb_incom_msg, NULL);
+       tcore_object_override_callback(co_sms, "\e+CBM:", on_event_sms_cb_incom_msg, NULL);
 
        /* Storing SMSP record length */
        smsp_record_len = g_new0(int, 1);