merge from tizen_2.4 14/51614/5 accepted/tizen/mobile/20151117.050504 accepted/tizen/tv/20151117.050529 accepted/tizen/wearable/20151117.050549 submit/tizen/20151117.021955
authorKyeonghun Lee <kh9090.lee@samsung.com>
Wed, 11 Nov 2015 07:42:43 +0000 (16:42 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Thu, 12 Nov 2015 02:37:55 +0000 (11:37 +0900)
Change-Id: I23964dbb9b5e1991cbe484d618537ccdd04957b1
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
178 files changed:
externals/CMakeLists.txt
externals/MsgAlarm.cpp
externals/MsgDevicedWrapper.cpp
externals/MsgNotificationWrapper.cpp
externals/MsgSensorWrapper.cpp
externals/MsgSoundPlayer.cpp
externals/MsgSpamFilter.cpp
framework/CMakeLists.txt
framework/deliver-handler/MsgDeliverHandler.cpp
framework/main.cpp
framework/plugin-manager/MsgPluginManager.cpp
framework/setting-handler/MsgSettingHandler.cpp
framework/storage-handler/MsgStorageManager.cpp
framework/storage-handler/MsgStorageMessage.cpp
framework/storage-handler/MsgStorageMms.cpp
framework/storage-handler/MsgStorageUtil.cpp
framework/submit-handler/MsgSubmitHandler.cpp
framework/transaction-manager/MsgCmdHandlerFilter.cpp
framework/transaction-manager/MsgCmdHandlerStorage.cpp
framework/transaction-manager/MsgCmdHandlerTransport.cpp
framework/transaction-manager/MsgTransManager.cpp
include/common/MsgCmdTypes.h
include/common/MsgInternalTypes.h
include/common/MsgPluginInterface.h
include/common/MsgTypes.h
include/externals/MsgAlarm.h
include/externals/MsgNotificationWrapper.h
include/externals/MsgSensorWrapper.h
include/externals/MsgSoundPlayer.h
include/externals/MsgSpamFilter.h
include/framework/MsgCmdHandler.h
include/framework/MsgDeliverHandler.h
include/framework/MsgStorageHandler.h
include/framework/MsgTransManager.h
include/mapi/msg_private.h
include/mapi/msg_storage_types.h
include/mapi/msg_types.h
include/proxy/MsgHandle.h
include/proxy/MsgProxyListener.h
include/utils/MsgCallStatusManager.h [new file with mode: 0644]
include/utils/MsgDebug.h
include/utils/MsgJsonParser.h
include/utils/MsgSqliteWrapper.h
include/utils/MsgTextConvert.h
include/utils/MsgUtilFile.h
include/utils/MsgUtilFunction.h
include/utils/MsgUtilMime.h [moved from plugin/mms_plugin/include/MmsPluginMIME.h with 81% similarity]
include/utils/MsgUtilStorage.h
include/utils/MsgVMessage.h
mapi/msg_control.cpp
mapi/msg_filter.cpp
mapi/msg_message.cpp
mapi/msg_mms.cpp
mapi/msg_setting.cpp
mapi/msg_storage.cpp
mapi/msg_svc.cpp
mapi/msg_transport.cpp
packaging/msg-service.spec
plugin/mms_plugin/CMakeLists.txt
plugin/mms_plugin/MmsPluginAppBase.cpp
plugin/mms_plugin/MmsPluginCodecCommon.cpp
plugin/mms_plugin/MmsPluginComposer.cpp
plugin/mms_plugin/MmsPluginConnManWrapper.cpp
plugin/mms_plugin/MmsPluginDecode.cpp
plugin/mms_plugin/MmsPluginDrm.cpp
plugin/mms_plugin/MmsPluginEncode.cpp
plugin/mms_plugin/MmsPluginEventHandler.cpp
plugin/mms_plugin/MmsPluginHttp.cpp
plugin/mms_plugin/MmsPluginInternal.cpp
plugin/mms_plugin/MmsPluginMain.cpp
plugin/mms_plugin/MmsPluginMessage.cpp
plugin/mms_plugin/MmsPluginSMILValidate.cpp
plugin/mms_plugin/MmsPluginStorage.cpp
plugin/mms_plugin/MmsPluginTcs.cpp [deleted file]
plugin/mms_plugin/MmsPluginTextConvert.cpp
plugin/mms_plugin/MmsPluginTransport.cpp
plugin/mms_plugin/MmsPluginUserAgent.cpp
plugin/mms_plugin/MmsPluginUtil.cpp
plugin/mms_plugin/include/MmsPluginAppBase.h
plugin/mms_plugin/include/MmsPluginCodec.h
plugin/mms_plugin/include/MmsPluginCodecCommon.h
plugin/mms_plugin/include/MmsPluginCodecTypes.h
plugin/mms_plugin/include/MmsPluginComposer.h
plugin/mms_plugin/include/MmsPluginConnManWrapper.h
plugin/mms_plugin/include/MmsPluginDebug.h
plugin/mms_plugin/include/MmsPluginDecode.h
plugin/mms_plugin/include/MmsPluginDrm.h
plugin/mms_plugin/include/MmsPluginEncode.h
plugin/mms_plugin/include/MmsPluginEventHandler.h
plugin/mms_plugin/include/MmsPluginHttp.h
plugin/mms_plugin/include/MmsPluginInternal.h
plugin/mms_plugin/include/MmsPluginMain.h
plugin/mms_plugin/include/MmsPluginMessage.h
plugin/mms_plugin/include/MmsPluginStorage.h
plugin/mms_plugin/include/MmsPluginTcs.h [deleted file]
plugin/mms_plugin/include/MmsPluginTextConvert.h
plugin/mms_plugin/include/MmsPluginTransport.h
plugin/mms_plugin/include/MmsPluginTypes.h
plugin/mms_plugin/include/MmsPluginUserAgent.h
plugin/mms_plugin/include/MmsPluginUtil.h
plugin/sms_cdma_plugin/CMakeLists.txt
plugin/sms_cdma_plugin/SmsCdmaPluginCallback.cpp
plugin/sms_cdma_plugin/SmsCdmaPluginCodec.cpp
plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp
plugin/sms_cdma_plugin/SmsCdmaPluginMain.cpp
plugin/sms_cdma_plugin/SmsCdmaPluginParamCodec.cpp
plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp
plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp
plugin/sms_cdma_plugin/SmsCdmaPluginTransport.cpp
plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp
plugin/sms_cdma_plugin/SmsCdmaPluginWapPushHandler.cpp
plugin/sms_cdma_plugin/include/SmsCdmaPluginCallback.h
plugin/sms_cdma_plugin/include/SmsCdmaPluginCodec.h
plugin/sms_cdma_plugin/include/SmsCdmaPluginEventHandler.h
plugin/sms_cdma_plugin/include/SmsCdmaPluginMain.h
plugin/sms_cdma_plugin/include/SmsCdmaPluginSetting.h
plugin/sms_cdma_plugin/include/SmsCdmaPluginStorage.h
plugin/sms_cdma_plugin/include/SmsCdmaPluginTransport.h
plugin/sms_cdma_plugin/include/SmsCdmaPluginTypes.h
plugin/sms_cdma_plugin/include/SmsCdmaPluginUAManager.h
plugin/sms_cdma_plugin/include/SmsCdmaPluginWapPushHandler.h
plugin/sms_plugin/CMakeLists.txt
plugin/sms_plugin/SmsPluginCallback.cpp
plugin/sms_plugin/SmsPluginCbMsgHandler.cpp
plugin/sms_plugin/SmsPluginConcatHandler.cpp
plugin/sms_plugin/SmsPluginDSHandler.cpp
plugin/sms_plugin/SmsPluginEventHandler.cpp
plugin/sms_plugin/SmsPluginMain.cpp
plugin/sms_plugin/SmsPluginParamCodec.cpp
plugin/sms_plugin/SmsPluginSatHandler.cpp
plugin/sms_plugin/SmsPluginSetting.cpp
plugin/sms_plugin/SmsPluginSimMsg.cpp
plugin/sms_plugin/SmsPluginStorage.cpp
plugin/sms_plugin/SmsPluginTpduCodec.cpp
plugin/sms_plugin/SmsPluginTransport.cpp
plugin/sms_plugin/SmsPluginUAManager.cpp
plugin/sms_plugin/SmsPluginUDCodec.cpp
plugin/sms_plugin/SmsPluginWapPushHandler.cpp
plugin/sms_plugin/include/SmsPluginCallback.h
plugin/sms_plugin/include/SmsPluginCbMsgHandler.h
plugin/sms_plugin/include/SmsPluginConcatHandler.h
plugin/sms_plugin/include/SmsPluginDSHandler.h
plugin/sms_plugin/include/SmsPluginEventHandler.h
plugin/sms_plugin/include/SmsPluginMain.h
plugin/sms_plugin/include/SmsPluginParamCodec.h
plugin/sms_plugin/include/SmsPluginSatHandler.h
plugin/sms_plugin/include/SmsPluginSetting.h
plugin/sms_plugin/include/SmsPluginSimMsg.h
plugin/sms_plugin/include/SmsPluginStorage.h
plugin/sms_plugin/include/SmsPluginTpduCodec.h
plugin/sms_plugin/include/SmsPluginTransport.h
plugin/sms_plugin/include/SmsPluginTypes.h
plugin/sms_plugin/include/SmsPluginUAManager.h
plugin/sms_plugin/include/SmsPluginUDCodec.h
plugin/sms_plugin/include/SmsPluginWapPushHandler.h
proxy/CMakeLists.txt
proxy/MsgHandleControl.cpp
proxy/MsgHandleFilter.cpp
proxy/MsgHandleSetting.cpp
proxy/MsgHandleStorage.cpp
proxy/MsgHandleTransport.cpp
proxy/MsgProxyListener.cpp
utils/CMakeLists.txt
utils/MsgCallStatusManager.cpp [new file with mode: 0644]
utils/MsgContact.cpp
utils/MsgDebug.cpp
utils/MsgIpcSocket.cpp
utils/MsgJsonParser.cpp
utils/MsgMmsMessage.cpp
utils/MsgSerialize.cpp
utils/MsgSmil.cpp
utils/MsgSqliteWrapper.cpp
utils/MsgTextConvert.cpp
utils/MsgUtilFile.cpp
utils/MsgUtilFunction.cpp
utils/MsgUtilMime.cpp [moved from plugin/mms_plugin/MmsPluginMIME.cpp with 93% similarity]
utils/MsgUtilStorage.cpp
utils/MsgVMessage.cpp

index 326fbb2..e94ae0b 100755 (executable)
@@ -32,7 +32,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(externals_pkgs REQUIRED glib-2.0 deviced mm-session alarm-service notification badge iniparser capi-appfw-application lbs-dbus mm-fileinfo mm-player mm-sound sensor feedback db-util)
+pkg_check_modules(externals_pkgs REQUIRED glib-2.0 mm-session alarm-service notification badge iniparser capi-appfw-application lbs-dbus mm-fileinfo mm-player mm-sound feedback capi-system-device motion)
 
 FOREACH(flag ${externals_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 1c53a3f..fb6091b 100755 (executable)
@@ -70,7 +70,8 @@ msg_error_t MsgAlarmInit()
        }
 
        retval = alarmmgr_set_cb(MsgAlarmCB, NULL);
-       if (retval != ALARMMGR_RESULT_SUCCESS) MSG_DEBUG("alarmmgr_set_cb() [%d]", retval);
+       if (retval != ALARMMGR_RESULT_SUCCESS)
+               MSG_DEBUG("alarmmgr_set_cb() [%d]", retval);
 
        alarmInit = true;
 
@@ -100,9 +101,9 @@ msg_error_t MsgAlarmRegistration(struct tm *timeInfo, msg_alarm_cb userCB, int *
        }
 
        *alarmId = 0;
-       alarm_info_talarm_info = NULL;
-       alarm_id_t      alarm_id = -1;
-       alarm_date_t    target_time;
+       alarm_info_t *alarm_info = NULL;
+       alarm_id_t alarm_id = -1;
+       alarm_date_t target_time;
 
        int retval = ALARMMGR_RESULT_SUCCESS;
 
@@ -124,16 +125,23 @@ msg_error_t MsgAlarmRegistration(struct tm *timeInfo, msg_alarm_cb userCB, int *
                        target_time.hour, target_time.min, target_time.sec);
 
        retval = alarmmgr_set_time(alarm_info, target_time);
-       if (retval != ALARMMGR_RESULT_SUCCESS) MSG_DEBUG("alarmmgr_set_time ret[%d]", retval);
+       if (retval != ALARMMGR_RESULT_SUCCESS)
+               MSG_DEBUG("alarmmgr_set_time ret[%d]", retval);
+
        retval = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_ONCE, 0);
-       if (retval != ALARMMGR_RESULT_SUCCESS) MSG_DEBUG("alarmmgr_set_repeat_mode ret[%d]", retval);
+       if (retval != ALARMMGR_RESULT_SUCCESS)
+               MSG_DEBUG("alarmmgr_set_repeat_mode ret[%d]", retval);
+
        retval = alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT);
-       if (retval != ALARMMGR_RESULT_SUCCESS) MSG_DEBUG("alarmmgr_set_type ret[%d]", retval);
+       if (retval != ALARMMGR_RESULT_SUCCESS)
+               MSG_DEBUG("alarmmgr_set_type ret[%d]", retval);
+
        retval = alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &alarm_id);
        MSG_DEBUG("alarmmgr_add_alarm_with_localtime ret[%d], alarm_id[%d]", retval, alarm_id);
 
        retval = alarmmgr_free_alarm(alarm_info);
-       if (retval != ALARMMGR_RESULT_SUCCESS) MSG_DEBUG("alarmmgr_free_alarm ret[%d]", retval);
+       if (retval != ALARMMGR_RESULT_SUCCESS)
+               MSG_DEBUG("alarmmgr_free_alarm ret[%d]", retval);
 
        *alarmId = (int)alarm_id;
 
index 005aa77..d43c957 100644 (file)
 */
 
 
-#include <dd-display.h>
+#include <device/power.h>
+#include <device/display.h>
 
+#include "MsgCallStatusManager.h"
 #include "MsgDebug.h"
 #include "MsgMutex.h"
 #include "MsgGconfWrapper.h"
@@ -34,9 +36,9 @@ void MsgDisplayLock()
        mx.lock();
 
        if (g_lock_cnt <= 0) {
-               ret = display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+               ret = device_power_request_lock(POWER_LOCK_CPU, 0);
                if (ret < 0) {
-                       MSG_DEBUG("display_lock_state() is failed [%d]", ret);
+                       MSG_DEBUG("device_power_request_lock() is failed [%d]", ret);
                }
        }
 
@@ -63,9 +65,9 @@ void MsgDisplayUnlock()
        MSG_DEBUG("Display lock count = [%d]", g_lock_cnt);
 
        if (g_lock_cnt <= 0) {
-               ret = display_unlock_state(LCD_OFF, PM_RESET_TIMER);
+               ret = device_power_release_lock(POWER_LOCK_CPU);
                if (ret < 0) {
-                       MSG_DEBUG("display_lock_state() is failed [%d]", ret);
+                       MSG_DEBUG("device_power_release_lock() is failed [%d]", ret);
                }
        }
 
@@ -80,14 +82,14 @@ void MsgChangePmState()
        MSG_BEGIN();
        int callStatus = 0;
 
-       callStatus = MsgSettingGetInt(VCONFKEY_CALL_STATE);
+       callStatus = MsgGetCallStatus();
        MSG_DEBUG("Call Status = %d", callStatus);
 
-       if (callStatus > VCONFKEY_CALL_OFF && callStatus < VCONFKEY_CALL_STATE_MAX) {
+       if (callStatus > 0 && callStatus < 3) {
                MSG_DEBUG("Call is activated. Do not turn on the lcd.");
        } else {
                MSG_DEBUG("Call is not activated. Turn on the lcd.");
-               display_change_state(LCD_NORMAL);
+               device_display_change_state(DISPLAY_STATE_NORMAL);
        }
 
        MSG_END();
index 3f78771..8011813 100755 (executable)
@@ -40,9 +40,12 @@ extern "C"
 #include <notification_list.h>
 #include <notification_text_domain.h>
 #include <notification_internal.h>
+#include <notification_status.h>
+#include <notification_setting.h>
+#include <notification_setting_internal.h>
 #include <feedback.h>
 #include <badge_internal.h>
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 }
 
 #ifndef MSG_WEARABLE_PROFILE
@@ -63,6 +66,7 @@ typedef struct _msg_noti_info_s
        int                     id;
        int                     layout;
        int                     count;
+       int                     senderCount;
        time_t          time;
        char            sender[MSG_NOTI_TEXT_LEN_S];
        char            text[MSG_NOTI_TEXT_LEN];
@@ -70,9 +74,17 @@ typedef struct _msg_noti_info_s
        char            imagePath[MAX_IMAGE_PATH_LEN + 1];              /**< Indicates the image path of contact. */
        int                     applist;
        app_control_h           svc_h;
+       app_control_h           active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM];
        msg_message_id_t        msg_id;
        unsigned char           extra_data;
        int             sim_idx;
+       int                     active_noti_button_num;
+       int             active_media_cnt;
+       int             active_media_size;
+       MSG_SUB_TYPE_T  active_subtype;         /**< to distinguish cb, push message */
+       char            active_sender[MSG_NOTI_TEXT_LEN_S];
+       char            active_subject[MSG_NOTI_TEXT_LEN_S];
+       char            active_text[MSG_NOTI_TEXT_LEN];
 }MSG_NOTI_INFO_S;
 
 typedef struct _report_notification_s
@@ -90,8 +102,9 @@ notification_h getHandle(int *noti_id);
 int getPrivId(msg_notification_type_t noti_type, int sim_idx);
 void updatePrivId(msg_notification_type_t noti_type, int noti_id, int sim_idx);
 
-void createInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info); // For addNoti()
-void createInfoData(MSG_NOTI_INFO_S *noti_info, bool bTicker); // For refreshNoti()
+void createInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info); /* For addNoti() */
+void createInfoData(MSG_NOTI_INFO_S *noti_info, msg_active_notification_type_t active_noti); /* For refreshNoti() */
+void createActiveInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info);
 void clearInfoData(notification_h noti_h, MSG_NOTI_INFO_S *noti_info);
 
 msg_error_t getLatestMsgInfo(MSG_NOTI_INFO_S *noti_info, bool isForInstantMessage);
@@ -102,6 +115,10 @@ void setText(notification_h noti_h, MSG_NOTI_INFO_S *noti_info);
 void setIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info);
 void setPkgName(notification_h noti_h, msg_notification_type_t noti_type);
 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
+void setActiveNotification(notification_h noti_h, MSG_NOTI_INFO_S *noti_info);
+void setActiveProperty(notification_h noti_h, MSG_NOTI_INFO_S *noti_info);
+void setActiveText(notification_h noti_h, MSG_NOTI_INFO_S *noti_info);
+void setActiveIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info);
 
 void setNotification(notification_h noti_h, MSG_NOTI_INFO_S *noti_info, bool bFeedback);
 
@@ -110,9 +127,10 @@ void MsgRefreshNotiCb(void *data);
 
 bool isExistAddressInReportTable(const char *addr);
 
-// Wrapper
+/* Wrapper */
 void createServiceHandle(app_control_h *svc_h);
 void setServiceAppId(app_control_h svc_h, const char* app_id);
+void setServiceUri(app_control_h svc_h, const char* uri);
 void setServiceOperation(app_control_h svc_h, const char* operation);
 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val);
 void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val);
@@ -126,16 +144,17 @@ void setNotiTime(notification_h noti_h, time_t time);
 void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path);
 void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path);
 void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path);
+void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler);
 
 
-// Alarm
+/* Alarm */
 void MsgNotiSoundRepeatAlarmCB(int alarmId);
 void MsgSoundCreateRepeatAlarm(int RepeatTime);
 void MsgSoundSetRepeatAlarm();
 
 void sendMsgReplyPopup(MSG_NOTI_INFO_S *noti_info);
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
 /*======================================================================================*/
 /*                                                             FUNCTION IMPLEMENTATION                                                                 */
@@ -152,96 +171,90 @@ msg_error_t MsgInsertNotification(MSG_MESSAGE_INFO_S *msg_info)
 
        msg_notification_type_t noti_type;
 
-       switch (msg_info->msgType.subType)
-       {
+       switch (msg_info->msgType.subType) {
 #ifdef MSG_NOTI_INTEGRATION
-               case MSG_NORMAL_SMS :
-               case MSG_CB_SMS :
-                       {
-                               if (msg_info->msgType.classType == MSG_CLASS_0) {
-                                       noti_type = MSG_NOTI_TYPE_CLASS0;
-                               } else {
-                                       noti_type = MSG_NOTI_TYPE_NORMAL;
-                               }
-                       }
-                       break;
+       case MSG_NORMAL_SMS:
+       case MSG_CB_SMS: {
+               if (msg_info->msgType.classType == MSG_CLASS_0) {
+                       noti_type = MSG_NOTI_TYPE_CLASS0;
+               } else {
+                       noti_type = MSG_NOTI_TYPE_NORMAL;
+               }
+               break;
+       }
 #else
-               case MSG_NORMAL_SMS :
-                       {
-                               if (msg_info->msgType.classType == MSG_CLASS_0) {
-                                       noti_type = MSG_NOTI_TYPE_CLASS0;
-                               } else if (msg_info->msgType.classType == MSG_CLASS_2) {
-                                       noti_type = MSG_NOTI_TYPE_SIM;
-                               } else {
-                                       noti_type = MSG_NOTI_TYPE_NORMAL;
-                               }
-                       }
-                       break;
-               case MSG_CB_SMS :
-                       noti_type = MSG_NOTI_TYPE_CB;
-                       break;
+       case MSG_NORMAL_SMS: {
+               if (msg_info->msgType.classType == MSG_CLASS_0) {
+                       noti_type = MSG_NOTI_TYPE_CLASS0;
+               } else if (msg_info->msgType.classType == MSG_CLASS_2) {
+                       noti_type = MSG_NOTI_TYPE_SIM;
+               } else {
+                       noti_type = MSG_NOTI_TYPE_NORMAL;
+               }
+               break;
+       }
+       case MSG_CB_SMS:
+               noti_type = MSG_NOTI_TYPE_CB;
+               break;
 #endif
-               case MSG_MWI_FAX_SMS :
-               case MSG_MWI_EMAIL_SMS :
-               case MSG_MWI_OTHER_SMS :
-                       noti_type = MSG_NOTI_TYPE_MWI;
-                       break;
-               case MSG_MWI_VOICE_SMS :
-                       noti_type = MSG_NOTI_TYPE_VOICE_1;
-                       break;
-               case MSG_MWI_VOICE2_SMS :
-                       noti_type = MSG_NOTI_TYPE_VOICE_2;
-                       break;
-               case MSG_STATUS_REPORT_SMS :
-                       noti_type = MSG_NOTI_TYPE_SMS_DELIVERY_REPORT;
-                       break;
-               case MSG_DELIVERYIND_MMS :
-                       noti_type = MSG_NOTI_TYPE_MMS_DELIVERY_REPORT;
-                       break;
-               case MSG_READORGIND_MMS :
-                       noti_type = MSG_NOTI_TYPE_MMS_READ_REPORT;
-                       break;
-               default :
-               {
+       case MSG_MWI_FAX_SMS:
+       case MSG_MWI_EMAIL_SMS:
+       case MSG_MWI_OTHER_SMS:
+               noti_type = MSG_NOTI_TYPE_MWI;
+               break;
+       case MSG_MWI_VOICE_SMS:
+               noti_type = MSG_NOTI_TYPE_VOICE_1;
+               break;
+       case MSG_MWI_VOICE2_SMS:
+               noti_type = MSG_NOTI_TYPE_VOICE_2;
+               break;
+       case MSG_STATUS_REPORT_SMS:
+               noti_type = MSG_NOTI_TYPE_SMS_DELIVERY_REPORT;
+               break;
+       case MSG_DELIVERYIND_MMS:
+               noti_type = MSG_NOTI_TYPE_MMS_DELIVERY_REPORT;
+               break;
+       case MSG_READORGIND_MMS:
+               noti_type = MSG_NOTI_TYPE_MMS_READ_REPORT;
+               break;
+       default:
 #ifdef MSG_NOTI_INTEGRATION
-                       noti_type = MSG_NOTI_TYPE_NORMAL;
+               noti_type = MSG_NOTI_TYPE_NORMAL;
 #else
-                       if (msg_info->msgType.classType == MSG_CLASS_2) {
-                               noti_type = MSG_NOTI_TYPE_SIM;
-                       } else {
-                               noti_type = MSG_NOTI_TYPE_NORMAL;
-                       }
-#endif
+               if (msg_info->msgType.classType == MSG_CLASS_2) {
+                       noti_type = MSG_NOTI_TYPE_SIM;
+               } else {
+                       noti_type = MSG_NOTI_TYPE_NORMAL;
                }
+#endif
                break;
        }
 
        MSG_DEBUG("Notification type = [%d]", noti_type);
 
-       switch (noti_type)
-       {
-               case MSG_NOTI_TYPE_NORMAL :
-               case MSG_NOTI_TYPE_SIM :
-               case MSG_NOTI_TYPE_CB :
-                       err = MsgRefreshNotification(noti_type, true, true);
-                       break;
-               case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT :
-               case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT :
-               case MSG_NOTI_TYPE_MMS_READ_REPORT :
-                       err = MsgAddReportNotification(noti_type, msg_info);
-                       break;
-               case MSG_NOTI_TYPE_VOICE_1 :
-               case MSG_NOTI_TYPE_VOICE_2 :
-               case MSG_NOTI_TYPE_MWI :
-               case MSG_NOTI_TYPE_CLASS0 :
-                       err = MsgAddNotification(noti_type, msg_info);
-                       break;
-               default :
-                       MSG_DEBUG("No matching type [%d]");
-                       break;
+       switch (noti_type) {
+       case MSG_NOTI_TYPE_NORMAL:
+       case MSG_NOTI_TYPE_SIM:
+       case MSG_NOTI_TYPE_CB:
+               err = MsgRefreshNotification(noti_type, true, MSG_ACTIVE_NOTI_TYPE_ACTIVE);
+               break;
+       case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT:
+       case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT:
+       case MSG_NOTI_TYPE_MMS_READ_REPORT:
+               err = MsgAddReportNotification(noti_type, msg_info);
+               break;
+       case MSG_NOTI_TYPE_VOICE_1:
+       case MSG_NOTI_TYPE_VOICE_2:
+       case MSG_NOTI_TYPE_MWI:
+       case MSG_NOTI_TYPE_CLASS0:
+               err = MsgAddNotification(noti_type, msg_info);
+               break;
+       default:
+               MSG_DEBUG("No matching type [%d]");
+               break;
        }
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
        MSG_END();
 
@@ -249,6 +262,32 @@ msg_error_t MsgInsertNotification(MSG_MESSAGE_INFO_S *msg_info)
 
 }
 
+msg_error_t MsgInsertOnlyActiveNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *msg_info)
+{
+       MSG_BEGIN();
+
+       msg_error_t msg_err = MSG_SUCCESS;
+#ifndef MSG_WEARABLE_PROFILE
+       notification_h noti_h = NULL;
+
+       MSG_NOTI_INFO_S noti_info = {0,};
+
+       noti_info.type = noti_type;
+       noti_info.active_noti_button_num = 1;
+
+       createActiveInfoData(&noti_info, msg_info);
+
+       noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
+
+       setActiveNotification(noti_h, &noti_info);
+
+       clearInfoData(noti_h, &noti_info);
+#endif /* MSG_WEARABLE_PROFILE */
+       MSG_END();
+       return msg_err;
+}
+
+
 msg_error_t MsgDeleteReportNotification(const char *addr)
 {
        MSG_BEGIN();
@@ -281,8 +320,7 @@ msg_error_t MsgDeleteReportNotification(const char *addr)
        if (list_length > 0) {
                GList *iter = g_list_first(msg_report_notification_list);
 
-               while (iter != NULL)
-               {
+               while (iter != NULL) {
                        isDelete = false;
                        report_notification_s *info = (report_notification_s*)(iter->data);
                        if (info == NULL) {
@@ -293,8 +331,7 @@ msg_error_t MsgDeleteReportNotification(const char *addr)
                        MSG_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
 
                        noti_h = notification_load(NULL, info->priv_id);
-                       if (noti_h == NULL)
-                       {
+                       if (noti_h == NULL) {
                                MSG_DEBUG("notification with priv_id [%d] is NULL", info->priv_id);
                                isDelete = true;
                        } else {
@@ -306,8 +343,7 @@ msg_error_t MsgDeleteReportNotification(const char *addr)
                                        if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) {
                                                MSG_SEC_DEBUG("delete report notification address [%s]", info->addressVal);
                                                isDelete = true;
-                                       }
-                                       else {
+                                       } else {
                                                MSG_DEBUG("delete notification failed");
                                        }
                                }
@@ -320,7 +356,7 @@ msg_error_t MsgDeleteReportNotification(const char *addr)
 
                        if (isDelete) {
                                msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info);
-                               if(info) {
+                               if (info) {
                                        delete info;
                                        info = NULL;
                                }
@@ -328,7 +364,7 @@ msg_error_t MsgDeleteReportNotification(const char *addr)
                }
        }
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
        MSG_END();
 
@@ -369,11 +405,12 @@ msg_error_t MsgAddReportNotification(msg_notification_type_t noti_type, MSG_MESS
 
 __END_OF_REFRESH_NOTI :
        clearInfoData(noti_h, &noti_info);
-#endif // MSG_WEARABLE_PROFILE
+
+#endif /* MSG_WEARABLE_PROFILE */
        return msg_err;
 }
 
-msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeedback, bool bTicker)
+msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeedback, msg_active_notification_type_t active_type)
 {
 
        msg_error_t msg_err = MSG_SUCCESS;
@@ -381,7 +418,7 @@ msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeed
 #ifndef MSG_WEARABLE_PROFILE
        notification_h noti_h = NULL;
        bool bNotification = true;
-//     bool bReplyPopup = false;
+/*     bool bReplyPopup = false; */
 
        MSG_NOTI_INFO_S noti_info;
        memset(&noti_info, 0x00, sizeof(MSG_NOTI_INFO_S));
@@ -397,7 +434,7 @@ msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeed
                goto __END_OF_REFRESH_NOTI;
        }
 
-       if (bTicker) {
+       if (active_type == MSG_ACTIVE_NOTI_TYPE_INSTANT) {
                msg_err = MsgInsertInstantMessage(noti_type);
 
                if (msg_err != MSG_SUCCESS) {
@@ -415,7 +452,7 @@ msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeed
                goto __END_OF_REFRESH_NOTI;
        }
 
-       createInfoData(&noti_info, bTicker);
+       createInfoData(&noti_info, active_type);
 
        noti_h = getHandle(&noti_info.id);
 
@@ -440,7 +477,8 @@ msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeed
 
 __END_OF_REFRESH_NOTI :
        clearInfoData(noti_h, &noti_info);
-#endif // MSG_WEARABLE_PROFILE
+
+#endif /* MSG_WEARABLE_PROFILE */
        return msg_err;
 }
 
@@ -458,6 +496,13 @@ msg_error_t MsgAddNotification(msg_notification_type_t noti_type, MSG_MESSAGE_IN
 
        createInfoData(&noti_info, msg_info);
 
+       /* check mwi or voicemail count is 0 then skip add notification */
+       if (noti_info.count == 0) {
+               MSG_DEBUG("Notification count is 0");
+               msg_err = MSG_ERR_INVALID_MESSAGE;
+               goto __END_OF_ADD_NOTI;
+       }
+
        noti_h = getHandle(&noti_info.id);
 
        if (noti_h == NULL) {
@@ -470,45 +515,46 @@ msg_error_t MsgAddNotification(msg_notification_type_t noti_type, MSG_MESSAGE_IN
 
 __END_OF_ADD_NOTI :
        clearInfoData(noti_h, &noti_info);
-#endif // MSG_WEARABLE_PROFILE
+
+#endif /* MSG_WEARABLE_PROFILE */
        return msg_err;
 }
 
 
-void MsgRefreshAllNotification(bool bWithSimNoti, bool bFeedback, bool bTickerNoti)
+void MsgRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_active_notification_type_t active_type)
 {
        MSG_BEGIN();
 
 #ifndef MSG_WEARABLE_PROFILE
        msg_error_t err = MSG_SUCCESS;
 
-//     MsgDeleteNotification(MSG_NOTI_TYPE_SIM);
+/*     MsgDeleteNotification(MSG_NOTI_TYPE_SIM); */
 
 #ifdef MSG_NOTI_INTEGRATION
-       err = MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, bFeedback, bTickerNoti);
+       err = MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, bFeedback, active_type);
        if (err != MSG_SUCCESS)
                MSG_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_NOTI_TYPE_NORMAL, err);
 #else
-       err = MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, bFeedback, bTickerNoti);
+       err = MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, bFeedback, active_type);
        if (err != MSG_SUCCESS)
                MSG_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_NOTI_TYPE_NORMAL, err);
 
-       err = MsgRefreshNotification(MSG_NOTI_TYPE_CB, bFeedback, bTickerNoti);
+       err = MsgRefreshNotification(MSG_NOTI_TYPE_CB, bFeedback, active_type);
        if (err != MSG_SUCCESS)
                MSG_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_NOTI_TYPE_CB, err);
 
        if (bWithSimNoti) {
-               err = MsgRefreshNotification(MSG_NOTI_TYPE_SIM, bFeedback, bTickerNoti);
+               err = MsgRefreshNotification(MSG_NOTI_TYPE_SIM, bFeedback, active_type);
                if (err != MSG_SUCCESS)
                        MSG_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_NOTI_TYPE_SIM, err);
        }
 #endif
 
-       err = MsgRefreshNotification(MSG_NOTI_TYPE_FAILED, bFeedback, bTickerNoti);
+       err = MsgRefreshNotification(MSG_NOTI_TYPE_FAILED, bFeedback, active_type);
        if (err != MSG_SUCCESS)
                MSG_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_NOTI_TYPE_FAILED, err);
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
        MSG_END();
 }
 
@@ -540,9 +586,81 @@ void MsgDeleteNotification(msg_notification_type_t noti_type, int simIndex)
        }
 
        updatePrivId(noti_type, 0, simIndex);
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 }
 
+bool MsgCheckNotificationSettingEnable(void)
+{
+       bool msg_noti_enabled = false;
+#ifndef MSG_WEARABLE_PROFILE
+       notification_system_setting_h system_setting = NULL;
+       notification_setting_h setting = NULL;
+
+       int err = NOTIFICATION_ERROR_NONE;
+
+       err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting);
+
+       if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
+               MSG_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
+       } else {
+               msg_noti_enabled = true;
+
+               bool allow_to_notify = false;
+               err = notification_setting_get_allow_to_notify(setting, &allow_to_notify);
+
+               if (err != NOTIFICATION_ERROR_NONE) {
+                       MSG_ERR("getting do not disturb setting is failed. err = %d", err);
+                       goto EXIT;
+               }
+
+               if (allow_to_notify) {
+                       MSG_DEBUG("message notification is allowed");
+
+                       // check do not disturb mode
+                       err = notification_system_setting_load_system_setting(&system_setting);
+
+                       if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
+                               MSG_ERR("getting system setting is failed. err = %d", err);
+                               goto EXIT;
+                       }
+
+                       bool do_not_disturb_mode = false;
+                       err = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb_mode);
+
+                       if (err != NOTIFICATION_ERROR_NONE) {
+                               MSG_ERR("getting do not disturb setting is failed. err = %d", err);
+                               goto EXIT;
+                       }
+
+                       if (do_not_disturb_mode) {
+                               bool is_msg_excepted = false;
+                               err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted);
+                               if (err != NOTIFICATION_ERROR_NONE) {
+                                       MSG_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err);
+                                       msg_noti_enabled = false;
+                               } else {
+                                       MSG_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted);
+                                       msg_noti_enabled = (is_msg_excepted) ? true : false;
+                               }
+                       } else {
+                               MSG_DEBUG("do not disturb mode is off");
+                       }
+               } else {
+                       MSG_INFO("message notification is not allowed");
+                       msg_noti_enabled = false;
+               }
+       }
+
+EXIT:
+       if (system_setting)
+               notification_system_setting_free_system_setting(system_setting);
+
+       if (setting)
+               notification_setting_free_notification(setting);
+
+#endif /* MSG_WEARABLE_PROFILE */
+       return msg_noti_enabled;
+}
 
 bool isExistAddressInReportTable(const char *addr)
 {
@@ -603,7 +721,7 @@ void MsgInitReportNotiList()
                char tempAddr[MAX_ADDRESS_VAL_LEN+1];
                memset(tempAddr, 0x00, sizeof(tempAddr));
 
-               noti_err  = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &b);
+               noti_err = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &b);
                if (noti_err != NOTIFICATION_ERROR_NONE) {
                        MSG_DEBUG("notification_get_excute_option() failed!!");
                        break;
@@ -630,7 +748,7 @@ void MsgInitReportNotiList()
        if (head_noti_list)
                notification_free_list(head_noti_list);
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
        MSG_END();
 }
 
@@ -647,10 +765,9 @@ msg_error_t MsgInitNoti()
 #ifndef MSG_NOTI_INTEGRATION
                MsgDeleteNotification(MSG_NOTI_TYPE_SIM, -1);
 #endif
-               MsgRefreshAllNotification(false, true, true);           // On Booting
+               MsgRefreshAllNotification(false, true, MSG_ACTIVE_NOTI_TYPE_INSTANT);           /* On Booting */
                MsgInitReportNotiList();
-       }
-       else {
+       } else {
                MSG_DEBUG("Notification server is not available. Init is defered");
 #ifndef MSG_NOTI_INTEGRATION
                MSG_NOTI_INFO_S *delNotiInfo = (MSG_NOTI_INFO_S *)calloc(1, sizeof(MSG_NOTI_INFO_S));
@@ -663,7 +780,7 @@ msg_error_t MsgInitNoti()
                notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL);
        }
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
        return MSG_SUCCESS;
 }
 
@@ -689,7 +806,7 @@ msg_error_t MsgDeleteNoti(msg_notification_type_t noti_type, int simIndex)
                MSG_DEBUG("Notification server is not available. Delete is defered");
                notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo);
        }
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
        return MSG_SUCCESS;
 }
 
@@ -700,10 +817,11 @@ msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg
        MSG_DEBUG("pTickerMsg=[%s], pLocaleTickerMsg=[%s]", pTickerMsg, pLocaleTickerMsg);
        MSG_DEBUG("play feedback=[%d], msgId=[%d]", bPlayFeedback, msgId);
 
-       MsgChangePmState();
+       if (MsgCheckNotificationSettingEnable())
+               MsgChangePmState();
 
        char *notiMsg = NULL;
-       bool bTicker = false;
+       msg_active_notification_type_t active_type = MSG_ACTIVE_NOTI_TYPE_NONE;
 
        notiMsg = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, pLocaleTickerMsg);
        MSG_DEBUG("notiMsg %s", notiMsg);
@@ -717,8 +835,8 @@ msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg
                        notification_status_message_post(notiMsg);
                }
        } else {
-               //Show ticker popup for sending failed msg.
-               bTicker = true;
+               /* Show ticker popup for sending failed msg. */
+               active_type = MSG_ACTIVE_NOTI_TYPE_INSTANT;
        }
 
        if (notiMsg) {
@@ -727,26 +845,25 @@ msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg
        }
 
        if (bPlayFeedback) {
-               if (msgId > 0 && \
-                       (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0))
-               {
+               if (msgId > 0 &&
+                       (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) == 0 || g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) == 0)) {
                        msg_error_t err = MSG_SUCCESS;
-                       err = MsgRefreshNotification(MSG_NOTI_TYPE_FAILED, true, bTicker);
+                       err = MsgRefreshNotification(MSG_NOTI_TYPE_FAILED, true, active_type);
                        if (err != MSG_SUCCESS) {
                                MSG_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
                        }
                } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SIM_MESSAGE_FULL) == 0) {
                        msg_error_t err = MSG_SUCCESS;
-                       err = MsgRefreshNotification(MSG_NOTI_TYPE_SIM_FULL, true, false);
+                       err = MsgRefreshNotification(MSG_NOTI_TYPE_SIM_FULL, true, MSG_ACTIVE_NOTI_TYPE_NONE);
                        if (err != MSG_SUCCESS) {
                                MSG_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
                        }
-               }
-               else {
+               } else {
                        MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_DEFAULT);
                }
        }
-#endif // MSG_WEARABLE_PROFILE
+
+#endif /* MSG_WEARABLE_PROFILE */
        return MSG_SUCCESS;
 }
 
@@ -762,7 +879,7 @@ msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt)
        err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist);
 
        if (err != BADGE_ERROR_NONE) {
-               MSG_DEBUG("Fail to badge_is_existing : %d", err);
+               MSG_ERR("Fail to badge_is_existing : %d", err);
                return MSG_ERR_UNKNOWN;
        }
 
@@ -770,7 +887,7 @@ msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt)
                /* create badge */
                err = badge_create(MSG_DEFAULT_APP_ID, "/usr/bin/msg-server");
                if (err != BADGE_ERROR_NONE) {
-                       MSG_DEBUG("Fail to badge_new : %d", err);
+                       MSG_ERR("Fail to badge_new : %d", err);
                        return MSG_ERR_UNKNOWN;
                }
        }
@@ -778,11 +895,11 @@ msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt)
        err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt);
 
        if (err != BADGE_ERROR_NONE) {
-               MSG_DEBUG("Fail to badge_set_count : %d", err);
+               MSG_ERR("Fail to badge_set_count : %d", err);
                return MSG_ERR_UNKNOWN;
        }
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
        return MSG_SUCCESS;
 }
 
@@ -790,7 +907,7 @@ msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt)
 
 void MsgRefreshNotiCb(void *data)
 {
-       MsgRefreshAllNotification(false, true, true);
+       MsgRefreshAllNotification(false, true, MSG_ACTIVE_NOTI_TYPE_INSTANT);
        MsgInitReportNotiList();
 
        if (data) {
@@ -849,48 +966,45 @@ int getPrivId(msg_notification_type_t noti_type, int sim_idx)
 
        int noti_id = 0;
 
-       switch (noti_type)
-       {
+       switch (noti_type) {
 #ifdef MSG_NOTI_INTEGRATION
-               case MSG_NOTI_TYPE_NORMAL :
-               case MSG_NOTI_TYPE_SIM :
-               case MSG_NOTI_TYPE_CB :
-                       noti_id = MsgSettingGetInt(NOTIFICATION_PRIV_ID);
-                       break;
+       case MSG_NOTI_TYPE_NORMAL:
+       case MSG_NOTI_TYPE_SIM:
+       case MSG_NOTI_TYPE_CB:
+               noti_id = MsgSettingGetInt(NOTIFICATION_PRIV_ID);
+               break;
 #else
-               case MSG_NOTI_TYPE_NORMAL :
-                       noti_id = MsgSettingGetInt(NOTIFICATION_PRIV_ID);
-                       break;
-               case MSG_NOTI_TYPE_SIM :
-                       noti_id = MsgSettingGetInt(SIM_MSG_NOTI_PRIV_ID);
-                       break;
-               case MSG_NOTI_TYPE_CB :
-                       noti_id = MsgSettingGetInt(CB_NOTI_PRIV_ID);
-                       break;
+       case MSG_NOTI_TYPE_NORMAL:
+               noti_id = MsgSettingGetInt(NOTIFICATION_PRIV_ID);
+               break;
+       case MSG_NOTI_TYPE_SIM:
+               noti_id = MsgSettingGetInt(SIM_MSG_NOTI_PRIV_ID);
+               break;
+       case MSG_NOTI_TYPE_CB:
+               noti_id = MsgSettingGetInt(CB_NOTI_PRIV_ID);
+               break;
 #endif
-               case MSG_NOTI_TYPE_FAILED :
-                       noti_id = MsgSettingGetInt(MSG_SENTFAIL_NOTI_ID);
-                       break;
-               case MSG_NOTI_TYPE_VOICE_1 :
-                       {
-                               char keyName[MAX_VCONFKEY_NAME_LEN] = {0,};
-                               snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
-                               noti_id = MsgSettingGetInt(keyName);
-                       }
-                       break;
-               case MSG_NOTI_TYPE_VOICE_2 :
-                       {
-                               char keyName[MAX_VCONFKEY_NAME_LEN] = {0,};
-                               snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
-                               noti_id = MsgSettingGetInt(keyName);
-                       }
-                       break;
-               case MSG_NOTI_TYPE_SIM_FULL :
-                       noti_id = MsgSettingGetInt(SIM_FULL_NOTI_PRIV_ID);
-                       break;
-               default :
-                       MSG_DEBUG("No matching noti type [%d]", noti_type);
-                       break;
+       case MSG_NOTI_TYPE_FAILED:
+               noti_id = MsgSettingGetInt(MSG_SENTFAIL_NOTI_ID);
+               break;
+       case MSG_NOTI_TYPE_VOICE_1: {
+               char keyName[MAX_VCONFKEY_NAME_LEN] = {0,};
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
+               noti_id = MsgSettingGetInt(keyName);
+               break;
+       }
+       case MSG_NOTI_TYPE_VOICE_2: {
+               char keyName[MAX_VCONFKEY_NAME_LEN] = {0,};
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
+               noti_id = MsgSettingGetInt(keyName);
+               break;
+       }
+       case MSG_NOTI_TYPE_SIM_FULL:
+               noti_id = MsgSettingGetInt(SIM_FULL_NOTI_PRIV_ID);
+               break;
+       default:
+               MSG_DEBUG("No matching noti type [%d]", noti_type);
+               break;
        }
 
        MSG_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx);
@@ -909,48 +1023,45 @@ void updatePrivId(msg_notification_type_t noti_type, int noti_id, int sim_idx)
 
        MSG_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx);
 
-       switch (noti_type)
-       {
+       switch (noti_type) {
 #ifdef MSG_NOTI_INTEGRATION
-               case MSG_NOTI_TYPE_NORMAL :
-               case MSG_NOTI_TYPE_SIM :
-               case MSG_NOTI_TYPE_CB :
-                       err = MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_id);
-                       break;
+       case MSG_NOTI_TYPE_NORMAL:
+       case MSG_NOTI_TYPE_SIM:
+       case MSG_NOTI_TYPE_CB:
+               err = MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_id);
+               break;
 #else
-               case MSG_NOTI_TYPE_NORMAL :
-                       err = MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_id);
-                       break;
-               case MSG_NOTI_TYPE_SIM :
-                       err = MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_id);
-                       break;
-               case MSG_NOTI_TYPE_CB :
-                       err = MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_id);
-                       break;
+       case MSG_NOTI_TYPE_NORMAL:
+               err = MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_id);
+               break;
+       case MSG_NOTI_TYPE_SIM:
+               err = MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_id);
+               break;
+       case MSG_NOTI_TYPE_CB:
+               err = MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_id);
+               break;
 #endif
-               case MSG_NOTI_TYPE_FAILED :
-                       err = MsgSettingSetInt(MSG_SENTFAIL_NOTI_ID, noti_id);
-                       break;
-               case MSG_NOTI_TYPE_VOICE_1 :
-                       {
-                               char keyName[MAX_VCONFKEY_NAME_LEN] = {0,};
-                               snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
-                               err = MsgSettingSetInt(keyName, noti_id);
-                       }
-                       break;
-               case MSG_NOTI_TYPE_VOICE_2 :
-                       {
-                               char keyName[MAX_VCONFKEY_NAME_LEN] = {0,};
-                               snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
-                               err = MsgSettingSetInt(keyName, noti_id);
-                       }
-                       break;
-               case MSG_NOTI_TYPE_SIM_FULL :
-                       err = MsgSettingSetInt(SIM_FULL_NOTI_PRIV_ID, noti_id);
-                       break;
-               default:
-                       MSG_DEBUG("No matching type [%d]", noti_type);
-                       break;
+       case MSG_NOTI_TYPE_FAILED:
+               err = MsgSettingSetInt(MSG_SENTFAIL_NOTI_ID, noti_id);
+               break;
+       case MSG_NOTI_TYPE_VOICE_1: {
+               char keyName[MAX_VCONFKEY_NAME_LEN] = {0,};
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx);
+               err = MsgSettingSetInt(keyName, noti_id);
+               break;
+       }
+       case MSG_NOTI_TYPE_VOICE_2: {
+               char keyName[MAX_VCONFKEY_NAME_LEN] = {0,};
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx);
+               err = MsgSettingSetInt(keyName, noti_id);
+               break;
+       }
+       case MSG_NOTI_TYPE_SIM_FULL:
+               err = MsgSettingSetInt(SIM_FULL_NOTI_PRIV_ID, noti_id);
+               break;
+       default:
+               MSG_DEBUG("No matching type [%d]", noti_type);
+               break;
        }
 
        if (err != MSG_SUCCESS)
@@ -960,102 +1071,102 @@ void updatePrivId(msg_notification_type_t noti_type, int noti_id, int sim_idx)
 }
 
 
-void createInfoData(MSG_NOTI_INFO_S *noti_info, bool bTicker)
+void createInfoData(MSG_NOTI_INFO_S *noti_info, msg_active_notification_type_t active_noti)
 {
        MSG_BEGIN();
 
        createServiceHandle(&noti_info->svc_h);
 
-       switch (noti_info->type)
-       {
-               case MSG_NOTI_TYPE_NORMAL :
-                       {
-                               if (noti_info->count > 1) {
-                                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
-                               } else {
-                                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
-                               }
+       switch (noti_info->type) {
+       case MSG_NOTI_TYPE_NORMAL: {
+               if (noti_info->count > 1) {
+                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
+               } else {
+                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
+               }
 
-                               setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
-                               addServiceExtraData(noti_info->svc_h, "type", "new_msg");
-                               addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
-                               addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
+               setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
+               addServiceExtraData(noti_info->svc_h, "type", "new_msg");
+               addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
+               addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message");
 
 #if 0
-                               bool bReplyPopup = false;
-                               if (MsgSettingGetBool(VCONFKEY_MESSAGE_POPUP_DISPLAY_ENABLE , &bReplyPopup) != MSG_SUCCESS) {
-                                       MSG_DEBUG("MsgSettingGetBool is failed.");
-                               }
+               bool bReplyPopup = false;
+               if (MsgSettingGetBool(VCONFKEY_MESSAGE_POPUP_DISPLAY_ENABLE , &bReplyPopup) != MSG_SUCCESS) {
+                       MSG_DEBUG("MsgSettingGetBool is failed.");
+               }
 #endif
-                               noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER;
-                       }
-                       break;
-
-               case MSG_NOTI_TYPE_CB :
-                       {
-                               if (noti_info->count > 1) {
-                                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
-                               } else {
-                                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
-                               }
+               noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER;
 
-                               setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
-                               addServiceExtraData(noti_info->svc_h, "type", "new_msg");
-                               addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
+               if (noti_info->active_noti_button_num == 0)
+                       noti_info->active_noti_button_num = 3;
+               break;
+       }
+       case MSG_NOTI_TYPE_CB: {
+               if (noti_info->count > 1) {
+                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
+               } else {
+                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
+               }
 
-                               if (bTicker)
-                                       noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
-                               else
-                                       noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
-                       }
-                       break;
+               setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
+               addServiceExtraData(noti_info->svc_h, "type", "new_msg");
+               addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
 
-               case MSG_NOTI_TYPE_SIM :
-                       {
-                               if (noti_info->count > 1) {
-                                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
-                               } else {
-                                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
-                               }
+               if (active_noti == MSG_ACTIVE_NOTI_TYPE_INSTANT)
+                       noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
+               else
+                       noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
 
-                               setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
-                               addServiceExtraData(noti_info->svc_h, "type", "new_msg");
-                               addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
+               noti_info->active_noti_button_num = 1;
+               break;
+       }
+       case MSG_NOTI_TYPE_SIM: {
+               if (noti_info->count > 1) {
+                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
+               } else {
+                       noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
+               }
 
-                               if (bTicker)
-                                       noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
-                               else
-                                       noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
-                       }
-                       break;
+               setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
+               addServiceExtraData(noti_info->svc_h, "type", "new_msg");
+               addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
 
-               case MSG_NOTI_TYPE_FAILED :
-                       {
-                               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
+               if (active_noti == MSG_ACTIVE_NOTI_TYPE_INSTANT)
+                       noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
+               else
+                       noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
 
-                               setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
-                               addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
-                               addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
+               if (noti_info->active_noti_button_num == 0)
+                       noti_info->active_noti_button_num = 3;
+               break;
+       }
+       case MSG_NOTI_TYPE_FAILED: {
+               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
 
-                               noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
-                       }
-                       break;
+               setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
+               addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg");
+               addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
 
-               case MSG_NOTI_TYPE_SIM_FULL :
-                       {
-                               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
+               noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK;
+               break;
+       }
+       case MSG_NOTI_TYPE_SIM_FULL: {
+               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
 
-                               setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
-                               addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
+               setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
+               addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting");
 
-                               noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
-                       }
+               noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
+               break;
+       }
+       default:
                break;
-
-               default :
-                       break;
        }
 
+       if (active_noti != MSG_ACTIVE_NOTI_TYPE_ACTIVE)
+               noti_info->active_noti_button_num = 0;
+
        MSG_END();
 }
 
@@ -1077,201 +1188,241 @@ void createInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info)
        createServiceHandle(&noti_info->svc_h);
        char keyName[MAX_VCONFKEY_NAME_LEN];
 
-       switch (noti_info->type)
-       {
-               case MSG_NOTI_TYPE_VOICE_1 :
-               case MSG_NOTI_TYPE_VOICE_2 :
-                       {
-                               memset(keyName, 0x00, sizeof(keyName));
-                               snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
-                               noti_info->count = MsgSettingGetInt(keyName);
-                               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
-                               noti_info->time = msg_info->displayTime;
-
-                               memset(keyName, 0x00, sizeof(keyName));
-                               snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
-                               char *voiceNumber = MsgSettingGetString(keyName);
-                               memset(keyName, 0x00, sizeof(keyName));
-                               snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
-                               char *voiceAlphaId = MsgSettingGetString(keyName);
-                               char *dialNumber = NULL;
-
-                               MSG_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
-
-                               if (voiceNumber && strlen(voiceNumber))
-                                       dialNumber = voiceNumber;
-
-                               if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
-                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
-                               } else if(dialNumber && strlen(dialNumber) > 0){
-                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
-                               }
+       switch (noti_info->type) {
+       case MSG_NOTI_TYPE_VOICE_1:
+       case MSG_NOTI_TYPE_VOICE_2: {
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx);
+               noti_info->count = MsgSettingGetInt(keyName);
+               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
+               noti_info->time = msg_info->displayTime;
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx);
+               char *voiceNumber = MsgSettingGetString(keyName);
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx);
+               char *voiceAlphaId = MsgSettingGetString(keyName);
+               char *dialNumber = NULL;
+
+               MSG_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber);
+
+               if (voiceNumber && strlen(voiceNumber))
+                       dialNumber = voiceNumber;
+
+               if (voiceAlphaId && strlen(voiceAlphaId) > 0) {
+                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId);
+               } else if (dialNumber && strlen(dialNumber) > 0) {
+                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber);
+               }
 
-                               if (dialNumber && strlen(dialNumber) > 0)
-                                       snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
+               if (dialNumber && strlen(dialNumber) > 0)
+                       snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber);
 
-                               if (noti_info->svc_h) {
-                                       char telnum[256] = {0,};
-                                       app_control_set_operation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
-                                       snprintf(telnum, sizeof(telnum), "tel:%s", noti_info->number);
-                                       app_control_set_uri(noti_info->svc_h, telnum);
-                               }
+               if (noti_info->svc_h) {
+                       setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
+                       setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
 
-                               MSG_FREE(voiceNumber);
-                               MSG_FREE(voiceAlphaId);
-                       }
-                       break;
+                       char slot_id[5] = {0,};
+                       snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
+                       addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
+               }
 
-               case MSG_NOTI_TYPE_MWI :
-               case MSG_NOTI_TYPE_CLASS0 :
-                       {
-                               noti_info->count = 1;
-                               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
-                               noti_info->time = msg_info->displayTime;
+               MSG_FREE(voiceNumber);
+               MSG_FREE(voiceAlphaId);
+               break;
+       }
+       case MSG_NOTI_TYPE_MWI:
+       case MSG_NOTI_TYPE_CLASS0: {
+               noti_info->count = 1;
+               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
+               noti_info->time = msg_info->displayTime;
 
-                               if (msg_info->addressList[0].displayName[0] == '\0')
-                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].addressVal);
-                               else
-                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].displayName);
+               if (msg_info->addressList[0].displayName[0] == '\0')
+                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].addressVal);
+               else
+                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].displayName);
 
-                               snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressList[0].addressVal);
+               snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressList[0].addressVal);
 
-                               snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
+               snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText);
 
-                               if (noti_info->type == MSG_NOTI_TYPE_MWI) {
-                                       if (noti_info->svc_h) {
-                                               char telnum[256] = {0,};
-                                               app_control_set_operation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
-                                               snprintf(telnum, sizeof(telnum), "tel:%s", noti_info->number);
-                                               app_control_set_uri(noti_info->svc_h, telnum);
-                                       }
+               if (noti_info->type == MSG_NOTI_TYPE_MWI) {
+                       if (noti_info->svc_h) {
+                               setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL);
+                               setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL);
 
-                               } else {
-                                       setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
-                                       addServiceExtraData(noti_info->svc_h, "type", "new_msg");
-                                       addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
-                               }
+                               char slot_id[5] = {0,};
+                               snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1);
+                               addServiceExtraData(noti_info->svc_h, "slot_id", slot_id);
                        }
-                       break;
 
-               case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT :
-                       {
-                               noti_info->count = 1;
-                               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
-                               noti_info->time = msg_info->displayTime;
-                               noti_info->extra_data = msg_info->networkStatus;
+               } else {
+                       setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0");
+                       addServiceExtraData(noti_info->svc_h, "type", "new_msg");
+                       addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
+               }
+               break;
+       }
+       case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT: {
+               noti_info->count = 1;
+               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
+               noti_info->time = msg_info->displayTime;
+               noti_info->extra_data = msg_info->networkStatus;
 
-                               //contacts-service is not used for gear
+/* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                               MSG_CONTACT_INFO_S contactInfo;
-                               memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
+               MSG_CONTACT_INFO_S contactInfo;
+               memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
 
-                               if (MsgGetContactInfo(&(msg_info->addressList[0]), &contactInfo) != MSG_SUCCESS) {
-                                       MSG_DEBUG("MsgGetContactInfo() fail.");
-                               }
+               if (MsgGetContactInfo(&(msg_info->addressList[0]), &contactInfo) != MSG_SUCCESS) {
+                       MSG_WARN("MsgGetContactInfo() fail.");
+               }
 
-                               snprintf(msg_info->addressList[0].displayName, sizeof(msg_info->addressList[0].displayName), "%s", contactInfo.firstName);
+               snprintf(msg_info->addressList[0].displayName, sizeof(msg_info->addressList[0].displayName), "%s", contactInfo.firstName);
 #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
 
-                               if (msg_info->addressList[0].displayName[0] == '\0')
-                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].addressVal);
-                               else
-                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].displayName);
+               if (msg_info->addressList[0].displayName[0] == '\0')
+                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].addressVal);
+               else
+                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].displayName);
 
-                               snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressList[0].addressVal);
+               snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressList[0].addressVal);
 
-                               if (noti_info->msg_id > 0) {
-                                       setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
-                                       addServiceExtraData(noti_info->svc_h, "type", "new_msg");
-                                       addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
-                                       addServiceExtraData(noti_info->svc_h, "address", msg_info->addressList[0].addressVal);
-                               }
-                       }
-                       break;
-               case MSG_NOTI_TYPE_MMS_READ_REPORT :
-               case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT :
-                       {
-                               noti_info->count = 1;
-                               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
-                               noti_info->time = msg_info->displayTime;
-
-                               //contacts-service is not used for gear
+               if (noti_info->msg_id > 0) {
+                       setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
+                       addServiceExtraData(noti_info->svc_h, "type", "new_msg");
+                       addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
+                       addServiceExtraData(noti_info->svc_h, "address", msg_info->addressList[0].addressVal);
+               }
+               break;
+       }
+       case MSG_NOTI_TYPE_MMS_READ_REPORT:
+       case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT: {
+               noti_info->count = 1;
+               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
+               noti_info->time = msg_info->displayTime;
+
+/* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                               MSG_CONTACT_INFO_S contactInfo;
-                               memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
+               MSG_CONTACT_INFO_S contactInfo;
+               memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
 
-                               if (MsgGetContactInfo(&(msg_info->addressList[0]), &contactInfo) != MSG_SUCCESS) {
-                                       MSG_DEBUG("MsgGetContactInfo() fail.");
-                               }
+               if (MsgGetContactInfo(&(msg_info->addressList[0]), &contactInfo) != MSG_SUCCESS) {
+                       MSG_WARN("MsgGetContactInfo() fail.");
+               }
 
-                               snprintf(msg_info->addressList[0].displayName, sizeof(msg_info->addressList[0].displayName), "%s", contactInfo.firstName);
+               snprintf(msg_info->addressList[0].displayName, sizeof(msg_info->addressList[0].displayName), "%s", contactInfo.firstName);
 #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
                                if (msg_info->addressList[0].displayName[0] == '\0')
                                        snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].addressVal);
                                else
                                        snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].displayName);
 
-                               snprintf(noti_info->number, sizeof(noti_info->number), "%s",msg_info->addressList[0].addressVal);
+               if (msg_info->addressList[0].displayName[0] == '\0')
+                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].addressVal);
+               else
+                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s",msg_info->addressList[0].displayName);
 
-                               MsgDbHandler *dbhandler = getDbHandle();
-                               char sqlQuery[MAX_QUERY_LEN+1];
-                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(noti_info->number, sizeof(noti_info->number), "%s",msg_info->addressList[0].addressVal);
 
-                               int report_status_type;
-                               int report_status_value;
+               MsgDbHandler *dbhandler = getDbHandle();
+               char sqlQuery[MAX_QUERY_LEN+1];
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
-                               if (noti_info->type == MSG_NOTI_TYPE_MMS_READ_REPORT) {
-                                       report_status_type = MSG_REPORT_TYPE_READ;
-                               } else {
-                                       report_status_type = MSG_REPORT_TYPE_DELIVERY;
-                               }
+               int report_status_type;
+               int report_status_value;
 
-                               char *normalNum = NULL;
-                               if (msg_info->addressList[0].addressVal[0] != '\0') {
-                                       normalNum = msg_normalize_number(msg_info->addressList[0].addressVal);
-                               }
+               if (noti_info->type == MSG_NOTI_TYPE_MMS_READ_REPORT) {
+                       report_status_type = MSG_REPORT_TYPE_READ;
+               } else {
+                       report_status_type = MSG_REPORT_TYPE_DELIVERY;
+               }
 
-                               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
-                                               "STATUS "
-                                               "FROM %s "
-                                               "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';",
-                                               MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, normalNum);
+               char *normalNum = NULL;
+               if (msg_info->addressList[0].addressVal[0] != '\0') {
+                       normalNum = msg_normalize_number(msg_info->addressList[0].addressVal);
+               }
 
-                               MSG_DEBUG("sqlQuery = [%s]", sqlQuery);
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
+                               "STATUS "
+                               "FROM %s "
+                               "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';",
+                               MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, normalNum);
 
-                               if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) {
-                                       MSG_DEBUG("prepareQuery is failed");
-                                       return;
-                               }
+               MSG_DEBUG("sqlQuery = [%s]", sqlQuery);
 
-                               if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
-                                       report_status_value = dbhandler->columnInt(0);
-                                       MSG_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
-                               } else {
-                                       MSG_DEBUG("DB Query Result Fail");
-                                       dbhandler->finalizeQuery();
-                                       return;
-                               }
+               if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) {
+                       MSG_DEBUG("prepareQuery is failed");
+                       return;
+               }
 
-                               dbhandler->finalizeQuery();
+               if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
+                       report_status_value = dbhandler->columnInt(0);
+                       MSG_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
+               } else {
+                       MSG_DEBUG("DB Query Result Fail");
+                       dbhandler->finalizeQuery();
+                       return;
+               }
 
-                               if (noti_info->msg_id > 0) {
-                                       setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
-                                       addServiceExtraData(noti_info->svc_h, "type", "new_msg");
-                                       addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
-                                       addServiceExtraData(noti_info->svc_h, "address", msg_info->addressList[0].addressVal);
-                               }
+               dbhandler->finalizeQuery();
 
-                               noti_info->extra_data = (unsigned char)report_status_value;
-                       }
-                       break;
+               if (noti_info->msg_id > 0) {
+                       setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID);
+                       addServiceExtraData(noti_info->svc_h, "type", "new_msg");
+                       addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id);
+                       addServiceExtraData(noti_info->svc_h, "address", msg_info->addressList[0].addressVal);
+               }
 
-               default:
-                       MSG_DEBUG("No matching type [%d]", noti_info->type);
-                       break;
+               noti_info->extra_data = (unsigned char)report_status_value;
+               break;
+       }
+       default:
+               MSG_DEBUG("No matching type [%d]", noti_info->type);
+               break;
        }
 
        noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK;
+       MSG_END();
+}
+
+
+void createActiveInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info)
+{
+       MSG_BEGIN();
+
+       if (!msg_info) {
+               MSG_DEBUG("msg_info is NULL");
+               return;
+       }
+
+       noti_info->msg_id = msg_info->msgId;
+       noti_info->sim_idx = msg_info->sim_idx;
+
+       switch (noti_info->type) {
+       case MSG_NOTI_TYPE_NORMAL: {
+               char *senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
+               snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr);
+               if (senderStr) {
+                       free(senderStr);
+                       senderStr = NULL;
+               }
+               break;
+       }
+       case MSG_NOTI_TYPE_CLASS0: {
+               if (msg_info->addressList[0].displayName[0] == '\0')
+                       snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressList[0].addressVal);
+               else
+                       snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressList[0].displayName);
+
+               snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText);
+               break;
+       }
+       default:
+               MSG_DEBUG("No matching type [%d]", noti_info->type);
+               break;
+       }
 
        MSG_END();
 }
@@ -1291,6 +1442,13 @@ void clearInfoData(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
                noti_info->svc_h = NULL;
        }
 
+       for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) {
+               if (noti_info->active_noti_svc_h[i]) {
+                       app_control_destroy(noti_info->active_noti_svc_h[i]);
+                       noti_info->active_noti_svc_h[i] = NULL;
+               }
+       }
+
        MSG_END();
 }
 
@@ -1301,19 +1459,19 @@ void setProperty(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
 
        int noti_err = NOTIFICATION_ERROR_NONE;
 
-       // set layout
+       /* set layout */
        noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
                MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
        }
 
-       // set led
+       /* set led */
        noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
                MSG_DEBUG("Fail to notification_set_led.");
        }
 
-       // set execute option
+       /* set execute option */
        bundle *bundle_data = NULL;
        bundle *reply_msg = NULL;
 
@@ -1323,72 +1481,62 @@ void setProperty(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
                MSG_DEBUG("bundle is NULL");
        }
 
-       // set execute option and property
-       switch (noti_info->type)
-       {
-               case MSG_NOTI_TYPE_NORMAL :
-                       {
-                               if (noti_info->count > 1) {
-                                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data);
-                                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, NULL);
-                               } else {
-                                       if (noti_info->svc_h){ // overwrite bundle key "type"
-                                               //addServiceExtraData(noti_info->svc_h, "type", "reply");
-                                               addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
-
-                                               app_control_to_bundle(noti_info->svc_h, &reply_msg);
-                                       }
-                                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
-                                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, reply_msg);
-                               }
-
-                               notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
-                       }
-                       break;
-
-               case MSG_NOTI_TYPE_CB :
-               case MSG_NOTI_TYPE_SIM :
-                       {
-                               if (noti_info->count > 1) {
-                                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data);
-                               } else {
-                                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
-                               }
-
-                               notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
-                       }
-                       break;
+       /* set execute option and property */
+       switch (noti_info->type) {
+       case MSG_NOTI_TYPE_NORMAL: {
+               if (noti_info->count > 1) {
+                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data);
+                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, NULL);
+               } else {
+                       if (noti_info->svc_h) { /* overwrite bundle key "type" */
+                               /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */
+                               addServiceExtraData(noti_info->svc_h, "show_list", "list_show");
 
-               case MSG_NOTI_TYPE_FAILED :
-                       {
-                               notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
-                               notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
+                               app_control_to_bundle(noti_info->svc_h, &reply_msg);
                        }
-                       break;
+                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
+                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, reply_msg);
+               }
 
-               case MSG_NOTI_TYPE_SIM_FULL :
-                       {
-                               notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
-                       }
-                       break;
+               notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
+               break;
+       }
+       case MSG_NOTI_TYPE_CB:
+       case MSG_NOTI_TYPE_SIM: {
+               if (noti_info->count > 1) {
+                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data);
+               } else {
+                       notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
+               }
 
-               case MSG_NOTI_TYPE_VOICE_1 :
-               case MSG_NOTI_TYPE_VOICE_2 :
-               case MSG_NOTI_TYPE_MWI :
-               case MSG_NOTI_TYPE_CLASS0 :
-               case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT :
-               case MSG_NOTI_TYPE_MMS_READ_REPORT :
-               case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT :
-                       {
-                               notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
-                       }
-                       break;
-               default:
-                       MSG_DEBUG("No matching type for notification_set_execute_option() [%d]", noti_info->type);
-                       break;
+               notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY);
+               break;
+       }
+       case MSG_NOTI_TYPE_FAILED: {
+               notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
+               notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
+               break;
+       }
+       case MSG_NOTI_TYPE_SIM_FULL: {
+               notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
+               break;
+       }
+       case MSG_NOTI_TYPE_VOICE_1:
+       case MSG_NOTI_TYPE_VOICE_2:
+       case MSG_NOTI_TYPE_MWI:
+       case MSG_NOTI_TYPE_CLASS0:
+       case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT:
+       case MSG_NOTI_TYPE_MMS_READ_REPORT:
+       case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT: {
+               notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data);
+               break;
+       }
+       default:
+               MSG_DEBUG("No matching type for notification_set_execute_option() [%d]", noti_info->type);
+               break;
        }
 
-       // set applist
+       /* set applist */
        noti_err = notification_set_display_applist(noti_h, noti_info->applist);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
                MSG_DEBUG("Fail to notification_set_display_applist");
@@ -1419,234 +1567,371 @@ void setText(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
                MSG_DEBUG("MsgSettingGetBool is failed.");
        }
 
-       // set title and content
-       switch (noti_info->type)
-       {
+       /* set title and content */
+       switch (noti_info->type) {
 #ifdef MSG_NOTI_INTEGRATION
-               case MSG_NOTI_TYPE_NORMAL :
-               case MSG_NOTI_TYPE_CB :
-               case MSG_NOTI_TYPE_SIM :
-                       {
-                               if (noti_info->count > 1) {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
-                                       setNotiTime(noti_h, noti_info->time);
-
-                                       snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
+       case MSG_NOTI_TYPE_NORMAL:
+       case MSG_NOTI_TYPE_CB:
+       case MSG_NOTI_TYPE_SIM: {
+               if (noti_info->count > 1) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+                       setNotiTime(noti_h, noti_info->time);
 
-                               } else {
-                                       if (bPreview) {
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
-                                       } else {
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
-                                       }
-                                       setNotiTime(noti_h, noti_info->time);
-                               }
+                       snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
+
+               } else {
+                       if (bPreview) {
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
+                       } else {
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
                        }
-                       break;
+                       setNotiTime(noti_h, noti_info->time);
+               }
+               break;
+       }
 #else
-               case MSG_NOTI_TYPE_NORMAL :
-                       {
-                               if (noti_info->count > 1) {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
-                                       setNotiTime(noti_h, noti_info->time);
+       case MSG_NOTI_TYPE_NORMAL: {
+               if (noti_info->count > 1) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+                       setNotiTime(noti_h, noti_info->time);
+
+                       snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
+               } else {
+                       if (bPreview) {
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
+                       } else {
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+                       }
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
+                       setNotiTime(noti_h, noti_info->time);
+               }
+               break;
+       }
+       case MSG_NOTI_TYPE_CB: {
+               if (noti_info->count > 1) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
+                       snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+                       setNotiTime(noti_h, noti_info->time);
 
-                                       snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
+               } else {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
+                       setNotiTime(noti_h, noti_info->time);
 
-                               } else {
-                                       if (bPreview) {
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
-                                       } else {
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE);
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
-                                       }
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
-                                       setNotiTime(noti_h, noti_info->time);
-                               }
+                       if (bPreview) {
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
+                       } else {
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
                        }
-                       break;
-
-               case MSG_NOTI_TYPE_CB :
-                       {
-                               if (noti_info->count > 1) {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
-                                       snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
-                                       setNotiTime(noti_h, noti_info->time);
+               }
+               break;
+       }
+       case MSG_NOTI_TYPE_SIM: {
+               if (noti_info->count > 1) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
+                       snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
 
-                               } else {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
-                                       setNotiTime(noti_h, noti_info->time);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+                       setNotiTime(noti_h, noti_info->time);
+               } else {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
+                       setNotiTime(noti_h, noti_info->time);
 
-                                       if (bPreview) {
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
-                                       } else {
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE);
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
-                                       }
-                               }
+                       if (bPreview) {
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
+                       } else {
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
+                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
                        }
-                       break;
+               }
+               break;
+       }
+#endif
+       case MSG_NOTI_TYPE_FAILED: {
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
+               if (noti_info->count > 1) {
+                       snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
+               }
+               setNotiTime(noti_h, noti_info->time);
+               break;
+       }
+       case MSG_NOTI_TYPE_VOICE_1:
+       case MSG_NOTI_TYPE_VOICE_2: {
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+               setNotiTime(noti_h, noti_info->time);
+
+               if (noti_info->count == 1) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
+               } else if (noti_info->count > 1) {
+                       snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
+               } else {
+                       MSG_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
+               }
+               break;
+       }
+       case MSG_NOTI_TYPE_MWI: {
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+               setNotiTime(noti_h, noti_info->time);
+               break;
+       }
+       case MSG_NOTI_TYPE_CLASS0: {
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+               setNotiTime(noti_h, noti_info->time);
+               break;
+       }
+       case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT: {
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
 
-               case MSG_NOTI_TYPE_SIM :
-                       {
-                               if (noti_info->count > 1) {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
-                                       snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
+               if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
+               } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
+               } else {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
+               }
 
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
-                                       setNotiTime(noti_h, noti_info->time);
-                               } else {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
-                                       setNotiTime(noti_h, noti_info->time);
+               setNotiTime(noti_h, noti_info->time);
+               break;
+       }
+       case MSG_NOTI_TYPE_MMS_READ_REPORT: {
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
 
-                                       if (bPreview) {
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL);
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL);
-                                       } else {
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE);
-                                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
-                                       }
-                               }
-                       }
-                       break;
+               if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
+               /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
+#if 0
+               } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
+                       /* notification free */
 #endif
-               case MSG_NOTI_TYPE_FAILED :
-                       {
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE);
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE);
-                               snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
-                               setNotiTime(noti_h, noti_info->time);
-                       }
-                       break;
+               } else {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
+               }
 
-               case MSG_NOTI_TYPE_VOICE_1 :
-               case MSG_NOTI_TYPE_VOICE_2 :
-                       {
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL);
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
-                               setNotiTime(noti_h, noti_info->time);
+               setNotiTime(noti_h, noti_info->time);
+               break;
+       }
+       case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT: {
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+
+               if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED)
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
+               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED)
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE);
+               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED)
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
+               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED)
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE);
+               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE)
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE);
+               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED)
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL);
+               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE)
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE);
+               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR)
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL);
+               /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */
+#if 0
+               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_NONE) {
+                       /* notification free */
+               }
+#endif
+               else
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
 
-                               if (noti_info->count == 1) {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL);
-                               } else if (noti_info->count > 1) {
-                                       snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count);
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL);
-                               } else {
-                                       MSG_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count);
-                               }
-                       }
-                       break;
+               setNotiTime(noti_h, noti_info->time);
+               break;
+       }
+       case MSG_NOTI_TYPE_SIM_FULL: {
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
+               break;
+       }
+       default:
+               MSG_DEBUG("No matching type [%d]", noti_info->type);
+               break;
+       }
 
-               case MSG_NOTI_TYPE_MWI :
-                       {
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL);
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
-                               setNotiTime(noti_h, noti_info->time);
-                       }
-                       break;
+       MSG_END();
 
-               case MSG_NOTI_TYPE_CLASS0 :
-                       {
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
-                               setNotiTime(noti_h, noti_info->time);
-                       }
-                       break;
+}
 
-               case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT :
-                       {
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE);
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+void setIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
+{
+       MSG_BEGIN();
 
-                               if(noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
-                               } else if(noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
+       switch (noti_info->type) {
+#ifdef MSG_NOTI_INTEGRATION
+       case MSG_NOTI_TYPE_NORMAL :
+       case MSG_NOTI_TYPE_CB :
+       case MSG_NOTI_TYPE_SIM :
+       {
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
+               if (noti_info->count > 1 && noti_info->senderCount > 1) {
+                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
+                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
+                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, "");
+               } else {
+                       if (noti_info->active_subtype == MSG_CB_SMS) {
+                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH);
+                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
+                       } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) {
+                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH);
+                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
+                       } else if (noti_info->active_subtype == MSG_SYNCML_CP) {
+                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
+                       } else {
+                               if (noti_info->imagePath[0] != '\0') {
+                                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath);
+                                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
                                } else {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
+                                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH);
+                                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
                                }
 
-                               setNotiTime(noti_h, noti_info->time);
+                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, MSG_MESSAGE_APP_SUB_ICON);
                        }
-                       break;
-
-               case MSG_NOTI_TYPE_MMS_READ_REPORT :
-                       {
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE);
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+               }
+               break;
+       }
+#else
+       case MSG_NOTI_TYPE_NORMAL :
+       {
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
 
-                               if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE);
-                               }
-                               //CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false
-#if 0
-                               else if (noti_info->extra_data == MSG_READ_REPORT_NONE) {
-                                       //notification free
-                               }
+               if (noti_info->count > 1) {
+                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
+               } else {
+                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
+               }
+               break;
+       }
+       case MSG_NOTI_TYPE_CB: {
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
+               break;
+       }
+       case MSG_NOTI_TYPE_SIM: {
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
+               break;
+       }
 #endif
-                               else {
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ);
-                               }
+       case MSG_NOTI_TYPE_FAILED: {
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SMS_SENDING_FAILED_ICON_PATH);
+               break;
+       }
+       case MSG_NOTI_TYPE_VOICE_1:
+       case MSG_NOTI_TYPE_VOICE_2:
+       case MSG_NOTI_TYPE_MWI: {
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
+               break;
+       }
+       case MSG_NOTI_TYPE_CLASS0:
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
+               break;
+       case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT:
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
+               break;
+       case MSG_NOTI_TYPE_MMS_READ_REPORT:
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
+               break;
+       case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT:
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
+               break;
+       case MSG_NOTI_TYPE_SIM_FULL:
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
+               break;
+       default:
+               MSG_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
+               break;
+       }
 
-                               setNotiTime(noti_h, noti_info->time);
-                       }
-                       break;
+       MSG_END();
+}
 
-               case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT :
-                       {
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE);
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL);
+void setActiveProperty(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
+{
+       MSG_BEGIN();
 
-                               if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED)
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE);
-                               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED)
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE);
-                               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED)
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE);
-                               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED)
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE);
-                               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE)
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE);
-                               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED)
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL);
-                               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE)
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE);
-                               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR)
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL);
-
-                               //CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false
-#if 0
-                               else if (noti_info->extra_data == MSG_DELIVERY_REPORT_NONE) {
-                                       //notification free
-                               }
-#endif
-                               else
-                                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE);
+       int noti_err = NOTIFICATION_ERROR_NONE;
 
-                               setNotiTime(noti_h, noti_info->time);
-                       }
-                       break;
+       /* set layout */
+       noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
+       }
 
-               case MSG_NOTI_TYPE_SIM_FULL :
-                       {
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL);
-                               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
-                       }
-                       break;
-               default:
-                       MSG_DEBUG("No matching type [%d]", noti_info->type);
-                       break;
+       /* set led */
+       noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_led.");
+       }
+
+       /* set applist */
+       noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_display_applist");
+       }
+
+       MSG_END();
+}
+
+
+void setActiveText(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
+{
+       MSG_BEGIN();
+
+       switch (noti_info->type) {
+       case MSG_NOTI_TYPE_NORMAL:
+       case MSG_NOTI_TYPE_SIM:
+       case MSG_NOTI_TYPE_CB: {
+               if (noti_info->active_subject[0] == '\0') {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
+               } else {
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL);
+                       setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL);
+               }
+               break;
+       }
+       case MSG_NOTI_TYPE_CLASS0: {
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL);
+               break;
+       }
+       default:
+               MSG_DEBUG("No matching type [%d]", noti_info->type);
+               break;
        }
 
        MSG_END();
@@ -1654,84 +1939,45 @@ void setText(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
 }
 
 
-void setIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
+void setActiveIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
 {
        MSG_BEGIN();
 
-       switch(noti_info->type)
+       switch (noti_info->type) {
+       case MSG_NOTI_TYPE_NORMAL :
+       case MSG_NOTI_TYPE_SIM :
        {
-#ifdef MSG_NOTI_INTEGRATION
-               case MSG_NOTI_TYPE_NORMAL :
-               case MSG_NOTI_TYPE_CB :
-               case MSG_NOTI_TYPE_SIM :
-                       {
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
-                       }
+               switch (noti_info->active_subtype) {
+               case MSG_CB_SMS :
+                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
                        break;
-#else
-               case MSG_NOTI_TYPE_NORMAL :
-                       {
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH);
+               case MSG_WAP_SI_SMS :
+               case MSG_WAP_SL_SMS :
+                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
+               case MSG_SYNCML_CP :
+                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
+               default :
+                       if (noti_info->imagePath[0] != '\0')
+                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
+                       else
+                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
 
-                               if (noti_info->count > 1) {
-                                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
-                               } else {
-                                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH);
-                               }
-                       }
-                       break;
-               case MSG_NOTI_TYPE_CB :
-                       {
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH);
-                       }
-                       break;
-               case MSG_NOTI_TYPE_SIM :
-                       {
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH);
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH);
-                       }
-                       break;
-#endif
-               case MSG_NOTI_TYPE_FAILED :
-                       {
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
-                       }
-                       break;
-               case MSG_NOTI_TYPE_VOICE_1 :
-               case MSG_NOTI_TYPE_VOICE_2 :
-               case MSG_NOTI_TYPE_MWI :
-                       {
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON);
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH);
-                       }
-                       break;
-               case MSG_NOTI_TYPE_CLASS0 :
-                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
-                       break;
-               case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT :
-                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
-                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
-                       break;
-               case MSG_NOTI_TYPE_MMS_READ_REPORT :
-                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
-                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
-                       break;
-               case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT :
-                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
-                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
-                       break;
-               case MSG_NOTI_TYPE_SIM_FULL :
-                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
-                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON);
-                       break;
-               default:
-                       MSG_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
-                       break;
+                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, MSG_MESSAGE_APP_SUB_ICON);
+               }
+
+               break;
+       }
+       case MSG_NOTI_TYPE_CB :
+       {
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH);
+               break;
+       }
+       case MSG_NOTI_TYPE_CLASS0 :
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
+               break;
+       default:
+               MSG_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
+               break;
        }
 
        MSG_END();
@@ -1748,52 +1994,48 @@ msg_error_t MsgInsertInstantMessage(msg_notification_type_t noti_type)
 
        setPkgName(noti, noti_type);
 
-       switch (noti_type)
-       {
-               case MSG_NOTI_TYPE_NORMAL :
-               case MSG_NOTI_TYPE_SIM :
-               case MSG_NOTI_TYPE_CB :
-               {
-                       MSG_NOTI_INFO_S noti_info;
-                       memset(&noti_info, 0x00, sizeof(MSG_NOTI_INFO_S));
-
-                       noti_info.type = noti_type;
-                       msg_err = getLatestMsgInfo(&noti_info, true);
-
-                       if (msg_err == MSG_SUCCESS) {
-                               MSG_DEBUG("Unread count [%d]", noti_info.count);
-                               if (noti_info.count == 1) {
-                                       MSG_SEC_DEBUG("noti_info.sender [%s]",noti_info.sender);
-                                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE,  noti_info.sender, NULL);
-                                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
-                               } else if (noti_info.count  > 1) {
-                                       gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
-
-                                       notiMsg = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES);
-                                       gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
-                                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
-                                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
-                                       g_free(outString);
-                                       g_free(cnt_string);
-                               }
-
-                               setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
+       switch (noti_type) {
+       case MSG_NOTI_TYPE_NORMAL:
+       case MSG_NOTI_TYPE_SIM:
+       case MSG_NOTI_TYPE_CB: {
+               MSG_NOTI_INFO_S noti_info;
+               memset(&noti_info, 0x00, sizeof(MSG_NOTI_INFO_S));
+
+               noti_info.type = noti_type;
+               msg_err = getLatestMsgInfo(&noti_info, true);
+
+               if (msg_err == MSG_SUCCESS) {
+                       MSG_DEBUG("Unread count [%d]", noti_info.count);
+                       if (noti_info.count == 1) {
+                               MSG_SEC_DEBUG("noti_info.sender [%s]",noti_info.sender);
+                               setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL);
+                               setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL);
+                       } else if (noti_info.count > 1) {
+                               gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
+
+                               notiMsg = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGE);
+                               gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
+                               setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
+                               setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
+                               g_free(outString);
+                               g_free(cnt_string);
                        }
-               }
-               break;
 
-               case MSG_NOTI_TYPE_FAILED:
-               {
-                       notiMsg = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
-                       setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
                        setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
                }
                break;
 
-               default:
-                       MSG_DEBUG("No matching type for MsgNotiType%d]", noti_type);
-                       goto _END_OF_INSTANT_NOTI;
-                       break;
+       }
+       case MSG_NOTI_TYPE_FAILED: {
+               notiMsg = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE);
+               setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL);
+               setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH);
+               break;
+       }
+       default:
+               MSG_DEBUG("No matching type for MsgNotiType%d]", noti_type);
+               goto _END_OF_INSTANT_NOTI;
+               break;
        }
 
        if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE)
@@ -1827,25 +2069,23 @@ void setPkgName(notification_h noti_h, msg_notification_type_t noti_type)
 
        int noti_err = NOTIFICATION_ERROR_NONE;
 
-       switch (noti_type)
-       {
-               case MSG_NOTI_TYPE_NORMAL :
-               case MSG_NOTI_TYPE_CB :
-               case MSG_NOTI_TYPE_SIM :
-               case MSG_NOTI_TYPE_FAILED :
-               case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT :
-               case MSG_NOTI_TYPE_MMS_READ_REPORT :
-               case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT :
-               case MSG_NOTI_TYPE_SIM_FULL :
-                       {
-                               noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
-                               if (noti_err != NOTIFICATION_ERROR_NONE)
-                                       MSG_ERR("notification_set_pkgname() is failed, [%d]", noti_err);
-                       }
-                       break;
-               default:
-                       MSG_DEBUG("No matching type for notification_set_pkgname() [%d]", noti_type);
-                       break;
+       switch (noti_type) {
+       case MSG_NOTI_TYPE_NORMAL:
+       case MSG_NOTI_TYPE_CB:
+       case MSG_NOTI_TYPE_SIM:
+       case MSG_NOTI_TYPE_FAILED:
+       case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT:
+       case MSG_NOTI_TYPE_MMS_READ_REPORT:
+       case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT:
+       case MSG_NOTI_TYPE_SIM_FULL: {
+               noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID);
+               if (noti_err != NOTIFICATION_ERROR_NONE)
+                       MSG_ERR("notification_set_pkgname() is failed, [%d]", noti_err);
+               break;
+       }
+       default:
+               MSG_DEBUG("No matching type for notification_set_pkgname() [%d]", noti_type);
+               break;
        }
 
        MSG_END();
@@ -1861,14 +2101,14 @@ void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMa
        MSG_ADDRESS_INFO_S addrInfo;
        memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
 
-       //contacts-service is not used for gear
+/* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
        MSG_CONTACT_INFO_S contactInfo;
        memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
 
        if (addressVal != NULL) {
                snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal);
-               // Get Contact Info
+               /* Get Contact Info */
                if (MsgGetContactInfo(&addrInfo, &contactInfo) != MSG_SUCCESS) {
                        MSG_DEBUG("MsgGetContactInfo() fail.");
                }
@@ -1883,7 +2123,7 @@ void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMa
        MsgSoundPlayer::instance()->MsgGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
 
        MSG_SEC_DEBUG("Sound File [%s]", msg_tone_file_path);
-#endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
 
        bool bPlaySound = false;
        bool bPlayVibration = false;
@@ -1891,14 +2131,14 @@ void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMa
 
        MsgSoundPlayer::instance()->MsgGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall);
 
-       if (!bBlockingMode) { // check blocking mode.
+       if (!bBlockingMode) { /* check blocking mode. */
                if (bPlaySound) {
-                       //contacts-service is not used for gear
+/* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
                        if (msg_tone_file_path)
                                setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path);
                        else {
-#endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
                                MSG_RINGTONE_TYPE_T ringtoneType = (MSG_RINGTONE_TYPE_T)MsgSettingGetInt(MSG_SETTING_RINGTONE_TYPE);
                                if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
                                        setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
@@ -1906,20 +2146,20 @@ void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMa
                                        setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
                        }
-#endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
                } else {
                        setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL);
                }
 
                if (bPlayVibration) {
-                       //contacts-service is not used for gear
+/* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
                        if (contactInfo.vibrationPath[0] == '\0')
                                setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
                        else
                                setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath);
-#endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                       } else {
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
+               } else {
                        setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL);
                }
        } else {
@@ -1930,12 +2170,103 @@ void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMa
 }
 
 
+void setActiveNotification(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
+{
+       MSG_BEGIN();
+
+       int noti_err = NOTIFICATION_ERROR_NONE;
+
+       setPkgName(noti_h, noti_info->type);
+
+       setActiveProperty(noti_h, noti_info);
+
+       setTextDomain(noti_h, noti_info->type);
+
+       setActiveText(noti_h, noti_info);
+
+       setActiveIcon(noti_h, noti_info);
+
+       if (noti_info->active_noti_button_num > 1) {
+               createServiceHandle(&noti_info->active_noti_svc_h[0]);
+               if (noti_info->active_noti_svc_h[0]) {
+                       setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID);
+                       setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL);
+
+                       MSG_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id);
+
+                       char tel_num[MSG_NOTI_TEXT_LEN_S] = {0,};
+                       snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number);
+                       MSG_SEC_DEBUG("Active sender number [%s]", noti_info->number);
+                       setServiceUri(noti_info->active_noti_svc_h[0], tel_num);
+               }
+
+               createServiceHandle(&noti_info->active_noti_svc_h[1]);
+               if (noti_info->active_noti_svc_h[1]) {
+                       setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
+
+                       MSG_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
+                       addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
+                       addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
+
+                       char slot_id[5] = {0,};
+                       snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
+                       addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
+               }
+       }
+
+       createServiceHandle(&noti_info->active_noti_svc_h[2]);
+       if (noti_info->active_noti_svc_h[2]) {
+               setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID);
+
+               MSG_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id);
+               addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg");
+               addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id);
+               addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti");
+
+               char slot_id[5] = {0,};
+               snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
+               addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id);
+       }
+
+       if (noti_info->active_noti_button_num > 1) {
+               setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
+               setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
+               setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
+
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL);
+       } else {
+               setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]);
+
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL);
+       }
+
+       noti_err = notification_post(noti_h);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_post");
+       }
+
+       MSG_END();
+}
+
+
 void setNotification(notification_h noti_h, MSG_NOTI_INFO_S *noti_info, bool bFeedback)
 {
        MSG_BEGIN();
 
        int noti_err = NOTIFICATION_ERROR_NONE;
 
+       if (bFeedback && noti_info->active_noti_button_num > 0 &&
+               ((noti_info->type >= MSG_NOTI_TYPE_NORMAL && noti_info->type <= MSG_NOTI_TYPE_SIM) || noti_info->type == MSG_NOTI_TYPE_CLASS0)) {
+               notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI);
+
+               setActiveNotification(active_noti_h, noti_info);
+
+               notification_free(active_noti_h);
+               active_noti_h = NULL;
+       }
+
        setPkgName(noti_h, noti_info->type);
 
        setProperty(noti_h, noti_info);
@@ -1985,567 +2316,623 @@ msg_error_t getLatestMsgInfo(MSG_NOTI_INFO_S *noti_info, bool isForInstantMessag
        int noti_err = NOTIFICATION_ERROR_NONE;
        msg_error_t msg_err = MSG_SUCCESS;
 
-       switch (noti_info->type)
-       {
+       switch (noti_info->type) {
+       case MSG_NOTI_TYPE_NORMAL:
 #ifdef MSG_NOTI_INTEGRATION
-               case MSG_NOTI_TYPE_NORMAL :
-               case MSG_NOTI_TYPE_CB :
-               case MSG_NOTI_TYPE_SIM :
-#else
-               case MSG_NOTI_TYPE_NORMAL :
+       case MSG_NOTI_TYPE_CB:
+       case MSG_NOTI_TYPE_SIM:
 #endif
-                       {
-                               int smsUnreadCnt = 0;
-                               int mmsUnreadCnt = 0;
+       {
+               int smsUnreadCnt = 0;
+               int mmsUnreadCnt = 0;
 
-                               char sqlQuery[MAX_QUERY_LEN+1];
-                               MSG_MAIN_TYPE_T mainType;
-                               MSG_SUB_TYPE_T subType;
+               char sqlQuery[MAX_QUERY_LEN+1];
+               MSG_MAIN_TYPE_T mainType;
+               MSG_SUB_TYPE_T subType;
+               int msgSize;
 
-                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
 #ifdef MSG_NOTI_INTEGRATION
-                               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT "
-                                               "A.ADDRESS_VAL, "
-                                               "B.SUB_TYPE "
-                                               "FROM %s A, %s B "
-                                               "WHERE A.CONV_ID=B.CONV_ID "
-                                               "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
-                                               "AND B.STORAGE_ID = %d  "
-                                               "GROUP BY A.ADDRESS_VAL "
-                                               "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
-                                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
-                                               MSG_INBOX_ID, MSG_CBMSGBOX_ID,
-                                               MSG_STORAGE_PHONE);
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT "
+                               "A.ADDRESS_VAL, "
+                               "B.SUB_TYPE "
+                               "FROM %s A, %s B "
+                               "WHERE A.CONV_ID=B.CONV_ID "
+                               "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
+                               "AND B.STORAGE_ID = %d "
+                               "GROUP BY A.ADDRESS_VAL "
+                               "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
+                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
+                               MSG_INBOX_ID, MSG_CBMSGBOX_ID,
+                               MSG_STORAGE_PHONE);
 #else
-                               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT "
-                                               "A.ADDRESS_VAL, "
-                                               "B.SUB_TYPE "
-                                               "FROM %s A, %s B "
-                                               "WHERE A.CONV_ID=B.CONV_ID "
-                                               "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
-                                               "AND B.STORAGE_ID = %d  "
-                                               "GROUP BY A.ADDRESS_VAL "
-                                               "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
-                                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
-                                               MSG_INBOX_ID,
-                                               MSG_STORAGE_PHONE);
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT "
+                               "A.ADDRESS_VAL, "
+                               "B.SUB_TYPE "
+                               "FROM %s A, %s B "
+                               "WHERE A.CONV_ID=B.CONV_ID "
+                               "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
+                               "AND B.STORAGE_ID = %d "
+                               "GROUP BY A.ADDRESS_VAL "
+                               "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;",
+                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
+                               MSG_INBOX_ID,
+                               MSG_STORAGE_PHONE);
 #endif
-                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
 
-                               int rowCnt = 0, index = 0;
+               int rowCnt = 0, index = 0;
 
-                               msg_err = dbhandler->getTable(sqlQuery, &rowCnt, &index);
-                               MSG_DEBUG("getTable() ret=[%d], rowCnt=[%d]", msg_err, rowCnt);
+               msg_err = dbhandler->getTable(sqlQuery, &rowCnt, &index);
+               MSG_DEBUG("getTable() ret=[%d], rowCnt=[%d]", msg_err, rowCnt);
 
-                               //contacts-service is not used for gear
+/* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                               MSG_ADDRESS_INFO_S tmpAddressInfo;
-
-                               for (int i = 1; i <= rowCnt; i++) {
-                                       memset(&tmpAddressInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
-                                       char *address = dbhandler->getColumnToString(index++);
-                                       if (address) {
-                                               snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
-                                               if (msg_is_valid_email(address)) {
-                                                       tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
-                                               } else {
-                                                       tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
-                                               }
-                                       }
-                                       subType = dbhandler->getColumnToInt(index++);
+               MSG_ADDRESS_INFO_S tmpAddressInfo;
+               int normalAddCnt = 0;
+
+               for (int i = 1; i <= rowCnt; i++) {
+                       memset(&tmpAddressInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+                       char *address = dbhandler->getColumnToString(index++);
+                       normalAddCnt++;
+                       if (address) {
+                               snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address);
+                               if (msg_is_valid_email(address)) {
+                                       tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL;
+                               } else {
+                                       tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN;
+                               }
+                       }
+                       subType = dbhandler->getColumnToInt(index++);
 
-                                       MSG_CONTACT_INFO_S tmpContact;
-                                       memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
+                       MSG_CONTACT_INFO_S tmpContact;
+                       memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
 
-                                       MsgGetContactInfo(&tmpAddressInfo, &tmpContact);
+                       MsgGetContactInfo(&tmpAddressInfo, &tmpContact);
 
-                                       if (rowCnt == 1) {
-                                               snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
-                                       }
+                       if (rowCnt == 1) {
+                               snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
+                       }
 
-                                       if (i > 1) {
-                                               g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                       }
+                       if (normalAddCnt > 1) {
+                               g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender));
+                       }
 
-                                       if (tmpContact.firstName[0] != '\0')
-                                               g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                       else if (tmpAddressInfo.addressVal[0] == '\0') {
-                                               char *senderStr = NULL;
-                                               senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
-                                               g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                               if (senderStr) {
-                                                       free(senderStr);
-                                                       senderStr = NULL;
-                                               }
-                                       } else {
-                                               char *senderStr = NULL;
-                                               if (subType == MSG_CB_SMS) {
-                                                       senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
-                                                       g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                               } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
-                                                       senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
-                                                       g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                               } else {
-                                                       g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                               }
-                                               if (senderStr) {
-                                                       free(senderStr);
-                                                       senderStr = NULL;
-                                               }
-                                       }
+                       if (tmpContact.firstName[0] != '\0') {
+                               g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender));
+                       } else if (tmpAddressInfo.addressVal[0] == '\0') {
+                               char *senderStr = NULL;
+                               senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
+                               g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
+                               if (senderStr) {
+                                       free(senderStr);
+                                       senderStr = NULL;
                                }
-#endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                               dbhandler->freeTable();
 
-                               MSG_SEC_DEBUG("sender info = [%s]", noti_info->sender);
+                               if (i == 1) {
+                                       noti_info->active_noti_button_num = 1;
+                               }
+                       } else {
+                               char *senderStr = NULL;
+                               if (subType == MSG_CB_SMS) {
+                                       senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE);
+                                       g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
+                                       noti_info->active_noti_button_num = 1;
+                               } else if (subType == MSG_SYNCML_CP) {
+                                       senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE);
+                                       g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
+                                       noti_info->active_noti_button_num = 1;
+                               } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) {
+                                       senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE);
+                                       g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
+                                       noti_info->active_noti_button_num = 1;
+                               } else {
+                                       g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender));
+                               }
+
+                               if (senderStr) {
+                                       free(senderStr);
+                                       senderStr = NULL;
+                               }
+                       }
+
+                       if (i == 1) {
+                               noti_info->active_subtype = subType;
+                               snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender);
+                               snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath);
+                       }
+               }
+
+               noti_info->senderCount = normalAddCnt;
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
+               dbhandler->freeTable();
 
-                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               MSG_SEC_DEBUG("sender info = [%s]", noti_info->sender);
+
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
 #ifdef MSG_NOTI_INTEGRATION
-                               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
-                                               "A.ADDRESS_VAL, "
-                                               "B.DISPLAY_TIME, "
-                                               "B.MSG_ID, "
-                                               "B.SUBJECT, "
-                                               "B.MSG_TEXT, "
-                                               "B.MAIN_TYPE, "
-                                               "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
-                                               "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
-                                               "FROM %s A, %s B "
-                                               "WHERE A.CONV_ID=B.CONV_ID "
-                                               "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
-                                               "AND B.STORAGE_ID = %d  "
-                                               "ORDER BY B.DISPLAY_TIME DESC;",
-                                               MSG_SMS_TYPE,
-                                               MSG_MMS_TYPE,
-                                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
-                                               MSG_INBOX_ID, MSG_CBMSGBOX_ID,
-                                               MSG_STORAGE_PHONE);
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
+                               "A.ADDRESS_VAL, "
+                               "B.DISPLAY_TIME, "
+                               "B.MSG_ID, "
+                               "B.SUBJECT, "
+                               "B.MSG_TEXT, "
+                               "B.MAIN_TYPE, "
+                               "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
+                               "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT, "
+                               "(CASE WHEN B.MAIN_TYPE = %d AND B.NETWORK_STATUS = %d THEN (SELECT C.MSG_SIZE FROM %s C WHERE B.MSG_ID = C.MSG_ID) ELSE -1 END) "
+                               "FROM %s A, %s B "
+                               "WHERE A.CONV_ID=B.CONV_ID "
+                               "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
+                               "AND B.STORAGE_ID = %d "
+                               "ORDER BY B.DISPLAY_TIME DESC;",
+                               MSG_SMS_TYPE,
+                               MSG_MMS_TYPE,
+                               MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME,
+                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
+                               MSG_INBOX_ID, MSG_CBMSGBOX_ID,
+                               MSG_STORAGE_PHONE);
 #else
-                               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
-                                               "A.ADDRESS_VAL, "
-                                               "B.DISPLAY_TIME, "
-                                               "B.MSG_ID, "
-                                               "B.SUBJECT, "
-                                               "B.MSG_TEXT, "
-                                               "B.MAIN_TYPE, "
-                                               "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
-                                               "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
-                                               "FROM %s A, %s B "
-                                               "WHERE A.CONV_ID=B.CONV_ID "
-                                               "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
-                                               "AND B.STORAGE_ID = %d  "
-                                               "ORDER BY B.DISPLAY_TIME DESC;",
-                                               MSG_SMS_TYPE,
-                                               MSG_MMS_TYPE,
-                                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
-                                               MSG_INBOX_ID,
-                                               MSG_STORAGE_PHONE);
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
+                               "A.ADDRESS_VAL, "
+                               "B.DISPLAY_TIME, "
+                               "B.MSG_ID, "
+                               "B.SUBJECT, "
+                               "B.MSG_TEXT, "
+                               "B.MAIN_TYPE, "
+                               "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, "
+                               "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT "
+                               "FROM %s A, %s B "
+                               "WHERE A.CONV_ID=B.CONV_ID "
+                               "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
+                               "AND B.STORAGE_ID = %d "
+                               "ORDER BY B.DISPLAY_TIME DESC;",
+                               MSG_SMS_TYPE,
+                               MSG_MMS_TYPE,
+                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
+                               MSG_INBOX_ID,
+                               MSG_STORAGE_PHONE);
 #endif
-                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
 
-                               if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
-                                       return MSG_ERR_DB_PREPARE;
+               if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_PREPARE;
 
-                               if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
+               if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
 
-                                       smsUnreadCnt = dbhandler->columnInt(6);
-                                       mmsUnreadCnt = dbhandler->columnInt(7);
+                       smsUnreadCnt = dbhandler->columnInt(6);
+                       mmsUnreadCnt = dbhandler->columnInt(7);
+                       msgSize = dbhandler->columnInt(8);
 
-                                       noti_info->count = smsUnreadCnt + mmsUnreadCnt;
+                       noti_info->count = smsUnreadCnt + mmsUnreadCnt;
 
-                                       if (noti_info->count > 0) {
-                                               snprintf(noti_info->number, sizeof(noti_info->number), "%s", (char*)dbhandler->columnText(0));
+                       if (noti_info->count > 0) {
+                               snprintf(noti_info->number, sizeof(noti_info->number), "%s", (char*)dbhandler->columnText(0));
 
-                                               noti_info->time = (time_t)dbhandler->columnInt(1);
+                               noti_info->time = (time_t)dbhandler->columnInt(1);
 
-                                               noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
+                               noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
 
-                                               mainType = (MSG_MAIN_TYPE_T)dbhandler->columnInt(5);
+                               mainType = (MSG_MAIN_TYPE_T)dbhandler->columnInt(5);
 
-                                               if (mainType == MSG_MMS_TYPE) {
-                                                       snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
-                                                       if (noti_info->text[0] == '\0') {
-                                                               char *noti_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
-                                                               snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
-                                                               g_free(noti_text);
-                                                       }
-                                               } else {
-                                                       snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(4));
-                                               }
+                               if (mainType == MSG_MMS_TYPE) {
+                                       snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
+                                       if (noti_info->text[0] == '\0') {
+                                               char *noti_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT);
+                                               snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text);
+                                               g_free(noti_text);
+                                       }
 
-                                               MSG_DEBUG("unread message ID [%d].", noti_info->msg_id);
-
-                                               if (!isForInstantMessage) {
-                                                       if (noti_info->id > 0 && noti_info->count == 1 ) {
-                                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
-                                                               if (noti_err != NOTIFICATION_ERROR_NONE) {
-                                                                       MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
-                                                               }
-                                                               noti_info->id = 0;
-                                                               if (MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_info->id) != MSG_SUCCESS)
-                                                                       MSG_DEBUG("MsgSettingSetInt fail : NOTIFICATION_PRIV_ID");
-                                                       }
-                                                       MsgSettingHandleNewMsg(smsUnreadCnt, mmsUnreadCnt);
-                                                       MsgInsertBadge(noti_info->count);
-                                                       MsgSoundSetRepeatAlarm();
-                                               }
+                                       char *prefix_subject = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON);
+                                       if (prefix_subject) {
+                                               snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text);
+                                               g_free(prefix_subject);
                                        } else {
+                                               snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text);
+                                       }
+
+                                       if (msgSize > -1) {
+                                               int kb_msg_size = msgSize / 1024;
+                                               if (kb_msg_size == 0 && msgSize > 0)
+                                                       kb_msg_size = 1;
+                                               else if (msgSize % 1024 >= 512)
+                                                       kb_msg_size++;
+
+                                               char *msg_size_string = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING);
+                                               char *msg_size_unit_kb = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB);
 
-                                               MSG_DEBUG("No unread message.");
-                                               MSG_DEBUG("notiPrivId [%d]", noti_info->id);
+                                               snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb);
 
-                                               dbhandler->finalizeQuery();
+                                               g_free(msg_size_string);
+                                               g_free(msg_size_unit_kb);
+                                       }
+
+                               } else {
+                                       snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(4));
+                               }
 
-                                               if (!isForInstantMessage) {
-                                                       // No unread message.
-                                                       if (noti_info->id > 0) {
-                                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
-                                                               if (noti_err != NOTIFICATION_ERROR_NONE) {
-                                                                       MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
-                                                               }
-                                                       }
+                               if (noti_info->active_text[0] == '\0')
+                                       snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", (char*)dbhandler->columnText(4));
 
-                                                       noti_info->id = 0;
+                               MSG_DEBUG("unread message ID [%d].", noti_info->msg_id);
 
-                                                       if(MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_info->id) != MSG_SUCCESS)
-                                                               MSG_DEBUG("MsgSettingSetInt fail : NOTIFICATION_PRIV_ID");
+                               MSG_DEBUG("active sender [%s]", noti_info->active_sender);
+                               MSG_DEBUG("active subject [%s]", noti_info->active_subject);
+                               MSG_DEBUG("active text [%s]", noti_info->active_text);
 
-                                                       MsgSettingHandleNewMsg(0,0);
-                                                       MsgInsertBadge(0);
-                                                       MsgSoundSetRepeatAlarm();
+                               if (!isForInstantMessage) {
+                                       if (noti_info->id > 0 && noti_info->count == 1) {
+                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                                                       MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
                                                }
 
-                                               return MSG_ERR_DB_STEP;
+                                               noti_info->id = 0;
+                                               if (MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_info->id) != MSG_SUCCESS)
+                                                       MSG_DEBUG("MsgSettingSetInt fail : NOTIFICATION_PRIV_ID");
                                        }
-                               } else {
-                                       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
-                                       dbhandler->finalizeQuery();
-                                       return MSG_ERR_DB_STEP;
+                                       MsgSettingHandleNewMsg(smsUnreadCnt, mmsUnreadCnt);
+                                       MsgInsertBadge(noti_info->count);
+                                       MsgSoundSetRepeatAlarm();
                                }
+                       } else {
+
+                               MSG_DEBUG("No unread message.");
+                               MSG_DEBUG("notiPrivId [%d]", noti_info->id);
 
                                dbhandler->finalizeQuery();
-                       }
-                       break;
 
-#ifndef MSG_NOTI_INTEGRATION
-               case MSG_NOTI_TYPE_CB :
-                       {
-                               char sqlQuery[MAX_QUERY_LEN+1];
-                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
-                               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
-                                               "A.ADDRESS_VAL, "
-                                               "B.DISPLAY_TIME, "
-                                               "B.MSG_ID, "
-                                               "B.MSG_TEXT "
-                                               "FROM %s A, %s B "
-                                               "WHERE A.CONV_ID=B.CONV_ID "
-                                               "AND B.READ_STATUS=0 "
-                                               "AND B.FOLDER_ID=%d "
-                                               "AND B.STORAGE_ID = %d "
-                                               "ORDER BY B.DISPLAY_TIME DESC;",
-                                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
-                                               MSG_CBMSGBOX_ID,
-                                               MSG_STORAGE_PHONE);
-
-                               if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
-                                       return MSG_ERR_DB_PREPARE;
-
-                               if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
-                                       MSG_ADDRESS_INFO_S addrInfo;
-                                       memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
-                                       if (dbhandler->columnText(0) != NULL)
-                                               snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
-
-                                       MSG_CONTACT_INFO_S tmpContact;
-                                       memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
-
-                                       MsgGetContactInfo(&addrInfo, &tmpContact);
-
-                                       if (tmpContact.firstName[0] != '\0') {
-                                               snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
-                                       } else if (addrInfo.addressVal[0] == '\0') {
-                                               char *senderStr = NULL;
-                                               senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
-                                               g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                               if (senderStr) {
-                                                       free(senderStr);
-                                                       senderStr = NULL;
+                               if (!isForInstantMessage) {
+                                       /* No unread message. */
+                                       if (noti_info->id > 0) {
+                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                                                       MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
                                                }
-                                       } else {
-                                               snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
                                        }
 
-                                       snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
+                                       noti_info->id = 0;
 
-                                       noti_info->time = (time_t)dbhandler->columnInt(1);
+                                       if (MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_info->id) != MSG_SUCCESS)
+                                               MSG_DEBUG("MsgSettingSetInt fail : NOTIFICATION_PRIV_ID");
 
-                                       noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
+                                       MsgSettingHandleNewMsg(0,0);
+                                       MsgInsertBadge(0);
+                                       MsgSoundSetRepeatAlarm();
+                               }
 
-                                       snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
+                               return MSG_ERR_DB_STEP;
+                       }
+               } else {
+                       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+                       dbhandler->finalizeQuery();
+                       return MSG_ERR_DB_STEP;
+               }
 
-                                       MSG_DEBUG("unread CB message [%d].", noti_info->msg_id);
-                               } else {
+               dbhandler->finalizeQuery();
+               break;
+       }
 
-                                       MSG_DEBUG("No unread CB message.");
-                                       MSG_DEBUG("notiCbId [%d]", noti_info->id);
+#ifndef MSG_NOTI_INTEGRATION
+       case MSG_NOTI_TYPE_CB: {
+               char sqlQuery[MAX_QUERY_LEN+1];
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
+                               "A.ADDRESS_VAL, "
+                               "B.DISPLAY_TIME, "
+                               "B.MSG_ID, "
+                               "B.MSG_TEXT "
+                               "FROM %s A, %s B "
+                               "WHERE A.CONV_ID=B.CONV_ID "
+                               "AND B.READ_STATUS=0 "
+                               "AND B.FOLDER_ID=%d "
+                               "AND B.STORAGE_ID = %d "
+                               "ORDER BY B.DISPLAY_TIME DESC;",
+                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
+                               MSG_CBMSGBOX_ID,
+                               MSG_STORAGE_PHONE);
+
+               if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_PREPARE;
+
+               if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
+                       MSG_ADDRESS_INFO_S addrInfo;
+                       memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+                       if (dbhandler->columnText(0) != NULL)
+                               snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
+
+                       MSG_CONTACT_INFO_S tmpContact;
+                       memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
+
+                       MsgGetContactInfo(&addrInfo, &tmpContact);
+
+                       if (tmpContact.firstName[0] != '\0') {
+                               snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
+                       } else if (addrInfo.addressVal[0] == '\0') {
+                               char *senderStr = NULL;
+                               senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
+                               g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
+                               if (senderStr) {
+                                       free(senderStr);
+                                       senderStr = NULL;
+                               }
+                       } else {
+                               snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
+                       }
 
-                                       dbhandler->finalizeQuery();
+                       snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
 
-                                       if (!isForInstantMessage) {
-                                               // No unread message.
-                                               if (noti_info->id > 0) {
-                                                       noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
-                                                       if (noti_err != NOTIFICATION_ERROR_NONE) {
-                                                               MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
-                                                       }
-                                               }
+                       noti_info->time = (time_t)dbhandler->columnInt(1);
 
-                                               noti_info->id = 0;
+                       noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
 
-                                               if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
-                                                       MSG_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
-                                       }
+                       snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
 
-                                       return MSG_ERR_DB_STEP;
-                               }
+                       MSG_DEBUG("unread CB message [%d].", noti_info->msg_id);
+               } else {
+                       MSG_DEBUG("No unread CB message.");
+                       MSG_DEBUG("notiCbId [%d]", noti_info->id);
 
-                               dbhandler->finalizeQuery();
+                       dbhandler->finalizeQuery();
 
-                               if (dbhandler->getTable(sqlQuery, &noti_info->count, NULL) != MSG_SUCCESS) {
-                                       MSG_DEBUG("getTable is failed");
-                                       dbhandler->freeTable();
-                                       return MSG_ERR_DB_GETTABLE;
+                       if (!isForInstantMessage) {
+                               /* No unread message. */
+                               if (noti_info->id > 0) {
+                                       noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                       if (noti_err != NOTIFICATION_ERROR_NONE) {
+                                               MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
+                                       }
                                }
 
-                               dbhandler->freeTable();
-                               MSG_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
+                               noti_info->id = 0;
+
+                               if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
+                                       MSG_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
                        }
-                       break;
+                       return MSG_ERR_DB_STEP;
+               }
 
-               case MSG_NOTI_TYPE_SIM :
-                       {
-                               char sqlQuery[MAX_QUERY_LEN+1];
-                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
-                               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
-                                               "A.ADDRESS_VAL, "
-                                               "B.DISPLAY_TIME, "
-                                               "B.MSG_ID, "
-                                               "B.MSG_TEXT, "
-                                               "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
-                                               "FROM %s A, %s B "
-                                               "WHERE A.CONV_ID=B.CONV_ID "
-                                               "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
-                                               "AND B.STORAGE_ID = %d "
-                                               "ORDER BY B.DISPLAY_TIME DESC;",
-                                               MSG_SMS_TYPE,
-                                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
-                                               MSG_INBOX_ID,
-                                               MSG_STORAGE_SIM);
-
-                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
-
-                               if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
-                                       return MSG_ERR_DB_PREPARE;
-
-                               if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
-
-                                       noti_info->count = dbhandler->columnInt(4);
-
-                                       if (noti_info->count > 0) {
-                                               MSG_ADDRESS_INFO_S addrInfo;
-                                               memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
-                                               if (dbhandler->columnText(0) != NULL)
-                                                       snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
-
-                                               MSG_CONTACT_INFO_S tmpContact;
-                                               memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
-
-                                               MsgGetContactInfo(&addrInfo, &tmpContact);
-
-                                               if (tmpContact.firstName[0] != '\0') {
-                                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
-                                               } else if (addrInfo.addressVal[0] == '\0') {
-                                                       char *senderStr = NULL;
-                                                       senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
-                                                       g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                                       if (senderStr) {
-                                                               free(senderStr);
-                                                               senderStr = NULL;
-                                                       }
-                                               } else {
-                                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
-                                               }
+               dbhandler->finalizeQuery();
 
-                                               snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
+               if (dbhandler->getTable(sqlQuery, &noti_info->count, NULL) != MSG_SUCCESS) {
+                       MSG_DEBUG("getTable is failed");
+                       dbhandler->freeTable();
+                       return MSG_ERR_DB_GETTABLE;
+               }
 
-                                               noti_info->time = (time_t)dbhandler->columnInt(1);
+               dbhandler->freeTable();
+               MSG_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count);
+               break;
+       }
+       case MSG_NOTI_TYPE_SIM: {
+               char sqlQuery[MAX_QUERY_LEN+1];
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
+                               "A.ADDRESS_VAL, "
+                               "B.DISPLAY_TIME, "
+                               "B.MSG_ID, "
+                               "B.MSG_TEXT, "
+                               "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT "
+                               "FROM %s A, %s B "
+                               "WHERE A.CONV_ID=B.CONV_ID "
+                               "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
+                               "AND B.STORAGE_ID = %d "
+                               "ORDER BY B.DISPLAY_TIME DESC;",
+                               MSG_SMS_TYPE,
+                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
+                               MSG_INBOX_ID,
+                               MSG_STORAGE_SIM);
+
+               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+
+               if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_PREPARE;
+
+               if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
+
+                       noti_info->count = dbhandler->columnInt(4);
+
+                       if (noti_info->count > 0) {
+                               MSG_ADDRESS_INFO_S addrInfo;
+                               memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+                               if (dbhandler->columnText(0) != NULL)
+                                       snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
+
+                               MSG_CONTACT_INFO_S tmpContact;
+                               memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
+
+                               MsgGetContactInfo(&addrInfo, &tmpContact);
+
+                               if (tmpContact.firstName[0] != '\0') {
+                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
+                               } else if (addrInfo.addressVal[0] == '\0') {
+                                       char *senderStr = NULL;
+                                       senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
+                                       g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
+                                       if (senderStr) {
+                                               free(senderStr);
+                                               senderStr = NULL;
+                                       }
+                               } else {
+                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
+                               }
 
-                                               noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
+                               snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
 
-                                               snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
+                               noti_info->time = (time_t)dbhandler->columnInt(1);
 
-                                               MSG_DEBUG("unread SIM message [%d].", noti_info->msg_id);
-                                       } else {
+                               noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
 
-                                               MSG_DEBUG("No unread SIM message.");
-                                               MSG_DEBUG("notiPrivId [%d]", noti_info->id);
+                               snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
 
-                                               dbhandler->finalizeQuery();
+                               MSG_DEBUG("unread SIM message [%d].", noti_info->msg_id);
+                       } else {
 
-                                               if (!isForInstantMessage) {
-                                                       // No unread message.
-                                                       if (noti_info->id > 0) {
-                                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
-                                                               if (noti_err != NOTIFICATION_ERROR_NONE) {
-                                                                       MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
-                                                               }
-                                                       }
+                               MSG_DEBUG("No unread SIM message.");
+                               MSG_DEBUG("notiPrivId [%d]", noti_info->id);
 
-                                                       noti_info->id = 0;
+                               dbhandler->finalizeQuery();
 
-                                                       if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
-                                                               MSG_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
+                               if (!isForInstantMessage) {
+                                       /* No unread message. */
+                                       if (noti_info->id > 0) {
+                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                                                       MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
                                                }
-
-                                               return MSG_ERR_DB_STEP;
                                        }
-                               } else {
-                                       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
-                                       dbhandler->finalizeQuery();
-                                       return MSG_ERR_DB_STEP;
+
+                                       noti_info->id = 0;
+
+                                       if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS)
+                                               MSG_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID");
                                }
 
-                               dbhandler->finalizeQuery();
+                               return MSG_ERR_DB_STEP;
                        }
-                       break;
+               } else {
+                       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+                       dbhandler->finalizeQuery();
+                       return MSG_ERR_DB_STEP;
+               }
+
+               dbhandler->finalizeQuery();
+               break;
+       }
 #endif
-               case MSG_NOTI_TYPE_FAILED :
-                       {
-                               MSG_MAIN_TYPE_T mainType;
-                               char sqlQuery[MAX_QUERY_LEN+1];
-                               memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
-                               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
-                                               "A.ADDRESS_VAL, "
-                                               "B.DISPLAY_TIME, "
-                                               "B.MSG_ID, "
-                                               "B.MSG_TEXT, "
-                                               "B.SUBJECT, "
-                                               "B.MAIN_TYPE, "
-                                               "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
-                                               "FROM %s A, %s B "
-                                               "WHERE A.CONV_ID=B.CONV_ID "
-                                               "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
-                                               "AND B.STORAGE_ID = %d  "
-                                               "ORDER BY B.DISPLAY_TIME DESC;",
-                                               MSG_NETWORK_SEND_FAIL,
-                                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
-                                               MSG_OUTBOX_ID,
-                                               MSG_STORAGE_PHONE);
-
-                               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
-
-                               if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
-                                       return MSG_ERR_DB_PREPARE;
-
-                               if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
-
-                                       noti_info->count = dbhandler->columnInt(6);
-
-                                       if (noti_info->count > 0) {
-                                               MSG_ADDRESS_INFO_S addrInfo;
-                                               memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
-                                               if (dbhandler->columnText(0) != NULL)
-                                                       snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
-
-                                               //contacts-service is not used for gear
+       case MSG_NOTI_TYPE_FAILED: {
+               MSG_MAIN_TYPE_T mainType;
+               char sqlQuery[MAX_QUERY_LEN+1];
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
+                               "A.ADDRESS_VAL, "
+                               "B.DISPLAY_TIME, "
+                               "B.MSG_ID, "
+                               "B.MSG_TEXT, "
+                               "B.SUBJECT, "
+                               "B.MAIN_TYPE, "
+                               "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT "
+                               "FROM %s A, %s B "
+                               "WHERE A.CONV_ID=B.CONV_ID "
+                               "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d "
+                               "AND B.STORAGE_ID = %d "
+                               "ORDER BY B.DISPLAY_TIME DESC;",
+                               MSG_NETWORK_SEND_FAIL,
+                               MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
+                               MSG_OUTBOX_ID,
+                               MSG_STORAGE_PHONE);
+
+               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+
+               if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_PREPARE;
+
+               if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) {
+
+                       noti_info->count = dbhandler->columnInt(6);
+
+                       if (noti_info->count > 0) {
+                               MSG_ADDRESS_INFO_S addrInfo;
+                               memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+                               if (dbhandler->columnText(0) != NULL)
+                                       snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0));
+
+/* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                                               MSG_CONTACT_INFO_S tmpContact;
-                                               memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
+                               MSG_CONTACT_INFO_S tmpContact;
+                               memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S));
 
-                                               MsgGetContactInfo(&addrInfo, &tmpContact);
+                               MsgGetContactInfo(&addrInfo, &tmpContact);
 
-                                               if (tmpContact.firstName[0] != '\0') {
-                                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
-                                               } else if (addrInfo.addressVal[0] == '\0') {
-#else //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
+                               if (tmpContact.firstName[0] != '\0') {
+                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName);
+                               } else if (addrInfo.addressVal[0] == '\0') {
+#else /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
                                                if (addrInfo.addressVal[0] == '\0') {
-#endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                                                       char *senderStr = NULL;
-                                                       senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
-                                                       g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
-                                                       if (senderStr) {
-                                                               free(senderStr);
-                                                               senderStr = NULL;
-                                                       }
-                                               } else {
-                                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
-                                               }
-
-                                               snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
+                                       char *senderStr = NULL;
+                                       senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER);
+                                       g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender));
+                                       if (senderStr) {
+                                               free(senderStr);
+                                               senderStr = NULL;
+                                       }
+                               } else {
+                                       snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal);
+                               }
 
-                                               noti_info->time = (time_t)dbhandler->columnInt(1);
+                               snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal);
 
-                                               noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
+                               noti_info->time = (time_t)dbhandler->columnInt(1);
 
-                                               mainType = (MSG_MAIN_TYPE_T)dbhandler->columnInt(5);
+                               noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2);
 
-                                               if (mainType == MSG_TYPE_MMS)
-                                                       snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(4));
-                                               else
-                                                       snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
+                               mainType = (MSG_MAIN_TYPE_T)dbhandler->columnInt(5);
 
-                                               MSG_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
-                                       } else {
+                               if (mainType == MSG_TYPE_MMS)
+                                       snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(4));
+                               else
+                                       snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3));
 
-                                               MSG_DEBUG("No sent failed message.");
-                                               MSG_DEBUG("failedNotiId [%d]", noti_info->id);
+                               MSG_DEBUG("Sent failed message ID [%d].", noti_info->msg_id);
 
-                                               dbhandler->finalizeQuery();
+                               if (!isForInstantMessage) {
+                                       if (noti_info->id > 0 && noti_info->count == 1) {
+                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                                                       MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
+                                               }
+                                               noti_info->id = 0;
+                                               if (MsgSettingSetInt(MSG_SENTFAIL_NOTI_ID, noti_info->id) != MSG_SUCCESS)
+                                                       MSG_DEBUG("MsgSettingSetInt fail : MSG_SENTFAIL_NOTI_ID");
+                                       }
+                               }
+                       } else {
 
-                                               if (!isForInstantMessage) {
-                                                       // No unread message.
-                                                       if (noti_info->id > 0) {
-                                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
-                                                               if (noti_err != NOTIFICATION_ERROR_NONE) {
-                                                                       MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
-                                                               }
-                                                       }
+                               MSG_DEBUG("No sent failed message.");
+                               MSG_DEBUG("failedNotiId [%d]", noti_info->id);
 
-                                                       noti_info->id = 0;
+                               dbhandler->finalizeQuery();
 
-                                                       if (MsgSettingSetInt(MSG_SENTFAIL_NOTI_ID, noti_info->id) != MSG_SUCCESS)
-                                                               MSG_DEBUG("MsgSettingSetInt fail : MSG_SENTFAIL_NOTI_ID");
+                               if (!isForInstantMessage) {
+                                       /* No unread message. */
+                                       if (noti_info->id > 0) {
+                                               noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id);
+                                               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                                                       MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
                                                }
-
-                                               return MSG_ERR_DB_STEP;
                                        }
-                               } else {
-                                       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
-                                       dbhandler->finalizeQuery();
-                                       return MSG_ERR_DB_STEP;
-                               }
 
-                               dbhandler->finalizeQuery();
-                       }
-                       break;
+                                       noti_info->id = 0;
 
-               case MSG_NOTI_TYPE_SIM_FULL :
-                       break;
+                                       if (MsgSettingSetInt(MSG_SENTFAIL_NOTI_ID, noti_info->id) != MSG_SUCCESS)
+                                               MSG_DEBUG("MsgSettingSetInt fail : MSG_SENTFAIL_NOTI_ID");
+                               }
 
-               default:
-                       {
-                               MSG_DEBUG("No matching type [%d]", noti_info->type);
-                               return MSG_ERR_UNKNOWN;
+                               return MSG_ERR_DB_STEP;
                        }
-                       break;
+               } else {
+                       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+                       dbhandler->finalizeQuery();
+                       return MSG_ERR_DB_STEP;
+               }
+
+               dbhandler->finalizeQuery();
+               break;
+       }
+       case MSG_NOTI_TYPE_SIM_FULL:
+               break;
+       default:
+               MSG_DEBUG("No matching type [%d]", noti_info->type);
+               return MSG_ERR_UNKNOWN;
        }
 
        MSG_END();
@@ -2576,6 +2963,17 @@ void setServiceAppId(app_control_h svc_h, const char* app_id)
 }
 
 
+void setServiceUri(app_control_h svc_h, const char* uri)
+{
+       int svc_err = APP_CONTROL_ERROR_NONE;
+
+       svc_err = app_control_set_uri(svc_h, uri);
+
+       if (svc_err != APP_CONTROL_ERROR_NONE)
+               MSG_DEBUG("app_control_set_uri() was failed, [%d]", svc_err);
+}
+
+
 void setServiceOperation(app_control_h svc_h, const char* operation)
 {
        int svc_err = APP_CONTROL_ERROR_NONE;
@@ -2713,6 +3111,17 @@ void setNotiVibration(notification_h noti_h, notification_vibration_type_e type,
 }
 
 
+void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler)
+{
+       int noti_err = NOTIFICATION_ERROR_NONE;
+
+       noti_err = notification_set_event_handler(noti_h, type, event_handler);
+
+       if (noti_err != NOTIFICATION_ERROR_NONE)
+               MSG_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err);
+}
+
+
 char *getTranslateText(const char *pkg_name, const char *locale_dir, const char *text)
 {
        char *notiMsg = NULL;
@@ -2738,11 +3147,11 @@ void MsgNotiSoundRepeatAlarmCB(int alarmId)
 {
        MSG_BEGIN();
 
-       MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, true, true);
+       MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, true, MSG_ACTIVE_NOTI_TYPE_ACTIVE);
 
 #ifndef MSG_NOTI_INTEGRATION
-       MsgRefreshNotification(MSG_NOTI_TYPE_SIM, true, true);
-       MsgRefreshNotification(MSG_NOTI_TYPE_CB, true, true);
+       MsgRefreshNotification(MSG_NOTI_TYPE_SIM, true, MSG_ACTIVE_NOTI_TYPE_ACTIVE);
+       MsgRefreshNotification(MSG_NOTI_TYPE_CB, true, MSG_ACTIVE_NOTI_TYPE_ACTIVE);
 #endif
 
        MSG_END();
@@ -2785,27 +3194,22 @@ void MsgSoundSetRepeatAlarm()
 
        nRepeatValue = MsgSettingGetInt(MSG_ALERT_REP_TYPE);
 
-       switch (nRepeatValue)
-       {
-               case MSG_ALERT_TONE_ONCE:
-                       nRepeatTime = 0;
-                       break;
-
-               case MSG_ALERT_TONE_2MINS:
-                       nRepeatTime = 2;
-                       break;
-
-               case MSG_ALERT_TONE_5MINS:
-                       nRepeatTime = 5;
-                       break;
-
-               case MSG_ALERT_TONE_10MINS:
-                       nRepeatTime = 10;
-                       break;
-
-               default:
-                       MSG_DEBUG("Invalid Repetition time");
-                       break;
+       switch (nRepeatValue) {
+       case MSG_ALERT_TONE_ONCE:
+               nRepeatTime = 0;
+               break;
+       case MSG_ALERT_TONE_2MINS:
+               nRepeatTime = 2;
+               break;
+       case MSG_ALERT_TONE_5MINS:
+               nRepeatTime = 5;
+               break;
+       case MSG_ALERT_TONE_10MINS:
+               nRepeatTime = 10;
+               break;
+       default:
+               MSG_DEBUG("Invalid Repetition time");
+               break;
        }
 
        MSG_DEBUG("nRepeatTime = %d", nRepeatTime);
@@ -2842,4 +3246,4 @@ void sendMsgReplyPopup(MSG_NOTI_INFO_S *noti_info)
        }
 }
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
index 84098af..ca7c001 100755 (executable)
 #include "MsgSensorWrapper.h"
 
 #ifndef MSG_WEARABLE_PROFILE
-#include <sensor_internal.h>
+#include <gesture_recognition.h>
 
 /*==================================================================================================
                                      VARIABLES
 ==================================================================================================*/
 
-int sensorHandler = -1;
+gesture_h gestureHandler = NULL;
 
 msg_sensor_cb SensorCBFunction = NULL;
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
 /*==================================================================================================
                                      FUNCTION IMPLEMENTATION
 ==================================================================================================*/
 
 #ifndef MSG_WEARABLE_PROFILE
-
-void MsgSensorCB(unsigned int event_type, sensor_event_data_t *event_data , void *data)
+void MsgGestureCB(gesture_type_e gesture, const gesture_data_h data, double timestamp, gesture_error_e error, void *user_data)
 {
-       int *my_event_data;
-
-       my_event_data = (int *)(event_data->event_data);
+       if (error != GESTURE_ERROR_NONE) {
+               MSG_DEBUG("Gesture error = [%d]", error);
+               return;
+       }
 
-       if (event_type == MOTION_ENGINE_EVENT_TOP_TO_BOTTOM)
-               if(*my_event_data == MOTION_ENGIEN_TOP_TO_BOTTOM_DETECTION) {
-                       MSG_DEBUG("top to bottom event detected.");
-                       if(MsgSettingGetInt(VCONFKEY_SETAPPL_MOTION_ACTIVATION))
-                               if(MsgSettingGetInt(VCONFKEY_SETAPPL_USE_TURN_OVER)) {
-                                       if(SensorCBFunction) SensorCBFunction();
-                               }
+       gesture_event_e event;
+       int ret = gesture_get_event(data, &event);
+       if (ret == GESTURE_ERROR_NONE && event == GESTURE_EVENT_DETECTED && \
+                       gesture == GESTURE_TURN_FACE_DOWN) {
+               MSG_DEBUG("GESTURE_TURN_FACE_DOWN gesture detected.");
+               if (MsgSettingGetInt(VCONFKEY_SETAPPL_MOTION_ACTIVATION)) {
+                       if (MsgSettingGetInt(VCONFKEY_SETAPPL_USE_TURN_OVER)) {
+                               if (SensorCBFunction)
+                                       SensorCBFunction();
+                       }
                }
+       }
 }
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
 msg_error_t MsgSensorConnect()
 {
-
 #ifndef MSG_WEARABLE_PROFILE
-
-       sensorHandler = sf_connect(MOTION_SENSOR);
-       if (sensorHandler < 0) {
-               MSG_DEBUG("sensor attach fail.");
+       bool supported = false;
+       int ret = gesture_is_supported(GESTURE_TURN_FACE_DOWN, &supported);
+       if (ret != GESTURE_ERROR_NONE) {
+               MSG_DEBUG("gesture_is_supported is failed [%d]", ret);
+               return MSG_ERR_UNKNOWN;
+       }
+       if (!supported) {
+               MSG_DEBUG("GESTURE_TURN_FACE_DOWN not supported in the current device.");
                return MSG_ERR_UNKNOWN;
        }
 
-#endif // MSG_WEARABLE_PROFILE
+       ret = gesture_create(&gestureHandler);
+       if (ret != GESTURE_ERROR_NONE) {
+               MSG_DEBUG("gesture_create is failed [%d]", ret);
+               return MSG_ERR_UNKNOWN;
+       }
+#endif /* MSG_WEARABLE_PROFILE */
 
        return MSG_SUCCESS;
 }
@@ -76,64 +88,48 @@ msg_error_t MsgSensorConnect()
 
 void MsgSensorDisconnect()
 {
-
 #ifndef MSG_WEARABLE_PROFILE
-
-       if(SensorCBFunction != NULL)
+       if (SensorCBFunction != NULL)
                SensorCBFunction = NULL;
 
-       if (sensorHandler < 0)
+       if (gestureHandler == NULL)
                return;
 
-       try
-       {
-               sf_stop(sensorHandler);
-       }
-       catch(int exception)
-       {
-               MSG_FATAL("sf_stop error[%d]", exception);
+       try {
+               gesture_stop_recognition(gestureHandler);
+       } catch(int exception) {
+               MSG_FATAL("gesture_stop_recognition error [%d]", exception);
        }
-       sf_disconnect(sensorHandler);
-
-#endif // MSG_WEARABLE_PROFILE
 
+       gesture_release(gestureHandler);
+       gestureHandler = NULL;
+#endif /* MSG_WEARABLE_PROFILE */
 }
 
 
 msg_error_t MsgRegSensorCB(msg_sensor_cb cb)
 {
-
 #ifndef MSG_WEARABLE_PROFILE
-
-       int resultCondition = -1;
-
-       if (sensorHandler < 0) {
-               MSG_DEBUG("Not connected to sensor FW.");
+       if (gestureHandler == NULL) {
+               MSG_DEBUG("Not connected to gesture FW.");
                return MSG_ERR_UNKNOWN;
        }
 
-       if(cb != NULL) {
-               // regist cb.
+       if (cb != NULL) {
+               /* regist cb. */
                SensorCBFunction = cb;
        } else {
                MSG_DEBUG("cb is NULL.");
                return MSG_ERR_UNKNOWN;
        }
 
-       resultCondition = sf_register_event(sensorHandler, MOTION_ENGINE_EVENT_TOP_TO_BOTTOM , NULL , MsgSensorCB,NULL);
-       if (resultCondition < 0) {
-               MSG_DEBUG("SLP_sensor_register_cb fail to gather data.");
+       int ret = gesture_start_recognition(gestureHandler, GESTURE_TURN_FACE_DOWN, \
+                               GESTURE_OPTION_DEFAULT, MsgGestureCB, NULL);
+       if (ret != GESTURE_ERROR_NONE) {
+               MSG_DEBUG("gesture_start_recognition failed");
                return MSG_ERR_UNKNOWN;
        }
-
-       MSG_DEBUG("Start SF.");
-       resultCondition = sf_start(sensorHandler, 0);
-       if (resultCondition < 0) {
-               MSG_DEBUG("SLP_sensor_start fail.");
-               return MSG_ERR_UNKNOWN;
-       }
-
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
        return MSG_SUCCESS;
 }
index 97d3ae0..dfae880 100755 (executable)
@@ -16,6 +16,7 @@
 
 #include <wait.h>
 
+#include "MsgCallStatusManager.h"
 #include "MsgDebug.h"
 #include "MsgCppTypes.h"
 #include "MsgGconfWrapper.h"
@@ -39,6 +40,7 @@
 #endif
 
 #include <feedback.h>
+#include <feedback-internal.h>
 #include <feedback-ids-mobile.h>
 
 /*==================================================================================================
@@ -62,7 +64,7 @@ MMHandleType hPlayerHandle = 0;
 
 pthread_mutex_t muMmPlay = PTHREAD_MUTEX_INITIALIZER;
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
 /*==================================================================================================
                                      IMPLEMENTATION OF Functions
@@ -75,7 +77,7 @@ void MsgSoundRepeatAlarmCB(int alarmId)
 
        MsgSoundPlayer::instance()->MsgSoundInitRepeatAlarm();
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
        MSG_END();
        return;
@@ -93,63 +95,61 @@ void MsgSensorCBStop()
 #else
        MsgDeleteNotification(MSG_NOTI_TYPE_ALL, -1);
 
-       MsgRefreshNotification(MSG_NOTI_TYPE_ALL, false, false);
+       MsgRefreshNotification(MSG_NOTI_TYPE_ALL, false, MSG_ACTIVE_NOTI_TYPE_NONE);
 
 #ifndef MSG_NOTI_INTEGRATION
-       MsgRefreshNotification(MSG_NOTI_TYPE_SIM, false, false);
+       MsgRefreshNotification(MSG_NOTI_TYPE_SIM, false, MSG_ACTIVE_NOTI_TYPE_NONE);
 #endif
 
 #endif
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
        MSG_END();
 }
 
+/*
+static gboolean MsgSoundMelodyTimeout(gpointer data)
+{
+       MSG_BEGIN();
 
-//static gboolean MsgSoundMelodyTimeout(gpointer data)
-//{
-//     MSG_BEGIN();
-//
-//     MsgSoundPlayer::instance()->MsgSoundPlayStop();
-//
-//     MSG_END();
-//
-//     return FALSE;
-//}
+       MsgSoundPlayer::instance()->MsgSoundPlayStop();
 
-#ifndef MSG_WEARABLE_PROFILE
+       MSG_END();
+
+       return FALSE;
+}
+*/
 
 static int MsgSoundPlayCallback(int message, void *param, void *user_param)
 {
 #ifdef _USE_MM_FW_
-       switch (message)
-       {
-               case MM_MESSAGE_BEGIN_OF_STREAM:
-                       MSG_DEBUG("Play is started.");
-                       break;
-               case MM_MESSAGE_END_OF_STREAM:
-               case MM_MESSAGE_STATE_INTERRUPTED:
-                       MSG_DEBUG("EOS or Interrupted.");
-                       MsgSoundPlayer::instance()->MsgSoundPlayStop();
-                       break;
-               case MM_MESSAGE_FILE_NOT_SUPPORTED:
-               case MM_MESSAGE_FILE_NOT_FOUND:
-               case MM_MESSAGE_DRM_NOT_AUTHORIZED:
-               case MM_MESSAGE_ERROR:
-                       MSG_DEBUG("message [%d] & play with default", message);
-                       MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_DEFAULT);
-                       break;
-               default:
-                       MSG_DEBUG("message [%d]", message);
-                       break;
+#ifndef MSG_WEARABLE_PROFILE
+       switch (message) {
+       case MM_MESSAGE_BEGIN_OF_STREAM:
+               MSG_DEBUG("Play is started.");
+               break;
+       case MM_MESSAGE_END_OF_STREAM:
+       case MM_MESSAGE_STATE_INTERRUPTED:
+               MSG_DEBUG("EOS or Interrupted.");
+               MsgSoundPlayer::instance()->MsgSoundPlayStop();
+               break;
+       case MM_MESSAGE_FILE_NOT_SUPPORTED:
+       case MM_MESSAGE_FILE_NOT_FOUND:
+       case MM_MESSAGE_DRM_NOT_AUTHORIZED:
+       case MM_MESSAGE_ERROR:
+               MSG_DEBUG("message [%d] & play with default", message);
+               MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_DEFAULT);
+               break;
+       default:
+               MSG_DEBUG("message [%d]", message);
+               break;
        }
+#endif /* MSG_WEARABLE_PROFILE */
 #endif
        return 1;
 }
 
-#endif // MSG_WEARABLE_PROFILE
-
 /*==================================================================================================
                                      IMPLEMENTATION OF MsgSoundPlayer - Member Functions
 ==================================================================================================*/
@@ -183,7 +183,7 @@ MsgSoundPlayer::MsgSoundPlayer()
        } else {
                MSG_DEBUG("Fail to MsgSensorConnect.");
        }
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 #endif
 }
 
@@ -235,8 +235,8 @@ void MsgSoundPlayer::MsgGetRingtonePath(char *userRingtonePath, char **msg_tone_
 
        memset(msg_tone_file_path, 0x00, sizeof(char)*(MSG_FILEPATH_LEN_MAX+1));
 
-       if ((tmpFilePath == NULL || MsgGetFileSize(tmpFilePath) < 1) || // wrong ringtone file path
-                       (MsgDrmIsDrmFile(tmpFilePath) && !MsgDrmCheckRingtone(tmpFilePath))) { // check DRM
+       if ((tmpFilePath == NULL || MsgGetFileSize(tmpFilePath) < 1) || /* wrong ringtone file path */
+                       (MsgDrmIsDrmFile(tmpFilePath) && !MsgDrmCheckRingtone(tmpFilePath))) { /* check DRM */
                if (tmpFilePath && (strcmp(tmpFilePath, "silent") == 0)) {
                        MSG_DEBUG("Set ringtone to NONE(Silent)");
                        msg_tone_file_path = NULL;
@@ -253,7 +253,7 @@ void MsgSoundPlayer::MsgGetRingtonePath(char *userRingtonePath, char **msg_tone_
                free(tmpFilePath);
                tmpFilePath = NULL;
        }
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
 }
 
@@ -282,11 +282,50 @@ bool MsgIsSoundPlayOnCall(void)
                MSG_DEBUG("mm_sound_get_active_device() err=[%d]", err);
        }
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 #endif
        return bPlayOnCall;
 }
 
+#ifndef MSG_WEARABLE_PROFILE
+void MsgSoundPlayer::MsgGetPlayStatus(bool bOnCall, bool bSound, bool bVibration, bool bMsgSound, bool bMsgVibration, bool *bPlaySound, bool *bPlayVibration)
+{
+       MSG_BEGIN();
+
+       /* samsung basic concept : feedback should follow profile setting.
+        * And if notification setting exist in msg app, then apply it prior to profile when profile either sound or vibration.
+        * But, Play sound when profile is vibration during call, if device does not support haptic */
+       if (bSound || bVibration) {
+               bool bHantic_device = false;
+#ifdef FEATURE_HAPTIC_ENABLE
+               bHantic_device = true;
+#endif
+               if (bHantic_device || (bOnCall == false)) {
+                       if (bSound) {
+                               if (bMsgSound) {
+                                       MSG_DEBUG("Play sound.");
+                                       *bPlaySound = true;
+                               }
+
+                               if (bMsgVibration) {
+                                       MSG_DEBUG("Play vibration.");
+                                       *bPlayVibration = true;
+                               }
+                       } else {
+                               if (bMsgVibration) {
+                                       MSG_DEBUG("Play vibration.");
+                                       *bPlayVibration = true;
+                               }
+                       }
+               } else { /* during call */
+                       if (bMsgSound || bMsgVibration) {
+                               MSG_DEBUG("Play sound.");
+                               *bPlaySound = true;
+                       }
+               }
+       }
+}
+#endif /* MSG_WEARABLE_PROFILE */
 
 void MsgSoundPlayer::MsgGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *bPlayVibration, bool *bOnCall)
 {
@@ -304,38 +343,44 @@ void MsgSoundPlayer::MsgGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *b
        *bOnCall = false;
 
        /* Global setting */
-       bool bSoundOn = false; // sound setting on notification panel
-       bool bVibrationOn = false; // vibration setting on notification panel
+       bool bSoundOn = false; /* sound setting on notification panel */
+       bool bVibrationOn = false; /* vibration setting on notification panel */
+
+       MsgSettingGetBool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &bSoundOn);
+       MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &bVibrationOn);
 
        /* Alert setting */
-#if 0  //not used value
-       bool bNotiVibrationOn = false; // alert vibration
+#if 0  /* not used value */
+       bool bNotiVibrationOn = false; /* alert vibration */
        MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, &bNotiVibrationOn);
 #endif
 
-       bool bMsgSettingNoti = true; // Alert for message notification
-       bool bMsgSettingVibration = false; // vibration for message notification
+       bool bMsgSettingNoti = true; /* Alert for message notification */
+       bool bMsgSettingVibration = false; /* vibration for message notification */
 
-       MsgSettingGetBool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &bSoundOn);
-       MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &bVibrationOn);
+       MSG_RINGTONE_TYPE_T ringtoneType = MSG_RINGTONE_TYPE_DEFAULT; //sound type for message notification
+       bool bMsgSettingSound = true;
 
        MsgSettingGetBool(MSG_SETTING_VIBRATION, &bMsgSettingVibration);
        MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &bMsgSettingNoti);
+       ringtoneType = (MSG_RINGTONE_TYPE_T)MsgSettingGetInt(MSG_SETTING_RINGTONE_TYPE);
+       if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
+               bMsgSettingSound = false;
 
-       MSG_SEC_DEBUG("Sound status : Sound mode=[%d], Manner mode=[%d]", bSoundOn, bVibrationOn);
-       MSG_SEC_DEBUG("Msg Setting : Noti Alert=[%d], With vibration=[%d]", bMsgSettingNoti, bMsgSettingVibration);
+       MSG_SEC_DEBUG("Sound status : Sound mode[%d], Manner mode[%d]", bSoundOn, bVibrationOn);
+       MSG_SEC_DEBUG("Msg Setting : Noti Alert[%d], vibration[%d], sound[%d], ringtoneType[%d]", bMsgSettingNoti, bMsgSettingVibration, bMsgSettingSound, ringtoneType);
 
        int callStatus = 0;
-//     int alertOnCall = 0;
+/*     int alertOnCall = 0; */
 
-       callStatus = MsgSettingGetInt(VCONFKEY_CALL_STATE);
+       callStatus = MsgGetCallStatus();
        MSG_DEBUG("Call Status [%d]", callStatus);
 
        /* Check call status */
-       if (callStatus > VCONFKEY_CALL_OFF && callStatus < VCONFKEY_CALL_STATE_MAX) {
+       if (callStatus > 0 && callStatus < 3) {
                /* 1. On Call */
 
-               *bOnCall = true; // set call status;
+               *bOnCall = true; /* set call status; */
 #if 0
                alertOnCall = MsgSettingGetInt(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT);
                MSG_DEBUG("Alert On Call [%d]", alertOnCall);
@@ -343,7 +388,7 @@ void MsgSoundPlayer::MsgGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *b
                if (alertOnCall == 0) {
                        MSG_DEBUG("Call is active & Alert on Call - Off");
                } else if (alertOnCall == 1) {
-                       /* set default value to true, while on Call  alert sound to be played  and vibration to be off. */
+                       /* set default value to true, while on Call alert sound to be played and vibration to be off. */
                        bool bPlayOnCall = true;
 
                        if (!bSoundOn) {
@@ -378,36 +423,21 @@ void MsgSoundPlayer::MsgGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *b
                /* 2. Call is not active */
 
                MSG_DEBUG("Call is not active.");
+               int voiceRecording = MsgSettingGetInt(VCONFKEY_RECORDER_STATE);
 
                if (bVoiceMail) {       /* 2-1. Voice message */
                        if (bMsgSettingNoti) {
-                               if (bSoundOn || bVibrationOn) {
-                                       MSG_DEBUG("Play vibration - voice message.");
-                                       *bPlayVibration = true;
-                               } else {
-                                       MSG_DEBUG("It doesn't play vibration - voice message.");
-                               }
-
-                               MSG_DEBUG("Play sound - voice message.");
-                               *bPlaySound = true;
+                               MsgGetPlayStatus(false, bSoundOn, bVibrationOn, bMsgSettingSound, bMsgSettingVibration, bPlaySound, bPlayVibration);
 
                        } else {
                                MSG_DEBUG("It doesn't play sound/vibration - voice message.");
                        }
                } else {        /* 2-1. Normal message */
                        if (bMsgSettingNoti) {
-                               if (bSoundOn) {
-                                       MSG_DEBUG("Play sound.");
-                                       *bPlaySound = true;
-                               } else {
-                                       MSG_DEBUG("It doesn't play vibration.");
-                               }
-
-                               if ((bSoundOn || bVibrationOn) && bMsgSettingVibration) {
-                                       MSG_DEBUG("Play vibration.");
-                                       *bPlayVibration = true;
+                               if (voiceRecording != VCONFKEY_RECORDER_STATE_RECORDING) {
+                                       MsgGetPlayStatus(false, bSoundOn, bVibrationOn, bMsgSettingSound, bMsgSettingVibration, bPlaySound, bPlayVibration);
                                } else {
-                                       MSG_DEBUG("It doesn't play vibration.");
+                                       MSG_DEBUG("It doesn't play sound/vibration.");
                                }
                        } else {
                                MSG_DEBUG("It doesn't play sound/vibration.");
@@ -415,7 +445,7 @@ void MsgSoundPlayer::MsgGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *b
                }
        }
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
        MSG_END();
 }
@@ -430,7 +460,7 @@ void MsgSoundPlayer::MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_
        MSG_DEBUG("soundType [%d]", soundType);
 
        /* check camera state */
-       int cameraState = 0;    // camera recording state
+       int cameraState = 0;    /* camera recording state */
        cameraState = MsgSettingGetInt(VCONFKEY_CAMERA_STATE);
        MSG_SEC_DEBUG("Camera state [%d]", cameraState);
 
@@ -439,19 +469,19 @@ void MsgSoundPlayer::MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_
                return;
        }
 
-       //contacts-service is not used for gear
+/* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
        /* get contact information */
        MSG_CONTACT_INFO_S contactInfo;
        memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
 
-       if(pAddrInfo) {
-               // Get Contact Info
+       if (pAddrInfo) {
+               /* Get Contact Info */
                if (MsgGetContactInfo(pAddrInfo, &contactInfo) != MSG_SUCCESS) {
                        MSG_DEBUG("MsgGetContactInfo() fail.");
                }
        }
-#endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
        /* get ringtone file path */
        char *msg_tone_file_path = NULL;
        unique_ptr<char*, void(*)(char**)> buf(&msg_tone_file_path, unique_ptr_deleter);
@@ -464,12 +494,12 @@ void MsgSoundPlayer::MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_
                memset(msg_tone_file_path, 0x00, sizeof(char)*(MAX_SOUND_FILE_LEN+1));
                strncpy(msg_tone_file_path, DEFAULT_ALERT_FILE, MAX_SOUND_FILE_LEN);
        }
-       //contacts-service is not used for gear
+/* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
        else {
                MsgGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
        }
-#endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
        MSG_SEC_DEBUG("soundType [%d], Sound File [%s]", soundType, msg_tone_file_path);
 
        /* get sound play status */
@@ -480,7 +510,7 @@ void MsgSoundPlayer::MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_
 
        MsgGetPlayStatus(bVoiceMsg, &bPlaySound, &bPlayVibration, &bOnCall);
 
-       MSG_SEC_DEBUG("sound=[%d], vibration=[%d], voice_msg?[%d], on_call?[%d]", \
+       MSG_SEC_DEBUG("sound=[%d], vibration=[%d], voice_msg?[%d], on_call?[%d]",
                        bPlaySound, bPlayVibration, bVoiceMsg, bOnCall);
 
        /* play sound */
@@ -508,17 +538,18 @@ void MsgSoundPlayer::MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_
                        MSG_DEBUG("MM Session Finish Success : %d", err);
        }
 
-       //contacts-service is not used for gear
+/* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
        /* play vibration */
        if (bPlayVibration) {
                MsgSoundPlayVibration(contactInfo.vibrationPath, bOnCall);
        }
-#endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-       // For repeatition.
-//     MsgSoundSetRepeatAlarm();
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
 
-#endif // MSG_WEARABLE_PROFILE
+       /* For repeatition. */
+/*     MsgSoundSetRepeatAlarm(); */
+
+#endif /* MSG_WEARABLE_PROFILE */
 #endif
        MSG_END();
 }
@@ -537,10 +568,8 @@ void MsgSoundPlayer::MsgSoundPlayStop()
                /* Stop playing media contents */
                int err = mm_player_stop(hPlayerHandle);
 
-               if (err != MM_ERROR_NONE) {
+               if (err != MM_ERROR_NONE)
                        MSG_DEBUG("stopping the player handle failed");
-               }
-
        }
 
        if (hPlayerHandle != 0) {
@@ -558,7 +587,7 @@ void MsgSoundPlayer::MsgSoundPlayStop()
 
        pthread_mutex_unlock(&muMmPlay);
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 #endif
        MSG_END();
 }
@@ -603,9 +632,8 @@ void MsgSoundPlayer::MsgSoundPlayMelody(char *pMsgToneFilePath)
                                "sound_priority", 2,
                                NULL);
 
-               if (err != MM_ERROR_NONE) {
+               if (err != MM_ERROR_NONE)
                        MSG_DEBUG("error setting the profile attr [%d]", err);
-               }
 
                err = mm_player_realize(hPlayerHandle);
 
@@ -617,7 +645,7 @@ void MsgSoundPlayer::MsgSoundPlayMelody(char *pMsgToneFilePath)
                                return;
                        }
                }
-       } while(err != MM_ERROR_NONE);
+       } while (err != MM_ERROR_NONE);
 
 
        pthread_mutex_lock(&muMmPlay);
@@ -628,14 +656,16 @@ void MsgSoundPlayer::MsgSoundPlayMelody(char *pMsgToneFilePath)
                MSG_DEBUG("mm_player_start, FAIL [%x]", err);
        } else {
                /* Add Timer to stop playing after 5 sec. */
-//             int g_contact_timer = -1;
-//             g_contact_timer = g_timeout_add(MSG_SOUND_TIMEOUT, (GSourceFunc)MsgSoundMelodyTimeout, NULL);
+               /*
+               int g_contact_timer = -1;
+               g_contact_timer = g_timeout_add(MSG_SOUND_TIMEOUT, (GSourceFunc)MsgSoundMelodyTimeout, NULL);
+               */
 
                bPlaying = true;
        }
        pthread_mutex_unlock(&muMmPlay);
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 #endif
 }
 
@@ -661,8 +691,7 @@ void MsgSoundPlayer::MsgSoundPlayVibration(char *vibrationPath, bool isOnCall)
                }
        }
 
-       if(vibrationPath && strlen(vibrationPath))
-       {
+       if (vibrationPath && strlen(vibrationPath)) {
                MSG_DEBUG("vibrationPath: [%s]", vibrationPath);
                ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, vibrationPath);
                if (ret != FEEDBACK_ERROR_NONE)
@@ -671,13 +700,10 @@ void MsgSoundPlayer::MsgSoundPlayVibration(char *vibrationPath, bool isOnCall)
 
                if (ret != FEEDBACK_ERROR_NONE)
                        MSG_DEBUG("Fail to feedback_play_type");
-       }
-       else
-       {
-               if (isOnCall)
+       } else {
+               if (isOnCall) {
                        ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, (feedback_pattern_e)FEEDBACK_PATTERN_MOBILE_MESSAGE_ON_CALL);
-               else
-               {
+               } else {
                        ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, NULL);
                        if (ret != FEEDBACK_ERROR_NONE)
                                MSG_DEBUG("Fail to feedback_set_resource_path");
@@ -688,7 +714,7 @@ void MsgSoundPlayer::MsgSoundPlayVibration(char *vibrationPath, bool isOnCall)
                        MSG_DEBUG("Fail to feedback_play_type");
        }
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
        MSG_END();
 }
@@ -704,13 +730,13 @@ void MsgSoundPlayer::MsgSoundPlayDtmf()
 
        ret = mm_sound_play_tone(MM_SOUND_TONE_PROP_BEEP2, VOLUME_TYPE_SYSTEM, 1.0, 300, &hToneHandle);
 
-       if(ret < 0) {
+       if (ret < 0) {
                MSG_DEBUG("play tone failed.");
        } else {
                MSG_DEBUG("play tone success.");
        }
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 #endif
        MSG_END();
 }
@@ -725,26 +751,25 @@ void MsgSoundPlayer::MsgSoundSetRepeatAlarm()
 
        nRepeatValue = MsgSettingGetInt(MSG_ALERT_REP_TYPE);
 
-       switch (nRepeatValue)
-       {
-               case MSG_ALERT_TONE_ONCE:
-                       nRepeatTime = 0;
+       switch (nRepeatValue) {
+       case MSG_ALERT_TONE_ONCE:
+               nRepeatTime = 0;
                break;
 
-               case MSG_ALERT_TONE_2MINS:
-                       nRepeatTime = 2;
+       case MSG_ALERT_TONE_2MINS:
+               nRepeatTime = 2;
                break;
 
-               case MSG_ALERT_TONE_5MINS:
-                       nRepeatTime = 5;
+       case MSG_ALERT_TONE_5MINS:
+               nRepeatTime = 5;
                break;
 
-               case MSG_ALERT_TONE_10MINS:
-                       nRepeatTime = 10;
+       case MSG_ALERT_TONE_10MINS:
+               nRepeatTime = 10;
                break;
 
-               default:
-                       MSG_DEBUG("Invalid Repetition time");
+       default:
+               MSG_DEBUG("Invalid Repetition time");
                break;
        }
 
@@ -752,15 +777,15 @@ void MsgSoundPlayer::MsgSoundSetRepeatAlarm()
 
        if (nRepeatTime > 0) {
                if (g_alarmId > 0) {
-                       if (MsgAlarmRemove(g_alarmId) != MSG_SUCCESS) {
+                       if (MsgAlarmRemove(g_alarmId) != MSG_SUCCESS)
                                MSG_FATAL("MsgAlarmRemove fail.");
-                       }
+
                        g_alarmId = 0;
                }
                MsgSoundCreateRepeatAlarm(nRepeatTime);
        }
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 }
 
 
@@ -790,7 +815,7 @@ void MsgSoundPlayer::MsgSoundCreateRepeatAlarm(int RepeatTime)
 
        MSG_END();
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 }
 
 
@@ -800,15 +825,15 @@ int MsgSoundPlayer::MsgSoundGetUnreadMsgCnt()
 
 #ifndef MSG_WEARABLE_PROFILE
 
-       // Get SMS Count
+       /* Get SMS Count */
        unreadCnt = MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_SMS_STATE);
 
-       // Get MMS Count
+       /* Get MMS Count */
        unreadCnt += MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_MMS_STATE);
 
        MSG_DEBUG("unread count : [%d]", unreadCnt);
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
        return unreadCnt;
 }
@@ -831,26 +856,25 @@ void MsgSoundPlayer::MsgSoundInitRepeatAlarm()
 
        nRepeatValue = MsgSettingGetInt(MSG_ALERT_REP_TYPE);
 
-       switch (nRepeatValue)
-       {
-               case MSG_ALERT_TONE_ONCE:
-                       nRepeatTime = 0;
+       switch (nRepeatValue) {
+       case MSG_ALERT_TONE_ONCE:
+               nRepeatTime = 0;
                break;
 
-               case MSG_ALERT_TONE_2MINS:
-                       nRepeatTime = 2;
+       case MSG_ALERT_TONE_2MINS:
+               nRepeatTime = 2;
                break;
 
-               case MSG_ALERT_TONE_5MINS:
-                       nRepeatTime = 5;
+       case MSG_ALERT_TONE_5MINS:
+               nRepeatTime = 5;
                break;
 
-               case MSG_ALERT_TONE_10MINS:
-                       nRepeatTime = 10;
+       case MSG_ALERT_TONE_10MINS:
+               nRepeatTime = 10;
                break;
 
-               default:
-                       MSG_DEBUG("Invalid Repetition time");
+       default:
+               MSG_DEBUG("Invalid Repetition time");
                break;
        }
 
@@ -859,7 +883,7 @@ void MsgSoundPlayer::MsgSoundInitRepeatAlarm()
        if (nRepeatTime > 0)
                MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_USER);
 
-#endif // MSG_WEARABLE_PROFILE
+#endif /* MSG_WEARABLE_PROFILE */
 
        MSG_END();
 }
index ec47690..0599e01 100755 (executable)
@@ -57,9 +57,9 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo)
 
        msg_error_t err = MSG_SUCCESS;
 
-       /=======================================================================
-       // Check Unknown Sender
-       // =======================================================================
+       /*========================================================================
+          Check Unknown Sender
+       ========================================================================*/
        bool bBlockUnknown = false;
 
        if (MsgSettingGetBool(MSG_BLOCK_UNKNOWN_MSG, &bBlockUnknown) == MSG_SUCCESS) {
@@ -69,9 +69,9 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo)
                }
        }
 
-       /=======================================================================
-       // Check Filter Operation
-       // =======================================================================
+       /*========================================================================
+          Check Filter Operation
+       ========================================================================*/
        bool filterFlag = false;
 
        MsgGetFilterOperation(&filterFlag);
@@ -81,9 +81,9 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo)
                return false;
        }
 
-       /=======================================================================
-       // Check Filter by Address
-       // =======================================================================
+       /*========================================================================
+          Check Filter by Address
+       ========================================================================*/
        int rowCnt = 0;
 
        MSG_SEC_DEBUG("pMsg->addressList[0].addressVal [%s]", pMsgInfo->addressList[0].addressVal);
@@ -113,10 +113,10 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo)
                pDbHandle->freeTable();
        }
 
-       /=======================================================================
-       // Check Filter by Subject
-       // =======================================================================
-       // Get Filter List
+       /*========================================================================
+          Check Filter by Subject
+       ========================================================================*/
+       /* Get Filter List */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
        snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILTER_VALUE FROM %s WHERE FILTER_TYPE = %d;",
@@ -140,8 +140,7 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo)
        int fileSize = 0;
        bool bFiltered = false;
 
-       for (int i = 1; i <= rowCnt; i++)
-       {
+       for (int i = 1; i <= rowCnt; i++) {
                memset(filterValue, 0x00, sizeof(filterValue));
 
                pDbHandle->getColumnToString(i, MAX_FILTER_VALUE_LEN, filterValue);
@@ -176,7 +175,7 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo)
                                        pData[strlen(pMsgInfo->msgText)] = '\0';
                                }
                        }
-               } else if(pMsgInfo->msgType.mainType == MSG_MMS_TYPE) {
+               } else if (pMsgInfo->msgType.mainType == MSG_MMS_TYPE) {
                        if (strlen(pMsgInfo->subject) > 0) {
                                if (pData) {
                                        delete[] pData;
@@ -190,7 +189,7 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo)
                        }
                }
 
-               // NULL value check
+               /* NULL value check */
                if (pData == NULL) {
                        MSG_DEBUG("pData is NULL");
 
@@ -205,7 +204,7 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo)
                        MSG_CONTACT_INFO_S contactInfo;
                        memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
 
-                       // Get Contact Info
+                       /* Get Contact Info */
                        if (MsgGetContactInfo(&(pMsgInfo->addressList[0]), &contactInfo) == MSG_SUCCESS) {
                                if (contactInfo.contactId > 0) {
                                        MSG_SEC_DEBUG("Msg is Filtered by Subject [%s] Data [%s], but address is in contact. Skip.", filterValue, pData);
@@ -254,9 +253,9 @@ bool MsgCheckFilterByWord(MsgDbHandler *pDbHandle, const char *pMsgText)
 
        msg_error_t err = MSG_SUCCESS;
 
-       /=======================================================================
-       // Check Filter Operation
-       // =======================================================================
+       /*========================================================================
+          Check Filter Operation
+       ========================================================================*/
        bool filterFlag = false;
 
        MsgGetFilterOperation(&filterFlag);
@@ -272,10 +271,10 @@ bool MsgCheckFilterByWord(MsgDbHandler *pDbHandle, const char *pMsgText)
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
 
-       /=======================================================================
-       // Check Filter by Word
-       // =======================================================================
-       // Get Filter List
+       /*========================================================================
+          Check Filter by Word
+       ========================================================================*/
+       /* Get Filter List */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
        snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILTER_VALUE FROM %s WHERE FILTER_TYPE = %d;",
@@ -292,15 +291,15 @@ bool MsgCheckFilterByWord(MsgDbHandler *pDbHandle, const char *pMsgText)
        char filterValue[MAX_FILTER_VALUE_LEN+1];
        bool bFiltered = false;
 
-       for (int i = 1; i <= rowCnt; i++)
-       {
+       for (int i = 1; i <= rowCnt; i++) {
                memset(filterValue, 0x00, sizeof(filterValue));
 
                pDbHandle->getColumnToString(i, MAX_FILTER_VALUE_LEN, filterValue);
 
                MSG_DEBUG("filterValue [%s]", filterValue);
 
-               if (strlen(filterValue) <= 0) continue;
+               if (strlen(filterValue) <= 0)
+                       continue;
 
                if (strcasestr(pMsgText, filterValue) != NULL) {
                        MSG_DEBUG("Msg is Filtered by Word [%s] ", filterValue);
index c096087..2e639c3 100755 (executable)
@@ -142,7 +142,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(main_pkgs REQUIRED glib-2.0 dlog vconf db-util)
+pkg_check_modules(main_pkgs REQUIRED glib-2.0 dlog vconf)
 
 FOREACH(flag ${main_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 096f80a..bf3282f 100755 (executable)
@@ -199,7 +199,7 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques
                MSG_SUB_TYPE_T subType = pMsgInfo->msgType.subType;
 
                /* If Retrieve Failed, Msg SubType is remained as Notification Ind */
-               if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_FAIL) {
+               if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_FAIL || pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_PENDING) {
                        pMsgInfo->folderId = MSG_INBOX_ID;
                        pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
                }
@@ -244,11 +244,11 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques
 
                        if (readStatus == true) {
                                MsgStoSetReadStatus(dbHandle, pMsgInfo->msgId, false);
-                               MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, false, false);
+                               MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, false, MSG_ACTIVE_NOTI_TYPE_NONE);
                        }
                }
 
-               if (subType == MSG_RETRIEVE_AUTOCONF_MMS) {
+               if (subType == MSG_RETRIEVE_AUTOCONF_MMS && pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) {
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
                        bool isFavorites = false;
                        if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) {
@@ -266,8 +266,10 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques
                }  else if (subType == MSG_RETRIEVE_MANUALCONF_MMS) {
                        if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) {
                                MSG_DEBUG("Manual success");
+#if 0 //disable as per UX request to not show success notification : 2015.9.18
                                if (pMsgInfo->folderId == MSG_INBOX_ID)
                                        MsgInsertTicker("Message Retrieved", MESSAGE_RETRIEVED, true, 0);
+#endif
                        } else if (pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_FAIL) {
                                MSG_DEBUG("Manual failed");
                                MsgInsertTicker("Retrieving message failed", RETRIEVING_MESSAGE_FAILED, true, pMsgInfo->msgId);
@@ -280,8 +282,10 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques
                if (plg == NULL)
                        return MSG_ERR_NULL_POINTER;
 
-               // change subType for storage update
-               pMsgInfo->msgType.subType = MSG_SENDCONF_MMS;
+               if (pMsgInfo->networkStatus == MSG_NETWORK_SEND_PENDING)
+                       pMsgInfo->msgType.subType = MSG_SENDREQ_MMS;
+               else
+                       pMsgInfo->msgType.subType = MSG_SENDCONF_MMS; // change subType for storage update
 
                err = MsgStoUpdateMMSMessage(pMsgInfo);
                if (err == MSG_SUCCESS)
@@ -430,13 +434,13 @@ msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti, bool *bO
                char keyName[MAX_VCONFKEY_NAME_LEN];
                memset(keyName, 0x00, sizeof(keyName));
                snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, pMsgInfo->sim_idx);
-               char *number = MsgSettingGetString(keyName);
-               int addrSize = strlen(pMsgInfo->addressList[0].addressVal);
-               char newPhoneNum[addrSize+1];
-               memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
-               MsgConvertNumber(pMsgInfo->addressList[0].addressVal, newPhoneNum, addrSize);
+               char *voiceNumber = MsgSettingGetString(keyName);
+
+               if (voiceNumber) {
+                       MSG_SEC_DEBUG("Voice Mail Number [%s]", voiceNumber);
 
-               if (g_str_has_suffix(number, newPhoneNum)) {
+                       memset(pMsgInfo->addressList[0].addressVal, 0x00, sizeof(pMsgInfo->addressList[0].addressVal));
+                       snprintf(pMsgInfo->addressList[0].addressVal, sizeof(pMsgInfo->addressList[0].addressVal), "%s", voiceNumber);
                        memset(keyName, 0x00, sizeof(keyName));
                        snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, pMsgInfo->sim_idx);
                        char *alphaId = MsgSettingGetString(keyName);
@@ -446,12 +450,9 @@ msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti, bool *bO
                                g_free(alphaId);
                                alphaId = NULL;
                        }
-               }
 
-               if(number)
-               {
-                       g_free(number);
-                       number = NULL;
+                       free(voiceNumber);
+                       voiceNumber = NULL;
                }
 
                memset(keyName, 0x00, sizeof(keyName));
@@ -494,6 +495,8 @@ msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti, bool *bO
 #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
                        *pSendNoti = false;
                        *bOnlyNoti = false;
+
+                       MsgInsertOnlyActiveNotification(MSG_NOTI_TYPE_CLASS0, pMsgInfo);
                }
        } else if ((pMsgInfo->msgType.subType >= MSG_WAP_SI_SMS) && (pMsgInfo->msgType.subType <= MSG_WAP_CO_SMS)) {
                MSG_DEBUG("Starting WAP Message Incoming.");
@@ -596,6 +599,7 @@ msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti, bool *bO
                                break;
                        case MSG_WAP_CO_SMS:
                                *pSendNoti = false;
+                               MsgInsertOnlyActiveNotification(MSG_NOTI_TYPE_NORMAL, pMsgInfo);
                                break;
                }
 #endif // MSG_WEARABLE_PROFILE
@@ -670,6 +674,7 @@ msg_error_t MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo,  bool *pSendNoti)
 
        // Add into DB
        if ((pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) && bReject == false) {
+               /* It should send noti response even if MMS is blocked by sender address. */
                //bFiltered = MsgCheckFilter(dbHandle, pMsgInfo);
                if (pMsgInfo->folderId == MSG_SPAMBOX_ID) {
                        bFiltered = true;
@@ -692,6 +697,7 @@ msg_error_t MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo,  bool *pSendNoti)
                        if (filterFlag == true && request.msgInfo.msgType.subType == MSG_GET_MMS) {
                                 /* Not to show MMS notification msg until it retrieves. */
                                pMsgInfo->folderId = MSG_IOSBOX_ID;
+                               *pSendNoti = false;
                        }
                }
 
@@ -740,7 +746,7 @@ msg_error_t MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo,  bool *pSendNoti)
                if (defaultNetworkSimId == pMsgInfo->sim_idx) {
                        request.msgInfo.msgId = pMsgInfo->msgId;
 
-                       MSG_DEBUG("-=====================[[[ %s ]]]] =========================", request.msgInfo.msgData);
+                       MSG_SEC_DEBUG("-=====================[[[ %s ]]]] =========================", request.msgInfo.msgData);
                        err = plg->submitReq(&request);
 
                        if (err == MSG_SUCCESS) {
index d6e2695..2f2f44c 100755 (executable)
@@ -17,6 +17,7 @@
 /*==================================================================================================
                                          INCLUDE FILES
 ==================================================================================================*/
+#include "MsgCallStatusManager.h"
 #include "MsgDebug.h"
 #include "MsgException.h"
 #include "MsgContact.h"
@@ -57,6 +58,8 @@ void* InitMsgServer(void*)
        MsgInitContactSvc();
 #endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED
 
+       MsgInitCallStatusManager();
+
        //CID 356902: Moving try block up to include MsgStoInitDB which also throws MsgException
        try
        {
@@ -173,6 +176,8 @@ int main(void)
        // Disconnect to DB
        MsgStoDisconnectDB();
 
+       MsgDeInitCallStatusManager();
+
        return 0;
 }
 
index 836afce..4acfea6 100755 (executable)
@@ -84,11 +84,13 @@ void MsgSentStatusListener(MSG_SENT_STATUS_S *pSentStatus)
 }
 
 
-void MsgStorageChangeListener(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
+void MsgStorageChangeListener(msg_storage_change_type_t storageChangeType, msg_id_list_s *pMsgIdList)
 {
        MSG_BEGIN();
 
-       MSG_DEBUG("StorageChangeType : [%d], msg ID : [%d]", storageChangeType, pMsgInfo->msgId);
+       for (int i = 0; i < pMsgIdList->nCount; i++) {
+               MSG_DEBUG("StorageChangeType : [%d], msg ID : [%d]", storageChangeType, pMsgIdList->msgIdList[i]);
+       }
 
        // establish connection to msgfw daemon
        MsgIpcClientSocket client;
@@ -103,7 +105,7 @@ void MsgStorageChangeListener(msg_storage_change_type_t storageChangeType, MSG_M
        }
 
        // composing command
-       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(msg_storage_change_type_t);
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + sizeof(msg_message_id_t) * pMsgIdList->nCount + sizeof(msg_storage_change_type_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
@@ -115,8 +117,9 @@ void MsgStorageChangeListener(msg_storage_change_type_t storageChangeType, MSG_M
 
        memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
 
-       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
-       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), &storageChangeType, sizeof(msg_storage_change_type_t));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &pMsgIdList->nCount, sizeof(int));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), (void*)pMsgIdList->msgIdList, sizeof(msg_message_id_t)*pMsgIdList->nCount);
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+(sizeof(msg_message_id_t)*pMsgIdList->nCount)), &storageChangeType, sizeof(msg_storage_change_type_t));
 
        // Send Command to Transaction Manager
        client.write(cmdBuf, cmdSize);
@@ -1150,11 +1153,11 @@ MsgPluginManager::MsgPluginManager()
 void MsgPluginManager::initialize()
 {
        int plg_len = sizeof(__msg_plg_items)/sizeof(MSG_PLG_TABLE_T);
-       for (int i=0; i < plg_len; i++) {
+       for (int i = 0; i < plg_len; i++) {
                MsgPlugin* pDupPlgCheck = checkPlugin(__msg_plg_items[i].type);
 
                if (pDupPlgCheck) {
-                       MSG_DEBUG("Plugin for type %d is duplicated", __msg_plg_items[i].type);
+                       MSG_INFO("Plugin for type %d is duplicated", __msg_plg_items[i].type);
                        continue;
                }
 
index 6f44866..b803b24 100755 (executable)
@@ -788,7 +788,9 @@ msg_error_t MsgSetCBMsgOpt(const MSG_SETTING_S *pSetting, bool bSetSim)
        msg_error_t err = MSG_SUCCESS;
 
        MSG_CBMSG_OPT_S cbOpt;
+#ifndef FEATURE_SMS_CDMA
        int iValue = 0;
+#endif
        bool bValue = false;
        char keyName[MAX_VCONFKEY_NAME_LEN];
        msg_sim_slot_id_t simIndex;
@@ -847,12 +849,8 @@ msg_error_t MsgSetCBMsgOpt(const MSG_SETTING_S *pSetting, bool bSetSim)
 #endif
 
        MsgDbHandler *dbHandle = getDbHandle();
-
-#ifdef FEATURE_SMS_CDMA
-       err = MsgStoAddCBChannelInfo(dbHandle, &cbOpt.channelData);
-#else
        err = MsgStoAddCBChannelInfo(dbHandle, &cbOpt.channelData, simIndex);
-#endif
+
        MSG_DEBUG("MsgStoAddCBChannelInfo : err=[%d]", err);
 
 #ifndef FEATURE_SMS_CDMA
@@ -908,12 +906,19 @@ msg_error_t MsgSetVoiceMailOpt(const MSG_SETTING_S *pSetting, bool bSetSim)
                }
 
                if (err != MSG_SUCCESS) {
+                       MSG_INFO("MsgSetConfigInSim is error, do not set voicemail");
                        goto _END_OF_SET_VOICE_OPT;
                }
 
                err = MsgSettingSetString(keyName, voiceMailOpt.mailNumber);
                if (err != MSG_SUCCESS)
                        MSG_ERR("Error to set config data [%s]", keyName);
+
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_DEFAULT_NUMBER, simIndex);
+               err = MsgSettingSetString(keyName, voiceMailOpt.mailNumber);
+               if (err != MSG_SUCCESS)
+                       MSG_ERR("Error to set config data [%s]", keyName);
        }
 
 _END_OF_SET_VOICE_OPT:
@@ -1138,11 +1143,8 @@ void MsgGetCBMsgOpt(MSG_SETTING_S *pSetting)
        pSetting->option.cbMsgOpt.maxSimCnt = MsgSettingGetInt(keyName);
 #endif
 
-#ifdef FEATURE_SMS_CDMA
-       err = MsgStoGetCBChannelInfo(dbHandle, &pSetting->option.cbMsgOpt.channelData);
-#else
        err = MsgStoGetCBChannelInfo(dbHandle, &pSetting->option.cbMsgOpt.channelData, simIndex);
-#endif
+
        if (err != MSG_SUCCESS)
                MSG_ERR("MsgStoGetCBChannelInfo : err=[%d]", err);
 
index 13d9825..8e8ffbe 100755 (executable)
@@ -576,7 +576,7 @@ msg_error_t MsgStoBackupMessage(msg_message_backup_type_t type, const char *file
                        return err;
                }
 
-               encoded_data = MsgVMessageAddRecord(dbHandle, &msgInfo);
+               encoded_data = MsgVMessageEncode(&msgInfo);
 
                if (msgInfo.bTextSms == false)
                {
@@ -668,7 +668,7 @@ msg_error_t MsgStoUpdateMms(MSG_MESSAGE_INFO_S *pMsg)
 msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id_list)
 {
        if (result_id_list == NULL) {
-               MSG_DEBUG("result_id_list is NULL");
+               MSG_ERR("result_id_list is NULL");
                return MSG_ERR_NULL_POINTER;
        }
 
@@ -678,6 +678,7 @@ msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id
 
        VTree* vMsg = NULL;
        VObject* pObject = NULL;
+       bool isMMS = false;
 
        msg_id_list_s *msgIdList = NULL;
        msgIdList = (msg_id_list_s *)calloc(1, sizeof(msg_id_list_s));
@@ -711,6 +712,7 @@ msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id
 
        while ((pTemp = strstr(pCurrent, "END:VMSG")) != NULL)
        {
+               isMMS = false;
                MSG_DEBUG("Start Position: %s", pCurrent);
 
                while (*pCurrent == '\r' || *pCurrent == '\n')
@@ -718,18 +720,32 @@ msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id
 
                MSG_DEBUG("Start Position2: %s", pCurrent);
 
-               vMsg = vmsg_decode(pCurrent);
-               if (vMsg == NULL) {
+               //decodes if it is sms
+               err = MsgVMessageDecodeSMS(pCurrent, &msgInfo);
+
+               //decode if it is mms
+               if (err == MSG_ERR_INVALID_MESSAGE) {
+                       MSG_DEBUG("Vmsg is not an SMS, decoding for MMS...");
+                       vMsg = vmsg_decode(pCurrent);
+                       isMMS = true;
+               } else if (err != MSG_SUCCESS) {
+                       MSG_ERR("Vmsg is an SMS, but format not supported.");
+                       goto __RETURN;
+               }
+
+               if (vMsg == NULL && isMMS) {
+                       MSG_ERR("Vmsg is an MMS, but format not supported.");
                        err = MSG_ERR_STORAGE_ERROR;
                        goto __RETURN;
                }
 #endif
 
-               pObject = vMsg->pTop;
-
-               memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+               if (isMMS) {
+                       pObject = vMsg->pTop;
+                       memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+               }
 
-               while (1)
+               while (1 && isMMS)
                {
                        while (1)
                        {
@@ -739,10 +755,7 @@ msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id
                                {
                                        case VMSG_TYPE_MSGTYPE :
                                        {
-                                               if (!strncmp(pObject->pszValue[0], "SMS", strlen("SMS"))) {
-                                                       msgInfo.msgType.mainType = MSG_SMS_TYPE;
-                                                       msgInfo.msgType.subType = MSG_NORMAL_SMS;
-                                               } else if (!strncmp(pObject->pszValue[0], "MMS RETRIEVED", strlen("MMS RETRIEVED"))) {
+                                               if (!strncmp(pObject->pszValue[0], "MMS RETRIEVED", strlen("MMS RETRIEVED"))) {
                                                        msgInfo.msgType.mainType = MSG_MMS_TYPE;
                                                        msgInfo.msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
                                                } else if (!strncmp(pObject->pszValue[0], "MMS SEND", strlen("MMS SEND"))) {
@@ -811,7 +824,7 @@ msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id
 
                                        case VMSG_TYPE_DATE :
                                        {
-                                               struct tm       displayTime;
+                                               struct tm displayTime;
 
                                                if (!_convert_vdata_str_to_tm(pObject->pszValue[0], &displayTime)) {
                                                        vmsg_free_vtree_memory( vMsg );
@@ -837,37 +850,7 @@ msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id
 
                                        case VMSG_TYPE_BODY :
                                        {
-                                               if (msgInfo.msgType.mainType == MSG_SMS_TYPE) {
-                                                       if (pObject->numOfBiData > MAX_MSG_DATA_LEN) {
-                                                               msgInfo.bTextSms = false;
-                                                               char fileName[MAX_COMMON_INFO_SIZE + 1];
-                                                               memset(fileName, 0x00, sizeof(fileName));
-
-                                                               if (MsgCreateFileName(fileName) == false) {
-                                                                       vmsg_free_vtree_memory(vMsg);
-                                                                       err = MSG_ERR_STORAGE_ERROR;
-                                                                       goto __RETURN;
-                                                               }
-
-                                                               if (MsgWriteIpcFile(fileName, pObject->pszValue[0], pObject->numOfBiData) == false) {
-                                                                       vmsg_free_vtree_memory(vMsg);
-                                                                       err = MSG_ERR_STORAGE_ERROR;
-                                                                       goto __RETURN;
-                                                               }
-
-                                                               strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
-                                                               msgInfo.dataSize = pObject->numOfBiData;
-                                                       } else {
-                                                               msgInfo.bTextSms = true;
-
-                                                               if(pObject->numOfBiData > 0) {
-                                                                       memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
-                                                                       memcpy(msgInfo.msgText, pObject->pszValue[0], pObject->numOfBiData);
-
-                                                                       msgInfo.dataSize = pObject->numOfBiData;
-                                                               }
-                                                       }
-                                               } else {
+                                               if (msgInfo.msgType.mainType == MSG_MMS_TYPE) {
                                                        msgInfo.bTextSms = true;
 #if 0
                                                        if(msgInfo.msgType.subType == MSG_NOTIFICATIONIND_MMS) {
index 4ed886a..6c05b7d 100755 (executable)
 #include "MsgUtilFile.h"
 #include "MsgMutex.h"
 #include "MsgUtilStorage.h"
-#include "MsgSoundPlayer.h"
 #include "MsgGconfWrapper.h"
 #include "MsgSqliteWrapper.h"
 #include "MsgPluginManager.h"
 #include "MsgStorageHandler.h"
 #include "MsgNotificationWrapper.h"
-#include "MsgMmsMessage.h"
 #include "MsgDevicedWrapper.h"
 
 using namespace std;
@@ -60,7 +58,7 @@ static gboolean resetNotification(void *pVoid)
 {
        MSG_BEGIN();
 
-       MsgRefreshAllNotification(true, false, false);
+       MsgRefreshAllNotification(true, false, MSG_ACTIVE_NOTI_TYPE_NONE);
 
        MSG_END();
 
@@ -111,11 +109,20 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS
        }
 
        int fileSize = 0;
-       gchar *contents = NULL;
 
        char *pFileData = NULL;
        unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter);
 
+       // Get File Data
+       if (pMsg->bTextSms == false) {
+               if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) {
+                       dbHandle->endTrans(false);
+                       return MSG_ERR_STORAGE_ERROR;
+               }
+
+               MSG_DEBUG("file size [%d]", fileSize);
+       }
+
        char keyName[MAX_VCONFKEY_NAME_LEN];
        memset(keyName, 0x00, sizeof(keyName));
        snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SUBS_ID, pMsg->sim_idx);
@@ -145,44 +152,20 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS
        if (pMsg->msgType.subType == MSG_NOTIFICATIONIND_MMS) {
                dbHandle->bindText("", 2);
        } else {
-               if (pMsg->bTextSms == false) {
-                       //CID 47860: pMsg->msgData is an array, hence null check is not required
-                       char fn[MSG_FILEPATH_LEN_MAX];
-                       memset(fn,0x00,MSG_FILEPATH_LEN_MAX);
-                       snprintf(fn, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_IPC_DATA_PATH, pMsg->msgData);
-
-                       if (g_file_get_contents((gchar*)fn, (gchar**)&contents, NULL, NULL)) {
-                               MSG_DEBUG("g_file_get_contents() Success!!");
-                               dbHandle->bindText(contents, 2);
-                       } else {
-                               MSG_DEBUG("g_file_get_contents() Failed!!");
-                               dbHandle->bindText("", 2);
-                       }
-
-               } else
+               if (pMsg->bTextSms == false)
+                       dbHandle->bindText(pFileData, 2);
+               else
                        dbHandle->bindText(pMsg->msgText, 2);
        }
 
        if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
                dbHandle->finalizeQuery();
                dbHandle->endTrans(false);
-               //free contents
-               if (contents) {
-                       g_free(contents);
-                       contents = NULL;
-               }
-
                return MSG_ERR_DB_EXEC;
        }
 
        dbHandle->finalizeQuery();
 
-       //free contents
-       if (contents) {
-               g_free(contents);
-               contents = NULL;
-       }
-
        if (pMsg->msgType.subType != MSG_SENDREQ_MMS) {
                err = MsgStoUpdateConversation(dbHandle, convId);
 
@@ -262,15 +245,13 @@ msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pS
                                return MSG_ERR_NULL_POINTER;
                        }
 
-                       if (pMmsSerializedData == NULL) {
-                               if (MsgOpenAndReadFile(pMsg->msgData, &pMmsSerializedData, &fileSize) == false) {
-                                       dbHandle->endTrans(false);
-                                       return MSG_ERR_STORAGE_ERROR;
-                               }
-
-                               MSG_DEBUG("file size [%d]", fileSize);
+                       if (MsgOpenAndReadFile(pMsg->msgData, &pMmsSerializedData, &fileSize) == false) {
+                               dbHandle->endTrans(false);
+                               return MSG_ERR_STORAGE_ERROR;
                        }
 
+                       MSG_DEBUG("file size [%d]", fileSize);
+
                        err = plg->addMessage(pMsg, pSendOptInfo, pMmsSerializedData);
 
                        if (err != MSG_SUCCESS) {
@@ -527,60 +508,62 @@ msg_error_t MsgStoUpdateReadStatus(msg_message_id_t msgId, bool bRead)
                return MSG_ERR_STORAGE_ERROR;
        }
 
-       MsgRefreshAllNotification(true, false, false);
+       MsgRefreshAllNotification(true, false, MSG_ACTIVE_NOTI_TYPE_NONE);
 
-       // Get STORAGE_ID
-       memset(sqlQuery, 0x00, sizeof(sqlQuery));
-       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT STORAGE_ID FROM %s WHERE MSG_ID = %d;",
-                       MSGFW_MESSAGE_TABLE_NAME, msgId);
+       if (bRead == true) {
+#ifndef FEATURE_SMS_CDMA
+               // Get STORAGE_ID
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT STORAGE_ID FROM %s WHERE MSG_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, msgId);
 
-       if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
-               return MSG_ERR_DB_PREPARE;
+               if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_PREPARE;
 
-       if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
-               storageId = dbHandle->columnInt(0);
-       } else {
+               if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+                       storageId = dbHandle->columnInt(0);
+               } else {
+                       dbHandle->finalizeQuery();
+                       return MSG_ERR_DB_STEP;
+               }
                dbHandle->finalizeQuery();
-               return MSG_ERR_DB_STEP;
-       }
-
-       dbHandle->finalizeQuery();
 
-       MSG_DEBUG("StorageId:[%d]", storageId);
+               MSG_DEBUG("StorageId:[%d]", storageId);
 
-#ifndef FEATURE_SMS_CDMA
-       // Update Read Status for SIM Msg
-       if (storageId == MSG_STORAGE_SIM) {
-               MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE);
+               // Update Read Status for SIM Msg
+               if (storageId == MSG_STORAGE_SIM) {
+                       MsgPlugin *plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE);
 
-               if (plg == NULL) {
-                       MSG_DEBUG("SMS Plug-in is NULL");
-                       return MSG_ERR_NULL_POINTER;
-               }
+                       if (plg == NULL) {
+                               MSG_DEBUG("SMS Plug-in is NULL");
+                               return MSG_ERR_NULL_POINTER;
+                       }
 
-               // Get SIM Msg ID
-               memset(sqlQuery, 0x00, sizeof(sqlQuery));
-               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_SLOT_ID, SIM_ID FROM %s WHERE MSG_ID = %d;",
-                               MSGFW_SIM_MSG_TABLE_NAME, msgId);
+                       // Get SIM Msg ID
+                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+                       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_SLOT_ID, SIM_ID FROM %s WHERE MSG_ID = %d;",
+                                       MSGFW_SIM_MSG_TABLE_NAME, msgId);
 
-               if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
-                       return MSG_ERR_DB_PREPARE;
+                       if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+                               return MSG_ERR_DB_PREPARE;
 
-               msg_sim_id_t simId;
-               msg_sim_slot_id_t sim_idx;
+                       msg_sim_id_t simId;
+                       msg_sim_slot_id_t sim_idx;
 
-               while (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
-                       sim_idx = dbHandle->columnInt(0);
-                       simId = dbHandle->columnInt(1);
+                       while (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+                               sim_idx = dbHandle->columnInt(0);
+                               simId = dbHandle->columnInt(1);
 
-                       if (plg->setReadStatus(sim_idx, simId) != MSG_SUCCESS) {
-                               MSG_DEBUG("Fail to Set Read Status for SIM SMS");
-                               continue;
+                               if (plg->setReadStatus(sim_idx, simId) != MSG_SUCCESS) {
+                                       MSG_DEBUG("Fail to Set Read Status for SIM SMS");
+                                       continue;
+                               }
                        }
+                       dbHandle->finalizeQuery();
                }
-               dbHandle->finalizeQuery();
-       }
 #endif
+       }
+
        return MSG_SUCCESS;
 }
 
@@ -1024,17 +1007,13 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication)
                if (MsgStoCheckMsgCntFull(dbHandle, &msgType, folderId) == MSG_SUCCESS) {
                        MSG_DEBUG("Set Memory Status");
 
-#ifndef FEATURE_SMS_CDMA
                        plg->setMemoryStatus(simIndex, MSG_SUCCESS);
-#else
-                       plg->setMemoryStatus(MSG_SUCCESS);
-#endif
                }
        }
 
        if (bCheckIndication == true) {
                MSG_DEBUG("bCheckIndication is true.");
-               MsgRefreshAllNotification(true, false, false);
+               MsgRefreshAllNotification(true, false, MSG_ACTIVE_NOTI_TYPE_NONE);
        }
 
        return MSG_SUCCESS;
@@ -1341,7 +1320,7 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD
 //                             err = MSG_ERR_UNKNOWN;
 //                     }
 
-                       MsgRefreshAllNotification(true, false, false);
+                       MsgRefreshAllNotification(true, false, MSG_ACTIVE_NOTI_TYPE_NONE);
                }
        }
 /*** **/
@@ -1524,8 +1503,8 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList)
        for (int i = 0; i < listCnt; i++) {
                if ( !i ) {
 
-                       char filePath[MSG_FILEPATH_LEN_MAX];
-                       char dirPath[MSG_FILEPATH_LEN_MAX];
+                       char filePath[MSG_FILEPATH_LEN_MAX] = {0,};
+                       char dirPath[MSG_FILEPATH_LEN_MAX] = {0,};
 
                        rowCnt = 0;
 
@@ -1722,7 +1701,8 @@ msg_error_t MsgStoMoveMessageToFolder(msg_message_id_t msgId, msg_folder_id_t de
        err = MsgStoUpdateConversation(dbHandle, convId);
 
        /* update notification */
-       MsgRefreshAllNotification(true, false, false);
+       if (destFolderId != MSG_SPAMBOX_ID)
+               MsgRefreshAllNotification(true, false, MSG_ACTIVE_NOTI_TYPE_NONE);
 
        return err;
 }
@@ -1796,6 +1776,7 @@ msg_error_t MsgStoMoveMessageToStorage(msg_message_id_t msgId, msg_storage_id_t
 
        default: //Moving message to memory (when destination storage id is MSG_STORAGE_PHONE)
                {
+#ifndef FEATURE_SMS_CDMA
                        bool bSimMsg = false;
                        int rowCnt = 0;
 
@@ -1818,7 +1799,6 @@ msg_error_t MsgStoMoveMessageToStorage(msg_message_id_t msgId, msg_storage_id_t
 
                        dbHandle->freeTable();
 
-#ifndef FEATURE_SMS_CDMA
                        if (bSimMsg == true) {
                                msg_sim_id_t simMsgId;
                                msg_sim_slot_id_t sim_idx;
@@ -2185,8 +2165,9 @@ msg_error_t MsgStoGetFailedMessage(int **failed_msg_list, int *count)
 
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
-       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE NETWORK_STATUS = %d AND FOLDER_ID = %d;",
-                               MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SEND_PENDING, MSG_OUTBOX_ID);
+       /* Folder ID == 2 : sending failed message, Folder ID == 1 : retrieve failed message */
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE (NETWORK_STATUS = %d OR NETWORK_STATUS == %d) AND (FOLDER_ID = %d OR FOLDER_ID = %d);",
+                               MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SEND_PENDING, MSG_NETWORK_RETRIEVE_PENDING, MSG_OUTBOX_ID, MSG_INBOX_ID);
        err = dbHandle->getTable(sqlQuery, &rowCnt, &index);
 
        if(err == MSG_ERR_DB_NORECORD){
@@ -2257,7 +2238,8 @@ msg_error_t MsgStoAddSyncMLMessage(MSG_MESSAGE_INFO_S *pMsgInfo, int extId, int
        pMsgInfo->msgId = (msg_message_id_t)rowId;
 
        MsgInsertNotification(pMsgInfo);
-       MsgChangePmState();
+       if (MsgCheckNotificationSettingEnable())
+               MsgChangePmState();
 
        MSG_END();
 
@@ -2377,14 +2359,27 @@ msg_error_t MsgStoDeleteThreadMessageList(msg_thread_id_t threadId, bool bInclud
        err = dbHandle->getTable(sqlQuery, &rowCnt, &index);
 
        if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
-               MSG_DEBUG("Fail to getTable().");
+               MSG_ERR("Fail to getTable().");
                dbHandle->freeTable();
                return err;
        }
 
        if (rowCnt <= 0) {
-//             dbHandle->freeTable();
-               err = MSG_SUCCESS;
+               dbHandle->freeTable();
+
+               err = MsgStoClearConversationTable(dbHandle);
+               if (err != MSG_SUCCESS) {
+                       MSG_ERR("Fail to MsgStoClearConversationTable().");
+                       return err;
+               }
+
+               err = MsgStoUpdateConversation(dbHandle, threadId);
+               if (err != MSG_SUCCESS) {
+                       MSG_ERR("Fail to MsgStoUpdateConversation().");
+                       return err;
+               }
+
+               return MSG_SUCCESS;
        }
 
        pMsgIdList->nCount = rowCnt;
@@ -2400,11 +2395,81 @@ msg_error_t MsgStoDeleteThreadMessageList(msg_thread_id_t threadId, bool bInclud
        /*** **/
 
        err = MsgStoDeleteMessageByList(pMsgIdList);
+       if (err != MSG_SUCCESS) {
+               MSG_ERR("Fail to MsgStoDeleteMessageByList().");
+               return err;
+       }
 
        return err;
 }
 
 
+msg_error_t MsgStoSetTempAddressTable(const char *pSearchVal, int *count)
+{
+       MSG_ADDRESS_INFO_S *pAddrInfo = NULL;
+       unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> buf(&pAddrInfo, unique_ptr_deleter);
+       *count = 0;
+
+       // get contact search list
+       if (MsgGetContactSearchList(pSearchVal, &pAddrInfo, count) != MSG_SUCCESS) {
+               MSG_DEBUG("MsgGetContactSearchList fail.");
+               *count = 0;
+               return MSG_SUCCESS;
+       }
+
+       if (*count == 0) {
+               return MSG_SUCCESS;
+       }
+       MsgDbHandler *dbHandle = getDbHandle();
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       dbHandle->beginTrans();
+       // reset address temp table
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s;", MSGFW_ADDRESS_TEMP_TABLE_NAME);
+       MSG_DEBUG("[%s]", sqlQuery);
+
+       if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_EXEC;
+
+       if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
+               dbHandle->finalizeQuery();
+               dbHandle->endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle->finalizeQuery();
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (?);", MSGFW_ADDRESS_TEMP_TABLE_NAME);
+       if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle->endTrans(false);
+               return MSG_ERR_DB_PREPARE;
+       }
+
+       char newPhoneNum[MAX_ADDRESS_VAL_LEN+1];
+       char tmpNum[MAX_ADDRESS_VAL_LEN+1];
+       for (int i = 0; i < *count; i++) {
+               memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
+               memset(tmpNum, 0x00, sizeof(tmpNum));
+               MsgConvertNumber(pAddrInfo[i].addressVal, tmpNum, sizeof(tmpNum));
+               snprintf(newPhoneNum, sizeof(newPhoneNum), "%%%%%s", tmpNum);
+               dbHandle->resetQuery();
+               dbHandle->bindText(newPhoneNum, 1);
+               if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
+                       dbHandle->finalizeQuery();
+                       dbHandle->endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+       }
+
+       dbHandle->finalizeQuery();
+       dbHandle->endTrans(true);
+
+       return MSG_SUCCESS;
+}
+
+
 msg_error_t MsgStoCountMsgByContact(const MSG_THREAD_LIST_INDEX_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pThreadCountInfo)
 {
        MsgDbHandler *dbHandle = getDbHandle();
@@ -2679,14 +2744,12 @@ msg_error_t MsgStoGetThreadInfo(msg_thread_id_t threadId, MSG_THREAD_VIEW_S *pTh
                        "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.PROTECTED = 1) AS PROTECTED, "
                        "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.FOLDER_ID = %d) AS DRAFT, "
                        "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.NETWORK_STATUS = %d) AS FAILED, "
-                       "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.NETWORK_STATUS = %d) AS SENDING, "
-                       "(SELECT SIM_INDEX FROM %s B WHERE B.CONV_ID = A.CONV_ID) "
+                       "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.NETWORK_STATUS = %d) AS SENDING "
                        "FROM %s A WHERE A.CONV_ID = %d AND A.SMS_CNT + A.MMS_CNT > 0;",
                        MSGFW_MESSAGE_TABLE_NAME,
                        MSGFW_MESSAGE_TABLE_NAME, MSG_DRAFT_ID,
                        MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SEND_FAIL,
                        MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SENDING,
-                       MSGFW_MESSAGE_TABLE_NAME,
                        MSGFW_CONVERSATION_TABLE_NAME, threadId);
 
        msg_error_t err = dbHandle->getTable(sqlQuery, &rowCnt, &index);
@@ -2738,8 +2801,6 @@ msg_error_t MsgStoGetThreadInfo(msg_thread_id_t threadId, MSG_THREAD_VIEW_S *pTh
                int sendingCnt = dbHandle->getColumnToInt(index++);
                if (sendingCnt > 0)
                        pThreadInfo->bSending = true;
-
-               pThreadInfo->simIndex = dbHandle->getColumnToInt(index++);
        }
 
        dbHandle->freeTable();
@@ -2758,12 +2819,10 @@ msg_error_t MsgStoRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S
        msg_error_t err = MSG_SUCCESS;
        char sqlQuery[MAX_QUERY_LEN+1];
 
-       if(MsgExistConversation(dbHandle, pMsg->threadId))
-       {
+       if(MsgExistConversation(dbHandle, pMsg->threadId)) {
                // add message to address table  which having same thread_id and datetime;
-               for (int i=0; i<pMsg->nAddressCnt; i++) {
-                       if(MsgExistAddress(dbHandle, pMsg, pMsg->threadId, i) == false)
-                       {
+               for (int i = 0; i < pMsg->nAddressCnt; i++) {
+                       if(MsgExistAddress(dbHandle, pMsg, pMsg->threadId, i) == false) {
                                unsigned int addrId;
                                MSG_CONTACT_INFO_S contactInfo;
                                memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
@@ -2808,11 +2867,10 @@ msg_error_t MsgStoRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S
                }
 
 
-               if(!MsgExistMessage(dbHandle, pMsg))
-               {
+               if(!MsgExistMessage(dbHandle, pMsg)) {
                        unsigned int rowId = 0;
 
-                       if(pMsg->threadId > 0 && pMsg->folderId == MSG_DRAFT_ID) {
+                       if (pMsg->threadId > 0 && pMsg->folderId == MSG_DRAFT_ID) {
                                memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
                                snprintf(sqlQuery, sizeof(sqlQuery),
@@ -3081,7 +3139,7 @@ msg_error_t MsgStoUpdateIMSI(int sim_idx)
 
                char *imsi = MsgSettingGetString(keyName);
 
-               MSG_DEBUG("imsi value exist -> %s", imsi);
+               MSG_SEC_DEBUG("imsi value exist -> %s", imsi);
 
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
index 74a8276..82ce2d7 100755 (executable)
@@ -80,12 +80,19 @@ msg_error_t MsgStoUpdateMMSMessage(MSG_MESSAGE_INFO_S *pMsg)
        char sqlQuery[MAX_QUERY_LEN+1];
 
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       MSG_INFO("[%d] [%d]", pMsg->msgType.subType, pMsg->networkStatus);
 
        if(pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
                if( pMsg->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS ) {
-                       snprintf(sqlQuery, sizeof(sqlQuery),
-                                       "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, FOLDER_ID = %d, DISPLAY_TIME = %lu, SUBJECT = ?, NETWORK_STATUS = %d, MSG_TEXT = ?, THUMB_PATH = '%s', DATA_SIZE = %d WHERE MSG_ID = %d;",
-                                       MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->folderId, pMsg->displayTime, pMsg->networkStatus, pMsg->thumbPath,  pMsg->dataSize, pMsg->msgId);
+                       if (pMsg->displayTime > 0) {
+                               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, FOLDER_ID = %d, DISPLAY_TIME = %lu, SUBJECT = ?, NETWORK_STATUS = %d, MSG_TEXT = ?, THUMB_PATH = '%s', DATA_SIZE = %d WHERE MSG_ID = %d;",
+                                               MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->folderId, pMsg->displayTime, pMsg->networkStatus, pMsg->thumbPath,  pMsg->dataSize, pMsg->msgId);
+                       } else {
+                               snprintf(sqlQuery, sizeof(sqlQuery),
+                                               "UPDATE %s SET MAIN_TYPE = %d, SUB_TYPE = %d, FOLDER_ID = %d, SUBJECT = ?, NETWORK_STATUS = %d, MSG_TEXT = ?, THUMB_PATH = '%s', DATA_SIZE = %d WHERE MSG_ID = %d;",
+                                               MSGFW_MESSAGE_TABLE_NAME, pMsg->msgType.mainType, pMsg->msgType.subType, pMsg->folderId, pMsg->networkStatus, pMsg->thumbPath,  pMsg->dataSize, pMsg->msgId);
+                       }
 
                        if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
                                return MSG_ERR_DB_PREPARE;
index 95cad90..468300c 100755 (executable)
@@ -166,8 +166,7 @@ msg_error_t MsgStoResetCBMessage()
 
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
-       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s",
-                       MSGFW_RECEIVED_CB_MSG_TABLE_NAME);
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s;", MSGFW_RECEIVED_CB_MSG_TABLE_NAME);
 
        if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
                MSG_DEBUG("Delete Received CB Msg Fail!!");
index 41e6825..aa52fdb 100755 (executable)
@@ -81,8 +81,12 @@ msg_error_t MsgSubmitReqSMS(MSG_REQUEST_INFO_S *pReqInfo)
        MSG_MAIN_TYPE_T mainType = pReqInfo->msgInfo.msgType.mainType;
        MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType);
 
-       if (plg == NULL)
-               return MSG_ERR_NULL_POINTER;
+       if (plg == NULL) {
+               MsgDbHandler *dbHandle = getDbHandle();
+               MsgStoUpdateNetworkStatus(dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+               MSG_ERR("No plugin for %d type", mainType);
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
+       }
 
        // If MSG ID > 0 -> MSG in DRAFT
        // Move Folder to OUTBOX
@@ -108,8 +112,11 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo)
 
        MsgPlugin *sms_plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE);
 
-       if (sms_plg == NULL){
-               return MSG_ERR_NULL_POINTER;
+       if (sms_plg == NULL) {
+               MsgDbHandler *dbHandle = getDbHandle();
+               MsgStoUpdateNetworkStatus(dbHandle, &(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+               MSG_ERR("No plugin for %d type", MSG_SMS_TYPE);
+               return MSG_ERR_INVALID_PLUGIN_HANDLE;
        }
 
        int defaultNetworkSimId = 0;
@@ -142,12 +149,12 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo)
 
        if(pReqInfo->msgInfo.msgType.subType == MSG_SENDREQ_JAVA_MMS)
        {
-               char fileName[MAX_COMMON_INFO_SIZE+1] = {0};
+               char fileName[MSG_FILENAME_LEN_MAX+1] = {0};
 
                // copy whole of MMS PDU filepath to msgData
-               strncpy(fileName, pReqInfo->msgInfo.msgData, MAX_COMMON_INFO_SIZE);
-               memset(pReqInfo->msgInfo.msgData, 0x00, MAX_MSG_DATA_LEN+1);
-               snprintf(pReqInfo->msgInfo.msgData, MAX_MSG_DATA_LEN+1, "%s%s", MSG_IPC_DATA_PATH, fileName);
+               strncpy(fileName, pReqInfo->msgInfo.msgData, MSG_FILENAME_LEN_MAX);
+               memset(pReqInfo->msgInfo.msgData, 0x00, sizeof(pReqInfo->msgInfo.msgData));
+               snprintf(pReqInfo->msgInfo.msgData, sizeof(pReqInfo->msgInfo.msgData), "%s%s", MSG_IPC_DATA_PATH, fileName);
 
                MSG_SEC_DEBUG("JAVA MMS PDU filepath:%s", pReqInfo->msgInfo.msgData);
 
@@ -164,6 +171,8 @@ msg_error_t MsgSubmitReqMMS(MSG_REQUEST_INFO_S *pReqInfo)
        }
        else if((pReqInfo->msgInfo.msgType.subType == MSG_SENDREQ_MMS) || (pReqInfo->msgInfo.msgType.subType == MSG_FORWARD_MMS))
        {
+               MSG_SEC_DEBUG("msgdata file path = [%s]", pReqInfo->msgInfo.msgData);
+
                if(pReqInfo->msgInfo.msgId > 0 && (pReqInfo->msgInfo.folderId == MSG_DRAFT_ID || pReqInfo->msgInfo.folderId == MSG_OUTBOX_ID)) {
                        MSG_DEBUG("Not New Message.");
                        pReqInfo->msgInfo.folderId = MSG_OUTBOX_ID;
index 614a9fa..319e708 100755 (executable)
@@ -195,8 +195,10 @@ int MsgGetFilterListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                        msg_struct_s *msg_struct;
                        for (int i = 0; i < filterList.nCount; i++) {
                                msg_struct = (msg_struct_s *)filterList.msg_struct_info[i];
-                               delete (MSG_FILTER_S *)msg_struct->data;
-                               delete msg_struct;
+                               if (msg_struct) {
+                                       delete (MSG_FILTER_S *)msg_struct->data;
+                                       delete msg_struct;
+                               }
                        }
                        g_free(filterList.msg_struct_info);
                }
index d59b71e..994be20 100755 (executable)
@@ -45,7 +45,7 @@ static gboolean  __refresh_noti(void *data)
 
        if (g_job_cnt <= 0) {
                MSG_DEBUG("## Refresh notification ##");
-               if (MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, false, false) != MSG_SUCCESS) {
+               if (MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, false, MSG_ACTIVE_NOTI_TYPE_NONE) != MSG_SUCCESS) {
                        MSG_DEBUG("MsgRefreshNoti is failed");
                }
                g_job_cnt = 0;
@@ -81,21 +81,18 @@ int MsgAddMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
 
        MsgDecodeMsgInfo((char *)pCmd->cmdData, &msgInfo, &sendOptInfo);
 
-       if(msgInfo.threadId) // threadId is not 0 : message restore from S-Cloud
-       {
+       if (msgInfo.bBackup) {
                err = MsgStoRestoreMessage(&msgInfo, &sendOptInfo);
 
                if (err == MSG_SUCCESS) {
-                               MSG_DEBUG("Command Handle Success : MsgStoRestoreMessage()");
+                       MSG_DEBUG("Command Handle Success : MsgStoRestoreMessage()");
 
-                               // Encoding Message ID
-                               dataSize = MsgEncodeMsgId(&(msgInfo.msgId), &encodedData);
+                       // Encoding Message ID
+                       dataSize = MsgEncodeMsgId(&(msgInfo.msgId), &encodedData);
                } else {
                        MSG_DEBUG("Command Handle Fail : MsgStoRestoreMessage()");
                }
-       }
-       else
-       {
+       } else {
                // Add Message
                msgInfo.msgId = 0;
                err = MsgStoAddMessage(&msgInfo, &sendOptInfo);
@@ -524,7 +521,7 @@ int MsgDeleteMessageByListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
        msg_id_list_s msgIdList;
        memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
 
-       memcpy(&msgIdList.nCount, pCmd->cmdData, sizeof(int));
+       memcpy(&msgIdList.nCount, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
 
        MSG_DEBUG("msgIdList.nCount [%d]", msgIdList.nCount);
 
@@ -533,8 +530,8 @@ int MsgDeleteMessageByListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
 
        msgIdList.msgIdList = msgIds;
 
-       for (int i=0; i<msgIdList.nCount; i++) {
-               msgIds[i] = *(msg_message_id_t *)(((char*)pCmd->cmdData) + (sizeof(int)*(i+1)));
+       for (int i = 0; i < msgIdList.nCount; i++) {
+               memcpy(&msgIds[i], (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+sizeof(msg_message_id_t)*i), sizeof(msg_message_id_t));
        }
 
        // Delete Message
@@ -894,8 +891,10 @@ int MsgGetFolderListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                        msg_struct_s *msg_struct;
                        for (int i = 0; i < folderList.nCount; i++) {
                                msg_struct = (msg_struct_s *)folderList.msg_struct_info[i];
-                               delete (MSG_FOLDER_INFO_S *)msg_struct->data;
-                               delete msg_struct;
+                               if (msg_struct) {
+                                       delete (MSG_FOLDER_INFO_S *)msg_struct->data;
+                                       delete msg_struct;
+                               }
                        }
                        g_free(folderList.msg_struct_info);
                }
@@ -969,8 +968,10 @@ int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                        msg_struct_s *msg_struct;
                        for (int i = 0; i < folderList.nCount; i++) {
                                msg_struct = (msg_struct_s *)msgThreadViewList.msg_struct_info[i];
-                               delete (MSG_THREAD_VIEW_S *)msg_struct->data;
-                               delete msg_struct;
+                               if (msg_struct) {
+                                       delete (MSG_THREAD_VIEW_S *)msg_struct->data;
+                                       delete msg_struct;
+                               }
                        }
                        g_free(msgThreadViewList.msg_struct_info);
                }
@@ -1022,18 +1023,54 @@ int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                }
 
                MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_DELETE, &msgIdList);
-               if(msgIdList.msgIdList != NULL)
-                       delete [] (char*)msgIdList.msgIdList;
+       } else {
+               MSG_DEBUG("Command Handle Fail : MsgStoDeleteThreadMessageList()");
+       }
+
+       if(msgIdList.msgIdList != NULL) {
+               delete [] (char*)msgIdList.msgIdList;
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_THREADMESSAGELIST, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgSetTempAddressTableHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       msg_error_t err = MSG_SUCCESS;
+
+       if (!pCmd || !ppEvent) {
+               MSG_DEBUG("pCmd or ppEvent is null");
+               return 0;
+       }
+
+       int search_len = 0;
+       memcpy(&search_len, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
+
+       char search_val[search_len + 1] = {0,};
+       memcpy(&search_val, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), sizeof(char)*search_len);
+
+       int eventSize = 0;
+       int count = 0;
+
+       err = MsgStoSetTempAddressTable(search_val, &count);
+
+       if (err == MSG_SUCCESS) {
+               MSG_DEBUG("Command Handle Success : MsgStoSetTmpAddressTable()");
        }
        else
        {
-               MSG_DEBUG("Command Handle Fail : MsgStoDeleteThreadMessageList()");
-               if(msgIdList.msgIdList != NULL)
-                       delete [] (char*)msgIdList.msgIdList;
+               MSG_DEBUG("Command Handle Fail : MsgStoSetTmpAddressTable()");
+               count = 0;
        }
 
        // Make Event Data
-       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_DELETE_THREADMESSAGELIST, err, (void**)ppEvent);
+       eventSize = MsgMakeEvent(&count, sizeof(int), MSG_EVENT_SET_TEMP_ADDRESS_TABLE, err, (void**)ppEvent);
+
+       MSG_END();
 
        return eventSize;
 }
@@ -1199,7 +1236,7 @@ int MsgBackupMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
        memcpy(&type, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(msg_message_backup_type_t));
        memcpy(&path, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_backup_type_t)), sizeof(path));
 
-       MSG_DEBUG("type = %d, path = %s", type, path);
+       char fullPath[MSG_FILEPATH_LEN_MAX+1] = {0,};
 
        err = MsgStoBackupMessage(type, path);
        if (err == MSG_SUCCESS)
@@ -1662,11 +1699,13 @@ int MsgUpdatePushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent)
        int eventSize = 0;
 
        // Get Message Info
-       MSG_PUSH_EVENT_INFO_S* pSrc = (MSG_PUSH_EVENT_INFO_S*)pCmd->cmdData;
-       MSG_PUSH_EVENT_INFO_S* pDst = (MSG_PUSH_EVENT_INFO_S*)(pCmd->cmdData + sizeof(MSG_PUSH_EVENT_INFO_S));
+       MSG_PUSH_EVENT_INFO_S pSrc;
+       MSG_PUSH_EVENT_INFO_S pDst;
+       memcpy(&pSrc, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_PUSH_EVENT_INFO_S));
+       memcpy(&pDst, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_PUSH_EVENT_INFO_S)), sizeof(MSG_PUSH_EVENT_INFO_S));
 
        // Add Message
-       err = MsgStoUpdatePushEvent(pSrc, pDst);
+       err = MsgStoUpdatePushEvent(&pSrc, &pDst);
 
        if (err == MSG_SUCCESS) {
                MSG_DEBUG("Command Handle Success : MsgStoUpdatePushEvent()");
@@ -1781,9 +1820,9 @@ int MsgUpdateIMSIHandler(const MSG_CMD_S *pCmd, char **ppEvent)
        err = MsgStoUpdateIMSI(sim_idx);
 
        if (err == MSG_SUCCESS) {
-               MSG_DEBUG("Command Handle Success : MsgStoUpdatePushEvent()");
+               MSG_DEBUG("Command Handle Success : MsgStoUpdateIMSI()");
        } else {
-               MSG_DEBUG("Command Handle Fail : MsgStoUpdatePushEvent()");
+               MSG_DEBUG("Command Handle Fail : MsgStoUpdateIMSI()");
        }
 
        // Make Event Data
index e6cd650..868f410 100755 (executable)
@@ -49,6 +49,7 @@ int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                return 0;
        }
 
+       int ret[3];
        int eventSize = 0;
 
        MSG_REQUEST_INFO_S reqInfo = {0,};
@@ -121,8 +122,12 @@ int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                tm->setJavaMMSList(&trId);
        }
 
+               ret[0] = reqId;
+               ret[1] = reqInfo.msgInfo.msgId;
+               ret[2] = reqInfo.msgInfo.threadId;
+
        // Make Event Data
-       eventSize = MsgMakeEvent(&reqId, sizeof(reqId), MSG_EVENT_SUBMIT_REQ, err, (void**)ppEvent);
+       eventSize = MsgMakeEvent(ret, sizeof(ret), MSG_EVENT_SUBMIT_REQ, err, (void**)ppEvent);
 
        /* reject_msg_support */
        if (((reqInfo.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS) &&
@@ -171,7 +176,7 @@ int MsgRegSentStatusCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
 
        // Get Message Request
        int listenerFd = 0;
-       memcpy(&listenerFd, pCmd->cmdData, sizeof(int));
+       memcpy(&listenerFd, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
        MSG_DEBUG("Registering sent status CB for %d", listenerFd);
 
        // storing dst fd in list
@@ -350,7 +355,7 @@ int MsgRegStorageChangeCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent)
 
        // Get Message Request
        int listenerFd = 0;
-       memcpy(&listenerFd, pCmd->cmdData, sizeof(int));
+       memcpy(&listenerFd, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
        MSG_DEBUG("Registering storage change CB for %d", listenerFd);
 
        // storing dst fd in list
@@ -373,7 +378,7 @@ int MsgRegIncomingReportMsgCallbackHandler(const MSG_CMD_S *pCmd, char **ppEvent
 
        // Get Message Request
        int listenerFd = 0;
-       memcpy(&listenerFd, pCmd->cmdData, sizeof(int));
+       memcpy(&listenerFd, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
        MSG_DEBUG("Registering report msg incoming CB for %d", listenerFd);
 
        // storing dst fd in list
@@ -578,10 +583,12 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
 
        if (msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) {
 
-               /* PLM P141008-05143 : Notification.Ind address is 1, but MMS retreived Conf address is correct.
-               So adding code for comparing exist address and new address and replace with new address(MMSconf) address */
-               if (msgInfo.nAddressCnt == 1 && msgInfo.networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS && (g_strcmp0(tmpAddr->addressVal, msgInfo.addressList[0].addressVal) != 0)) {
-                       MSG_WARN("Address of NotiInd and MMSConf are different!!, Replace [NotiInd : %s] from [MMSConf : %s]", tmpAddr->addressVal, msgInfo.addressList[0].addressVal);
+               /* PLM P141008-05143 & P150710-01521 : Notification.Ind address and MMS retreived Conf address are different.
+                   Replace Notification.Ind address with MMS retreived Conf address if and only if MMS retreived Conf address is a valid address not junk*/
+               if (msgInfo.nAddressCnt == 1 && msgInfo.networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS && MsgIsNumber(msgInfo.addressList[0].addressVal)
+                       && strlen(msgInfo.addressList[0].addressVal) >= (unsigned int)MsgContactGetMinMatchDigit() && msgInfo.addressList[0].addressType != MSG_ADDRESS_TYPE_EMAIL
+                       && (g_strcmp0(tmpAddr->addressVal, msgInfo.addressList[0].addressVal) != 0)) {
+                       MSG_WARN("Address of NotiInd and MMSConf are different!!, Replace [NotiInd address: %s] from [MMSConf address: %s]", tmpAddr->addressVal, msgInfo.addressList[0].addressVal);
                        memset(tmpAddr->addressVal, 0x00, MAX_ADDRESS_VAL_LEN);
                        strncpy(tmpAddr->addressVal, msgInfo.addressList[0].addressVal, MAX_ADDRESS_VAL_LEN);
                }
@@ -682,6 +689,7 @@ __BYPASS_UPDATE:
                } else {
                        MSG_DEBUG("message-dialog: send success");
 
+#if 0 // disabled as per UX request to not show success notification : 2015. 09. 18
                        bool bTTS = false;
 
                        if (MsgSettingGetBool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &bTTS) != MSG_SUCCESS) {
@@ -692,6 +700,7 @@ __BYPASS_UPDATE:
                                MsgInsertTicker("Multimedia message sent.", MULTIMEDIA_MESSAGE_SENT, false, 0);
                        }
 
+#endif
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
                        MSG_SEC_DEBUG("Enter MsgAddPhoneLog() : msgInfo.addressList[0].addressVal [%s]", msgInfo.addressList[0].addressVal);
                        MsgAddPhoneLog(&msgInfo);
@@ -797,8 +806,19 @@ int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                MSG_DEBUG("MsgStoAddCBMsg is fail");
        }
 
-       MsgInsertNotification(&msgInfo);
-       MsgChangePmState();
+       if (msgInfo.msgType.classType == MSG_CLASS_0) {
+               MsgLaunchClass0(msgInfo.msgId);
+               bool isFavorites = false;
+               if (!checkBlockingMode(msgInfo.addressList[0].addressVal, &isFavorites)) {
+                       MsgPlayTTSMode(msgInfo.msgType.subType, msgInfo.msgId, isFavorites);
+                       MsgSoundPlayer::instance()->MsgSoundPlayStart(&(msgInfo.addressList[0]), MSG_SOUND_PLAY_USER);
+               }
+       } else {
+               MsgInsertNotification(&msgInfo);
+       }
+
+       if (MsgCheckNotificationSettingEnable())
+               MsgChangePmState();
 
        msg_id_list_s msgIdList;
        msg_message_id_t msgIds[1];
@@ -920,39 +940,36 @@ int MsgStorageChangeHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                return 0;
        }
 
+       msg_id_list_s msgIdList;
+       memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
        msg_storage_change_type_t storageChangeType;
 
-       MSG_MESSAGE_INFO_S msgInfo;
-       memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+       memcpy(&msgIdList.nCount, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
 
-       memcpy(&msgInfo, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(MSG_MESSAGE_INFO_S));
-       memcpy(&storageChangeType, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), sizeof(msg_storage_change_type_t));
+       msgIdList.msgIdList = new msg_message_id_t[msgIdList.nCount];
+       for (int i = 0; i < msgIdList.nCount; i++) {
+               memcpy(&msgIdList.msgIdList[i], (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+i*sizeof(msg_message_id_t)), sizeof(msg_message_id_t));
+       }
+
+       memcpy(&storageChangeType, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+(sizeof(msg_message_id_t)*msgIdList.nCount)), sizeof(msg_storage_change_type_t));
 
        char* encodedData = NULL;
        unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
 
        int eventSize = 0;
 
-       MSG_DEBUG("storageChangeType : [%d], msg Id : [%d]", storageChangeType, msgInfo.msgId);
-
-       if (msgInfo.msgType.mainType == MSG_TYPE_SMS) {
-               if (storageChangeType == MSG_STORAGE_CHANGE_UPDATE)
-                       MsgStoUpdateMessage(&msgInfo, NULL);
-               else if (storageChangeType == MSG_STORAGE_CHANGE_DELETE)
-                       MsgStoDeleteMessage(msgInfo.msgId, true);
+       MSG_DEBUG("msgIdList.nCount [%d]", msgIdList.nCount);
+       for (int i = 0; i < msgIdList.nCount; i++) {
+               MSG_DEBUG("storageChangeType : [%d], msg Id : [%d]", storageChangeType, msgIdList.msgIdList[i]);
        }
 
        // broadcast to listener threads, here
-       msg_id_list_s msgIdList;
-       msg_message_id_t msgIds[1];
-       memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
-
-       msgIdList.nCount = 1;
-       msgIds[0] = msgInfo.msgId;
-       msgIdList.msgIdList = msgIds;
-
        MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, storageChangeType, &msgIdList);
 
+       if (msgIdList.msgIdList) {
+               delete [] msgIdList.msgIdList;
+       }
+
        // Make Event Data to Client
        eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_STORAGE_CHANGE_IND, MSG_SUCCESS, (void**)ppEvent);
 
@@ -992,7 +1009,19 @@ int MsgResendMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                        MSG_DEBUG("MsgStoGetMessage() Error!! [%d]", err);
                }
 
-               reqInfo.msgInfo.networkStatus = MSG_NETWORK_SENDING;
+               if (reqInfo.msgInfo.msgType.subType ==  MSG_GET_MMS || \
+                               reqInfo.msgInfo.msgType.subType  == MSG_NOTIFICATIONIND_MMS || \
+                               reqInfo.msgInfo.msgType.subType  == MSG_RETRIEVE_MMS)
+               {
+                       MSG_WARN("retrieve pending id[%d]", reqInfo.msgInfo.msgId);
+                       /* For retrieving failed msg (MMS)*/
+                       reqInfo.msgInfo.msgType.subType = MSG_RETRIEVE_MMS;
+                       reqInfo.msgInfo.folderId = MSG_OUTBOX_ID; // outbox fixed
+                       reqInfo.msgInfo.networkStatus = MSG_NETWORK_RETRIEVING;
+               } else {
+                       /* For sending failed msg */
+                       reqInfo.msgInfo.networkStatus = MSG_NETWORK_SENDING;
+               }
 
                msg_id_list_s msgIdList;
                msg_message_id_t msgIds[1];
index d4e7d87..c7b9c99 100755 (executable)
@@ -62,7 +62,7 @@ MsgTransactionManager* MsgTransactionManager::pInstance = NULL;
 MsgIpcServerSocket MsgTransactionManager::servSock;
 
 
-MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv(), eventQueue()
+MsgTransactionManager::MsgTransactionManager() : running(false), mx(), mxQ(), cv(), eventQueue()
 {
        sentMsgMap.clear();
        statusCBFdMap.clear();
@@ -128,6 +128,7 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv(), eve
 
        handlerMap[MSG_CMD_GET_THREADVIEWLIST]  = &MsgGetThreadViewListHandler;
        handlerMap[MSG_CMD_DELETE_THREADMESSAGELIST]    = &MsgDeleteThreadMessageListHandler;
+       handlerMap[MSG_CMD_SET_TEMP_ADDRESS_TABLE]      = &MsgSetTempAddressTableHandler;
 
        handlerMap[MSG_CMD_GET_CONTACT_COUNT]   = &MsgCountMsgByContactHandler;
        handlerMap[MSG_CMD_GET_QUICKPANEL_DATA]         = &MsgGetQuickPanelDataHandler;
@@ -226,9 +227,6 @@ void MsgTransactionManager::run()
 
                MSG_DEBUG("Wait For Select() : nfds %d", nfds);
 
-               // set Status;
-//             setTMStatus();
-
                if(select(nfds, &readfds, NULL, NULL, NULL) == -1) {
                        THROW(MsgException::SELECT_ERROR, "select error : %s", g_strerror(errno));
                }
@@ -254,9 +252,6 @@ void MsgTransactionManager::run()
                {
                        MSG_FATAL("%s", e.what());
                }
-
-               // Release Memory
-               MsgReleaseMemory();
        }
 }
 
@@ -274,6 +269,8 @@ void MsgTransactionManager::insertSentMsg(int reqId, MSG_PROXY_INFO_S* pPrxInfo)
 
        MSG_DEBUG("msg for submit: reqId %d listenerFd %d handleAddr %x", reqId, pPrxInfo->listenerFd, pPrxInfo->handleAddr);
 
+       MutexLocker lock(mx);
+
        fd_map::iterator it = statusCBFdMap.find(pPrxInfo->listenerFd);
 
        if (it == statusCBFdMap.end()) { // if the status CB is not registered
@@ -300,6 +297,8 @@ MSG_PROXY_INFO_S* MsgTransactionManager::getProxyInfo(int reqId)
 
 void MsgTransactionManager::delProxyInfo(int reqId)
 {
+       MutexLocker lock(mx);
+
        sentmsg_map::iterator it = sentMsgMap.find(reqId);
 
        if (it == sentMsgMap.end())
@@ -315,19 +314,18 @@ void MsgTransactionManager::workerEventQueue()
        MSG_CMD_S* pCmd = NULL;
        int (*pfHandler)(const MSG_CMD_S*, char**) = NULL;
        char* pEventData = NULL;
-       unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        int fd = -1;
        int eventSize = 0;
 
        while (1) {
-               mx.lock();
+               mxQ.lock();
                while (!eventQueue.front(&pCmd)) { /* if no item, wait */
                        MSG_DEBUG ("waiting for task");
-                       cv.wait(mx.pMutex());
+                       cv.wait(mxQ.pMutex());
                }
                eventQueue.pop_front(); /* pop it from queue*/
-               mx.unlock();
+               mxQ.unlock();
 
                if (!pCmd) {
                        MSG_FATAL("pCmd NULL");
@@ -357,6 +355,7 @@ void MsgTransactionManager::workerEventQueue()
                MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
                servSock.write(fd, pEventData, eventSize);
                g_free (pCmd); pCmd = NULL;
+               g_free (pEventData); pEventData = NULL;
        }
 }
 
@@ -426,10 +425,10 @@ void MsgTransactionManager::handleRequest(int fd)
                        memcpy (pCmdDup, pCmd, len);
                        memcpy (pCmdDup->cmdCookie, &fd, sizeof(int)); /* Now, cmdCookie keeps fd for return */
 
-                       mx.lock(); /* aquire lock before adding cmd */
+                       mxQ.lock(); /* aquire lock before adding cmd */
                        eventQueue.push_back(pCmdDup);
                        cv.signal(); /* wake up worker */
-                       mx.unlock();
+                       mxQ.unlock();
                }
                break;
        }
@@ -463,6 +462,8 @@ void MsgTransactionManager::cleanup(int fd)
 {
        MSG_BEGIN();
 
+       MutexLocker lock(mx);
+
        servSock.close(fd);
 
        MSG_DEBUG("fd %d disonnected", fd);
@@ -777,6 +778,8 @@ void MsgTransactionManager::setIncomingMsgCB(MSG_CMD_REG_INCOMING_MSG_CB_S *pCbI
                return;
        }
 
+       MutexLocker lock(mx);
+
        newmsg_list::iterator it = newMsgCBList.begin();
 
        for (; it != newMsgCBList.end(); it++)
@@ -800,6 +803,8 @@ void MsgTransactionManager::setMMSConfMsgCB(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB
                return;
        }
 
+       MutexLocker lock(mx);
+
        mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
 
        for (; it != newMMSConfMsgCBList.end(); it++)
@@ -823,6 +828,8 @@ void MsgTransactionManager::setPushMsgCB(MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S *pCb
                return;
        }
 
+       MutexLocker lock(mx);
+
        pushmsg_list::iterator it = newPushMsgCBList.begin();
 
        for (; it != newPushMsgCBList.end(); it++)
@@ -846,6 +853,8 @@ void MsgTransactionManager::setCBMsgCB(MSG_CMD_REG_INCOMING_CB_MSG_CB_S *pCbInfo
                return;
        }
 
+       MutexLocker lock(mx);
+
        cbmsg_list::iterator it = newCBMsgCBList.begin();
 
        for (; it != newCBMsgCBList.end(); it++)
@@ -877,6 +886,8 @@ void MsgTransactionManager::setSyncMLMsgCB(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S
                return;
        }
 
+       MutexLocker lock(mx);
+
        syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
 
        for (; it != newSyncMLMsgCBList.end(); it++)
@@ -900,6 +911,8 @@ void MsgTransactionManager::setLBSMsgCB(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S *pCbIn
                return;
        }
 
+       MutexLocker lock(mx);
+
        lbsmsg_list::iterator it = newLBSMsgCBList.begin();
 
        for (; it != newLBSMsgCBList.end(); it++)
@@ -946,6 +959,8 @@ void MsgTransactionManager::setSyncMLMsgOperationCB(MSG_CMD_REG_SYNCML_MSG_OPERA
                return;
        }
 
+       MutexLocker lock(mx);
+
        syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
 
        for (; it != operationSyncMLMsgCBList.end(); it++)
@@ -966,6 +981,8 @@ void MsgTransactionManager::setStorageChangeCB(int listenerFd)
        if (listenerFd <= 0)
                THROW(MsgException::INVALID_PARAM,"InParam Error: listenerFd %d", listenerFd);
 
+       MutexLocker lock(mx);
+
        storageChangeFdMap[listenerFd] = true;
 }
 
@@ -975,6 +992,8 @@ void MsgTransactionManager::setReportMsgCB(int listenerFd)
        if (listenerFd <= 0)
                THROW(MsgException::INVALID_PARAM,"InParam Error: listenerFd %d", listenerFd);
 
+       MutexLocker lock(mx);
+
        reportMsgCBFdMap[listenerFd] = true;
 }
 
@@ -1021,6 +1040,8 @@ void MsgTransactionManager::broadcastIncomingMsgCB(const msg_error_t err, const
 
        MSG_DEBUG("valid %d dstport %d", msgInfo->msgPort.valid, msgInfo->msgPort.dstPort);
 
+       MutexLocker lock(mx);
+
        newmsg_list::iterator it = newMsgCBList.begin();
 
        for (; it != newMsgCBList.end(); it++)
@@ -1069,6 +1090,8 @@ void MsgTransactionManager::broadcastMMSConfCB(const msg_error_t err, const MSG_
 
        int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_INCOMING_MMS_CONF, err, (void**)(&pEventData));
 
+       MutexLocker lock(mx);
+
        mmsconf_list::iterator it = newMMSConfMsgCBList.begin();
 
        for (; it != newMMSConfMsgCBList.end(); it++)
@@ -1106,6 +1129,8 @@ void MsgTransactionManager::broadcastPushMsgCB(const msg_error_t err, const MSG_
 
        int eventSize = MsgMakeEvent(pushData, sizeof(MSG_PUSH_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND, err, (void**)(&pEventData));
 
+       MutexLocker lock(mx);
+
        pushmsg_list::iterator it = newPushMsgCBList.begin();
 
        for (; it != newPushMsgCBList.end(); it++)
@@ -1130,6 +1155,8 @@ void MsgTransactionManager::broadcastCBMsgCB(const msg_error_t err, const MSG_CB
 
        int eventSize = MsgMakeEvent(cbMsg, sizeof(MSG_CB_MSG_S), MSG_EVENT_PLG_INCOMING_CB_MSG_IND, err, (void**)(&pEventData));
 
+       MutexLocker lock(mx);
+
        cbmsg_list::iterator it = newCBMsgCBList.begin();
 
        for (; it != newCBMsgCBList.end(); it++)
@@ -1162,6 +1189,8 @@ void MsgTransactionManager::broadcastSyncMLMsgCB(const msg_error_t err, const MS
 
        int eventSize = MsgMakeEvent(syncMLData, sizeof(MSG_SYNCML_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND, err, (void**)(&pEventData));
 
+       MutexLocker lock(mx);
+
        syncmlmsg_list::iterator it = newSyncMLMsgCBList.begin();
 
        for (; it != newSyncMLMsgCBList.end(); it++)
@@ -1184,6 +1213,8 @@ void MsgTransactionManager::broadcastLBSMsgCB(const msg_error_t err, const MSG_L
 
        int eventSize = MsgMakeEvent(lbsData, sizeof(MSG_LBS_MESSAGE_DATA_S), MSG_EVENT_PLG_INCOMING_LBS_MSG_IND, err, (void**)(&pEventData));
 
+       MutexLocker lock(mx);
+
        lbsmsg_list::iterator it = newLBSMsgCBList.begin();
 
        for (; it != newLBSMsgCBList.end(); it++)
@@ -1213,6 +1244,8 @@ void MsgTransactionManager::broadcastSyncMLMsgOperationCB(const msg_error_t err,
 
        int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_SYNCML_OPERATION, err, (void**)(&pEventData));
 
+       MutexLocker lock(mx);
+
        syncmlop_list::iterator it = operationSyncMLMsgCBList.begin();
 
        for( ; it != operationSyncMLMsgCBList.end() ; it++ )
@@ -1249,6 +1282,8 @@ void MsgTransactionManager::broadcastStorageChangeCB(const msg_error_t err, cons
 
        int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_STORAGE_CHANGE_IND, err, (void**)(&pEventData));
 
+       MutexLocker lock(mx);
+
        fd_map::iterator it = storageChangeFdMap.begin();
 
        for (; it != storageChangeFdMap.end(); it++)
@@ -1285,6 +1320,8 @@ void MsgTransactionManager::broadcastReportMsgCB(const msg_error_t err, const ms
 
        int eventSize = MsgMakeEvent(encodedData, dataSize, MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND, err, (void**)(&pEventData));
 
+       MutexLocker lock(mx);
+
        fd_map::iterator it = reportMsgCBFdMap.begin();
 
        for (; it != reportMsgCBFdMap.end(); it++)
@@ -1297,34 +1334,6 @@ void MsgTransactionManager::broadcastReportMsgCB(const msg_error_t err, const ms
 }
 
 
-void MsgTransactionManager::setTMStatus()
-{
-       MSG_BEGIN();
-       mx.lock();
-       cv.signal();
-       mx.unlock();
-       MSG_END();
-}
-
-
-void MsgTransactionManager::getTMStatus()
-{
-       MSG_BEGIN();
-       mx.lock();
-
-       int ret = 0;
-
-       ret = cv.timedwait(mx.pMutex(), 3);
-
-       mx.unlock();
-
-       if (ret == ETIMEDOUT)
-       {
-               MSG_DEBUG("MsgTransactionManager::getTMStatus TIME-OUT");
-       }
-       MSG_END();
-}
-
 bool MsgTransactionManager::initCynara()
 {
        int ret;
index ecab740..cf5be05 100755 (executable)
@@ -162,6 +162,7 @@ enum _MSG_CMD_TYPE_E
        MSG_CMD_PLG_RESEND_MESSAGE,
        MSG_CMD_REG_REPORT_MSG_INCOMING_CB,
        MSG_CMD_UPDATE_IMSI,
+       MSG_CMD_SET_TEMP_ADDRESS_TABLE,
 
 #ifdef FEATURE_SMS_CDMA
        MSG_CMD_PLG_CHECK_UNIQUENESS,
@@ -272,6 +273,7 @@ enum _MSG_EVENT_TYPE_E
        MSG_EVENT_PLG_RESEND_MESSAGE,
        MSG_EVENT_REG_REPORT_MSG_INCOMING_CB,
        MSG_EVENT_UPDATE_IMSI,
+       MSG_EVENT_SET_TEMP_ADDRESS_TABLE,
 
 #ifdef FEATURE_SMS_CDMA
        MSG_EVENT_PLG_CHECK_UNIQUENESS,
index 3194ec0..49d965d 100755 (executable)
@@ -81,6 +81,8 @@
 #define DEFAULT_MMS_STYLE_OPT_PATH     DEFAULT_SETTING_PATH"/mms_style"
 #define DEFAULT_PUSH_MSG_OPT_PATH      DEFAULT_SETTING_PATH"/push_msg"
 #define DEFAULT_CB_MSG_OPT_PATH                DEFAULT_SETTING_PATH"/cb_msg"
+#define DEFAULT_CB_CMAS_MSG_OPT_PATH   DEFAULT_CB_MSG_OPT_PATH"/cmas_init"
+
 #define DEFAULT_VOICE_MAIL_OPT_PATH    DEFAULT_SETTING_PATH"/voice_mail"
 #define DEFAULT_MSGSIZE_OPT_PATH               DEFAULT_SETTING_PATH"/size_opt"
 #define DEFAULT_SIM_COUNT_PATH                 DEFAULT_SETTING_PATH"/sim_count"
 #define VOICEMAIL_NUMBER                               DEFAULT_VOICE_MAIL_OPT_PATH"/voice_mail_number"
 #define VOICEMAIL_COUNT                                DEFAULT_VOICE_MAIL_OPT_PATH"/voice_mail_count"
 #define VOICEMAIL_ALPHA_ID                             DEFAULT_VOICE_MAIL_OPT_PATH"/voice_mail_alphaid"
-#define VOICEMAIL_DEFAULT_NUMBER       ""
+#define VOICEMAIL_DEFAULT_NUMBER               DEFAULT_VOICE_MAIL_OPT_PATH"/voice_mail_default_number"
 #define VOICEMAIL_DEFAULT_ALPHA_ID     ""
 
 #define MSGSIZE_OPTION                                 DEFAULT_MSGSIZE_OPT_PATH"/msg_size"
 #ifdef FEATURE_SMS_CDMA
 #define MSG_MESSAGE_ID_COUNTER                 DEFAULT_GENERAL_OPT_PATH"/msg_id_counter"
 #endif
+#define MSG_MESSAGE_DURING_CALL                        DEFAULT_GENERAL_OPT_PATH"/during_call"
 
 #define MSG_DEFAULT_APP_ID                     "org.tizen.message"
 #define MSG_QUICKPANEL_APP_ID          "org.tizen.quickpanel"
-#define MSG_CALL_APP_ID                                "org.tizen.call"
+#define MSG_INDICATOR_APP_ID           "org.tizen.indicator"
+#define MSG_CALL_APP_ID                                "org.tizen.call-ui"
+#define MSG_TEL_URI_VOICEMAIL          "tel:VOICEMAIL"
 
 #define MSG_TELEPHONY_SMS_FEATURE      "http://tizen.org/feature/network.telephony.sms"
 #define MSG_TELEPHONY_MMS_FEATURE      "http://tizen.org/feature/network.telephony.mms"
@@ -262,6 +267,7 @@ typedef struct
        char                                    thumbPath[MSG_FILEPATH_LEN_MAX+1];
        bool                                    bStore;                                                                                 /**< Indicates whether the message is stored or not if it is MWI message. */
        int                                             sim_idx;
+       char                                    msgURL[MMS_LOCATION_LEN + 1];
 } MSG_MESSAGE_INFO_S;
 
 
@@ -318,7 +324,6 @@ typedef struct
        bool                                            bDraft;
        bool                                            bSendFailed;
        bool                                            bSending;
-       int                                                     simIndex;
 } MSG_THREAD_VIEW_S;
 
 
@@ -514,6 +519,12 @@ typedef struct _MSG_UNIQUE_INDEX_S
        int                                             telesvc_id;
 } MSG_UNIQUE_INDEX_S;
 
+typedef struct
+{
+       time_t                                  receivedTime;
+       unsigned short                  serialNum;
+       unsigned short                  messageId;      // Message Identifier
+} MSG_CB_DUPLICATE_S;
 #endif
 
 
@@ -608,7 +619,7 @@ enum _MSG_MMS_ITEM_TYPE_E
        MSG_MMS_ITEM_TYPE_AUDIO,                /**< Indicates the audio media */
        MSG_MMS_ITEM_TYPE_VIDEO,                /**< Indicates the video media */
        MSG_MMS_ITEM_TYPE_ATTACH,               /**< Indicates the attach file */
-       MSG_MMS_ITEM_TYPE_PAGE, /**< Indicates the page count */
+       MSG_MMS_ITEM_TYPE_PAGE,         /**< Indicates the page count */
        MSG_MMS_ITEM_TYPE_MALWARE,              /**< Indicates the tcs bc level*/
        MSG_MMS_ITEM_TYPE_1ST_MEDIA,    /**< Indicates the 1st media path*/
 };
index a761501..a530ae4 100755 (executable)
@@ -1051,7 +1051,7 @@ typedef msg_error_t (*MsgPlgGetDefaultNetworkSimId) (int *simId);
 
 // framework defined callbacks.
 typedef void (*MsgPlgOnSentStatus)(MSG_SENT_STATUS_S *pSentStatus);
-typedef void (*MsgPlgOnStorageChange)(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo);
+typedef void (*MsgPlgOnStorageChange)(msg_storage_change_type_t storageChangeType, msg_id_list_s *pMsgIdList);
 typedef msg_error_t (*MsgPlgOnMsgIncoming)(MSG_MESSAGE_INFO_S *pMsgInfo);
 typedef msg_error_t (*MsgPlgOnInitSimBySat)(void);
 typedef msg_error_t (*MsgPlgOnSyncMLMsgIncoming)(MSG_SYNCML_MESSAGE_DATA_S *pSyncMLData);
index ae49fde..d91eeed 100755 (executable)
@@ -66,6 +66,8 @@
  */
 #define MSG_DRM_SUPPORT        (0)
 
+#define MAX_TELEPHONY_HANDLE_CNT       (3)
+
 /**
  *     @brief  Defines message struct handle.
  */
index 954b147..f125515 100755 (executable)
@@ -32,4 +32,4 @@ typedef void (*msg_alarm_cb)(int alarmId);
 msg_error_t MsgAlarmRegistration(struct tm *timeInfo, msg_alarm_cb userCB, int *alarmId);
 msg_error_t MsgAlarmRemove(int alarmId);
 
-#endif // MSG_ALARM_H
+#endif /* MSG_ALARM_H */
index 2bd902c..4a99b2a 100755 (executable)
 
 #define MSG_APP_LOCALEDIR                      "/usr/apps/" MSG_DEFAULT_APP_ID "/res/locale"
 
-#define MSG_NOTIFICATION_ICON_DIR                      MSG_QUICKPANEL_APP_ID "/shared/res/noti_icons/Message"
-
-// notification icon
-#define MSG_NORMAL_ICON_PATH   "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/noti_message.png"
-#define MSG_SIM_ICON_PATH      "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/noti_message_sim-card.png"
-#define MSG_VOICE_ICON_PATH            "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/noti_voice_mail.png"
-#define MSG_CB_ICON_PATH                       "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/noti_message_cb-msg.png"
-#define MSG_READ_ICON_PATH             "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/noti_message_read_report.png"
-#define MSG_DELIVERY_ICON_PATH "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/noti_message_delivery_report.png"
-#define MSG_REPLY_ICON_PATH                    "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/noti_message_reply.png"
-#define MSG_SMS_SENDING_FAILED_ICON_PATH               "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/noti_message_failed.png"
-#define MSG_MMS_SENDING_FAILED_ICON_PATH               "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/noti_message_mms_failed.png"
-#define MSG_MMS_RETRIVE_FAILED_ICON_PATH               "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/noti_message_mms_problem.png"
+#define MSG_NOTIFICATION_ICON_DIR                      MSG_QUICKPANEL_APP_ID "/shared/res/noti_icons"
+#define MSG_STATUS_ICON_DIR                    MSG_INDICATOR_APP_ID "/res/icons"
+
+/* notification icon */
+#define MSG_NORMAL_ICON_PATH   "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Message/noti_message.png"
+#define MSG_SIM_ICON_PATH      "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_sim-card.png"
+#define MSG_OTA_ICON_PATH      "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_OTA.png"
+#define MSG_VOICE_ICON_PATH            "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Message/noti_voice_mail.png"
+#define MSG_CB_ICON_PATH                       "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_cb-msg.png"
+#define MSG_READ_ICON_PATH             "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_read_report.png"
+#define MSG_DELIVERY_ICON_PATH "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_delivery_report.png"
+#define MSG_REPLY_ICON_PATH                    "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_reply.png"
+#define MSG_SMS_SENDING_FAILED_ICON_PATH               "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_failed.png"
+#define MSG_MMS_SENDING_FAILED_ICON_PATH               "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_mms_failed.png"
+#define MSG_MMS_RETRIVE_FAILED_ICON_PATH               "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_mms_problem.png"
 #define MSG_EMERGENCY_ICON_PATH                "/usr/apps/" MSG_DEFAULT_APP_ID "/res/icons/default/small/noti_emergency_mode.png"
-
-// status bar icon
-#define MSG_NORMAL_STATUS_ICON                         "/usr/apps/" MSG_DEFAULT_APP_ID "/res/icons/default/small/status_bar_message.png"
-#define MSG_FAILED_STATUS_ICON                         "/usr/apps/" MSG_DEFAULT_APP_ID "/res/icons/default/small/status_bar_cancel_message.png"
-#define MSG_DELIVER_REPORT_STATUS_ICON "/usr/apps/" MSG_DEFAULT_APP_ID "/res/icons/default/small/status_bar_delivery_report_message.png"
-#define MSG_READ_REPORT_STATUS_ICON            "/usr/apps/" MSG_DEFAULT_APP_ID "/res/icons/default/small/status_bar_read_report_message.png"
-#define MSG_VOICE_MSG_STATUS_ICON                      "/usr/apps/" MSG_DEFAULT_APP_ID "/res/icons/default/small/status_bar_voicemail.png"
-#define MSG_SIM_FULL_STATUS_ICON               "/usr/apps/" MSG_DEFAULT_APP_ID "/res/icons/default/small/status_bar_sim_card_full.png"
+#define MSG_NO_CONTACT_PROFILE_ICON_PATH       "/usr/apps/" MSG_NOTIFICATION_ICON_DIR "/Contact/noti_contact_default.png"
+#define MSG_ACTIVE_PUSH_ICON_PATH              "reserved:push_message"
+#define MSG_MESSAGE_APP_SUB_ICON               "/usr/apps/" MSG_DEFAULT_APP_ID "/res/icons/default/small/org.tizen.message.png"
+
+/* status bar icon */
+#define MSG_NORMAL_STATUS_ICON                         "/usr/apps/" MSG_STATUS_ICON_DIR "/Notify/B03_notify_message.png"
+#define MSG_FAILED_STATUS_ICON                         "/usr/apps/" MSG_STATUS_ICON_DIR "/Notify/B03_notify_message_failed.png"
+#define MSG_DELIVER_REPORT_STATUS_ICON "/usr/apps/" MSG_STATUS_ICON_DIR "/Event/B03_event_delivery_report_message.png"
+#define MSG_READ_REPORT_STATUS_ICON            "/usr/apps/" MSG_STATUS_ICON_DIR "/Event/B03_event_read_report_message.png"
+#define MSG_VOICE_MSG_STATUS_ICON                      "/usr/apps/" MSG_STATUS_ICON_DIR "/Event/B03_event_voicemail.png"
+#define MSG_SIM_FULL_STATUS_ICON               "/usr/apps/" MSG_STATUS_ICON_DIR "/SIM card full/B03_sim_card_full.png"
 
 #ifndef TIZEN_I586_ENABLED
-// system string
+/* system string */
 #define NEW_MESSAGE                    "IDS_MSGF_POP_NEW_MESSAGE"
 #define NEW_MESSAGES                   "IDS_MSGF_POP_NEW_MESSAGES"
 #define MSG_UNKNOWN_SENDER     "IDS_MSGF_BODY_UNKNOWN"
 #define MSG_NO_SUBJECT                 "IDS_MSGF_BODY_NO_SUBJECT"
+#define MSG_SUBJECT_COLON      "IDS_MSGF_OPT_SUBJECT_COLON"
 
 
-// message app string for ticker noti
+/* message app string for ticker noti */
 #define SENDING_MULTIMEDIA_MESSAGE_FAILED      "IDS_MSGF_POP_SENDING_MULTIMEDIA_MESSAGE_FAILED"
 #define MULTIMEDIA_MESSAGE_SENT                                        "IDS_MSGF_POP_MULTIMEDIA_MESSAGE_SENT"
 #define RETRIEVING_MESSAGE_FAILED                                      "IDS_MSGF_POP_RETRIEVING_MESSAGE_FAILED"
 #define SMS_SIM_CARD_FULL                              "IDS_MSG_HEADER_SIM_CARD_FULL"
 #define SMS_MESSAGE_SIZE_OVER_SIM_SLOT_SIZE    "IDS_MSGF_BODY_MESSAGE_IS_TOO_LARGE_TO_STORE_AS_A_SINGLE_MESSAGE_TO_SIM_CARD"
 
-// message app string for quickpanel noti
+/* message app string for quickpanel noti */
 #define MSG_MESSAGE            "IDS_MSGF_BODY_MESSAGE"
 #define VOICE_MAIL                                     "IDS_MSGF_BODY_VOICEMAIL"
 #define NEW_VOICE_MAIL                 "IDS_MSGF_BODY_NEW_VOICEMAIL"
-#define APP_NEW_MESSAGE "IDS_MSGF_POP_NEW_MESSAGE"
-#define APP_NEW_MESSAGES "IDS_MSGF_POP_NEW_MESSAGES"
 #define CB_MESSAGE "IDS_MSGF_BODY_CB_MESSAGES"
+#define CP_MESSAGE "IDS_MSGF_BODY_CP_MESSAGES"
 #define PUSH_MESSAGE "IDS_MSGF_BODY_PUSH_MESSAGES"
 #define DELIVERY_MESSAGE "IDS_MSGF_BODY_DELIVERY_REPORT"
 #define READ_REPORT_MESSAGE "IDS_MSGF_POP_READ_REPORT"
 #define VOICE_N_MESSAGE        "IDS_MSGF_BODY_PD_MESSAGES"
 #define SIM_CARD_MESSAGE               "IDS_MSGF_BODY_SIM_CARD_MESSAGES"
 #define READ_REPORT_READ               "IDS_COM_BODY_READ"
-#define READ_REPORT_DELETE     "IDS_COM_POP_DELETED"
+#define READ_REPORT_DELETE     "IDS_MSG_OPT_DELETE"
 #define FAILED_MSG_EXIST       "IDS_MSG_BODY_FAILED_MESSAGES_EXIST"
 #define ENABLE_EMERGENCY_MODE  "IDS_MSG_BODY_ENABLE_EMERGENCY_MODE_JPN_DCM"
 #define EMERGENCY_MODE_DESCRIPTION     "IDS_MSG_SBODY_TAP_HERE_TO_ENABLE_EMERGENCY_MODE_TO_SAVE_BATTERY_POWER_JPN_DCM"
-#define FAILED_TO_SEND_MESSAGE "IDS_MSG_TPOP_FAILED_TO_SEND_MESSAGE_ABB"
+#define FAILED_TO_SEND_MESSAGE "IDS_MSG_HEADER_FAILED_TO_SEND_MESSAGE_ABB"
+#define MESSAGE_SIZE_UNIT_KB   "IDS_MSGF_BODY_MSGSIZE_KB"
+#define MESSAGE_SIZE_STRING            "IDS_MSGF_BODY_MESSAGE_SIZE"
+#define MSG_SUBJECT_COLON      "IDS_MSGF_OPT_SUBJECT_COLON"
 #else
-// system string
+/* system string */
 #define NEW_MESSAGE                    "New message"
 #define NEW_MESSAGES                   "New messages"
 #define MSG_UNKNOWN_SENDER     "New message from Unknown."
 #define MSG_NO_SUBJECT                 "No subject"
 
 
-// message app string for ticker noti
+/* message app string for ticker noti */
 #define SENDING_MULTIMEDIA_MESSAGE_FAILED      "Sending multimedia message failed"
 #define MULTIMEDIA_MESSAGE_SENT                                        "Multimedia message sent."
 #define RETRIEVING_MESSAGE_FAILED                                      "Retrieving message failed"
 #define SMS_MESSAGE_MEMORY_FULL                        "Not enough memory. Delete some items."
 #define SMS_FDN_RESTRICTED                             "Unable to send the message while Fixed dialling mode is enabled."
 #define SMS_SIM_CARD_FULL                              "SIM card full"
-#define SMS_MESSAGE_SIZE_OVER_SIM_SLOT_SIZE    "Message is too large to store as a single message to SIM card." //
+#define SMS_MESSAGE_SIZE_OVER_SIM_SLOT_SIZE    "Message is too large to store as a single message to SIM card."
 
-// message app string for quickpanel noti
+/* message app string for quickpanel noti */
 #define MSG_MESSAGE            "Message"
 #define VOICE_MAIL                                     "Voicemail"
 #define NEW_VOICE_MAIL                 "New voicemail"
-#define APP_NEW_MESSAGE "New message"
-#define APP_NEW_MESSAGES "New messages"
 #define CB_MESSAGE "CB messages"
+#define CP_MESSAGE "CP messages"
 #define PUSH_MESSAGE "Push messages"
 #define DELIVERY_MESSAGE "Delivery report"
 #define READ_REPORT_MESSAGE "Read report"
 #define FAILED_MSG_EXIST       "Failed messages exist."
 #define ENABLE_EMERGENCY_MODE  "Enable Emergency mode"
 #define EMERGENCY_MODE_DESCRIPTION     "Tap here to enable Emergency mode to save battery power."
-#define FAILED_TO_SEND_MESSAGE "Failed to send message." //
+#define FAILED_TO_SEND_MESSAGE "Failed to send message."
+#define MESSAGE_SIZE_UNIT_KB   "KB"
+#define MESSAGE_SIZE_STRING            "Message Size"
+#define MSG_SUBJECT_COLON      "Subject:"
 #endif
 
 #define NOTIFICATION_PRIV_ID   DEFAULT_SETTING_PATH"/notification_priv_id"
 
 #define MSG_NOTI_TEXT_LEN      (512)
 #define MSG_NOTI_TEXT_LEN_S    (256)
+#define MSG_ACTIVE_NOTI_BUTTON_NUM 3
 
-enum _msg_notification_type_e
-{
+enum _msg_notification_type_e {
        MSG_NOTI_TYPE_ALL = 0x00,
 
-       // Refresh single/multiple notification
+       /* Refresh single/multiple notification */
        MSG_NOTI_TYPE_NORMAL,
        MSG_NOTI_TYPE_CB,
        MSG_NOTI_TYPE_SIM,
        MSG_NOTI_TYPE_FAILED,
 
-       // Add only single notification
+       /* Add only single notification */
        MSG_NOTI_TYPE_VOICE_1,
        MSG_NOTI_TYPE_VOICE_2,
        MSG_NOTI_TYPE_MWI,
@@ -184,13 +194,21 @@ enum _msg_notification_type_e
        MSG_NOTI_TYPE_SIM_FULL,
 };
 
-typedef unsigned char msg_notification_type_t; //_msg_notification_type_e
+enum _msg_active_notification_type_e {
+       MSG_ACTIVE_NOTI_TYPE_NONE,
+       MSG_ACTIVE_NOTI_TYPE_ACTIVE,
+       MSG_ACTIVE_NOTI_TYPE_INSTANT,
+};
+
+typedef unsigned char msg_notification_type_t; /* _msg_notification_type_e */
+typedef unsigned char msg_active_notification_type_t; /* _msg_active_notification_type_e */
 
 msg_error_t MsgInsertNotification(MSG_MESSAGE_INFO_S *msg_info);
 
 msg_error_t MsgAddNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *msg_info);
-msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeedback, bool bTicker);
+msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeedback, msg_active_notification_type_t active_type);
 msg_error_t MsgAddReportNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *msg_info);
+msg_error_t MsgInsertOnlyActiveNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *pMsgInfo);
 msg_error_t MsgDeleteReportNotification(const char *addr);
 
 msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId);
@@ -199,9 +217,10 @@ msg_error_t MsgInitNoti();
 msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt);
 msg_error_t MsgDeleteNoti(msg_notification_type_t noti_type, int simIndex);
 
-void MsgRefreshAllNotification(bool bWithSimNoti, bool bFeedback, bool bTickerNoti);
+void MsgRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_active_notification_type_t active_type);
 void MsgDeleteNotification(msg_notification_type_t noti_type, int simIndex);
 void MsgInitReportNotiList();
+bool MsgCheckNotificationSettingEnable(void);
 
 char *getTranslateText(const char *pkg_name, const char *locale_dir, const char *text);
 
index ab1e279..ed7014f 100755 (executable)
@@ -34,4 +34,4 @@ msg_error_t MsgSensorConnect();
 void MsgSensorDisconnect();
 msg_error_t MsgRegSensorCB(msg_sensor_cb cb);
 
-#endif // MSG_SENSOR_H
+#endif /* MSG_SENSOR_H */
index 0aec565..7030c9d 100755 (executable)
@@ -37,8 +37,7 @@ enum _MSG_SOUND_TYPE_E
 /*==================================================================================================
                                 CLASS DEFINITIONS
 ==================================================================================================*/
-class MsgSoundPlayer
-{
+class MsgSoundPlayer {
 public:
        static MsgSoundPlayer* instance();
 
@@ -61,6 +60,7 @@ private:
        void MsgSoundSetRepeatAlarm();
        void MsgSoundCreateRepeatAlarm(int RepeatTime);
        int MsgSoundGetUnreadMsgCnt();
+       void MsgGetPlayStatus(bool bOnCall, bool bSound, bool bVibration, bool bMsgSound, bool bMsgVibration, bool *bPlaySound, bool *bPlayVibration);
 
        static MsgSoundPlayer* pInstance;
 
@@ -73,5 +73,5 @@ private:
        char *defaultRingtonePath;
 };
 
-#endif // MSG_SOUND_PLAYER_H
+#endif /* MSG_SOUND_PLAYER_H */
 
index ea67d8e..beba140 100755 (executable)
@@ -35,4 +35,4 @@ msg_error_t MsgGetFilterOperation(bool *pSetFlag);
 bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo);
 bool MsgCheckFilterByWord(MsgDbHandler *pDbHandle, const char *pMsgText);
 
-#endif // MSG_SPAM_FILTER_H
+#endif /* MSG_SPAM_FILTER_H */
index 21a86a2..ffe0462 100755 (executable)
@@ -51,6 +51,7 @@ int MsgInitSimBySatHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 
 int MsgGetThreadViewListHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 int MsgDeleteThreadMessageListHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+int MsgSetTempAddressTableHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 
 int MsgCountMsgByContactHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 int MsgGetQuickPanelDataHandler(const MSG_CMD_S *pCmd, char **ppEvent);
index c8f3cb8..e959c48 100755 (executable)
@@ -32,6 +32,9 @@ msg_error_t MsgHandleIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti);
 msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti, bool *bOnlyNoti);
 msg_error_t MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti);
 
+void MsgPlayTTSMode(MSG_SUB_TYPE_T msgSubType, msg_message_id_t msgId, bool isFavorites);
+void MsgLaunchClass0(msg_message_id_t msgId);
+
 /*==================================================================================================
                                        DEFINES
 ==================================================================================================*/
index 488935c..bad0eb2 100755 (executable)
@@ -72,6 +72,7 @@ msg_error_t MsgStoGetMsgType(msg_message_id_t msgId, MSG_MESSAGE_TYPE_S* pMsgTyp
 msg_error_t MsgStoGetText(msg_message_id_t MsgId, char *pSubject, char *pMsgText);
 msg_error_t MsgStoGetQuickPanelData(msg_quickpanel_type_t Type, MSG_MESSAGE_INFO_S *pMsg);
 msg_error_t MsgStoDeleteThreadMessageList(msg_thread_id_t ThreadId, bool bIncludeProtect, msg_id_list_s *pMsgIdList);
+msg_error_t MsgStoSetTempAddressTable(const char *pSearchVal, int *count);
 msg_error_t MsgStoCountMsgByContact(const MSG_THREAD_LIST_INDEX_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pThreadCountInfo);
 msg_error_t MsgStoGetSmsReportStatus(msg_message_id_t msgId, int *count, MSG_REPORT_STATUS_INFO_S **pReportStatus);
 msg_error_t MsgStoGetMmsReportStatus(msg_message_id_t msgId, int *count, MSG_REPORT_STATUS_INFO_S **pReportStatus);
index 9046eb3..f2fc587 100755 (executable)
@@ -93,8 +93,6 @@ public:
        void broadcastSyncMLMsgOperationCB(const msg_error_t err, const int msgId, const int extId);
        void broadcastStorageChangeCB(const msg_error_t err, const msg_storage_change_type_t storageChangeType, const msg_id_list_s *pMsgIdList);
        void broadcastReportMsgCB(const msg_error_t err, const msg_report_type_t reportMsgType, const MSG_MESSAGE_INFO_S *pMsgInfo);
-       void setTMStatus();
-       void getTMStatus();
 
        bool initCynara();
        void finishCynara();
@@ -129,7 +127,8 @@ private:
        fd_map storageChangeFdMap;      // src_fd, true if registered
        fd_map reportMsgCBFdMap;        // src_fd, true if registered
 
-       Mutex mx;
+       Mutex mx; /* mutex for shared resources like callback listeners */
+       Mutex mxQ; /* mutex for event queue */
        CndVar cv;
        MsgSimpleQ<MSG_CMD_S*> eventQueue;
 
index 2f9d00b..407c725 100755 (executable)
@@ -38,9 +38,9 @@
 #define CHECK_MSG_SUPPORTED(feature_name) \
        do { \
                bool bSupported = false; \
-               bSupported = MsgCheckFeatureSupport(feature_name); \
+               bSupported = MsgCheckFeatureSupport((feature_name)); \
                if (bSupported == false) {\
-                       MSG_ERR("Feature [%s] not supported", feature_name);\
+                       MSG_ERR("Feature [%s] not supported", (feature_name));\
                        return MSG_ERR_NOT_SUPPORTED; \
                } \
        } while(0)
@@ -48,9 +48,9 @@
 #define CHECK_MSG_SUPPORTED_RETURN_NULL(feature_name) \
        do { \
                bool bSupported = false; \
-               bSupported = MsgCheckFeatureSupport(feature_name); \
+               bSupported = MsgCheckFeatureSupport((feature_name)); \
                if (bSupported == false) {\
-                       MSG_ERR("Feature [%s] not supported", feature_name);\
+                       MSG_ERR("Feature [%s] not supported", (feature_name));\
                        return NULL; \
                } \
        } while(0)
@@ -59,7 +59,7 @@
                                                                         FUNCTION PROTOTYPES
 ==================================================================================================*/
 
-// message
+/* message */
 void msg_message_create_struct(msg_struct_s *msg_struct);
 int msg_message_release(msg_struct_s **msg_struct);
 
@@ -84,8 +84,7 @@ int msg_message_list_clear(msg_struct_t msg_struct_handle, int field);
 
 
 
-
-// filter
+/* filter */
 int msg_get_filter_info_bool(void *filter, int field, bool *value);
 int msg_get_filter_info_int(void *filter, int field, int *value);
 int msg_get_filter_info_str(void *filter, int field, char *value, int size);
@@ -94,7 +93,7 @@ int msg_set_filter_info_int(void *filter, int field, int value);
 int msg_set_filter_info_str(void *filter, int field, char *value, int size);
 
 
-// mms
+/* mms */
 msg_struct_s *msg_mms_create_struct(int field);
 void *msg_mms_create_struct_data(int field);
 int msg_mms_release_struct(msg_struct_s **msg_struct_data);
@@ -114,7 +113,9 @@ int msg_mms_list_append(msg_struct_t msg_struct_handle, int field, msg_struct_t
 
 void convert_to_hidden_mmsdata(MMS_DATA_S *pSrc, msg_struct_s *pDest);
 void convert_from_hidden_mmsdata(msg_struct_s *pSrc, MMS_DATA_S *pDest);
-// setting
+
+
+/* setting */
 int msg_setting_get_int_value(msg_struct_s *msg_struct, int field, int *value);
 int msg_setting_get_str_value(msg_struct_s *msg_struct, int field, char *src, int size);
 int msg_setting_get_bool_value(msg_struct_s *msg_struct, int field, bool *value);
index fb2504a..3f4dfa2 100755 (executable)
 /**
  *     @brief  The structure type that represents message ID list.
  */
-typedef struct
-{
-       int                                     nCount;                         /**< The count of message ID informatioin */
-       msg_message_id_t        *msgIdList;                     /**< The pointer to message ID informatioin */
+typedef struct {
+       int                                     nCount;                         /**< The count of message ID information */
+       msg_message_id_t        *msgIdList;                     /**< The pointer to message ID information */
 }msg_id_list_s;
 
 
@@ -104,8 +103,7 @@ typedef void (*msg_storage_change_cb)(msg_handle_t handle, msg_storage_change_ty
  *     @brief Enumeration for the values of a storage type. \n
  *            This enum is used as the value of msg_storage_id_t.
  */
-enum _MSG_STORAGE_ID_E
-{
+enum _MSG_STORAGE_ID_E {
        MSG_STORAGE_UNKNOWN = 0,                /**< Storage ID is unknown. */
        MSG_STORAGE_PHONE,                          /**< Storage ID is Phone. */
        MSG_STORAGE_SIM,                                /**< Storage ID is SIM card in slot 1. */
@@ -117,8 +115,7 @@ enum _MSG_STORAGE_ID_E
  *     @brief  Enumeration for the values of a storage type. \n
  *             This enum is used as the value of msg_folder_id_t.
  */
-enum _MSG_FOLDER_ID_E
-{
+enum _MSG_FOLDER_ID_E {
        MSG_IOSBOX_ID = -1,                         /**< Indicates INBOX, OUTBOX and SENTBOX group folder ID. (Only for search option.) */
        MSG_ALLBOX_ID = 0,                              /**< Indicates INBOX, OUTBOX, SENTBOX and DRAFTBOX group folder ID. (Only for search option.) */
        MSG_INBOX_ID = 1,                               /**< Indicates INBOX folder ID */
@@ -135,8 +132,7 @@ enum _MSG_FOLDER_ID_E
  *     @brief  Enumeration for the values of a folder type. \n
  *             This enum is used as the value of msg_folder_type_t.
  */
-enum _MSG_FOLDER_TYPE_E
-{
+enum _MSG_FOLDER_TYPE_E {
        MSG_FOLDER_TYPE_INBOX = 1,              /**< Inbox folder */
        MSG_FOLDER_TYPE_OUTBOX,             /**< Outbox folder */
        MSG_FOLDER_TYPE_DRAFT,              /**< Draft folder */
@@ -149,8 +145,7 @@ enum _MSG_FOLDER_TYPE_E
  *     @brief  Enumeration for the values of a sort type. \n
  *             This enum is used as the value of msg_sort_type_t.
  */
-enum _MSG_SORT_TYPE_E
-{
+enum _MSG_SORT_TYPE_E {
        MSG_SORT_BY_UNKNOWN = 0,                        /**< Unknown sort type */
        MSG_SORT_BY_DISPLAY_FROM,                   /**< Sort by display from */
        MSG_SORT_BY_DISPLAY_TO,                     /**< Sort by display to */
@@ -168,8 +163,7 @@ enum _MSG_SORT_TYPE_E
  *     @brief  Enumeration for the values of a message type for quick panel. \n
  *             This enum is used as the value of msg_quickpanel_type_t.
  */
-enum _MSG_QUICKPANEL_TYPE_E
-{
+enum _MSG_QUICKPANEL_TYPE_E {
        MSG_QUICKPANEL_SMS = 0,                         /**< Quickpanel SMS */
        MSG_QUICKPANEL_MMS,                                     /**< Quickpanel MMS */
        MSG_QUICKPANEL_DELIVER_REP,                     /**< Quickpanel delivery report */
@@ -182,8 +176,7 @@ enum _MSG_QUICKPANEL_TYPE_E
 /**
  *     @brief  Enumeration for the values of a count limit for each mailbox.
  */
-enum _MSG_COUNT_LIMIT_MAILBOX_TYPE_E
-{
+enum _MSG_COUNT_LIMIT_MAILBOX_TYPE_E {
        MSG_COUNT_LIMIT_INBOX_TYPE,                             /**< Message count limit of inbox folder*/
        MSG_COUNT_LIMIT_OUTBOX_TYPE,                    /**< Message count limit of outbox folder*/
        MSG_COUNT_LIMIT_SENTBOX_TYPE,                   /**< Message count limit of sentbox folder*/
@@ -196,8 +189,7 @@ enum _MSG_COUNT_LIMIT_MAILBOX_TYPE_E
 /**
  *     @brief  Enumeration for the values of a count limit for each message type.
  */
-enum _MSG_COUNT_LIMIT_MSG_TYPE_E
-{
+enum _MSG_COUNT_LIMIT_MSG_TYPE_E {
        MSG_COUNT_LIMIT_SMS_TYPE,                               /**< Message count limit for SMS */
        MSG_COUNT_LIMIT_MMS_TYPE,                               /**< Message count limit for MMS */
        MSG_COUNT_LIMIT_CB_TYPE,                                /**< Message count limit for callback messages */
@@ -211,8 +203,7 @@ enum _MSG_COUNT_LIMIT_MSG_TYPE_E
  *     @brief  Enumeration for the values of a storage change type. \n
  *             This enum is used with storage change callback functions.
  */
-enum _MSG_STORAGE_CHANGE_TYPE_E
-{
+enum _MSG_STORAGE_CHANGE_TYPE_E {
        // msg data
        MSG_STORAGE_CHANGE_INSERT = 1,                  /**< Indicates storage change by an INSERT operation*/
        MSG_STORAGE_CHANGE_UPDATE,                              /**< Indicates storage change by an UPDATE operation*/
index c26ade7..fbba025 100755 (executable)
 /**
  * @brief      Definition for maximum file path length
  */
-#define        MSG_FILEPATH_LEN_MAX 1024
+#define MSG_FILEPATH_LEN_MAX 1024
 
-// setting
+/* setting */
 /**
  * @brief      Definition for maximum SMSC name length
  */
 /**
  * @brief      Definition for maximum file name length
  */
-#define        MSG_FILENAME_LEN_MAX 1024
+#define MSG_FILENAME_LEN_MAX 1024
 
 /**
  * @brief      Definition for maximum message id length
  */
-#define        MSG_MSG_ID_LEN 1024
+#define MSG_MSG_ID_LEN 1024
 
 /**
  * @brief      Definition for maximum in transition id length
 /**
  * @brief      Definition for maximum region id length
  */
-#define        MAX_SMIL_REGION_ID 151
+#define MAX_SMIL_REGION_ID 151
 
 /**
  * @brief      Definition for maximum transition id length
 /**
  * @brief      Definition for maximum fit size
  */
-#define        MAX_SMIL_FIT_SIZE 31
+#define MAX_SMIL_FIT_SIZE 31
 
 /**
  * @brief      Definition for maximum pages in a MMS
  */
-#define        MMS_PAGE_MAX 20
+#define MMS_PAGE_MAX 20
 
 /**
  * @brief      Definition for maximum media in a MMS
  */
-#define        MMS_MEDIA_MAX 60
+#define MMS_MEDIA_MAX 60
 
 /**
  * @brief      Definition for maximum alternate text length
  */
-#define        MAX_SMIL_ALT_LEN 255
+#define MAX_SMIL_ALT_LEN 255
 
 
-//font size
+/*font size */
 /**
  * @brief      Definition for small font size
  */
-#define        MMS_SMIL_FONT_SIZE_SMALL 24
+#define MMS_SMIL_FONT_SIZE_SMALL 24
 
 /**
  * @brief      Definition for normal font size
  */
-#define        MMS_SMIL_FONT_SIZE_NORMAL 30
+#define MMS_SMIL_FONT_SIZE_NORMAL 30
 
 /**
  * @brief      Definition for large font size
  */
-#define        MMS_SMIL_FONT_SIZE_LARGE 36
+#define MMS_SMIL_FONT_SIZE_LARGE 36
 
 /**
  * @brief      Definition for maximum length of java app ID
@@ -433,7 +433,7 @@ typedef unsigned int msg_message_backup_type_t;
  */
 typedef unsigned int msg_thread_id_t;
 
-// filter
+/* filter */
 /**
  * @brief  The filter ID.
  */
@@ -837,7 +837,7 @@ enum MSG_MMS_PAGE_INFO_E {
  *  @brief  Enumeration for the values of MMS media informations. \n
  *          This enum is used as member of #msg_struct_t for MSG_STRUCT_MMS_MEDIA.
  */
-enum MSG_MMS_MEDIA_INFO {
+enum MSG_MMS_MEDIA_INFO_E {
        MSG_MMS_MEDIA_TYPE_INT = MSG_STRUCT_MMS_MEDIA+1,  /**< Indicates the SMIL media type. See enum MmsSmilMediaType */
        MSG_MMS_MEDIA_SRC_STR,                            /**< Indicates the media source name */
        MSG_MMS_MEDIA_FILENAME_STR,                       /**< Indicates the file name */
@@ -1142,8 +1142,7 @@ enum MSG_CB_MSG_E {
  *  @brief  Enumeration for the values of a message class type. \n
  *             This enum is used as the value of MSG_CLASS_TYPE_T.
  */
-enum _MSG_CLASS_TYPE_E
-{
+enum _MSG_CLASS_TYPE_E {
        MSG_CLASS_0 = 0,                /**< Immediately presented on the recipient device display */
        MSG_CLASS_1,                    /**< Stored in the mobile equipment or SIM (depending on memory availability) */
        MSG_CLASS_2,                    /**< Stored in SIM */
@@ -1156,8 +1155,7 @@ enum _MSG_CLASS_TYPE_E
  *          More members maybe added if needed. \n
  *             This enum is used as the value of msg_message_type_t.
  */
-enum _MSG_MESSAGE_TYPE_E
-{
+enum _MSG_MESSAGE_TYPE_E {
        MSG_TYPE_INVALID = 0,               /** < Invalid Type Message */
 
        MSG_TYPE_SMS,                       /** < Normal SMS Message */
@@ -1180,6 +1178,7 @@ enum _MSG_MESSAGE_TYPE_E
        MSG_TYPE_SMS_CMAS_SEVERE,           /** < CB - CMAS Severe Alerts */
        MSG_TYPE_SMS_CMAS_AMBER,            /** < CB - CMAS AMBER Alerts (Child Abduction Emergency) */
        MSG_TYPE_SMS_CMAS_TEST,             /** < CB - CMAS Test */
+       MSG_TYPE_SMS_CMAS_EXERCISE,         /** < CB - CMAS Exercise */
        MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED, /** < CB - CMAS Operator defined */
        MSG_MESSAGE_TYPE_MAX,               /** < Placeholder for max value of this enum */
 };
@@ -1188,8 +1187,7 @@ enum _MSG_MESSAGE_TYPE_E
  *  @brief  Enumeration for the backup type of Message. More members maybe added if needed \n
  *             This enum is used as the value of msg_message_backup_type_t.
  */
-enum _MSG_MESSAGE_BACKUP_TYPE_E
-{
+enum _MSG_MESSAGE_BACKUP_TYPE_E {
        MSG_BACKUP_TYPE_ALL = 0,                /**< Backup all*/
        MSG_BACKUP_TYPE_SMS,                    /**< Backup SMS*/
        MSG_BACKUP_TYPE_MMS,                    /**< Backup MMS*/
@@ -1200,8 +1198,7 @@ enum _MSG_MESSAGE_BACKUP_TYPE_E
  *             Success code is zero, but all error codes SHOULD be negative and smaller than MSG_SUCCESS. \n
  *             This enum is used as the value of msg_error_t.
  */
-enum _MSG_ERROR_E
-{
+enum _MSG_ERROR_E {
        MSG_SUCCESS = 0,                        /**< Successful */
 
        MSG_ERR_NULL_MSGHANDLE = -1,            /**< Message handle is NULL */
@@ -1295,8 +1292,7 @@ enum _MSG_ERROR_E
  *  @brief  Enumeration for the values of a message priority. \n
  *             This enum is used as the value of msg_priority_type_t.
  */
-enum _MSG_PRIORITY_TYPE_E
-{
+enum _MSG_PRIORITY_TYPE_E {
        MSG_MESSAGE_PRIORITY_LOW,               /**< Low priority */
        MSG_MESSAGE_PRIORITY_NORMAL,    /**< Normal priority */
        MSG_MESSAGE_PRIORITY_HIGH,              /**< High priority */
@@ -1307,8 +1303,7 @@ enum _MSG_PRIORITY_TYPE_E
  *  @brief  Enumeration for the values of a network status. \n
  *             This enum is used as the value of msg_network_status_t.
  */
-enum _MSG_NETWORK_STATUS_E
-{
+enum _MSG_NETWORK_STATUS_E {
        MSG_NETWORK_NOT_SEND = 0,                            /**< Message is not sending */
        MSG_NETWORK_SENDING,                                 /**< Sending message */
        MSG_NETWORK_SEND_SUCCESS,                            /**< Message is sent successfully */
@@ -1320,20 +1315,20 @@ enum _MSG_NETWORK_STATUS_E
        MSG_NETWORK_RETRIEVING,                              /**< Retrieving message */
        MSG_NETWORK_RETRIEVE_SUCCESS,                        /**< Message is retrieved successfully */
        MSG_NETWORK_RETRIEVE_FAIL,                           /**< Failed to retrieve */
-       MSG_NETWORK_SEND_TIMEOUT,                            /**< Send timed-out*/ // WILL BE REMOVED
-       MSG_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING,        /**< Send failed due to mandatory info missing*/ // WILL BE REMOVED
-       MSG_NETWORK_SEND_FAIL_TEMPORARY,                     /**<Send failed temporarily*/ // WILL BE REMOVED
-       MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD,        /**< Send failed by MO control- ALLOWED WITH MOD*/ // WILL BE REMOVED
-       MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED,     /**< Send failed by MO control*/ // WILL BE REMOVED
+       MSG_NETWORK_SEND_TIMEOUT,                            /**< Send timed-out*/ /* WILL BE REMOVED */
+       MSG_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING,        /**< Send failed due to mandatory info missing*/ /* WILL BE REMOVED */
+       MSG_NETWORK_SEND_FAIL_TEMPORARY,                     /**<Send failed temporarily*/ /* WILL BE REMOVED */
+       MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD,        /**< Send failed by MO control- ALLOWED WITH MOD*/ /* WILL BE REMOVED */
+       MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED,     /**< Send failed by MO control*/ /* WILL BE REMOVED */
        MSG_NETWORK_DELIVER_PENDING,                         /**< Delivery pending*/
        MSG_NETWORK_DELIVER_EXPIRED,                         /**< Delivery expired*/
        MSG_NETWORK_SEND_PENDING,                            /**< Send is pending*/
 #ifdef FEATURE_SMS_CDMA
-       MSG_NETWORK_SEND_FAIL_UNKNOWN_SUBSCRIBER,                  /**< Unknown subscriber(destination) */
+       MSG_NETWORK_SEND_FAIL_UNKNOWN_SUBSCRIBER,            /**< Unknown subscriber(destination) */
        MSG_NETWORK_SEND_FAIL_MS_DISABLED,                   /**< Mobile station originated SMS disabled */
        MSG_NETWORK_SEND_FAIL_NETWORK_NOT_READY,             /**< Network not ready */
-       MSG_NETWORK_RETRIEVE_PENDING,                        /**< Retrieve is pending*/
 #endif
+       MSG_NETWORK_RETRIEVE_PENDING,                        /**< Retrieve is pending */
 };
 
 
@@ -1341,8 +1336,7 @@ enum _MSG_NETWORK_STATUS_E
  *  @brief  Enumeration for the values of an address type. \n
  *             This enum is used as the value of msg_address_type_t.
 */
-enum _MSG_ADDRESS_TYPE_E
-{
+enum _MSG_ADDRESS_TYPE_E {
        MSG_ADDRESS_TYPE_UNKNOWN = 0,   /**< The address type is unknown. */
        MSG_ADDRESS_TYPE_PLMN,                  /**< The address type is for a phone number like +1012345678. */
        MSG_ADDRESS_TYPE_EMAIL,                 /**< The address type is for an email address like abc@example.email. */
@@ -1353,8 +1347,7 @@ enum _MSG_ADDRESS_TYPE_E
  *  @brief  Enumeration for the values of a recipient type. \n
  *             This enum is used as the value of msg_recipient_type_t.
 */
-enum _MSG_RECIPIENT_TYPE_E
-{
+enum _MSG_RECIPIENT_TYPE_E {
        MSG_RECIPIENTS_TYPE_UNKNOWN = 0,    /**< The recipient type is unknown. */
        MSG_RECIPIENTS_TYPE_TO,             /**< The recipient type is for "To". */
        MSG_RECIPIENTS_TYPE_CC,             /**< The recipient type is for "Cc". */
@@ -1366,8 +1359,7 @@ enum _MSG_RECIPIENT_TYPE_E
  *  @brief  Enumeration for the values of a direction type. \n
  *             This enum is used as the value of msg_direction_type_t.
  */
-enum _MSG_DIRECTION_TYPE_E
-{
+enum _MSG_DIRECTION_TYPE_E {
        MSG_DIRECTION_TYPE_MO = 0,              /**< The direction type is for mobile originated */
        MSG_DIRECTION_TYPE_MT,                  /**< The direction type is for mobile terminated */
 };
@@ -1377,8 +1369,7 @@ enum _MSG_DIRECTION_TYPE_E
  *  @brief  Enumeration for the values of a string encoding type. \n
  *             This enum is used as the value of msg_encode_type_t.
  */
-enum _MSG_ENCODE_TYPE_E
-{
+enum _MSG_ENCODE_TYPE_E {
        MSG_ENCODE_GSM7BIT = 0,      /**< The string encoding type is GSM7BIT */
        MSG_ENCODE_8BIT,             /**< The string encoding type is 8 BIT */
        MSG_ENCODE_UCS2,             /**< The string encoding type is UCS2 */
@@ -1397,16 +1388,15 @@ enum _MSG_ENCODE_TYPE_E
  *  @brief  Enumeration for the action type of Push Message. \n
  *             This enum is used as the value of msg_push_action_t.
  */
-enum _MSG_PUSH_ACTION_E
-{
-       // SI Action
+enum _MSG_PUSH_ACTION_E {
+       /* SI Action */
        MSG_PUSH_SI_ACTION_SIGNAL_NONE = 0x00,          /**<  No signal for push message action */
        MSG_PUSH_SI_ACTION_SIGNAL_LOW,                          /**< Low signal for push message action */
        MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM,                       /**< Medium signal for push message action */
        MSG_PUSH_SI_ACTION_SIGNAL_HIGH,                         /**< High signal for push message action */
        MSG_PUSH_SI_ACTION_DELETE,                                      /**< Delete push message */
 
-       // SL Action
+       /* SL Action */
        MSG_PUSH_SL_ACTION_EXECUTE_LOW,                         /**< Action: execute-low*/
        MSG_PUSH_SL_ACTION_EXECUTE_HIGH,                        /**< Action: execute-high*/
        MSG_PUSH_SL_ACTION_CACHE,                                       /**< Action: cache*/
@@ -1417,8 +1407,7 @@ enum _MSG_PUSH_ACTION_E
  *  @brief  Enumeration for the type of SyncML Message. \n
  *             This enum is used as the value of msg_syncml_message_type_t.
  */
- enum _MSG_SYNCML_MESSAGE_TYPE_E
- {
+ enum _MSG_SYNCML_MESSAGE_TYPE_E {
        DM_WBXML,                                       /** < DM WBXML SyncML Message */
        DM_XML,                                         /** < DM XML SyncML Message */
        DM_NOTIFICATION,                        /** < DM Notification SyncML Message */
@@ -1437,8 +1426,7 @@ enum _MSG_PUSH_ACTION_E
  *  @brief  Enumeration for the values of a Delivery Report Status. \n
  *             This enum is used as the value of msg_delivery_report_status_t.
 */
- enum _MSG_DELIVERY_REPORT_STATUS_E
- {
+ enum _MSG_DELIVERY_REPORT_STATUS_E  {
         MSG_DELIVERY_REPORT_NONE                               =       -1,     /**< Indicates the status unavailable */
         MSG_DELIVERY_REPORT_EXPIRED                    =       0,      /**< Indicates the expired status of message */
         MSG_DELIVERY_REPORT_SUCCESS                    =       1,      /**< Indicates the success status of message */
@@ -1456,8 +1444,7 @@ enum _MSG_PUSH_ACTION_E
  *  @brief  Enumeration for the values of a Read Report Status. \n
  *             This enum is used as the value of msg_read_report_status_t.
 */
-enum _MSG_READ_REPORT_STATUS_E
- {
+enum _MSG_READ_REPORT_STATUS_E  {
         MSG_READ_REPORT_NONE                   =       -1,       /**< Indicates the status unavailable */
         MSG_READ_REPORT_IS_READ                =       0,        /**< Indicates the message is read */
         MSG_READ_REPORT_IS_DELETED     =       1,        /**< Indicates the message is deleted */
@@ -1468,20 +1455,18 @@ enum _MSG_READ_REPORT_STATUS_E
  *  @brief  Enumeration for the values of a Report Type. \n
  *             This enum is used as the value of msg_read_report_status_t.
 */
-enum _MSG_REPORT_TYPE_E
- {
+enum _MSG_REPORT_TYPE_E  {
         MSG_REPORT_TYPE_DELIVERY       =       0,      /**< Indicates the type is delivery report*/
-        MSG_REPORT_TYPE_READ   =       1,          /**< Indicates the type is read report*/
+        MSG_REPORT_TYPE_READ           =       1,          /**< Indicates the type is read report*/
         MSG_REPORT_TYPE_READ_REPORT_SENT = 2,  /**< Indicates the type is read report sent*/
  };
 
-// filter
+/* filter */
 /**
  *  @brief  Enumeration for the values of a filter type. \n
  *             This enum is used as the value of msg_filter_type_t.
  */
-enum _MSG_FILTER_TYPE_E
-{
+enum _MSG_FILTER_TYPE_E {
        MSG_FILTER_BY_WORD = 0,             /**< Filtered by sub string in the text */
        MSG_FILTER_BY_ADDRESS_SAME,         /**< Filtered by address exactly same as */
        MSG_FILTER_BY_ADDRESS_START,        /**< Filtered by address start with */
@@ -1490,17 +1475,16 @@ enum _MSG_FILTER_TYPE_E
 };
 
 
-// mms
+/* mms */
 
 /**
  *  @brief  Enumeration for the values of a MIME type.
  */
-typedef enum   _MimeType
-{
-       // 0
+typedef enum   _MimeType {
+       /* 0 */
        MIME_ASTERISK                                       = 0x0000, /**< Indicates the valid default MIME type  */
 
-       // 1
+       /* 1 */
        MIME_APPLICATION_XML                                = 0x1000, /**< Indicates the application XML type */
        MIME_APPLICATION_WML_XML                            = 0x1001, /**< Indicates the application WML XML type  */
        MIME_APPLICATION_XHTML_XML                          = 0x1002, /**< Indicates the application XHTML XML type  */
@@ -1517,7 +1501,7 @@ typedef enum      _MimeType
        MIME_APPLICATION_RAM                                = 0x100d, /**< Indicates the application RAM type */
        MIME_APPLICATION_ASTERIC                            = 0x100e, /**< Indicates the application as main type and generic sub type */
 
-       // 16
+       /* 16 */
        MIME_APPLICATION_VND_WAP_XHTMLXML                   = 0x1100, /**< Indicates the application wap xhtml xml type */
        MIME_APPLICATION_VND_WAP_WMLC                       = 0x1101, /**< Indicates the application wap wmlc type */
        MIME_APPLICATION_VND_WAP_WMLSCRIPTC                 = 0x1102, /**< Indicates the application wap wmlscrpitc type */
@@ -1552,7 +1536,7 @@ typedef enum      _MimeType
        MIME_APPLICATION_VND_POWERPOINT                     = 0x111f, /**< Indicates the application Power point type */
        MIME_APPLICATION_VND_MSWORD                         = 0x1120, /**< Indicates the application MS Word type */
 
-       // 49
+       /* 49 */
        MIME_APPLICATION_X_HDMLC                            = 0x1200, /**< Indicates the application x hdmlc type */
        MIME_APPLICATION_X_X968_USERCERT                    = 0x1201, /**< Indicates the application x x968 user certified type */
        MIME_APPLICATION_X_WWW_FORM_URLENCODED              = 0x1202, /**< Indicates the application x www form url encoded type */
@@ -1561,7 +1545,7 @@ typedef enum      _MimeType
        MIME_APPLICATION_X_EXCEL                            = 0x1205, /**< Indicates the application x excel type */
        MIME_APPLICATION_X_POWERPOINT                       = 0x1206, /**< Indicates the application x power point type */
 
-       // 56
+       /* 56 */
        MIME_AUDIO_BASIC                                    = 0x2000, /**< Indicates the audio basic type  */
        MIME_AUDIO_MPEG                                     = 0x2001, /**< Indicates the audio mpeg type  */
        MIME_AUDIO_MP3                                      = 0x2002, /**< Indicates the audio mp3 type  */
@@ -1591,11 +1575,12 @@ typedef enum    _MimeType
        MIME_AUDIO_XMF                                      = 0x201a, /**< Indicates the audio xmf type  */
        MIME_AUDIO_IMY                                      = 0x201b, /**< Indicates the audio imy type  */
        MIME_AUDIO_MOBILE_XMF                               = 0x201c, /**< Indicates the audio mobile xmf type  */
+       MIME_AUDIO_OGG                                          = 0x201d, /**< Indicates the audio mobile xmf type  */
 
-       //85
+       /* 86 */
        MIME_AUDIO_VND_RN_REALAUDIO                         = 0x2100, /**< Indicates the audio rn real audio type  */
 
-       // 86
+       /* 87 */
        MIME_AUDIO_X_MPEG                                   = 0x2200, /**< Indicates the audio x mpeg type  */
        MIME_AUDIO_X_MP3                                    = 0x2201, /**< Indicates the audio x mp3 type  */
        MIME_AUDIO_X_MPEG3                                  = 0x2202, /**< Indicates the audio x mpeg3 type  */
@@ -1616,7 +1601,7 @@ typedef enum      _MimeType
        MIME_AUDIO_X_MS_ASF                                 = 0x2211, /**< Indicates the audio ms asf  type  */
        MIME_AUDIO_X_XMF                                    = 0x2212, /**< Indicates the audio x xmf  type  */
 
-       // 105
+       /* 106 */
        MIME_IMAGE_GIF                                      = 0x3000, /**< Indicates the image gif type  */
        MIME_IMAGE_JPEG                                     = 0x3001, /**< Indicates the image jpeg type  */
        MIME_IMAGE_JPG                                      = 0x3002, /**< Indicates the image jpg type  */
@@ -1629,18 +1614,18 @@ typedef enum    _MimeType
        MIME_IMAGE_SVG                                      = 0x3009, /**< Indicates the image svg type  */
        MIME_IMAGE_SVG1                                     = 0x300a, /**< Indicates the image svg1 type  */
 
-       // 116
+       /* 117 */
        MIME_IMAGE_VND_WAP_WBMP                             = 0x3100, /**< Indicates the image vnd wap wbmp type  */
        MIME_IMAGE_VND_TMO_GIF                              = 0x3101, /**< Indicates the image vnd tmo gif type  */
        MIME_IMAGE_VND_TMO_JPG                              = 0x3102, /**< Indicates the image vnd tmo jpg type  */
 
-       // 119
+       /* 120 */
        MIME_IMAGE_X_BMP                                    = 0x3200, /**< Indicates the image x bmp type  */
 
-       // 120
+       /* 121 */
        MIME_MESSAGE_RFC822                                 = 0x4000, /**< Indicates the message rfc822 type  */
 
-       // 121
+       /* 122 */
        MIME_MULTIPART_MIXED                                = 0x5000, /**< Indicates the multipart mixed type  */
        MIME_MULTIPART_RELATED                              = 0x5001, /**< Indicates the multipart related type  */
        MIME_MULTIPART_ALTERNATIVE                          = 0x5002, /**< Indicates the multipart alternative type  */
@@ -1649,7 +1634,7 @@ typedef enum      _MimeType
        MIME_MULTIPART_REPORT                               = 0x5005, /**< Indicates the multipart report type  */
        MIME_MULTIPART_VOICE_MESSAGE                        = 0x5006, /**< Indicates the multipart voice message type  */
 
-       // 128
+       /* 129 */
        MIME_TEXT_TXT                                       = 0x6000, /**< Indicates the text txt type  */
        MIME_TEXT_HTML                                      = 0x6001, /**< Indicates the text html type  */
        MIME_TEXT_PLAIN                                     = 0x6002, /**< Indicates the text plain type  */
@@ -1658,7 +1643,7 @@ typedef enum      _MimeType
        MIME_TEXT_IMELODY                                   = 0x6005, /**< Indicates the text imelody type  */
        MIME_TEXT_CALENDAR                                  = 0x6006, /**< Indicates the text calendar type */
 
-       // 134
+       /* 135 */
        MIME_TEXT_VND_WAP_WMLSCRIPT                         = 0x6100, /**< Indicates the text wap wmlscript  type  */
        MIME_TEXT_VND_WAP_WML                               = 0x6101, /**< Indicates the text wap wml  type  */
        MIME_TEXT_VND_WAP_WTA_EVENT                         = 0x6102, /**< Indicates the text wap wta event  type  */
@@ -1668,7 +1653,7 @@ typedef enum      _MimeType
        MIME_TEXT_VND_WAP_CO                                = 0x6106, /**< Indicates the text wap co  type  */
        MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR               = 0x6107, /**< Indicates the text sun j2me type  */
 
-       // 142
+       /* 143 */
        MIME_TEXT_X_HDML                                    = 0x6200, /**< Indicates the x html  type  */
        MIME_TEXT_X_VCALENDAR                               = 0x6201, /**< Indicates the x calendar  type  */
        MIME_TEXT_X_VCARD                                   = 0x6202, /**< Indicates the x vcard  type  */
@@ -1677,7 +1662,7 @@ typedef enum      _MimeType
        MIME_TEXT_X_VNOTE                                   = 0x6205, /**< Indicates the x vnote  type  */
        MIME_TEXT_X_VTODO                                   = 0x6206, /**< Indicates the x todo  type  */
 
-       // 149
+       /* 150 */
        MIME_VIDEO_MPEG4                                    = 0x7000, /**< Indicates the mpeg4  type  */
        MIME_VIDEO_MP4                                      = 0x7001, /**< Indicates the mp4  type  */
        MIME_VIDEO_H263                                     = 0x7002, /**< Indicates the h263  type  */
@@ -1689,11 +1674,11 @@ typedef enum    _MimeType
        MIME_VIDEO_MPEG                                     = 0x7008, /**< Indicates the mpeg  type  */
        MIME_VIDEO_MOV                                      = 0x7009, /**< Indicates the mov  type  */
 
-       // 158
+       /* 159 */
        MIME_VIDEO_VND_RN_REALVIDEO                         = 0x7100, /**< Indicates the pn real video type  */
        MIME_VIDEO_VND_RN_REALMEDIA                         = 0x7101, /**< Indicates the pn multi rate real media type  */
 
-       // 160
+       /* 161 */
        MIME_VIDEO_X_MP4                                    = 0x7200, /**< Indicates the video x mp4 type  */
        MIME_VIDEO_X_PV_MP4                                 = 0x7201, /**< Indicates the video x pv mp4 type  */
        MIME_VIDEO_X_PN_REALVIDEO                           = 0x7202, /**< Indicates the x pn real video type  */
@@ -1710,20 +1695,18 @@ typedef enum    _MimeType
 /**
  *  @brief  Enumeration for the values of a DRM type.
  */
-typedef enum
-{
+typedef enum {
        MSG_DRM_TYPE_NONE       = 0, /**< Indicates the DRM type none */
        MSG_DRM_TYPE_FL         = 1, /**< Indicates the forward lock */         /* 2004-07-09: forwardLock type */
        MSG_DRM_TYPE_CD         = 2, /**< Indicates the combined delivery */    /* 2004-07-09: combined delivery type */
        MSG_DRM_TYPE_SD         = 3, /**< Indicates the separate delivery */    /* 2004-07-09: seperate delivery type */
-       MSG_DRM_TYPE_SSD        = 4      /**< Indicates the special separate delivery */        // 2005-02-28: add Special Sperate Delivery
+       MSG_DRM_TYPE_SSD                = 4      /**< Indicates the special separate delivery */        /* 2005-02-28: add Special Sperate Delivery */
 }MsgDrmType;
 
 /**
  *  @brief  Enumeration for the values of a SMIL region type.
  */
-typedef enum _REGION_FIT_TYPE_T
-{
+typedef enum _REGION_FIT_TYPE_T {
        MMSUI_IMAGE_REGION_FIT_HIDDEN,   /**< Indicates the hidden fit type */
        MMSUI_IMAGE_REGION_FIT_MEET,     /**< Indicates the meet fit type */
 }REGION_FIT_TYPE_T;
@@ -1732,8 +1715,7 @@ typedef enum _REGION_FIT_TYPE_T
 /**
  *  @brief  Enumeration for the values of a SMIL media type.
  */
-typedef enum
-{
+typedef enum {
        MMS_SMIL_MEDIA_INVALID = 0,       /**< Indicates the invalid media type */
        MMS_SMIL_MEDIA_IMG,               /**< Indicates the image media */
        MMS_SMIL_MEDIA_AUDIO,             /**< Indicates the audio media */
@@ -1747,8 +1729,7 @@ typedef enum
 /**
  *  @brief  Enumeration for the values of a SMIL transition type.
  */
-typedef enum
-{
+typedef enum {
        MMS_SMIL_TRANS_NONE = 0,         /**< Indicates the transition type none */                     /* default */
        MMS_SMIL_TRANS_SLIDEWIPE = 1,    /**< Indicates the slide wipe transition */
        MMS_SMIL_TRANS_BARWIPE = 2,      /**< Indicates the bar wipe transition */
@@ -1766,8 +1747,7 @@ typedef enum
 /**
  *  @brief  Enumeration for the values of a SMIL transition sub type.
  */
-typedef enum
-{
+typedef enum {
        MMS_SMIL_TRANS_SUB_NONE = 0,          /**< Indicates the transition sub type none */
        MMS_SMIL_TRANS_SUB_FROM_LEFT = 1,     /**< Indicates the from left transition */        /* slideWipe's default */
        MMS_SMIL_TRANS_SUB_FROM_TOP = 2,      /**< Indicates the from top transition */
@@ -1782,8 +1762,7 @@ typedef enum
 /**
  *  @brief  Enumeration for the values of a text font type.
  */
-typedef enum
-{
+typedef enum {
        MMS_SMIL_FONT_TYPE_NONE = 0,     /**< Indicates the font type none */
        MMS_SMIL_FONT_TYPE_NORMAL = 1,   /**< Indicates the font type normal */
        MMS_SMIL_FONT_TYPE_ITALIC = 2,   /**< Indicates the font type italic */
@@ -1794,17 +1773,16 @@ typedef enum
 /**
  *  @brief  Enumeration for the values of a MMS text direction.
  */
-typedef enum   _MmsTextDir{
+typedef enum   _MmsTextDir {
        MMS_TEXT_DIRECTION_INVALID = -1, /**< Indicates the invalid direction */
        MMS_TEXT_DIRECTION_RIGHT = 0,    /**< Indicates the right direction */
-       MMS_TEXT_DIRECTION_DOWN,         /**< Indicates the down direction */           // supported to GC
+       MMS_TEXT_DIRECTION_DOWN,         /**< Indicates the down direction */           /* supported to GC */
 } MmsTextDirection;
 
 /**
  *  @brief  Enumeration for the values of MMS Read Report Sent Status.
  */
-typedef enum
-{
+typedef enum {
        MMS_RECEIVE_READ_REPORT_NO_SEND,    /**< Not sent yet */
        MMS_RECEIVE_READ_REPORT_MUST_SEND,  /**< Not sent yet, but will be sent */
        MMS_RECEIVE_READ_REPORT_SENT,       /**< Sent */
@@ -1812,14 +1790,13 @@ typedef enum
 } MmsRecvReadReportSendStatus ;
 
 
-// setting
+/* setting */
 
 /**
  *  @brief  Enumeration for the values of an option type. \n
  *             This enum is used as the value of MSG_OPTION_TYPE_T.
  */
-enum _MSG_OPTION_TYPE_E
-{
+enum _MSG_OPTION_TYPE_E {
        MSG_GENERAL_OPT,            /**< General option */
        MSG_SMS_SENDOPT,            /**< SMS send option */
        MSG_SMSC_LIST,              /**< SMSC list option */
@@ -1839,8 +1816,7 @@ enum _MSG_OPTION_TYPE_E
  *  @brief  Enumeration for the values of an SMS network mode. \n
  *             This enum is used as the value of MSG_SMS_NETWORK_MODE_T.
  */
-enum _MSG_SMS_NETWORK_MODE_E
-{
+enum _MSG_SMS_NETWORK_MODE_E {
        MSG_SMS_NETWORK_PS_ONLY = 0x01,     /**< Packet switched */
        MSG_SMS_NETWORK_CS_ONLY = 0x02,     /**< Circuit switched */
        MSG_SMS_NETWORK_PS_FIRST = 0x03,    /**< Packet switching preferred */
@@ -1851,8 +1827,7 @@ enum _MSG_SMS_NETWORK_MODE_E
  *  @brief  Enumeration for the value of period of playing alert tone. \n
  *             The values for this type SHOULD be in MSG_ALERT_TONE_T.
  */
-enum _MSG_ALERT_TONE_E
-{
+enum _MSG_ALERT_TONE_E {
        MSG_ALERT_TONE_ONCE,        /**< Play alert tone once*/
        MSG_ALERT_TONE_2MINS,       /**< Repeat alarm in 2 mins*/
        MSG_ALERT_TONE_5MINS,       /**< Repeat alarm in 5 mins*/
@@ -1864,8 +1839,7 @@ enum _MSG_ALERT_TONE_E
  *  @brief  Enumeration for the value of a default storage to save SMS. \n
  *             The values for this type SHOULD be in MSG_SMS_SAVE_STORAGE_T.
  */
-enum _MSG_SMS_SAVE_STORAGE_E
-{
+enum _MSG_SMS_SAVE_STORAGE_E {
        MSG_SMS_SAVE_STORAGE_SIM,           /**< Save SMS to SIM*/
        MSG_SMS_SAVE_STORAGE_PHONE,         /**< Save SMS to phone*/
 };
@@ -1875,8 +1849,7 @@ enum _MSG_SMS_SAVE_STORAGE_E
  *  @brief  Enumeration for the values of the type of number for SMS center address. \n
  *             This enum is used as the value of MSG_SMS_TON_T.
  */
-enum _MSG_SMS_TON_E
-{
+enum _MSG_SMS_TON_E {
        MSG_TON_UNKNOWN = 0,            /**< Unknown */
        MSG_TON_INTERNATIONAL,          /**< International */
        MSG_TON_NATIONAL,               /**< National */
@@ -1892,8 +1865,7 @@ enum _MSG_SMS_TON_E
  *  @brief  Enumeration for the values of the numbering plan ID for SMS center address. \n
  *             This enum is used as the value of MSG_SMS_NPI_T.
  */
-enum _MSG_SMS_NPI_E
-{
+enum _MSG_SMS_NPI_E {
        MSG_NPI_UNKNOWN = 0,                        /**< Unknown */
        MSG_NPI_ISDN = 1,                           /**< ISDN */
        MSG_NPI_DATA = 3,                           /**< Data */
@@ -1910,8 +1882,7 @@ enum _MSG_SMS_NPI_E
  *  @brief  Enumeration for the values of the protocol ID for SMS center address. \n
  *             This enum is used as the value of MSG_SMS_PID_T.
  */
-enum  _MSG_SMS_PID_E
-{
+enum  _MSG_SMS_PID_E {
        MSG_PID_NONE,       /**< None */
        MSG_PID_TEXT,       /**< Text */
        MSG_PID_VOICE,      /**< Voice */
@@ -1933,8 +1904,7 @@ enum  _MSG_SMS_PID_E
  *     197 to 255 : (TP-VP - 192) x 1 week
  *
  */
-enum  _MSG_VAL_PERIOD_E
-{
+enum  _MSG_VAL_PERIOD_E {
        MSG_VAL_ZERO = 0,               /**< Validity period is zero */
        MSG_VAL_1DAY = 167,             /**< Validity period is 1 day */
        MSG_VAL_2DAYS = 168,            /**< Validity period is 2 days */
@@ -1953,8 +1923,7 @@ enum  _MSG_VAL_PERIOD_E
  *  @brief  Enumeration for the values of the MMS expiry time. \n
  *             This enum is used as the value of MSG_MMS_EXPIRY_TIME_T.
  */
-enum  _MSG_MMS_EXPIRY_TIME_E
-{
+enum  _MSG_MMS_EXPIRY_TIME_E {
        MSG_EXPIRY_TIME_MAXIMUM = 0,            /**< Expiry time is zero */
        MSG_EXPIRY_TIME_1DAY = 86400,           /**< Expiry time is 1 day */
        MSG_EXPIRY_TIME_2DAYS = 2*86400,        /**< Expiry time is 2 days */
@@ -1967,8 +1936,7 @@ enum  _MSG_MMS_EXPIRY_TIME_E
  *  @brief  Enumeration for the values of the MMS delivery time. \n
  *             This enum is used as the value of MSG_MMS_DELIVERY_TIME_T.
  */
-enum  _MSG_MMS_DELIVERY_TIME_E
-{
+enum  _MSG_MMS_DELIVERY_TIME_E {
        MSG_DELIVERY_TIME_IMMEDIATLY = 0,           /**< Immediate MMS delivery */
        MSG_DELIVERY_TIME_1HOUR = 3600,             /**< MMS delivery in 1 hour */
        MSG_DELIVERY_TIME_1DAY = 86400,             /**< MMS delivery in 1 day */
@@ -1981,8 +1949,7 @@ enum  _MSG_MMS_DELIVERY_TIME_E
  *  @brief  Enumeration for the values of the MMS class type. \n
  *             This enum is used as the value of MSG_MMS_MSG_CLASS_TYPE_T.
  */
-enum _MSG_MMS_MSG_CLASS_TYPE_E
-{
+enum _MSG_MMS_MSG_CLASS_TYPE_E {
        MSG_CLASS_PERSONAL,             /**<Personal message class*/
        MSG_CLASS_ADVERTISEMENT,        /**<Advertisement message class*/
        MSG_CLASS_INFORMATIONAL,        /**<Informational message class */
@@ -1995,8 +1962,7 @@ enum _MSG_MMS_MSG_CLASS_TYPE_E
  *  @brief  Enumeration for the values of the MMS reply charging type. \n
  *             This enum is used as the value of MSG_MMS_REPLY_CHARGING_TYPE_T.
  */
-enum _MSG_MMS_REPLY_CHARGING_TYPE_E
-{
+enum _MSG_MMS_REPLY_CHARGING_TYPE_E {
        MSG_REPLY_CHARGING_NONE,                    /**<Reply-Charging none */
        MSG_REPLY_CHARGING_REQUESTED,               /**<Reply-Charging requested */
        MSG_REPLY_CHARGING_REQUESTED_TEXT_ONLY,     /**<Reply-Charging requested text-only */
@@ -2010,8 +1976,7 @@ enum _MSG_MMS_REPLY_CHARGING_TYPE_E
  *  @brief  Enumeration for the values of the MMS creation mode. \n
  *             This enum is used as the value of MSG_MMS_CREATION_MODE_T.
  */
-enum _MSG_MMS_CREATION_MODE_E
-{
+enum _MSG_MMS_CREATION_MODE_E {
        MSG_CREATION_MODE_RESTRICTED,           /**< MMS created in restricted mode */
        MSG_CREATION_MODE_WARNING,              /**< MMS created in warning mode */
        MSG_CREATION_MODE_FREE                  /**< MMS created in free mode */
@@ -2022,8 +1987,7 @@ enum _MSG_MMS_CREATION_MODE_E
  *  @brief  Enumeration for the values of the retrieve type for MMS home network. \n
  *             This enum is used as the value of MSG_MMS_HOME_RETRIEVE_TYPE_T.
  */
-enum _MSG_MMS_HOME_RETRIEVE_TYPE_E
-{
+enum _MSG_MMS_HOME_RETRIEVE_TYPE_E {
        MSG_HOME_AUTO_DOWNLOAD,             /**< Home auto download */
        MSG_HOME_MANUAL,                    /**< Home manual */
        MSG_HOME_RESTRICTED,                /**< Home restricted */
@@ -2036,8 +2000,7 @@ enum _MSG_MMS_HOME_RETRIEVE_TYPE_E
  *  @brief  Enumeration for the values of the retrieve type for MMS abroad network. \n
  *             This enum is used as the value of MSG_MMS_ABROAD_RETRIEVE_TYPE_T.
  */
-enum _MSG_MMS_ABROAD_RETRIEVE_TYPE_E
-{
+enum _MSG_MMS_ABROAD_RETRIEVE_TYPE_E {
        MSG_ABROAD_AUTO_DOWNLOAD,   /**< Abroad auto download */
        MSG_ABROAD_MANUAL,          /**< Abroad manual */
        MSG_ABROAD_RESTRICTED,      /**< Abroad restricted */
@@ -2050,8 +2013,7 @@ enum _MSG_MMS_ABROAD_RETRIEVE_TYPE_E
  *  @brief  Enumeration for the values of the frequency of sending MMS read report. \n
  *             This enum is used as the value of MSG_MMS_SEND_READ_REPORT_T.
  */
-enum _MSG_MMS_SEND_READ_REPORT_E
-{
+enum _MSG_MMS_SEND_READ_REPORT_E {
        MSG_SEND_READ_REPORT_ALWAYS,    /**< Read report always */
        MSG_SEND_READ_REPORT_NEVER,     /**< Read report never */
        MSG_SEND_READ_REPORT_REQUEST,   /**< Read report request */
@@ -2063,8 +2025,7 @@ enum _MSG_MMS_SEND_READ_REPORT_E
  *  @brief  Enumeration for the values of the service type for a push message. \n
  *             This enum is used as the value of MSG_PUSH_SERVICE_TYPE_T.
  */
-enum _MSG_PUSH_SERVICE_TYPE_E
-{
+enum _MSG_PUSH_SERVICE_TYPE_E {
        MSG_PUSH_SERVICE_ALWAYS,    /**< Push message service always */
        MSG_PUSH_SERVICE_PROMPT,    /**< Push message service prompt */
        MSG_PUSH_SERVICE_NEVER,     /**< Push message service never */
@@ -2075,8 +2036,7 @@ enum _MSG_PUSH_SERVICE_TYPE_E
  *  @brief  Enumeration for the values of the language type for a cell broadcasting message. \n
  *             This enum is used as the value of MSG_CB_LANGUAGE_TYPE_T.
  */
-enum _MSG_CB_LANGUAGE_TYPE_E
-{
+enum _MSG_CB_LANGUAGE_TYPE_E {
        MSG_CBLANG_TYPE_ALL,            /**< CB check all */
        MSG_CBLANG_TYPE_ENG,            /**< CB message English  */
        MSG_CBLANG_TYPE_GER,            /**< CB message Germany */
@@ -2094,8 +2054,7 @@ enum _MSG_CB_LANGUAGE_TYPE_E
  *  @brief  Enumeration for the values of SIM status. \n
  *             This enum is used as the value of MSG_SIM_STATUS_T.
  */
-enum _MSG_SIM_STATUS_E
-{
+enum _MSG_SIM_STATUS_E {
        MSG_SIM_STATUS_NORMAL = 0,          /**< SIM normal */
        MSG_SIM_STATUS_CHANGED,             /**< SIM changed */
        MSG_SIM_STATUS_NOT_FOUND,           /**< SIM not found */
@@ -2105,8 +2064,7 @@ enum _MSG_SIM_STATUS_E
  *  @brief  Enumeration for the values of a message ringtone type. \n
  *             This enum is used as the value of MSG_RINGTONE_TYPE_T.
  */
-enum _MSG_RINGTONE_TYPE_E
-{
+enum _MSG_RINGTONE_TYPE_E {
        MSG_RINGTONE_TYPE_DEFAULT = 0,  /**< Default ringtone type */
        MSG_RINGTONE_TYPE_USER,         /**< User defined ringtone type */
        MSG_RINGTONE_TYPE_SILENT        /**< Silent type */
@@ -2116,8 +2074,7 @@ enum _MSG_RINGTONE_TYPE_E
  *  @brief  Enumeration for the values of a SIM index(SIM slot number). \n
  *             This enum is used as the value of msg_sim_slot_id_t.
  */
-enum _MSG_SIM_SLOT_ID_E
-{
+enum _MSG_SIM_SLOT_ID_E {
        MSG_SIM_SLOT_ID_1 = 1,  /**SIM Slot #1 */
        MSG_SIM_SLOT_ID_2,      /**SIM Slot #2 */
 };
index 831a4d4..4764f6e 100755 (executable)
@@ -31,6 +31,7 @@
 #include "MsgCmdTypes.h"
 #include "MsgInternalTypes.h"
 #include "MsgIpcSocket.h"
+#include "MsgMutex.h"
 
 /*==================================================================================================
                                      CLASS DEFINITIONS
@@ -42,11 +43,11 @@ class MsgHandle
                MsgHandle();
                virtual ~MsgHandle();
 
-               // Control
+               /* Control */
                void openHandle();
                void closeHandle(MsgHandle* pHandle);
 
-               // Transport
+               /* Transport */
                msg_error_t submitReq(MSG_REQUEST_S* pReq);
 
                msg_error_t regSentStatusCallback(msg_sent_status_cb onStatusChanged,  void *pUserParam);
@@ -61,7 +62,7 @@ class MsgHandle
 
                msg_error_t operateSyncMLMessage(msg_message_id_t msgId);
 
-               // Storage
+               /* Storage */
                int addMessage(MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt);
                msg_error_t addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg);
                msg_error_t updateMessage(const MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt);
@@ -92,7 +93,7 @@ class MsgHandle
 
                msg_error_t getAddressList(const msg_thread_id_t threadId, msg_struct_list_s *pAddrList);
 
-               // Filter
+               /* Filter */
                msg_error_t addFilter(const MSG_FILTER_S *pFilter);
                msg_error_t updateFilter(const MSG_FILTER_S *pFilter);
                msg_error_t deleteFilter(msg_filter_id_t FilterId);
@@ -101,7 +102,7 @@ class MsgHandle
                msg_error_t getFilterOperation(bool *pSetFlag);
                msg_error_t setFilterActivation(msg_filter_id_t filter_id, bool active);
 
-               //setting
+               /*setting */
                msg_error_t getSMSCOption(msg_struct_t msg_struct);
                msg_error_t setSMSCOption(msg_struct_t msg_struct);
                msg_error_t getCBOption(msg_struct_t msg_struct);
@@ -121,11 +122,11 @@ class MsgHandle
                msg_error_t getMsgSizeOpt(msg_struct_t msg_struct);
                msg_error_t setMsgSizeOpt(msg_struct_t msg_struct);
 
-               //Backup & Restore
+               /*Backup & Restore */
                msg_error_t backupMessage(msg_message_backup_type_t type, const char *backup_filepath);
                msg_error_t restoreMessage(const char *backup_filepath);
                msg_error_t getVobject(msg_message_id_t MsgId, void** encodedData);
-               // ETC
+               /* ETC */
                msg_error_t searchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList);
 
                msg_error_t getRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList);
@@ -137,7 +138,7 @@ class MsgHandle
                msg_error_t getMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_struct_list_s *pMsgList);
                msg_error_t getMediaList(const msg_thread_id_t thread_id, msg_list_handle_t *pMediaList);
 
-               // Push Event
+               /* Push Event */
                msg_error_t addPushEvent(MSG_PUSH_EVENT_INFO_S *push_event);
                msg_error_t deletePushEvent(MSG_PUSH_EVENT_INFO_S *push_event);
                msg_error_t updatePushEvent(MSG_PUSH_EVENT_INFO_S *pSrc, MSG_PUSH_EVENT_INFO_S *pDst);
@@ -145,9 +146,10 @@ class MsgHandle
                void convertMsgStruct(const MSG_MESSAGE_INFO_S *pSource, MSG_MESSAGE_HIDDEN_S *pDest);
                void convertSendOptStruct(const MSG_SENDINGOPT_INFO_S* pSrc, MSG_SENDINGOPT_S* pDest, MSG_MESSAGE_TYPE_S msgType);
 
-       private:
                void connectSocket();
-               void    disconnectSocket();
+               void disconnectSocket();
+
+       private:
                void write(const char *pCmd, int CmdSize, char **ppEvent);
                void read(char **ppEvent);
                void generateConnectionId(char *ConnectionId);
@@ -162,7 +164,8 @@ class MsgHandle
                char mCookie[MAX_COOKIE_LEN];
 
                MsgIpcClientSocket mClientSock;
+               Mutex mx;
 };
 
-#endif // MSG_HANDLE_H
+#endif /* MSG_HANDLE_H */
 
index 7b4fc39..3ae3ce0 100755 (executable)
 /*==================================================================================================
                                          VARIABLES
 ==================================================================================================*/
-typedef struct
-{
+typedef struct {
        MsgHandle* hAddr;
+       int fd;
        msg_sent_status_cb pfSentStatusCB;
        void* userParam;
 } MSG_SENT_STATUS_CB_ITEM_S;
 
-typedef struct
-{
+
+typedef struct {
        MsgHandle* hAddr;
+       int fd;
        msg_sms_incoming_cb pfIncomingCB;
        int port;
        void* userParam;
 } MSG_INCOMING_CB_ITEM_S;
 
-typedef struct
-{
+
+typedef struct {
        MsgHandle* hAddr;
+       int fd;
        msg_mms_conf_msg_incoming_cb pfMMSConfIncomingCB;
        char appId[MAX_MMS_JAVA_APPID_LEN+1];
        void* userParam;
 } MSG_MMS_CONF_INCOMING_CB_ITEM_S;
 
-typedef struct
-{
+
+typedef struct {
        MsgHandle* hAddr;
+       int fd;
        msg_push_msg_incoming_cb pfPushIncomingCB;
        char appId[MAX_WAPPUSH_ID_LEN+1];
        void* userParam;
 } MSG_PUSH_INCOMING_CB_ITEM_S;
 
-typedef struct
-{
+
+typedef struct {
        MsgHandle* hAddr;
+       int fd;
        msg_cb_incoming_cb pfCBIncomingCB;
        bool bsave;
        void* userParam;
 } MSG_CB_INCOMING_CB_ITEM_S;
 
-typedef struct
-{
+
+typedef struct {
        MsgHandle* hAddr;
+       int fd;
        msg_syncml_msg_incoming_cb pfSyncMLIncomingCB;
        void* userParam;
 } MSG_SYNCML_INCOMING_CB_ITEM_S;
 
-typedef struct
-{
+
+typedef struct {
        MsgHandle* hAddr;
+       int fd;
        msg_lbs_msg_incoming_cb pfLBSMsgIncoming;
        void* userParam;
 } MSG_LBS_INCOMING_CB_ITEM_S;
 
-typedef struct
-{
+
+typedef struct {
        MsgHandle* hAddr;
+       int fd;
        msg_syncml_msg_operation_cb pfSyncMLOperationCB;
        void* userParam;
 } MSG_SYNCML_OPERATION_CB_ITEM_S;
 
-typedef struct
-{
+
+typedef struct {
        MsgHandle* hAddr;
+       int fd;
        msg_storage_change_cb pfStorageChangeCB;
        void* userParam;
 } MSG_STORAGE_CHANGE_CB_ITEM_S;
 
 
-typedef struct
-{
+typedef struct {
        MsgHandle* hAddr;
+       int fd;
        msg_report_msg_incoming_cb pfReportMsgIncomingCB;
        void* userParam;
 } MSG_REPORT_INCOMING_CB_ITEM_S;
@@ -133,24 +141,29 @@ public:
        void start(MsgHandle* pMsgHandle);
        void stop();
 
-       bool regSentStatusEventCB(MsgHandle* pMsgHandle, msg_sent_status_cb pfSentStatus, void *pUserParam);
-       bool regMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam);
-       bool regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam);
-       bool regPushMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_push_msg_incoming_cb pfNewPushMessage, const char *pAppId, void *pUserParam);
-       bool regCBMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_cb_incoming_cb pfNewCBMessage, bool bSave, void *pUserParam);
-       bool regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam);
-       bool regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam);
-       bool regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam);
-       bool regStorageChangeEventCB(MsgHandle* pMsgHandle, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam);
-       bool regReportMsgIncomingCB(MsgHandle* pMsgHandle, msg_report_msg_incoming_cb pfReportMessage, void *pUserParam);
+       bool regSentStatusEventCB(MsgHandle* pMsgHandle, int fd, msg_sent_status_cb pfSentStatus, void *pUserParam);
+       bool regMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam);
+       bool regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam);
+       bool regPushMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_push_msg_incoming_cb pfNewPushMessage, const char *pAppId, void *pUserParam);
+       bool regCBMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_cb_incoming_cb pfNewCBMessage, bool bSave, void *pUserParam);
+       bool regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam);
+       bool regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam);
+       bool regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, int fd, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam);
+       bool regStorageChangeEventCB(MsgHandle* pMsgHandle, int fd, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam);
+       bool regReportMsgIncomingCB(MsgHandle* pMsgHandle, int fd, msg_report_msg_incoming_cb pfReportMessage, void *pUserParam);
 
        void clearListOfClosedHandle(MsgHandle* pMsgHandle);
+       void refreshListOfOpenedHandle(MsgHandle* pMsgHandle);
 
        void handleEvent(const MSG_EVENT_S* ptr);
 
        int getRemoteFd();
        int readFromSocket(char** buf, unsigned int* len);
        void resetProxyListener();
+       void refreshProxyListener();
+       void clearProxyCBLists();
+       void insertOpenHandleSet(MsgHandle* pMsgHandle);
+       void clearOpenHandleSet();
 #ifdef CHECK_SENT_STATUS_CALLBACK
        int getSentStatusCbCnt();
 #endif
@@ -185,5 +198,5 @@ private:
        guint eventSourceId;
 };
 
-#endif // __MSG_PROXY_LISTENER_H__
+#endif /* __MSG_PROXY_LISTENER_H__ */
 
diff --git a/include/utils/MsgCallStatusManager.h b/include/utils/MsgCallStatusManager.h
new file mode 100644 (file)
index 0000000..e4ac0d2
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef MSG_CALL_STATUS_MANAGER_H
+#define MSG_CALL_STATUS_MANAGER_H
+
+/*==================================================================================================
+                                    INCLUDE FILES
+==================================================================================================*/
+#include <gio/gio.h>
+
+/*==================================================================================================
+                                    DEFINES
+==================================================================================================*/
+#define CALL_MGR_BUS_NAME "org.tizen.callmgr"
+#define CALL_MGR_PATH_NAME "/org/tizen/callmgr"
+#define CALL_MGR_INTERFACE_NAME "org.tizen.callmgr"
+#define CALL_MGR_MEMBER_NAME "CallStatus"
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+void MsgInitCallStatusManager();
+void MsgDeInitCallStatusManager();
+int MsgGetCallStatus();
+
+#endif // MSG_CALL_STATUS_MANAGER_H
+
index 8bd06c6..13d8f5e 100755 (executable)
                SECURE_SLOGI("* Info * " fmt"\n", ##__VA_ARGS__);\
        } while (0)
 
+#define MSG_SEC_ERR(fmt, ...)\
+       do\
+       {\
+               SECURE_LOG(LOG_ERROR, LOG_TAG, "* Error *" fmt "\n", ##__VA_ARGS__);\
+       } while (0)
+
 /*valid data log macros*/
 #define MSG_SMS_VLD_INFO(fmt, ...)\
        do\
index 9cebec0..08d1e8e 100755 (executable)
 #include <stdio.h>
 #include "MsgDebug.h"
 
+typedef enum {
+        MSG_JSON_GEN_ARRAY,
+        MSG_JSON_GEN_OBJECT
+} msg_json_gen_type;
+
+typedef struct msg_json_gen_object_t {
+       msg_json_gen_type type;
+       void *value;
+} msg_json_gen_object;
+
+msg_json_gen_object* msg_json_gen_new_obj(msg_json_gen_type type);
+void msg_json_gen_free_obj(msg_json_gen_object *obj);
+void msg_json_gen_set_child(msg_json_gen_object *parent, const char *key, msg_json_gen_object *child);
+void msg_json_gen_set_value(msg_json_gen_object *parent, const char *key, long long int value);
+void msg_json_gen_set_value(msg_json_gen_object *parent, const char *key, const char *value);
+char* msg_json_gen_make_json_msg(msg_json_gen_object *root_obj, unsigned long *len);
+
 #define MSG_JSON_OBJ_SET_STR(json_obj, key, val)\
        if(json_obj && key && val){\
                json_object_set_string_member(json_obj, key, val);\
@@ -112,11 +129,13 @@ typedef struct msg_json_parser_object_t {
                                         MSG_JSON_PARSER_STRING,
                                         MSG_JSON_PARSER_ARRAY,
                                         MSG_JSON_PARSER_OBJECT */
-        double number_value; /** Value of the node. VALID
+        double float_value; /** Value of the node. VALID
+                                        only if type is
+                                        MSG_JSON_PARSER_REAL */
+        long long int number_value; /** Value of the node. VALID
                                         only if type is
                                         MSG_JSON_PARSER_UINT,
                                         MSG_JSON_PARSER_INT,
-                                        MSG_JSON_PARSER_REAL,
                                         MSG_JSON_PARSER_BOOLEAN */
 } msg_json_parser_object;
 
@@ -127,6 +146,6 @@ int msg_json_parser_object_get_value(msg_json_parser_object *json_obj);
 int msg_json_parser_get_next_child(const msg_json_parser_object *parent, msg_json_parser_object *child, int index);
 void msg_json_parser_parse_buffer(msg_json_parser_handle handle, const char* value, int value_len, msg_json_parser_object *json_obj);
 int msg_json_parser_get_child_by_name(const msg_json_parser_object *parent, msg_json_parser_object *child, const char *name);
+int msg_json_parser_get_child_count(msg_json_parser_object *object);
 
 #endif /*__MSG_JSON_PARSER_H__*/
-
index dcd79c2..d640827 100755 (executable)
@@ -21,8 +21,8 @@
                                     INCLUDE FILES
 ==================================================================================================*/
 #include "MsgTypes.h"
-#include <db-util.h>
 #include "MsgMutex.h"
+#include <sqlite3.h>
 
 /*==================================================================================================
                                     DEFINES
@@ -89,6 +89,7 @@ public:
        ~MsgDbHandler();
 
        msg_error_t connect();
+       msg_error_t connectReadOnly();
        msg_error_t disconnect();
 
        bool checkTableExist(const char *pTableName);
@@ -122,7 +123,7 @@ private:
        sqlite3_stmt *stmt;
        pthread_mutex_t *mmapMx;
        int shm_fd;
-       static Mutex mx;
+       bool in_trans;
 };
 
 
index 3401874..d922c99 100755 (executable)
@@ -258,11 +258,7 @@ public:
 
        int convertUTF8ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_LANGUAGE_ID_T *pLangId, OUT bool *bIncludeAbnormalChar);
        int convertUTF8ToUCS2(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen);
-#ifndef FEATURE_SMS_CDMA
-       int convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_LANGUAGE_ID_T *pLangId, OUT msg_encode_type_t *pCharType);
-#else
        int convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT msg_encode_type_t *pCharType);
-#endif
 
        int convertGSM7bitToUTF8(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, IN MSG_LANG_INFO_S *pLangInfo);
        int convertUCS2ToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN  int srcTextLen);
@@ -274,7 +270,11 @@ private:
        ~MsgTextConvert();
 
        int convertUCS2ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_LANGUAGE_ID_T *pLangId, OUT bool *bIncludeAbnormalChar);
+#ifndef FEATURE_SMS_CDMA
+       int convertUCS2ToGSM7bitAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown);
+#else
        int convertUCS2ToASCII(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown);
+#endif
 
        int convertGSM7bitToUCS2(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, IN MSG_LANG_INFO_S *pLangInfo);
 
index ecea9b5..c8d06e5 100755 (executable)
@@ -26,6 +26,8 @@
 /*==================================================================================================
                                        FUNCTION PROTOTYPES
 ==================================================================================================*/
+//File Util
+bool MakeThumbnail(char *srcPath, char *dstPath);
 /**  file operation wrapper - for avoding runtime error */
 FILE* MsgOpenFile(const char* filepath, const char* opt);
 void MsgCloseFile(FILE* pFile);
@@ -61,5 +63,8 @@ bool MsgCreateFile(const char *pFilePath,char *pData, int DataSize);
 char *MsgGetDirName(char *file_path);
 char *MsgGetFileName(char *file_path);
 int MsgCheckFilepathSmack(const char *app_smack_label, char *file_path);
+
+bool MsgScanFile(char *filePath);
+void MsgGetMimeType(char *filePath, char *mimeType, int size);
 #endif // MSG_UTIL_FILE_H
 
index d7774c3..54e0d44 100755 (executable)
@@ -136,7 +136,22 @@ char* msg_clean_country_code(char *src);
 
 char* msg_normalize_number(char *src);
 
+char *getTranslateText(const char *pkg_name, const char *locale_dir, const char *text);
+
 msg_error_t MsgMakeSortRule(const MSG_SORT_RULE_S *pSortRule, char *pSqlSort);
 
 bool msg_is_valid_email(char *pAddress);
+
+msg_error_t msg_write_text_to_msg_info(MSG_MESSAGE_INFO_S *pMsgInfo, char *text);
+
+void msg_replace_available_file_name(char *fileName);
+
+void msg_replace_space_char(char *pszText);
+
+gchar * msg_replace_non_ascii_char(const gchar *pszText, gunichar replacementChar);
+
+/* Dbus function */
+void MsgDbusInit();
+void MsgDbusDeinit();
+
 #endif // MSG_UTIL_FUNCTION_H
similarity index 81%
rename from plugin/mms_plugin/include/MmsPluginMIME.h
rename to include/utils/MsgUtilMime.h
index fe53ff8..df1cb59 100755 (executable)
  * limitations under the License.
 */
 
-#ifndef MMS_PLUGIN_MIME_H
-#define MMS_PLUGIN_MIME_H
+#ifndef MSG_UTIL_MIME_H
+#define MSG_UTIL_MIME_H
 
-#include "MmsPluginTypes.h"
+#include "msg_types.h"
 
 #define UNDEFINED_BINARY       0xFF
 
@@ -46,8 +46,10 @@ MimeType MimeGetMimeIntFromMimeString(char *szMimeStr);
 
 char *MimeGetMimeStringFromMimeInt(int mimeType);
 
-bool MmsGetMimeTypeFromExt(MimeMainType mainType, const char *pExt, MimeType *pMimeType, const char **ppszMimeType);
+bool MsgGetMimeTypeFromExt(MimeMainType mainType, const char *pExt, MimeType *pMimeType, const char **ppszMimeType);
 
-bool MmsGetMimeTypeFromFileName(MimeMainType mainType, const char *pFileName, MimeType *pMimeType, const char **ppszMimeType);
+bool MsgGetMimeTypeFromFileName(MimeMainType mainType, const char *pFileName, MimeType *pMimeType, const char **ppszMimeType);
 
-#endif // MMS_PLUGIN_MIME_H
+bool MsgGetMainTypeFromMetaData(const char *pFileName, MimeMainType *mainType);
+
+#endif /* MSG_UTIL_MIME_H */
index 14347aa..cb2cf0e 100755 (executable)
@@ -83,11 +83,11 @@ msg_error_t MsgStoUpdateNetworkStatus(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_
 msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList);
 msg_error_t MsgStoGetConversationViewItem(msg_message_id_t msgId, MSG_CONVERSATION_VIEW_S *pConv);
 msg_error_t MsgStoGetConversationViewList(msg_thread_id_t ThreadId, msg_struct_list_s *pConvViewList);
-msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList);
+msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList, int contactCount);
 
 msg_error_t MsgStoGetRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList);
 msg_error_t MsgStoGetAddressList(const msg_thread_id_t threadId, msg_struct_list_s *pAddrList);
-msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_struct_list_s *pMsgList);
+msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_struct_list_s *pMsgList, int contactCount);
 msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t *pMediaList);
 
 #ifdef FEATURE_SMS_CDMA
index ad9f3e3..ebc8fd9 100755 (executable)
@@ -28,9 +28,9 @@
 /*==================================================================================================
                                      FUNCTION PROTOTYPES
 ==================================================================================================*/
-char* MsgVMessageAddRecord(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg);
 char* MsgVMessageEncode(MSG_MESSAGE_INFO_S *pMsg);
-char* _convert_tm_to_vdata_str(const struct tm * tm);
+char *MsgVMessageEncodeSMS(MSG_MESSAGE_INFO_S *pMsg);
+msg_error_t MsgVMessageDecodeSMS(const char *vmsg_stream, MSG_MESSAGE_INFO_S *pMsg);
 bool _convert_vdata_str_to_tm(const char* szText, struct tm * tm);
 
 #endif //MSG_VMESSAGE_H
index a396014..038ed5f 100755 (executable)
 EXPORT_API int msg_open_msg_handle(msg_handle_t *handle)
 {
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL)
-       {
-               MSG_FATAL("Input Paramter is NULL");
+       if (handle == NULL) {
+               MSG_FATAL("Input Parameter is NULL");
                return MSG_ERR_INVALID_PARAMETER;
        }
+       /* Create MsgHandle */
        MsgHandle* pHandle = new MsgHandle();
 
-       // Create MsgHandle
+       if (pHandle == NULL)
+               return MSG_ERR_MEMORY_ERROR;
        *handle = (msg_handle_t)pHandle;
 
-       if (*handle == NULL)
-               return MSG_ERR_INVALID_PARAMETER;
-
-       try
-       {
-               // Connect to Socket
+       try {
+               /* Connect to Socket */
                pHandle->openHandle();
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
 
-               // Destroy MsgHandle
-               delete (MsgHandle*)(*handle);
-               (*handle) = NULL;
+               /* Destroy MsgHandle */
+               delete pHandle;
+               *handle = NULL;
 
                if (e.errorCode() == MsgException::SERVER_READY_ERROR)
                        return MSG_ERR_SERVER_NOT_READY;
-               else if(e.errorCode() == MsgException::SECURITY_ERROR)
+               else if (e.errorCode() == MsgException::SECURITY_ERROR)
                        return MSG_ERR_PERMISSION_DENIED;
                else
                        return MSG_ERR_COMMUNICATION_ERROR;
@@ -79,36 +72,30 @@ EXPORT_API int msg_open_msg_handle(msg_handle_t *handle)
 EXPORT_API int msg_close_msg_handle(msg_handle_t *handle)
 {
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL || *handle == NULL)
-       {
-               MSG_FATAL("Input Paramter is NULL");
+       if (handle == NULL || *handle == NULL) {
+               MSG_FATAL("Input Parameter is NULL");
                return MSG_ERR_INVALID_PARAMETER;
        }
 
        MsgHandle* pHandle = (MsgHandle*)(*handle);
 
-       try
-       {
-               // Disconnect to Socket
+       try {
+               /* Disconnect from Socket */
                pHandle->closeHandle(pHandle);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_COMMUNICATION_ERROR;
        }
 
-       // Destroy MsgHandle
-       delete (MsgHandle*)(*handle);
-       (*handle) = NULL;
+       /* Destroy MsgHandle */
+       delete pHandle;
+       *handle = NULL;
 
        return MSG_SUCCESS;
 }
index 86f60c2..038668c 100755 (executable)
@@ -31,30 +31,23 @@ EXPORT_API int msg_add_filter(msg_handle_t handle, const msg_struct_t msg_struct
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct_handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
        MSG_TYPE_CHECK(msg_struct->type, MSG_STRUCT_FILTER);
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->addFilter((const MSG_FILTER_S *)msg_struct->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_FILTER_ERROR;
        }
@@ -68,30 +61,23 @@ EXPORT_API int msg_update_filter(msg_handle_t handle, const msg_struct_t msg_str
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct_handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
        MSG_TYPE_CHECK(msg_struct->type, MSG_STRUCT_FILTER);
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->updateFilter((const MSG_FILTER_S *)msg_struct->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_FILTER_ERROR;
        }
@@ -105,27 +91,20 @@ EXPORT_API int msg_delete_filter(msg_handle_t handle, msg_filter_id_t filter_id)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->deleteFilter(filter_id);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_FILTER_ERROR;
        }
@@ -139,27 +118,20 @@ EXPORT_API int msg_get_filter_list(msg_handle_t handle, msg_struct_list_s *filte
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || filter_list == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getFilterList(filter_list);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_FILTER_ERROR;
        }
@@ -173,27 +145,20 @@ EXPORT_API int msg_set_filter_operation(msg_handle_t handle, bool set_flag)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setFilterOperation(set_flag);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_FILTER_ERROR;
        }
@@ -207,27 +172,20 @@ EXPORT_API int msg_get_filter_operation(msg_handle_t handle, bool *set_flag)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || set_flag == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getFilterOperation(set_flag);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_FILTER_ERROR;
        }
@@ -241,27 +199,20 @@ EXPORT_API int msg_set_filter_active(msg_handle_t handle, msg_filter_id_t filter
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setFilterActivation(filter_id, active);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_FILTER_ERROR;
        }
@@ -279,8 +230,7 @@ int msg_get_filter_info_bool(void *filter, int field, bool *value)
 
        MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_FILTER_ACTIVE_BOOL :
                *value = filter_data->bActive;
                break;
@@ -302,8 +252,7 @@ int msg_get_filter_info_int(void *filter, int field, int *value)
 
        MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_FILTER_ID_INT :
                *value = filter_data->filterId;
                break;
@@ -326,8 +275,7 @@ int msg_get_filter_info_str(void *filter, int field, char *value, int size)
 
        MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_FILTER_VALUE_STR :
                strncpy(value, filter_data->filterValue, size);
                break;
@@ -346,8 +294,7 @@ int msg_set_filter_info_bool(void *filter, int field, bool value)
        msg_error_t err = MSG_SUCCESS;
        MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_FILTER_ACTIVE_BOOL :
                filter_data->bActive = value;
                break;
@@ -366,8 +313,7 @@ int msg_set_filter_info_int(void *filter, int field, int value)
        msg_error_t err = MSG_SUCCESS;
        MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_FILTER_ID_INT :
                filter_data->filterId = value;
                break;
@@ -389,8 +335,7 @@ int msg_set_filter_info_str(void *filter, int field, char *value, int size)
        msg_error_t err = MSG_SUCCESS;
        MSG_FILTER_S *filter_data = (MSG_FILTER_S *)filter;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_FILTER_VALUE_STR :
        {
                int len = (size > MAX_FILTER_VALUE_LEN)?MAX_FILTER_VALUE_LEN:size;
index d46941a..827a8fb 100755 (executable)
@@ -122,10 +122,9 @@ int msg_message_release(msg_struct_s **msg_struct)
                msg->mmsDataSize = 0;
        }
 
-       // Memory Free
-       if (msg->addr_list != NULL)
-       {
-               for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
+       /* Memory Free */
+       if (msg->addr_list != NULL) {
+               for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
                        msg_struct_s * addrInfo = (msg_struct_s *)msg->addr_list->msg_struct_info[i];
                        delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
                        addrInfo->data = NULL;
@@ -139,7 +138,7 @@ int msg_message_release(msg_struct_s **msg_struct)
                msg->addr_list = NULL;
        }
 
-       // Free GList *addressList
+       /* Free GList *addressList */
        if (msg->addressList) {
                g_list_free_full(msg->addressList, __msg_message_release_address_struct);
                msg->addressList = NULL;
@@ -163,8 +162,7 @@ int msg_message_get_int_value(void *data, int field, int *value)
 
        MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)data;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MESSAGE_ID_INT :
                *value = msg_data->msgId;
                break;
@@ -176,8 +174,7 @@ int msg_message_get_int_value(void *data, int field, int *value)
                break;
        case MSG_MESSAGE_TYPE_INT :
        {
-        if (msg_data->mainType == MSG_SMS_TYPE)
-        {
+               if (msg_data->mainType == MSG_SMS_TYPE) {
                        switch (msg_data->subType) {
                                case MSG_CB_SMS :
                                        *value = MSG_TYPE_SMS_CB;
@@ -219,6 +216,9 @@ int msg_message_get_int_value(void *data, int field, int *value)
                                case MSG_CMAS_TEST :
                                        *value = MSG_TYPE_SMS_CMAS_TEST;
                                        break;
+                               case MSG_CMAS_EXERCISE :
+                                       *value = MSG_TYPE_SMS_CMAS_EXERCISE;
+                                       break;
                                case MSG_CMAS_OPERATOR_DEFINED :
                                        *value = MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED;
                                        break;
@@ -227,17 +227,16 @@ int msg_message_get_int_value(void *data, int field, int *value)
                                        break;
                        }
                }
-               else if (msg_data->mainType == MSG_MMS_TYPE)
-               {
+               else if (msg_data->mainType == MSG_MMS_TYPE) {
                        if (msg_data->subType == MSG_NOTIFICATIONIND_MMS)
                                *value = MSG_TYPE_MMS_NOTI;
                        else if (msg_data->subType == MSG_SENDREQ_JAVA_MMS)
                                *value = MSG_TYPE_MMS_JAVA;
                        else
                                *value = MSG_TYPE_MMS;
-               }
-               else
+               } else {
                        *value = MSG_TYPE_INVALID;
+               }
 
                break;
        }
@@ -412,8 +411,7 @@ int msg_message_set_int_value(void *data, int field, int value)
 
        MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)data;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MESSAGE_ID_INT :
                msg_data->msgId = value;
                break;
@@ -428,28 +426,25 @@ int msg_message_set_int_value(void *data, int field, int value)
                if (value == MSG_TYPE_SMS) {
                        msg_data->mainType = MSG_SMS_TYPE;
                        msg_data->subType = MSG_NORMAL_SMS;
-               }
-               else if (value == MSG_TYPE_MMS) {
+               } else if (value == MSG_TYPE_MMS) {
                        msg_data->mainType = MSG_MMS_TYPE;
                        msg_data->subType = MSG_SENDREQ_MMS;
-               }
-               else if (value == MSG_TYPE_MMS_JAVA) {
+               } else if (value == MSG_TYPE_MMS_JAVA) {
                        msg_data->mainType = MSG_MMS_TYPE;
                        msg_data->subType = MSG_SENDREQ_JAVA_MMS;
-               }
-               else if (value == MSG_TYPE_SMS_SYNCML) {
+               } else if (value == MSG_TYPE_SMS_SYNCML) {
                        msg_data->mainType = MSG_SMS_TYPE;
                        msg_data->subType = MSG_SYNCML_CP;
-               }
-               else if (value == MSG_TYPE_SMS_REJECT) {
+               } else if (value == MSG_TYPE_SMS_REJECT) {
                        msg_data->mainType = MSG_SMS_TYPE;
                        msg_data->subType = MSG_REJECT_SMS;
-               }
-               else if (value == MSG_TYPE_SMS_ETWS_PRIMARY) {
+               } else if (value == MSG_TYPE_SMS_ETWS_PRIMARY) {
                        msg_data->mainType = MSG_SMS_TYPE;
                        msg_data->subType = MSG_ETWS_SMS;
+               } else {
+                       ret = MSG_ERR_INVALID_PARAMETER;
                }
-        break;
+               break;
        }
        case MSG_MESSAGE_CLASS_TYPE_INT :
                msg_data->classType = value;
@@ -600,14 +595,12 @@ void msg_message_copy_message(MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_HIDDEN_S *
        pDst->simIndex = pSrc->simIndex;
        memcpy(pDst->subject, pSrc->subject, sizeof(pDst->subject));
 
-       if(pSrc->pMmsData && pSrc->mmsDataSize)
-       {
+       if (pSrc->pMmsData && pSrc->mmsDataSize) {
                pDst->pMmsData = new char[pSrc->mmsDataSize];
                memcpy(pDst->pMmsData, pSrc->pMmsData, pSrc->mmsDataSize);
        }
 
-       if(pSrc->dataSize && pSrc->pData)
-       {
+       if (pSrc->dataSize && pSrc->pData) {
                int data_len = strlen((const char *)pSrc->pData);
                pDst->pData = new char[data_len + 1];
                memset(pDst->pData, 0x00, data_len + 1);
@@ -618,8 +611,7 @@ void msg_message_copy_message(MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_HIDDEN_S *
        msg_struct_list_s *dst_addrlist = pDst->addr_list;
        dst_addrlist->nCount = src_addrlist->nCount;
 
-       for(int i=0; i < MAX_TO_ADDRESS_CNT; ++i)
-       {
+       for (int i = 0; i < MAX_TO_ADDRESS_CNT; ++i) {
                msg_struct_s *src_addr = (msg_struct_s *)src_addrlist->msg_struct_info[i];
                msg_struct_s *dst_addr = (msg_struct_s *)dst_addrlist->msg_struct_info[i];
                memcpy(dst_addr->data, src_addr->data, sizeof(MSG_ADDRESS_INFO_S));
@@ -630,7 +622,7 @@ void msg_message_copy_message(MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_HIDDEN_S *
                memcpy(pDst->thumbPath, pSrc->thumbPath, sizeof(pDst->thumbPath));
        }
 
-       for (unsigned int i=0; i < g_list_length(pSrc->addressList); i++) {
+       for (unsigned int i = 0; i < g_list_length(pSrc->addressList); i++) {
                msg_struct_s *addr_struct = __msg_message_create_address_struct();
                MSG_ADDRESS_INFO_S *addrInfo = (MSG_ADDRESS_INFO_S *)addr_struct->data;
 
@@ -659,61 +651,63 @@ int msg_cb_message_get_int_value(void *data, int field, int *value)
 
        *value = 0;
 
-       switch (field)
-       {
-               case MSG_CB_MSG_TYPE_INT :
-                       {
-                               switch (cb_msg->type) {
-                                       case MSG_ETWS_SMS :
-                                               *value = MSG_TYPE_SMS_ETWS_PRIMARY;
-                                               break;
-                                       case MSG_CB_SMS:
-                                               *value = ((cb_msg->messageId & 0xFFF8) == 0x1100 ) ? MSG_TYPE_SMS_ETWS_SECONDARY : MSG_TYPE_SMS_CB;
-                                               break;
-                                       case MSG_CMAS_PRESIDENTIAL :
-                                               *value = MSG_TYPE_SMS_CMAS_PRESIDENTIAL;
-                                               break;
-                                       case MSG_CMAS_EXTREME :
-                                               *value = MSG_TYPE_SMS_CMAS_EXTREME;
-                                               break;
-                                       case MSG_CMAS_SEVERE :
-                                               *value = MSG_TYPE_SMS_CMAS_SEVERE;
-                                               break;
-                                       case MSG_CMAS_AMBER :
-                                               *value = MSG_TYPE_SMS_CMAS_AMBER;
-                                               break;
-                                       case MSG_CMAS_TEST :
-                                               *value = MSG_TYPE_SMS_CMAS_TEST;
-                                               break;
-                                       case MSG_CMAS_OPERATOR_DEFINED :
-                                               *value = MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED;
-                                               break;
-                                       default :
-                                               ret = MSG_ERR_UNKNOWN;
-                               }
+       switch (field) {
+       case MSG_CB_MSG_TYPE_INT :
+               {
+                       switch (cb_msg->type) {
+                       case MSG_ETWS_SMS :
+                               *value = MSG_TYPE_SMS_ETWS_PRIMARY;
+                               break;
+                       case MSG_CB_SMS:
+                               *value = ((cb_msg->messageId & 0xFFF8) == 0x1100 ) ? MSG_TYPE_SMS_ETWS_SECONDARY : MSG_TYPE_SMS_CB;
+                               break;
+                       case MSG_CMAS_PRESIDENTIAL :
+                               *value = MSG_TYPE_SMS_CMAS_PRESIDENTIAL;
+                               break;
+                       case MSG_CMAS_EXTREME :
+                               *value = MSG_TYPE_SMS_CMAS_EXTREME;
+                               break;
+                       case MSG_CMAS_SEVERE :
+                               *value = MSG_TYPE_SMS_CMAS_SEVERE;
+                               break;
+                       case MSG_CMAS_AMBER :
+                               *value = MSG_TYPE_SMS_CMAS_AMBER;
+                               break;
+                       case MSG_CMAS_TEST :
+                               *value = MSG_TYPE_SMS_CMAS_TEST;
+                               break;
+                       case MSG_CMAS_EXERCISE :
+                               *value = MSG_TYPE_SMS_CMAS_EXERCISE;
+                               break;
+                       case MSG_CMAS_OPERATOR_DEFINED :
+                               *value = MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED;
+                               break;
+                       default :
+                               ret = MSG_ERR_UNKNOWN;
                        }
-                       break;
-               case MSG_CB_MSG_RECV_TIME_INT :
-                       *value = cb_msg->receivedTime;
-                       break;
-               case MSG_CB_MSG_SERIAL_NUM_INT :
-                       *value = cb_msg->serialNum;
-                       break;
-               case MSG_CB_MSG_MSG_ID_INT :
-                       *value = cb_msg->messageId;
-                       break;
-               case MSG_CB_MSG_DCS_INT :
-                       *value = (int)cb_msg->dcs;
-                       break;
-               case MSG_CB_MSG_CB_TEXT_LEN_INT :
-                       *value = cb_msg->cbTextLen;
-                       break;
-               case MSG_CB_MSG_ETWS_WARNING_TYPE_INT :
-                       *value = cb_msg->etwsWarningType;
-                       break;
-               default :
-                       ret = MSG_ERR_INVALID_PARAMETER;
-                       break;
+               }
+               break;
+       case MSG_CB_MSG_RECV_TIME_INT :
+               *value = cb_msg->receivedTime;
+               break;
+       case MSG_CB_MSG_SERIAL_NUM_INT :
+               *value = cb_msg->serialNum;
+               break;
+       case MSG_CB_MSG_MSG_ID_INT :
+               *value = cb_msg->messageId;
+               break;
+       case MSG_CB_MSG_DCS_INT :
+               *value = (int)cb_msg->dcs;
+               break;
+       case MSG_CB_MSG_CB_TEXT_LEN_INT :
+               *value = cb_msg->cbTextLen;
+               break;
+       case MSG_CB_MSG_ETWS_WARNING_TYPE_INT :
+               *value = cb_msg->etwsWarningType;
+               break;
+       default :
+               ret = MSG_ERR_INVALID_PARAMETER;
+               break;
        }
 
        return ret;
@@ -729,34 +723,34 @@ int msg_cb_message_get_str_value(void *data, int field, char *value, int size)
        MSG_CB_MSG_S *cb_msg = (MSG_CB_MSG_S *)data;
 
        switch (field) {
-               case MSG_CB_MSG_CB_TEXT_STR:
-                       {
-                               int     copylen = 0;
-                               copylen = (size > cb_msg->cbTextLen) ? cb_msg->cbTextLen : size - 1;
-                               memcpy (value, cb_msg->cbText, copylen);
-                               value[copylen] = '\0';
-                       }
-                       break;
-               case MSG_CB_MSG_LANGUAGE_TYPE_STR:
-                       {
-                               int     copylen = 0;
-                               copylen = ((size_t)size > strlen((const char*)cb_msg->language_type)) ? strlen((const char*)cb_msg->language_type) : size - 1;
-                               memcpy (value, cb_msg->language_type, copylen);
-                               value[copylen] = '\0';
-                       }
-                       break;
-               case MSG_CB_MSG_ETWS_WARNING_SECU_INFO_STR:
-                       {
-                               if ((size_t)size < sizeof(cb_msg->etwsWarningSecurityInfo))
-                                       ret = MSG_ERR_INVALID_PARAMETER;
-                               else
-                                       memcpy (value, cb_msg->etwsWarningSecurityInfo, sizeof(cb_msg->etwsWarningSecurityInfo));
-                       }
-                       break;
-
-               default :
+       case MSG_CB_MSG_CB_TEXT_STR:
+       {
+               int     copylen = 0;
+               copylen = (size > cb_msg->cbTextLen) ? cb_msg->cbTextLen : size - 1;
+               memcpy (value, cb_msg->cbText, copylen);
+               value[copylen] = '\0';
+       }
+       break;
+       case MSG_CB_MSG_LANGUAGE_TYPE_STR:
+       {
+               int     copylen = 0;
+               copylen = ((size_t)size > strlen((const char*)cb_msg->language_type)) ? strlen((const char*)cb_msg->language_type) : size - 1;
+               memcpy (value, cb_msg->language_type, copylen);
+               value[copylen] = '\0';
+       }
+       break;
+       case MSG_CB_MSG_ETWS_WARNING_SECU_INFO_STR:
+       {
+               if ((size_t)size < sizeof(cb_msg->etwsWarningSecurityInfo))
                        ret = MSG_ERR_INVALID_PARAMETER;
-                       break;
+               else
+                       memcpy (value, cb_msg->etwsWarningSecurityInfo, sizeof(cb_msg->etwsWarningSecurityInfo));
+       }
+       break;
+
+       default :
+               ret = MSG_ERR_INVALID_PARAMETER;
+               break;
        }
 
        return ret;
@@ -767,12 +761,11 @@ int msg_cb_message_get_str_value(void *data, int field, char *value, int size)
 EXPORT_API int msg_get_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t mms_struct_handle)
 {
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
-       //TODO :: check message type is MMS
+       /* TODO :: check message type is MMS */
        int ret = MSG_SUCCESS;
 
-       if (msg_struct_handle == NULL || mms_struct_handle == NULL) {
+       if (msg_struct_handle == NULL || mms_struct_handle == NULL)
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
        msg_struct_s *mms_struct = (msg_struct_s *)mms_struct_handle;
@@ -780,15 +773,13 @@ EXPORT_API int msg_get_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t m
        MSG_TYPE_CHECK(msg_struct->type, MSG_STRUCT_MESSAGE_INFO);
        MSG_TYPE_CHECK(mms_struct->type, MSG_STRUCT_MMS);
 
-       if (msg_struct->data == NULL || mms_struct->data == NULL) {
+       if (msg_struct->data == NULL || mms_struct->data == NULL)
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)msg_struct->data;
 
-       if (msg_data->pMmsData == NULL) {
+       if (msg_data->pMmsData == NULL)
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MMS_DATA_S *mms_data = NULL;
 
@@ -808,12 +799,11 @@ EXPORT_API int msg_get_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t m
 EXPORT_API int msg_set_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t mms_struct_handle)
 {
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
-       //TODO :: check message type is MMS
+       /* TODO :: check message type is MMS */
        int ret = MSG_SUCCESS;
 
-       if (msg_struct_handle == NULL || mms_struct_handle == NULL) {
+       if (msg_struct_handle == NULL || mms_struct_handle == NULL)
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
        msg_struct_s *mms_struct = (msg_struct_s *)mms_struct_handle;
@@ -821,9 +811,8 @@ EXPORT_API int msg_set_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t m
        MSG_TYPE_CHECK(msg_struct->type, MSG_STRUCT_MESSAGE_INFO);
        MSG_TYPE_CHECK(mms_struct->type, MSG_STRUCT_MMS);
 
-       if (msg_struct->data == NULL || mms_struct->data == NULL) {
+       if (msg_struct->data == NULL || mms_struct->data == NULL)
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)msg_struct->data;
 
@@ -838,7 +827,7 @@ EXPORT_API int msg_set_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t m
        if (mmsDataSize > 0)
                msg_data->mmsDataSize = mmsDataSize;
 
-       //TODO:: set subtype
+       /* TODO:: set subtype */
 
        MsgMmsRelease(&mms_data);
 
@@ -853,7 +842,7 @@ int msg_message_list_append(msg_struct_t msg_struct_handle, int field, msg_struc
        MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)msg_struct->data;
 
        msg_struct_s *msg_struct_item = NULL;
-       switch(field) {
+       switch (field) {
        case MSG_MESSAGE_ADDR_LIST_HND:
        {
                msg_struct_item = __msg_message_create_address_struct();
@@ -876,10 +865,10 @@ int msg_message_list_clear(msg_struct_t msg_struct_handle, int field)
        msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
        MSG_MESSAGE_HIDDEN_S *msg_data = (MSG_MESSAGE_HIDDEN_S *)msg_struct->data;
 
-       switch(field) {
+       switch (field) {
        case MSG_MESSAGE_ADDR_LIST_HND:
        {
-               // Free GList *addressList
+               /* Free GList *addressList */
                if (msg_data->addressList) {
                        g_list_free_full(msg_data->addressList, __msg_message_release_address_struct);
                        msg_data->addressList = NULL;
index 1ffe9ab..f8312a9 100755 (executable)
@@ -29,9 +29,8 @@
 #include "msg.h"
 #include "msg_private.h"
 
-//Internel Struct
-typedef struct
-{
+/* Internel Struct */
+typedef struct {
        GList                   *pagelist;
        GList                   *regionlist;
        GList                   *attachlist;
@@ -41,11 +40,10 @@ typedef struct
        MMS_APPID_INFO_S        msgAppId;
        MMS_HEADER_DATA_S header;
        MMS_MULTIPART_DATA_S smil;
-       GList *multipartlist;//MMS_MULTIPART_DATA_S
+       GList *multipartlist; /* MMS_MULTIPART_DATA_S */
 } MMS_DATA_HIDDEN_S;
 
-typedef struct
-{
+typedef struct {
        MmsSmilMediaType        mediatype; /**< Indicates the SMIL media type. see enum MmsSmilMediaType */
 
        char                    szSrc[MSG_FILEPATH_LEN_MAX + 1];/**< Indicates the media source name */
@@ -120,8 +118,7 @@ void *msg_mms_create_struct_data(int field)
 {
        void *data = NULL;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_STRUCT_MMS:
                data = (void *)new MMS_DATA_HIDDEN_S;
                bzero(data, sizeof(MMS_DATA_HIDDEN_S));
@@ -179,20 +176,31 @@ void *msg_mms_create_struct_data(int field)
 void msg_mms_list_item_free_func(gpointer data)
 {
        msg_struct_s *msg_struct = (msg_struct_s *)data;
-       if (msg_struct->type == MSG_STRUCT_MMS_MEDIA)  {
+
+       switch (msg_struct->type) {
+       case MSG_STRUCT_MMS_MEDIA :
                __msg_mms_release_media(msg_struct);
-       } else if (msg_struct->type == MSG_STRUCT_MMS_PAGE) {
+               break;
+       case MSG_STRUCT_MMS_PAGE :
                __msg_mms_release_page(msg_struct);
-       } else if (msg_struct->type == MSG_STRUCT_MMS_ATTACH) {
+               break;
+       case MSG_STRUCT_MMS_ATTACH :
                __msg_mms_release_attach(msg_struct);
-       } else if (msg_struct->type == MSG_STRUCT_MMS_REGION) {
+               break;
+       case MSG_STRUCT_MMS_REGION :
                __msg_mms_release_region(msg_struct);
-       } else if (msg_struct->type == MSG_STRUCT_MMS_TRANSITION) {
+               break;
+       case MSG_STRUCT_MMS_TRANSITION :
                __msg_mms_release_transition(msg_struct);
-       } else if (msg_struct->type == MSG_STRUCT_MMS_META) {
+               break;
+       case MSG_STRUCT_MMS_META :
                __msg_mms_release_meta(msg_struct);
-       } else if (msg_struct->type == MSG_STRUCT_MULTIPART_INFO) {
+               break;
+       case MSG_STRUCT_MULTIPART_INFO :
                __msg_mms_release_multipart(msg_struct);
+               break;
+       default :
+               break;
        }
 }
 
@@ -358,8 +366,7 @@ int msg_mms_release_struct(msg_struct_s **msg_struct_data)
        msg_struct_s *msg_struct = (msg_struct_s *)*msg_struct_data;
        int type = msg_struct->type;
 
-       switch(type)
-       {
+       switch (type) {
        case MSG_STRUCT_MMS:
                __msg_mms_release_mms(*msg_struct_data);
                *msg_struct_data = NULL;
@@ -423,7 +430,7 @@ int msg_mms_get_int_value(msg_struct_s *msg_struct, int field, int *value)
 {
        msg_error_t err = MSG_SUCCESS;
 
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MMS:
        {
                MMS_DATA_HIDDEN_S *mms_data = (MMS_DATA_HIDDEN_S *)msg_struct->data;
@@ -581,7 +588,7 @@ int msg_mms_get_int_value(msg_struct_s *msg_struct, int field, int *value)
        break;
        case MSG_STRUCT_MULTIPART_INFO:
                err = msg_multipart_get_int_value(msg_struct->data, field, value);
-       break;
+               break;
 
        default :
                err = MSG_ERR_INVALID_PARAMETER;
@@ -594,11 +601,11 @@ int msg_mms_get_str_value(msg_struct_s *msg_struct, int field, char *value, int
 {
        msg_error_t err = MSG_SUCCESS;
 
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MMS:
        {
                MMS_DATA_HIDDEN_S *mms_data = (MMS_DATA_HIDDEN_S *)msg_struct->data;
-               if (field == MSG_MMS_HEADER_CONTENT_LOCATION_STR) {// mms header
+               if (field == MSG_MMS_HEADER_CONTENT_LOCATION_STR) { /* mms header */
                        strncpy(value, mms_data->header.contentLocation, size);
                } else if (field == MSG_MMS_HEADER_CONTENT_TYPE_STR) {
                        strncpy(value, mms_data->header.szContentType, size);
@@ -609,7 +616,7 @@ int msg_mms_get_str_value(msg_struct_s *msg_struct, int field, char *value, int
                } else if (field == MSG_MMS_HEADER_TR_ID_STR) {
                        strncpy(value, mms_data->header.trID, size);
 
-               } else if (field == MSG_MMS_SMIL_MULTIPART_CONTENT_TYPE_STR) { // smil
+               } else if (field == MSG_MMS_SMIL_MULTIPART_CONTENT_TYPE_STR) { /* smil */
                        strncpy(value, mms_data->smil.szContentType, size);
                } else if (field == MSG_MMS_SMIL_MULTIPART_NAME_STR) {
                        strncpy(value, mms_data->smil.szFileName, size);
@@ -733,7 +740,7 @@ int msg_mms_get_bool_value(msg_struct_s *msg_struct, int field, bool *value)
 {
        msg_error_t err = MSG_SUCCESS;
 
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MMS:
        {
                MMS_DATA_HIDDEN_S *mms_data = (MMS_DATA_HIDDEN_S *)msg_struct->data;
@@ -790,7 +797,7 @@ int msg_mms_get_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s
 {
        msg_error_t err = MSG_SUCCESS;
 
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MMS_MEDIA:
        {
                MMS_MEDIA_HIDDEN_S *mms_media_data = (MMS_MEDIA_HIDDEN_S *)msg_struct->data;
@@ -813,7 +820,7 @@ int msg_mms_get_list_handle(msg_struct_s *msg_struct, int field, msg_list_handle
 {
        msg_error_t err = MSG_SUCCESS;
 
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MMS:
        {
                MMS_DATA_HIDDEN_S *mms_data = (MMS_DATA_HIDDEN_S *)msg_struct->data;
@@ -853,7 +860,7 @@ int msg_mms_set_int_value(msg_struct_s *msg_struct, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
 
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MMS:
        {
                MMS_DATA_HIDDEN_S *mms_data = (MMS_DATA_HIDDEN_S *)msg_struct->data;
@@ -1022,7 +1029,7 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int
 {
        msg_error_t err = MSG_SUCCESS;
 
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MMS_MEDIA:
        {
                MMS_MEDIA_HIDDEN_S *mms_media_data = (MMS_MEDIA_HIDDEN_S *)msg_struct->data;
@@ -1155,7 +1162,7 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int
        case MSG_STRUCT_MMS:
        {
                MMS_DATA_HIDDEN_S *mms_data = (MMS_DATA_HIDDEN_S *)msg_struct->data;
-               if (field == MSG_MMS_HEADER_CONTENT_LOCATION_STR) {// mms header
+               if (field == MSG_MMS_HEADER_CONTENT_LOCATION_STR) { /* mms header */
                        strncpy(mms_data->header.contentLocation, value, sizeof(mms_data->header.contentLocation) - 1 );
                } else if (field == MSG_MMS_HEADER_CONTENT_TYPE_STR) {
                        strncpy(mms_data->header.szContentType, value, sizeof(mms_data->header.szContentType) - 1 );
@@ -1166,7 +1173,7 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int
                } else if (field == MSG_MMS_HEADER_TR_ID_STR) {
                        strncpy(mms_data->header.trID, value, sizeof(mms_data->header.trID) - 1 );
 
-               } else if (field == MSG_MMS_SMIL_MULTIPART_CONTENT_TYPE_STR) { // smil
+               } else if (field == MSG_MMS_SMIL_MULTIPART_CONTENT_TYPE_STR) { /* smil */
                        strncpy(mms_data->smil.szContentType, value, sizeof(mms_data->smil.szContentType) - 1 );
                } else if (field == MSG_MMS_SMIL_MULTIPART_NAME_STR) {
                        strncpy(mms_data->smil.szFileName, value, sizeof(mms_data->smil.szFileName) - 1 );
@@ -1197,7 +1204,7 @@ int msg_mms_set_bool_value(msg_struct_s *msg_struct, int field, bool value)
 {
        msg_error_t err = MSG_SUCCESS;
 
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MMS:
        {
                MMS_DATA_HIDDEN_S *mms_data = (MMS_DATA_HIDDEN_S *)msg_struct->data;
@@ -1250,7 +1257,7 @@ int msg_mms_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s
 {
        msg_error_t err = MSG_SUCCESS;
 
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MMS_MEDIA:
        {
                MMS_MEDIA_HIDDEN_S *mms_media_data = (MMS_MEDIA_HIDDEN_S *)msg_struct->data;
@@ -1276,7 +1283,7 @@ int msg_mms_list_append(msg_struct_t msg_struct_handle, int field, msg_struct_t
        msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
        msg_struct_s *msg_struct_item = NULL;
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MMS:
        {
 
@@ -1392,7 +1399,6 @@ void convert_from_media_data(const MMS_MEDIA_S *pSrc, msg_struct_s *pDest)
 void convert_to_mmsdata2(MMS_DATA_HIDDEN_S *pSrcMms, MMS_MESSAGE_DATA_S *pDest)
 {
        int i, j;
-       //MMS_DATA_HIDDEN_S *pSrcMms = (MMS_DATA_HIDDEN_S *)pSrc->data;
 
        pDest->pageCnt = g_list_length(pSrcMms->pagelist);
 
@@ -1479,7 +1485,6 @@ void convert_to_mmsdata2(MMS_DATA_HIDDEN_S *pSrcMms, MMS_MESSAGE_DATA_S *pDest)
 void convert_from_mmsdata2(const MMS_MESSAGE_DATA_S *pSrc, MMS_DATA_HIDDEN_S *pDestMms)
 {
        int i, j;
-       //MMS_DATA_HIDDEN_S *pDestMms = (MMS_DATA_HIDDEN_S *)pDest->data;
 
        for (i = 0; i < pSrc->pageCnt; i++) {
                msg_struct_s *page_struct = msg_mms_create_struct(MSG_STRUCT_MMS_PAGE);
@@ -1622,7 +1627,7 @@ int msg_multipart_set_str_value(void *data, int field, char *value, int size)
 
        MMS_MULTIPART_DATA_S *msg_data = (MMS_MULTIPART_DATA_S *)data;
 
-       //CID 41980: Reducing the size argument to strncpy calls to accomodate string termination '\0' in case source string is larger than size
+       /* CID 41980: Reducing the size argument to strncpy calls to accomodate string termination '\0' in case source string is larger than size */
        switch (field) {
        case MSG_MMS_MULTIPART_CONTENT_TYPE_STR:
                strncpy(msg_data->szContentType, value, MSG_MSG_ID_LEN);
index f960133..386d47d 100755 (executable)
@@ -77,8 +77,7 @@ int msg_setting_get_str_value(msg_struct_s *msg_struct, int field, char *src, in
 {
        int err = MSG_SUCCESS;
 
-       switch (msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_SETTING_SMSC_INFO :
                err = msg_get_smsc_info_str(msg_struct->data, field, src, size);
                break;
@@ -202,8 +201,7 @@ int msg_setting_set_str_value(msg_struct_s *msg_struct, int field, char *value,
 {
        int err = MSG_SUCCESS;
 
-       switch (msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_SETTING_SMSC_INFO :
                err = msg_set_smsc_info_str(msg_struct->data, field, value, size);
                break;
@@ -265,27 +263,20 @@ EXPORT_API int msg_get_smsc_opt(msg_handle_t handle, msg_struct_t msg_struct)
 
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getSMSCOption(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -299,27 +290,20 @@ EXPORT_API int msg_set_smsc_opt(msg_handle_t handle, msg_struct_t msg_struct)
 
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setSMSCOption(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -336,8 +320,7 @@ int msg_get_smsc_opt_list(void *smsc_opt, int field, void **value)
 
        int ret = MSG_SUCCESS;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_SMSC_LIST_STRUCT :
                *value = (void *)smsc_opt_data->smsc_list;
                break;
@@ -358,8 +341,7 @@ int msg_get_smsc_opt_int(void *smsc_opt, int field, int *value)
 
        MSG_SMSC_LIST_HIDDEN_S *smsc_opt_data = (MSG_SMSC_LIST_HIDDEN_S *)smsc_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_SMSC_SELECTED_ID_INT :
                *value = smsc_opt_data->selected;
                break;
@@ -383,8 +365,7 @@ int msg_set_smsc_opt_int(void *smsc_opt, int field, int value)
 
        MSG_SMSC_LIST_HIDDEN_S *smsc_opt_data = (MSG_SMSC_LIST_HIDDEN_S *)smsc_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_SMSC_SELECTED_ID_INT :
                smsc_opt_data->selected = value;
                break;
@@ -411,8 +392,7 @@ int msg_get_smsc_info_int(void *smsc_info, int field, int *value)
 
        MSG_SMSC_DATA_S *smsc_data = (MSG_SMSC_DATA_S *)smsc_info;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_SMSC_ADDR_TON_INT :
                *value = smsc_data->smscAddr.ton;
                break;
@@ -442,8 +422,7 @@ int msg_set_smsc_info_int(void *smsc_info, int field, int value)
 
        MSG_SMSC_DATA_S *smsc_data = (MSG_SMSC_DATA_S *)smsc_info;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_SMSC_ADDR_TON_INT :
                smsc_data->smscAddr.ton = value;
                break;
@@ -471,8 +450,7 @@ int msg_get_smsc_info_str(void *smsc_info, int field, char *value, int size)
 
        MSG_SMSC_DATA_S *smsc_data = (MSG_SMSC_DATA_S *)smsc_info;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_SMSC_ADDR_STR :
                strncpy(value, smsc_data->smscAddr.address, size);
                break;
@@ -495,8 +473,7 @@ int msg_set_smsc_info_str(void *smsc_info, int field, char *val, int size)
 
        MSG_SMSC_DATA_S *smsc_data = (MSG_SMSC_DATA_S *)smsc_info;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_SMSC_ADDR_STR :
                bzero(smsc_data->smscAddr.address, sizeof(smsc_data->smscAddr.address));
                snprintf(smsc_data->smscAddr.address, sizeof(smsc_data->smscAddr.address), "%s", val);
@@ -519,27 +496,20 @@ EXPORT_API int msg_get_cb_opt(msg_handle_t handle, msg_struct_t msg_struct)
 
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getCBOption(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -553,27 +523,20 @@ EXPORT_API int msg_set_cb_opt(msg_handle_t handle, msg_struct_t msg_struct)
 
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setCBOption(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -590,8 +553,7 @@ int msg_get_cb_option_int(void *cb_opt, int field, int *value)
 
        MSG_CBMSG_OPT_HIDDEN_S *cb_opt_data = (MSG_CBMSG_OPT_HIDDEN_S *)cb_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_CB_MAX_SIM_COUNT_INT :
                *value = cb_opt_data->maxSimCnt;
                break;
@@ -615,8 +577,7 @@ int msg_set_cb_option_int(void *cb_opt, int field, int value)
 
        MSG_CBMSG_OPT_HIDDEN_S *cb_opt_data = (MSG_CBMSG_OPT_HIDDEN_S *)cb_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_CB_MAX_SIM_COUNT_INT :
                cb_opt_data->maxSimCnt = value;
                break;
@@ -641,8 +602,7 @@ int msg_get_cb_option_bool(void *cb_opt, int field, bool *value)
 
        MSG_CBMSG_OPT_HIDDEN_S *cb_opt_data = (MSG_CBMSG_OPT_HIDDEN_S *)cb_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_CB_RECEIVE_BOOL :
                *value = cb_opt_data->bReceive;
                break;
@@ -693,8 +653,7 @@ int msg_set_cb_option_bool(void *cb_opt, int field, bool value)
 
        MSG_CBMSG_OPT_HIDDEN_S *cb_opt_data = (MSG_CBMSG_OPT_HIDDEN_S *)cb_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_CB_RECEIVE_BOOL :
                cb_opt_data->bReceive = value;
                break;
@@ -745,8 +704,7 @@ int msg_get_cb_option_list(void *cb_opt, int field, void **value)
 
        int ret = MSG_SUCCESS;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_CB_CHANNEL_LIST_STRUCT :
                *value = (void *)cb_opt_data->channelData;
                break;
@@ -767,8 +725,7 @@ int msg_get_cb_channel_info_int(void *cb_ch_info, int field, int *value)
 
        MSG_CB_CHANNEL_INFO_S *cb_ch_data = (MSG_CB_CHANNEL_INFO_S *)cb_ch_info;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_CB_CHANNEL_ID_FROM_INT :
                *value = cb_ch_data->from;
                break;
@@ -792,8 +749,7 @@ int msg_set_cb_channel_info_int(void *cb_ch_info, int field, int value)
 
        MSG_CB_CHANNEL_INFO_S *cb_ch_data = (MSG_CB_CHANNEL_INFO_S *)cb_ch_info;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_CB_CHANNEL_ID_FROM_INT :
                cb_ch_data->from = value;
                break;
@@ -817,8 +773,7 @@ int msg_get_cb_channel_info_bool(void *cb_ch_info, int field, bool *value)
 
        MSG_CB_CHANNEL_INFO_S *cb_ch_data = (MSG_CB_CHANNEL_INFO_S *)cb_ch_info;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_CB_CHANNEL_ACTIVATE_BOOL :
                *value = cb_ch_data->bActivate;
                break;
@@ -839,8 +794,7 @@ int msg_set_cb_channel_info_bool(void *cb_ch_info, int field, bool value)
 
        MSG_CB_CHANNEL_INFO_S *cb_ch_data = (MSG_CB_CHANNEL_INFO_S *)cb_ch_info;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_CB_CHANNEL_ACTIVATE_BOOL :
                cb_ch_data->bActivate = value;
                break;
@@ -859,8 +813,7 @@ int msg_get_cb_channel_info_str(void *cb_ch_info, int field, char *value, int si
 
        MSG_CB_CHANNEL_INFO_S *cb_ch_data = (MSG_CB_CHANNEL_INFO_S *)cb_ch_info;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_CB_CHANNEL_NAME_STR :
                strncpy(value, cb_ch_data->name, size);
                break;
@@ -880,8 +833,7 @@ int msg_set_cb_channel_info_str(void *cb_ch_info, int field, char *val, int size
 
        MSG_CB_CHANNEL_INFO_S *cb_ch_data = (MSG_CB_CHANNEL_INFO_S *)cb_ch_info;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_CB_CHANNEL_NAME_STR :
                bzero(cb_ch_data->name, sizeof(cb_ch_data->name));
                snprintf(cb_ch_data->name, sizeof(cb_ch_data->name), "%s", val);
@@ -900,27 +852,20 @@ EXPORT_API int msg_get_sms_send_opt(msg_handle_t handle, msg_struct_t msg_struct
 
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getSmsSendOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -934,27 +879,20 @@ EXPORT_API int msg_set_sms_send_opt(msg_handle_t handle, msg_struct_t msg_struct
 
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setSmsSendOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -971,8 +909,7 @@ int msg_get_sms_send_opt_int(void *sms_send_opt, int field, int *value)
 
        MSG_SMS_SENDOPT_S *send_opt = (MSG_SMS_SENDOPT_S *)sms_send_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_SMS_SENDOPT_ENCODE_TYPE_INT :
                *value = send_opt->dcs;
                break;
@@ -999,8 +936,7 @@ int msg_set_sms_send_opt_int(void *sms_send_opt, int field, int value)
 
        MSG_SMS_SENDOPT_S *send_opt = (MSG_SMS_SENDOPT_S *)sms_send_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_SMS_SENDOPT_ENCODE_TYPE_INT :
                send_opt->dcs = value;
                break;
@@ -1027,8 +963,7 @@ int msg_get_sms_send_opt_bool(void *sms_send_opt, int field, bool *value)
 
        MSG_SMS_SENDOPT_S *send_opt = (MSG_SMS_SENDOPT_S *)sms_send_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_SMS_SENDOPT_REPLY_PATH_BOOL :
                *value = send_opt->bReplyPath;
                break;
@@ -1052,8 +987,7 @@ int msg_set_sms_send_opt_bool(void *sms_send_opt, int field, bool value)
 
        MSG_SMS_SENDOPT_S *send_opt = (MSG_SMS_SENDOPT_S *)sms_send_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_SMS_SENDOPT_REPLY_PATH_BOOL :
                send_opt->bReplyPath = value;
                break;
@@ -1074,27 +1008,20 @@ EXPORT_API int msg_get_mms_send_opt(msg_handle_t handle, msg_struct_t msg_struct
 
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /*Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getMmsSendOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -1108,27 +1035,20 @@ EXPORT_API int msg_set_mms_send_opt(msg_handle_t handle, msg_struct_t msg_struct
 
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setMmsSendOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -1146,8 +1066,7 @@ int msg_get_mms_send_opt_int(void *mms_send_opt, int field, int *value)
 
        MSG_MMS_SENDOPT_S *send_opt = (MSG_MMS_SENDOPT_S *)mms_send_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MMS_SENDOPT_CLASS_TYPE_INT :
                *value = send_opt->msgClass;
                break;
@@ -1192,8 +1111,7 @@ int msg_set_mms_send_opt_int(void *mms_send_opt, int field, int value)
 
        MSG_MMS_SENDOPT_S *send_opt = (MSG_MMS_SENDOPT_S *)mms_send_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MMS_SENDOPT_CLASS_TYPE_INT :
                send_opt->msgClass = value;
                break;
@@ -1238,8 +1156,7 @@ int msg_get_mms_send_opt_bool(void *mms_send_opt, int field, bool *value)
 
        MSG_MMS_SENDOPT_S *send_opt = (MSG_MMS_SENDOPT_S *)mms_send_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MMS_SENDOPT_SENDER_VISIBILITY_BOOL :
                *value = send_opt->bSenderVisibility;
                break;
@@ -1275,8 +1192,7 @@ int msg_set_mms_send_opt_bool(void *mms_send_opt, int field, bool value)
 
        MSG_MMS_SENDOPT_S *send_opt = (MSG_MMS_SENDOPT_S *)mms_send_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MMS_SENDOPT_SENDER_VISIBILITY_BOOL :
                send_opt->bSenderVisibility = value;
                break;
@@ -1309,27 +1225,20 @@ EXPORT_API int msg_get_mms_recv_opt(msg_handle_t handle, msg_struct_t msg_struct
 
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getMmsRecvOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -1343,27 +1252,20 @@ EXPORT_API int msg_set_mms_recv_opt(msg_handle_t handle, msg_struct_t msg_struct
 
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setMmsRecvOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -1380,8 +1282,7 @@ int msg_get_mms_recv_opt_int(void *mms_recv_opt, int field, int *value)
 
        MSG_MMS_RECVOPT_S *recv_opt = (MSG_MMS_RECVOPT_S *)mms_recv_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT :
                *value = recv_opt->homeNetwork;
                break;
@@ -1405,8 +1306,7 @@ int msg_set_mms_recv_opt_int(void *mms_recv_opt, int field, int value)
 
        MSG_MMS_RECVOPT_S *recv_opt = (MSG_MMS_RECVOPT_S *)mms_recv_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT :
                recv_opt->homeNetwork = value;
                break;
@@ -1430,8 +1330,7 @@ int msg_get_mms_recv_opt_bool(void *mms_recv_opt, int field, bool *value)
 
        MSG_MMS_RECVOPT_S *recv_opt = (MSG_MMS_RECVOPT_S *)mms_recv_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MMS_RECVOPT_READ_REPORT_BOOL :
                *value = recv_opt->readReceipt;
                break;
@@ -1461,8 +1360,7 @@ int msg_set_mms_recv_opt_bool(void *mms_recv_opt, int field, bool value)
 
        MSG_MMS_RECVOPT_S *recv_opt = (MSG_MMS_RECVOPT_S *)mms_recv_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MMS_RECVOPT_READ_REPORT_BOOL :
                recv_opt->readReceipt = value;
                break;
@@ -1488,27 +1386,20 @@ EXPORT_API int msg_get_push_msg_opt(msg_handle_t handle, msg_struct_t msg_struct
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getPushMsgOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -1521,27 +1412,20 @@ EXPORT_API int msg_set_push_msg_opt(msg_handle_t handle, msg_struct_t msg_struct
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setPushMsgOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -1558,8 +1442,7 @@ int msg_get_push_msg_opt_int(void *push_msg_opt, int field, int *value)
 
        MSG_PUSHMSG_OPT_S *push_opt = (MSG_PUSHMSG_OPT_S *)push_msg_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_PUSHMSG_SERVICE_TYPE_INT :
                *value = push_opt->serviceType;
                break;
@@ -1580,8 +1463,7 @@ int msg_set_push_msg_opt_int(void *push_msg_opt, int field, int value)
 
        MSG_PUSHMSG_OPT_S *push_opt = (MSG_PUSHMSG_OPT_S *)push_msg_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_PUSHMSG_SERVICE_TYPE_INT :
                push_opt->serviceType = value;
                break;
@@ -1602,8 +1484,7 @@ int msg_get_push_msg_opt_bool(void *push_msg_opt, int field, bool *value)
 
        MSG_PUSHMSG_OPT_S *push_opt = (MSG_PUSHMSG_OPT_S *)push_msg_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_PUSHMSG_RECEIVE_BOOL :
                *value = push_opt->bReceive;
                break;
@@ -1624,8 +1505,7 @@ int msg_set_push_msg_opt_bool(void *push_msg_opt, int field, bool value)
 
        MSG_PUSHMSG_OPT_S *push_opt = (MSG_PUSHMSG_OPT_S *)push_msg_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_PUSHMSG_RECEIVE_BOOL :
                push_opt->bReceive = value;
                break;
@@ -1642,27 +1522,20 @@ EXPORT_API int msg_get_voice_msg_opt(msg_handle_t handle, msg_struct_t msg_struc
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getVoiceMsgOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -1675,27 +1548,20 @@ EXPORT_API int msg_set_voice_msg_opt(msg_handle_t handle, msg_struct_t msg_struc
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setVoiceMsgOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -1712,8 +1578,7 @@ int msg_get_voice_msg_opt_int(void *voice_msg_opt, int field, int *value)
 
        MSG_VOICEMAIL_OPT_S *voice_opt = (MSG_VOICEMAIL_OPT_S *)voice_msg_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_VOICEMSG_SIM_INDEX_INT :
                *value = voice_opt->simIndex;
                break;
@@ -1737,8 +1602,7 @@ int msg_set_voice_msg_opt_int(void *voice_msg_opt, int field, int value)
 
        MSG_VOICEMAIL_OPT_S *voice_opt = (MSG_VOICEMAIL_OPT_S *)voice_msg_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_VOICEMSG_SIM_INDEX_INT :
                voice_opt->simIndex = value;
                break;
@@ -1757,8 +1621,7 @@ int msg_get_voice_msg_opt_str(void *voice_msg_opt, int field, char *value, int s
 
        MSG_VOICEMAIL_OPT_S *voice_opt = (MSG_VOICEMAIL_OPT_S *)voice_msg_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_VOICEMSG_ADDRESS_STR :
                strncpy(value, voice_opt->mailNumber, size);
                break;
@@ -1781,8 +1644,7 @@ int msg_set_voice_msg_opt_str(void *voice_msg_opt, int field, char *val, int siz
 
        MSG_VOICEMAIL_OPT_S *voice_opt = (MSG_VOICEMAIL_OPT_S *)voice_msg_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_VOICEMSG_ADDRESS_STR :
                bzero(voice_opt->mailNumber, sizeof(voice_opt->mailNumber));
                snprintf(voice_opt->mailNumber, sizeof(voice_opt->mailNumber), "%s", val);
@@ -1800,27 +1662,20 @@ EXPORT_API int msg_get_general_opt(msg_handle_t handle, msg_struct_t msg_struct)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getGeneralOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -1833,27 +1688,20 @@ EXPORT_API int msg_set_general_opt(msg_handle_t handle, msg_struct_t msg_struct)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setGeneralOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -1870,8 +1718,7 @@ int msg_get_general_opt_int(void *general_opt, int field, int *value)
 
        MSG_GENERAL_OPT_S *opt = (MSG_GENERAL_OPT_S *)general_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_GENERAL_ALERT_TONE_INT :
                *value = opt->alertTone;
                break;
@@ -1901,8 +1748,7 @@ int msg_set_general_opt_int(void *general_opt, int field, int value)
 
        MSG_GENERAL_OPT_S *opt = (MSG_GENERAL_OPT_S *)general_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_GENERAL_ALERT_TONE_INT :
                opt->alertTone = value;
                break;
@@ -1932,8 +1778,7 @@ int msg_get_general_opt_bool(void *general_opt, int field, bool *value)
 
        MSG_GENERAL_OPT_S *opt = (MSG_GENERAL_OPT_S *)general_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_GENERAL_KEEP_COPY_BOOL :
                *value = opt->bKeepCopy;
                break;
@@ -1969,8 +1814,7 @@ int msg_set_general_opt_bool(void *general_opt, int field, bool value)
 
        MSG_GENERAL_OPT_S *opt = (MSG_GENERAL_OPT_S *)general_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_GENERAL_KEEP_COPY_BOOL :
                opt->bKeepCopy = value;
                break;
@@ -2004,8 +1848,7 @@ int msg_get_general_opt_str(void *general_opt, int field, char *value, int size)
 
        MSG_GENERAL_OPT_S *opt = (MSG_GENERAL_OPT_S *)general_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_GENERAL_RINGTONE_PATH_STR :
                strncpy(value, opt->ringtonePath, size);
                break;
@@ -2025,8 +1868,7 @@ int msg_set_general_opt_str(void *general_opt, int field, char *val, int size)
 
        MSG_GENERAL_OPT_S *opt = (MSG_GENERAL_OPT_S *)general_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_GENERAL_RINGTONE_PATH_STR :
                bzero(opt->ringtonePath, sizeof(opt->ringtonePath));
                snprintf(opt->ringtonePath, sizeof(opt->ringtonePath), "%s", val);
@@ -2045,27 +1887,20 @@ EXPORT_API int msg_get_msgsize_opt(msg_handle_t handle, msg_struct_t msg_struct)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getMsgSizeOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -2078,27 +1913,20 @@ EXPORT_API int msg_set_msgsize_opt(msg_handle_t handle, msg_struct_t msg_struct)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_struct == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setMsgSizeOpt(msg_struct);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_SET_READ_ERROR;
        }
@@ -2115,8 +1943,7 @@ int msg_get_msgsize_opt_int(void *size_opt, int field, int *value)
 
        MSG_MSGSIZE_OPT_S *msg_opt = (MSG_MSGSIZE_OPT_S *)size_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MESSAGE_SIZE_INT :
                *value = msg_opt->nMsgSize;
                break;
@@ -2137,8 +1964,7 @@ int msg_set_msgsize_opt_int(void *size_opt, int field, int value)
 
        MSG_MSGSIZE_OPT_S *msg_opt = (MSG_MSGSIZE_OPT_S *)size_opt;
 
-       switch (field)
-       {
+       switch (field) {
        case MSG_MESSAGE_SIZE_INT :
                msg_opt->nMsgSize = value;
                break;
index 5c7cf34..b35b9cc 100755 (executable)
@@ -35,18 +35,14 @@ EXPORT_API int msg_add_message(msg_handle_t handle, msg_struct_t opq_msg, const
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || opq_msg == NULL || send_opt == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
@@ -56,12 +52,9 @@ EXPORT_API int msg_add_message(msg_handle_t handle, msg_struct_t opq_msg, const
        msg_struct_s *pStruct = (msg_struct_s *)send_opt;
        MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_SENDOPT);
 
-       try
-       {
+       try {
                err = pHandle->addMessage((MSG_MESSAGE_HIDDEN_S *)pMsgStruct->data, (MSG_SENDINGOPT_S *)pStruct->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -75,29 +68,22 @@ EXPORT_API int msg_add_syncml_message(msg_handle_t handle, const msg_struct_t sy
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || syncml_msg == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
        msg_struct_s *pStruct = (msg_struct_s *)syncml_msg;
        MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_SYNCML_INFO);
 
-       try
-       {
+       try {
                err = pHandle->addSyncMLMessage((MSG_SYNCML_MESSAGE_S *)pStruct->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -111,18 +97,14 @@ EXPORT_API int msg_update_message(msg_handle_t handle, const msg_struct_t opq_ms
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || opq_msg == NULL || send_opt == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
@@ -134,12 +116,10 @@ EXPORT_API int msg_update_message(msg_handle_t handle, const msg_struct_t opq_ms
 
        MSG_MESSAGE_HIDDEN_S *msg = (MSG_MESSAGE_HIDDEN_S *)pMsgStruct->data;
        MSG_SENDINGOPT_S *sendingOpt = (MSG_SENDINGOPT_S *)pStruct->data;
-       try
-       {
+
+       try {
                err = pHandle->updateMessage(msg, sendingOpt);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -153,27 +133,20 @@ EXPORT_API int msg_update_read_status(msg_handle_t handle, msg_message_id_t msg_
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->updateReadStatus(msg_id, read);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -187,27 +160,20 @@ EXPORT_API int msg_set_conversation_to_read(msg_handle_t handle, msg_thread_id_t
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->setConversationToRead(thread_id);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -221,27 +187,20 @@ EXPORT_API int msg_update_protected_status(msg_handle_t handle, msg_message_id_t
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->updateProtectedStatus(msg_id, is_protected);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -254,27 +213,20 @@ EXPORT_API int msg_delete_message(msg_handle_t handle, msg_message_id_t msg_id)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->deleteMessage(msg_id);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -288,27 +240,20 @@ EXPORT_API int msg_delete_all_msgs_in_folder(msg_handle_t handle, msg_folder_id_
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->deleteAllMessagesInFolder(folder_id, bOnlyDB);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -322,27 +267,20 @@ EXPORT_API int msg_delete_msgs_by_list(msg_handle_t handle, msg_id_list_s *msg_i
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_id_list == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->deleteMessagesByList(msg_id_list);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -356,27 +294,20 @@ EXPORT_API int msg_move_msg_to_folder(msg_handle_t handle, msg_message_id_t msg_
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->moveMessageToFolder(msg_id, dest_folder_id);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -390,33 +321,25 @@ EXPORT_API int msg_move_msg_to_storage(msg_handle_t handle, msg_message_id_t msg
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
-       if (storage_id < MSG_STORAGE_PHONE || storage_id > MSG_STORAGE_SIM2)
-       {
+       if (storage_id < MSG_STORAGE_PHONE || storage_id > MSG_STORAGE_SIM2) {
                MSG_FATAL("unsupported storage [%d]", storage_id);
                return MSG_ERR_INVALID_PARAMETER;
        }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->moveMessageToStorage(msg_id, storage_id);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -430,29 +353,22 @@ EXPORT_API int msg_count_message(msg_handle_t handle, msg_folder_id_t folder_id,
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || count_info == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
        msg_struct_s *pStruct = (msg_struct_s *)count_info;
        MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_COUNT_INFO);
 
-       try
-       {
+       try {
                err = pHandle->countMessage(folder_id, (MSG_COUNT_INFO_S *)pStruct->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -466,48 +382,35 @@ EXPORT_API int msg_count_msg_by_type(msg_handle_t handle, msg_message_type_t msg
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_count == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
        MSG_MESSAGE_TYPE_S msgType = {0};
 
-       if (msg_type == MSG_TYPE_SMS)
-       {
+       if (msg_type == MSG_TYPE_SMS) {
                msgType.mainType = MSG_SMS_TYPE;
                msgType.subType = MSG_NORMAL_SMS;
-       }
-       else if (msg_type == MSG_TYPE_SMS_WAPPUSH)
-       {
+       } else if (msg_type == MSG_TYPE_SMS_WAPPUSH) {
                msgType.mainType = MSG_SMS_TYPE;
                msgType.subType = MSG_WAP_SI_SMS;
-       }
-       else if (msg_type == MSG_TYPE_MMS)
-       {
+       } else if (msg_type == MSG_TYPE_MMS) {
                msgType.mainType = MSG_MMS_TYPE;
                msgType.subType = MSG_SENDREQ_MMS;
-       }
-       else {
+       } else {
                return MSG_ERR_INVALID_PARAMETER;
        }
 
-       try
-       {
+       try {
                err = pHandle->countMsgByType(&msgType, msg_count);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -521,18 +424,14 @@ EXPORT_API int msg_count_msg_by_contact(msg_handle_t handle, const msg_struct_t
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || addr_info == NULL || msg_thread_count_list == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
@@ -542,12 +441,9 @@ EXPORT_API int msg_count_msg_by_contact(msg_handle_t handle, const msg_struct_t
        msg_struct_s *pCount = (msg_struct_s *)msg_thread_count_list;
        MSG_TYPE_CHECK(pCount->type, MSG_STRUCT_THREAD_COUNT_INFO);
 
-       try
-       {
+       try {
                err = pHandle->countMsgByContact((MSG_THREAD_LIST_INDEX_INFO_S *)pAddr->data, (MSG_THREAD_COUNT_INFO_S *)pCount->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -561,19 +457,14 @@ EXPORT_API int msg_get_message(msg_handle_t handle, msg_message_id_t msg_id, msg
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || opq_msg == NULL || send_opt == NULL)
-       {
-               MSG_FATAL("handle or opq_msg is NULL");
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
@@ -583,12 +474,9 @@ EXPORT_API int msg_get_message(msg_handle_t handle, msg_message_id_t msg_id, msg
        msg_struct_s *pStruct = (msg_struct_s *)send_opt;
        MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_SENDOPT);
 
-       try
-       {
+       try {
                err = pHandle->getMessage(msg_id, (MSG_MESSAGE_HIDDEN_S *)pMsgStruct->data, (MSG_SENDINGOPT_S *)pStruct->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -601,28 +489,22 @@ EXPORT_API int msg_get_vobject_data(msg_handle_t handle, msg_message_id_t msg_id
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL || result_data == NULL)
-       {
+       if (handle == NULL || result_data == NULL) {
                MSG_FATAL("handle or result_data is NULL");
                return MSG_ERR_INVALID_PARAMETER;
        }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getVobject(msg_id, result_data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -635,16 +517,13 @@ EXPORT_API int msg_get_conversation(msg_handle_t handle, msg_message_id_t msg_id
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL || conv == NULL)
-       {
+       if (handle == NULL || conv == NULL) {
                MSG_FATAL("handle or opq_msg is NULL");
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -654,12 +533,9 @@ EXPORT_API int msg_get_conversation(msg_handle_t handle, msg_message_id_t msg_id
        msg_struct_s *pMsgStruct = (msg_struct_s *)conv;
        MSG_TYPE_CHECK(pMsgStruct->type, MSG_STRUCT_CONV_INFO);
 
-       try
-       {
+       try {
                err = pHandle->getConversationViewItem(msg_id, (MSG_CONVERSATION_VIEW_S *)pMsgStruct->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -672,42 +548,32 @@ EXPORT_API int msg_get_thread_view_list(msg_handle_t handle, const msg_struct_t
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_thread_view_list == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
        msg_struct_s *pStruct =(msg_struct_s *)sort_rule;
-       if (pStruct) {
+       if (pStruct)
                MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_SORT_RULE);
-       }
-       try
-       {
-               if (pStruct == NULL)
-               {
+
+       try {
+               if (pStruct == NULL) {
                        MSG_SORT_RULE_S sortRule = {0};
 
                        sortRule.sortType = MSG_SORT_BY_THREAD_DATE;
                        sortRule.bAscending = false;
 
                        err = pHandle->getThreadViewList(&sortRule, msg_thread_view_list);
-               }
-               else
-               {
+               } else {
                        err = pHandle->getThreadViewList((MSG_SORT_RULE_S *)pStruct->data, msg_thread_view_list);
                }
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -721,27 +587,20 @@ EXPORT_API int msg_get_conversation_view_list(msg_handle_t handle, msg_thread_id
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_conv_view_list == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getConversationViewList(thread_id, msg_conv_view_list);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -755,27 +614,20 @@ EXPORT_API int msg_delete_thread_message_list(msg_handle_t handle, msg_thread_id
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->deleteThreadMessageList(thread_id, include_protected_msg);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -789,29 +641,22 @@ EXPORT_API int msg_add_folder(msg_handle_t handle, const msg_struct_t folder_inf
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || folder_info == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
        msg_struct_s *pStruct = (msg_struct_s *)folder_info;
        MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_FOLDER_INFO);
 
-       try
-       {
+       try {
                err = pHandle->addFolder((MSG_FOLDER_INFO_S *)pStruct->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -825,29 +670,22 @@ EXPORT_API int msg_update_folder(msg_handle_t handle, const msg_struct_t folder_
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || folder_info == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
        msg_struct_s *pStruct = (msg_struct_s *)folder_info;
        MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_FOLDER_INFO);
 
-       try
-       {
+       try {
                err = pHandle->updateFolder((MSG_FOLDER_INFO_S *)pStruct->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -861,27 +699,20 @@ EXPORT_API int msg_delete_folder(msg_handle_t handle, msg_folder_id_t folder_id)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->deleteFolder(folder_id);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -895,27 +726,20 @@ EXPORT_API int msg_get_folder_list(msg_handle_t handle, msg_struct_list_s *folde
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || folder_list == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getFolderList(folder_list);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -927,28 +751,23 @@ EXPORT_API int msg_get_folder_list(msg_handle_t handle, msg_struct_list_s *folde
 EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_type, msg_folder_id_t folder_id, unsigned int num_msg)
 {
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL)
-       {
+       if (handle == NULL) {
                MSG_DEBUG("Handle is NULL");
                return MSG_ERR_INVALID_PARAMETER;
        }
 
-       if (msg_type >= MSG_MESSAGE_TYPE_MAX)
-       {
+       if (msg_type >= MSG_MESSAGE_TYPE_MAX) {
                MSG_DEBUG("msg_type is invalid [%d]", msg_type);
                return MSG_ERR_INVALID_PARAMETER;
        }
 
-       if (folder_id >= MSG_MAX_FOLDER_ID)
-       {
+       if (folder_id >= MSG_MAX_FOLDER_ID) {
                MSG_DEBUG("folderId is invalid [%d]", folder_id);
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -961,7 +780,7 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_
 
        char strMsg[20] = {0};
        char prefix[10] ="0103001";
-//     int postfix = 8111;
+/*     int postfix = 8111; */
        int postfix = 0;
 
        srand(getpid());
@@ -971,8 +790,7 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_
        MSG_MESSAGE_HIDDEN_S *msgInfo = NULL;
        MSG_ADDRESS_INFO_S *addrInfo = NULL;
 
-       for (unsigned int i = 0; i < num_msg; i++)
-       {
+       for (unsigned int i = 0; i < num_msg; i++) {
                msg_s = (msg_struct_s *)msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
                if (msg_s == NULL)
                        return MSG_ERR_NOT_SUPPORTED;
@@ -981,13 +799,10 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_
 
                msgInfo->folderId = folder_id;
 
-               if (msg_type == MSG_TYPE_MMS)
-               {
+               if (msg_type == MSG_TYPE_MMS) {
                        msgInfo->mainType = MSG_MMS_TYPE;
                        msgInfo->subType = MSG_SENDREQ_MMS;
-               }
-               else
-               {
+               } else {
                        msgInfo->mainType = MSG_SMS_TYPE;
                        msgInfo->subType = MSG_NORMAL_SMS;
 
@@ -1024,60 +839,59 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_
                else
                        msgInfo->direction = MSG_DIRECTION_TYPE_MT;
 
-               if (msg_type == MSG_TYPE_MMS)
-               {
+               if (msg_type == MSG_TYPE_MMS) {
                        snprintf(msgInfo->subject, MAX_SUBJECT_LEN+1, "subject %d", i);
 
-                       if(folder_id == MSG_INBOX_ID) msgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS;
+                       if (folder_id == MSG_INBOX_ID)
+                               msgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS;
 
                        msg_struct_t mms_data = msg_create_struct(MSG_STRUCT_MMS);
 
                        msg_set_mms_struct((msg_struct_t)msg_s, mms_data);
 
                        msg_release_struct(&mms_data);
-                       //MMS_MESSAGE_DATA_S* mms_data;
-                       //MMS_PAGE_S* page[2];
-                       //MMS_MEDIA_S* media[5];
-
-//                     mms_data = msg_mms_create_message();
-
-//                     msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
-//                     msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
-//                     msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
-
-                       //------------>  1st Slide Composing
-//                     page[0] = msg_mms_add_page(mms_data, 5440);
-
-//                     media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
-//                     media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
-//                     media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
-//                     media[2]->sMedia.sText.nColor = 0x000000;
-//                     media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
-//                     media[2]->sMedia.sText.bBold = true;
-
-                       //------------>  2nd Slide Composing
-//                     page[1] = msg_mms_add_page(mms_data, 4544);
-
-//                     media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
-//                     media[3]->sMedia.sText.nColor = 0x000000;
-//                     media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
-//                     media[3]->sMedia.sText.bItalic = true;
-//                     media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
-//                     strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
-
-                       //FIXME msg_mms_set_message_body((msg_message_t)&msgInfo, mms_data);
-
-//                     msg_mms_destroy_message(mms_data);
+/*
+*                      MMS_MESSAGE_DATA_S* mms_data;
+*                      MMS_PAGE_S* page[2];
+*                      MMS_MEDIA_S* media[5];
+*
+*                      mms_data = msg_mms_create_message();
+*
+*                      msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
+*                      msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
+*                      msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
+*
+*                      ------------>  1st Slide Composing
+*                      page[0] = msg_mms_add_page(mms_data, 5440);
+*
+*                      media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
+*                      media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
+*                      media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
+*                      media[2]->sMedia.sText.nColor = 0x000000;
+*                      media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+*                      media[2]->sMedia.sText.bBold = true;
+*
+*                      ------------>  2nd Slide Composing
+*                      page[1] = msg_mms_add_page(mms_data, 4544);
+*
+*                      media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
+*                      media[3]->sMedia.sText.nColor = 0x000000;
+*                      media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
+*                      media[3]->sMedia.sText.bItalic = true;
+*                      media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
+*                      strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
+*
+*                      //FIXME msg_mms_set_message_body((msg_message_t)&msgInfo, mms_data);
+*
+*                      msg_mms_destroy_message(mms_data);
+*/
                }
 
-               //err = msg_add_message(handle, (msg_message_t)&msgInfo, &sendingOpt);
-               try
-               {
+               /*err = msg_add_message(handle, (msg_message_t)&msgInfo, &sendingOpt);*/
+               try {
                        MsgHandle* pHandle = (MsgHandle*)handle;
                        err = pHandle->addMessage(msgInfo, &sendingOpt);
-               }
-               catch (MsgException& e)
-               {
+               } catch (MsgException& e) {
                        MSG_FATAL("%s", e.what());
                        msg_release_struct((msg_struct_t *)&msg_s);
                        return MSG_ERR_STORAGE_ERROR;
@@ -1085,8 +899,7 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_
 
                msg_release_struct((msg_struct_t *)&msg_s);
 
-               if (err < 0)
-               {
+               if (err < 0) {
                        MSG_DEBUG("err [%d]", err);
                        return err;
                }
@@ -1101,16 +914,13 @@ EXPORT_API int msg_get_quick_panel_data(msg_handle_t handle, msg_quickpanel_type
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL || opq_msg == NULL )
-       {
+       if (handle == NULL || opq_msg == NULL ) {
                MSG_FATAL("handle or opq_msg is NULL");
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -1124,12 +934,9 @@ EXPORT_API int msg_get_quick_panel_data(msg_handle_t handle, msg_quickpanel_type
        msg_struct_s *pMsg = (msg_struct_s *)opq_msg;
        MSG_TYPE_CHECK(pMsg->type, MSG_STRUCT_MESSAGE_INFO);
 
-       try
-       {
+       try {
                err = pHandle->getQuickPanelData(type, (MSG_MESSAGE_HIDDEN_S *)pMsg->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1143,27 +950,20 @@ EXPORT_API int msg_reset_database(msg_handle_t handle)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->resetDatabase();
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1177,27 +977,20 @@ EXPORT_API int msg_get_mem_size(msg_handle_t handle, unsigned int* memsize)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || memsize == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getMemSize(memsize);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1211,27 +1004,20 @@ EXPORT_API int msg_backup_message(msg_handle_t handle, msg_message_backup_type_t
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || backup_filepath == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->backupMessage(type, backup_filepath);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1245,27 +1031,20 @@ EXPORT_API int msg_restore_message(msg_handle_t handle, const char *backup_filep
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || backup_filepath == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->restoreMessage(backup_filepath);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1279,32 +1058,23 @@ EXPORT_API int msg_search_message_for_thread_view(msg_handle_t handle, const cha
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || search_string == NULL || msg_thread_view_list == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        if (strlen(search_string) <= 0 || strlen(search_string) > MAX_MSG_TEXT_LEN)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->searchMessage(search_string, msg_thread_view_list);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1317,27 +1087,20 @@ EXPORT_API int msg_get_reject_msg_list(msg_handle_t handle, const char *phone_nu
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_reject_msg_list == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getRejectMsgList(phone_num, msg_reject_msg_list);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1351,27 +1114,20 @@ EXPORT_API int msg_reg_storage_change_callback(msg_handle_t handle, msg_storage_
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || cb == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->regStorageChangeCallback(cb, user_param);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                if (e.errorCode() == MsgException::SERVER_READY_ERROR)
                        return MSG_ERR_PERMISSION_DENIED;
@@ -1387,27 +1143,20 @@ EXPORT_API int msg_get_report_status(msg_handle_t handle, msg_message_id_t msg_i
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_id < 1 || report_list == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getReportStatus(msg_id, report_list);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1420,27 +1169,20 @@ EXPORT_API int msg_get_address_list(msg_handle_t handle, msg_thread_id_t thread_
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_address_list == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getAddressList(thread_id, msg_address_list);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1454,30 +1196,24 @@ EXPORT_API int msg_get_thread_id_by_address(msg_handle_t handle, msg_struct_list
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_address_list == NULL || thread_id == NULL) {
                return MSG_ERR_INVALID_PARAMETER;
        }
 
-       if (msg_address_list->nCount < 1 ) {
+       if (msg_address_list->nCount < 1 )
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getThreadIdByAddress(msg_address_list, thread_id);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1491,27 +1227,20 @@ EXPORT_API int msg_get_thread_id_by_address2(msg_handle_t handle, msg_list_handl
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_address_list == NULL || thread_id == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getThreadIdByAddress(msg_address_list, thread_id);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1525,13 +1254,11 @@ EXPORT_API int msg_get_thread(msg_handle_t handle, msg_thread_id_t thread_id, ms
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msg_thread == NULL ) {
                MSG_FATAL("handle or msg_thread is NULL");
@@ -1544,12 +1271,9 @@ EXPORT_API int msg_get_thread(msg_handle_t handle, msg_thread_id_t thread_id, ms
 
        MSG_THREAD_VIEW_S* pThreadInfo = (MSG_THREAD_VIEW_S *)msgThread->data;
 
-       try
-       {
+       try {
                err = pHandle->getThread(thread_id, pThreadInfo);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1562,28 +1286,22 @@ EXPORT_API int msg_get_message_list2(msg_handle_t handle, const msg_struct_t msg
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL || msg_list_conditions == NULL || msg_list == NULL) {
+       if (handle == NULL || msg_list_conditions == NULL || msg_list == NULL)
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
        msg_struct_s *pStruct = (msg_struct_s *)msg_list_conditions;
        MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_MSG_LIST_CONDITION);
 
-       try
-       {
+       try {
                err = pHandle->getMessageList((MSG_LIST_CONDITION_S *)pStruct->data, msg_list);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1596,26 +1314,20 @@ EXPORT_API int msg_get_media_list(msg_handle_t handle, msg_thread_id_t thread_id
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL || msg_list == NULL) {
+       if (handle == NULL || msg_list == NULL)
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->getMediaList(thread_id, msg_list);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -1626,54 +1338,53 @@ EXPORT_API int msg_get_media_list(msg_handle_t handle, msg_thread_id_t thread_id
 
 static int msg_get_msg_type(int mainType, int subType)
 {
-       if (mainType == MSG_SMS_TYPE)
-       {
+       if (mainType == MSG_SMS_TYPE) {
                switch (subType) {
-                       case MSG_CB_SMS :
-                               return MSG_TYPE_SMS_CB;
-                       case MSG_JAVACB_SMS :
-                               return MSG_TYPE_SMS_JAVACB;
-                       case MSG_WAP_SI_SMS :
-                       case MSG_WAP_SL_SMS :
-                               return MSG_TYPE_SMS_WAPPUSH;
-                       case MSG_MWI_VOICE_SMS :
-                       case MSG_MWI_FAX_SMS :
-                       case MSG_MWI_EMAIL_SMS :
-                       case MSG_MWI_OTHER_SMS :
-                               return MSG_TYPE_SMS_MWI;
-                       case MSG_SYNCML_CP :
-                               return MSG_TYPE_SMS_SYNCML;
-                       case MSG_REJECT_SMS :
-                               return MSG_TYPE_SMS_REJECT;
-                       case MSG_ETWS_SMS :
-                               return MSG_TYPE_SMS_ETWS_PRIMARY;
-                       case MSG_CMAS_PRESIDENTIAL :
-                               return MSG_TYPE_SMS_CMAS_PRESIDENTIAL;
-                       case MSG_CMAS_EXTREME :
-                               return MSG_TYPE_SMS_CMAS_EXTREME;
-                       case MSG_CMAS_SEVERE :
-                               return MSG_TYPE_SMS_CMAS_SEVERE;
-                       case MSG_CMAS_AMBER :
-                               return MSG_TYPE_SMS_CMAS_AMBER;
-                       case MSG_CMAS_TEST :
-                               return MSG_TYPE_SMS_CMAS_TEST;
-                       case MSG_CMAS_OPERATOR_DEFINED :
-                               return MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED;
-                       default :
-                               return MSG_TYPE_SMS;
+               case MSG_CB_SMS :
+                       return MSG_TYPE_SMS_CB;
+               case MSG_JAVACB_SMS :
+                       return MSG_TYPE_SMS_JAVACB;
+               case MSG_WAP_SI_SMS :
+               case MSG_WAP_SL_SMS :
+                       return MSG_TYPE_SMS_WAPPUSH;
+               case MSG_MWI_VOICE_SMS :
+               case MSG_MWI_FAX_SMS :
+               case MSG_MWI_EMAIL_SMS :
+               case MSG_MWI_OTHER_SMS :
+                       return MSG_TYPE_SMS_MWI;
+               case MSG_SYNCML_CP :
+                       return MSG_TYPE_SMS_SYNCML;
+               case MSG_REJECT_SMS :
+                       return MSG_TYPE_SMS_REJECT;
+               case MSG_ETWS_SMS :
+                       return MSG_TYPE_SMS_ETWS_PRIMARY;
+               case MSG_CMAS_PRESIDENTIAL :
+                       return MSG_TYPE_SMS_CMAS_PRESIDENTIAL;
+               case MSG_CMAS_EXTREME :
+                       return MSG_TYPE_SMS_CMAS_EXTREME;
+               case MSG_CMAS_SEVERE :
+                       return MSG_TYPE_SMS_CMAS_SEVERE;
+               case MSG_CMAS_AMBER :
+                       return MSG_TYPE_SMS_CMAS_AMBER;
+               case MSG_CMAS_TEST :
+                       return MSG_TYPE_SMS_CMAS_TEST;
+               case MSG_CMAS_EXERCISE :
+                       return MSG_TYPE_SMS_CMAS_EXERCISE;
+               case MSG_CMAS_OPERATOR_DEFINED :
+                       return MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED;
+               default :
+                       return MSG_TYPE_SMS;
                }
-       }
-       else if (mainType == MSG_MMS_TYPE)
-       {
+       } else if (mainType == MSG_MMS_TYPE) {
                if (subType == MSG_NOTIFICATIONIND_MMS)
                        return MSG_TYPE_MMS_NOTI;
                else if (subType == MSG_SENDREQ_JAVA_MMS)
                        return MSG_TYPE_MMS_JAVA;
                else
                        return MSG_TYPE_MMS;
-       }
-       else
+       } else {
                return MSG_TYPE_INVALID;
+       }
 }
 
 
@@ -1686,8 +1397,7 @@ int msg_syncml_info_get_int(void *syncml_info, int field, int *value)
 
        MSG_SYNCML_MESSAGE_S *pSync = (MSG_SYNCML_MESSAGE_S *)syncml_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_SYNCML_INFO_EXTID_INT:
                *value = pSync->extId;
                break;
@@ -1711,8 +1421,7 @@ int msg_count_info_get_int(void *count_info, int field, int *value)
 
        MSG_COUNT_INFO_S *pCount = (MSG_COUNT_INFO_S *)count_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_COUNT_INFO_READ_INT:
                *value = pCount->nReadCnt;
                break;
@@ -1742,8 +1451,7 @@ int msg_thread_count_get_int(void *count_info, int field, int *value)
 
        MSG_THREAD_COUNT_INFO_S *pCount = (MSG_THREAD_COUNT_INFO_S *)count_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_THREAD_COUNT_TOTAL_INT:
                *value = pCount->totalCount;
                break;
@@ -1772,8 +1480,7 @@ int msg_thread_index_get_int(void *index_info, int field, int *value)
        int ret = MSG_SUCCESS;
 
        MSG_THREAD_LIST_INDEX_S *pIndex = (MSG_THREAD_LIST_INDEX_S *)index_info;
-       switch(field)
-       {
+       switch (field) {
        case MSG_THREAD_LIST_INDEX_CONTACTID_INT:
                *value = pIndex->contactId;
                break;
@@ -1794,8 +1501,7 @@ int msg_sortrule_get_int(void *sort_info, int field, int *value)
 
        MSG_SORT_RULE_S *pSort = (MSG_SORT_RULE_S *)sort_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_SORT_RULE_SORT_TYPE_INT:
                *value = pSort->sortType;
                break;
@@ -1816,8 +1522,7 @@ int msg_folder_info_get_int(void *folder_info, int field, int *value)
 
        MSG_FOLDER_INFO_S *pFolder = (MSG_FOLDER_INFO_S *)folder_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_FOLDER_INFO_ID_INT:
                *value = pFolder->folderId;
                break;
@@ -1841,8 +1546,7 @@ int msg_thread_info_get_int(void *data, int field, int *value)
 
        MSG_THREAD_VIEW_S *pThread = (MSG_THREAD_VIEW_S *)data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_THREAD_ID_INT :
                *value = pThread->threadId;
                break;
@@ -1882,8 +1586,7 @@ int msg_conv_info_get_int(void *data, int field, int *value)
 
        MSG_CONVERSATION_VIEW_S *pConv = (MSG_CONVERSATION_VIEW_S *)data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_CONV_MSG_ID_INT :
                *value = pConv->msgId;
                break;
@@ -1944,8 +1647,7 @@ int msg_list_condition_get_int(void *condition_info, int field, int *value)
 
        MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)condition_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_LIST_CONDITION_FOLDER_ID_INT:
                *value = pCond->folderId;
                break;
@@ -1990,8 +1692,7 @@ int msg_report_status_get_int(void *report_info, int field, int *value)
        int ret = MSG_SUCCESS;
 
        MSG_REPORT_STATUS_INFO_S *pReport = (MSG_REPORT_STATUS_INFO_S *)report_info;
-       switch(field)
-       {
+       switch (field) {
        case MSG_REPORT_TYPE_INT:
                *value = pReport->type;
                break;
@@ -2001,7 +1702,6 @@ int msg_report_status_get_int(void *report_info, int field, int *value)
        case MSG_REPORT_TIME_INT:
                *value = pReport->statusTime;
                break;
-
        default:
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
@@ -2012,9 +1712,12 @@ int msg_report_status_get_int(void *report_info, int field, int *value)
 
 int msg_report_status_get_str(void *report_info, int field, char *value, int size)
 {
+       if (!report_info)
+               return MSG_ERR_NULL_POINTER;
+
        MSG_REPORT_STATUS_INFO_S *pReport = (MSG_REPORT_STATUS_INFO_S *)report_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_REPORT_ADDRESS_STR:
                strncpy(value, pReport->addressVal, size);
                break;
@@ -2026,24 +1729,30 @@ int msg_report_status_get_str(void *report_info, int field, char *value, int siz
 
 int msg_folder_info_get_str(void *folder_info, int field, char *value, int size)
 {
+       if (!folder_info)
+               return MSG_ERR_NULL_POINTER;
+
        MSG_FOLDER_INFO_S *pFolder = (MSG_FOLDER_INFO_S *)folder_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_FOLDER_INFO_NAME_STR:
                strncpy(value, pFolder->folderName, size);
                break;
        default:
                return MSG_ERR_INVALID_PARAMETER;
        }
+
        return MSG_SUCCESS;
 }
 
 int msg_thread_info_get_str(void *data, int field, char *value, int size)
 {
+       if (!data)
+               return MSG_ERR_NULL_POINTER;
+
        MSG_THREAD_VIEW_S *pThread = (MSG_THREAD_VIEW_S *)data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_THREAD_NAME_STR :
                strncpy(value, pThread->threadName, size);
                break;
@@ -2060,10 +1769,12 @@ int msg_thread_info_get_str(void *data, int field, char *value, int size)
 
 int msg_conv_info_get_str(void *data, int field, char *value, int size)
 {
+       if (!data)
+               return MSG_ERR_NULL_POINTER;
+
        MSG_CONVERSATION_VIEW_S *pConv = (MSG_CONVERSATION_VIEW_S *)data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_CONV_MSG_SUBJECT_STR :
                strncpy(value, pConv->subject, size);
                break;
@@ -2096,9 +1807,12 @@ int msg_conv_info_get_str(void *data, int field, char *value, int size)
 
 int msg_list_condition_get_str(void *condition_info, int field, char *value, int size)
 {
+       if (!condition_info)
+               return MSG_ERR_NULL_POINTER;
+
        MSG_LIST_CONDITION_S *cond = (MSG_LIST_CONDITION_S *)condition_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_LIST_CONDITION_ADDRESS_VALUE_STR:
                if (cond->pAddressVal)
                        strncpy(value, cond->pAddressVal, size);
@@ -2123,8 +1837,8 @@ int msg_sendopt_get_bool(void *send_opt, int field, bool *value)
        int ret = MSG_SUCCESS;
 
        MSG_SENDINGOPT_S *sendopt = (MSG_SENDINGOPT_S *)send_opt;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_SEND_OPT_SETTING_BOOL:
                *value = sendopt->bSetting;
                break;
@@ -2138,6 +1852,7 @@ int msg_sendopt_get_bool(void *send_opt, int field, bool *value)
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
        }
+
        return ret;
 }
 
@@ -2149,8 +1864,8 @@ int msg_sortrule_get_bool(void *sort_rule, int field, bool *value)
        int ret = MSG_SUCCESS;
 
        MSG_SORT_RULE_S *pSort = (MSG_SORT_RULE_S *)sort_rule;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_SORT_RULE_ACSCEND_BOOL:
                *value = pSort->bAscending;
                break;
@@ -2158,6 +1873,7 @@ int msg_sortrule_get_bool(void *sort_rule, int field, bool *value)
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
        }
+
        return ret;
 }
 
@@ -2170,8 +1886,7 @@ int msg_conv_get_bool(void *data, int field, bool *value)
 
        MSG_CONVERSATION_VIEW_S *pConv = (MSG_CONVERSATION_VIEW_S *)data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_CONV_MSG_READ_BOOL:
                *value = pConv->bRead;
                break;
@@ -2182,6 +1897,7 @@ int msg_conv_get_bool(void *data, int field, bool *value)
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
        }
+
        return ret;
 }
 
@@ -2194,8 +1910,7 @@ int msg_thread_info_get_bool(void *data, int field, bool *value)
 
        MSG_THREAD_VIEW_S *pthreadInfo = (MSG_THREAD_VIEW_S *)data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_THREAD_PROTECTED_BOOL:
                *value = pthreadInfo->bProtected;
                break;
@@ -2212,6 +1927,7 @@ int msg_thread_info_get_bool(void *data, int field, bool *value)
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
        }
+
        return ret;
 }
 
@@ -2225,8 +1941,7 @@ int msg_list_condition_get_bool(void *data, int field, bool *value)
 
        MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_LIST_CONDITION_PROTECTED_BOOL:
                *value = pCond->bProtected;
                break;
@@ -2240,6 +1955,7 @@ int msg_list_condition_get_bool(void *data, int field, bool *value)
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
        }
+
        return ret;
 }
 
@@ -2247,13 +1963,13 @@ int msg_list_condition_get_bool(void *data, int field, bool *value)
 int msg_sendopt_get_struct_handle(msg_struct_s *msg_struct, int field, void **value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!msg_struct || !value)
+
+       if (!msg_struct || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_SENDINGOPT_S *sendopt = (MSG_SENDINGOPT_S *)msg_struct->data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_SEND_OPT_MMS_OPT_HND:
                *value = (void *)sendopt->mmsSendOpt;
                break;
@@ -2264,6 +1980,7 @@ int msg_sendopt_get_struct_handle(msg_struct_s *msg_struct, int field, void **va
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
@@ -2271,13 +1988,12 @@ int msg_syncml_get_struct_handle(msg_struct_s *msg_struct, int field, void **val
 {
        msg_error_t err = MSG_SUCCESS;
 
-       if(!msg_struct || !value)
+       if (!msg_struct || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_SYNCML_MESSAGE_S *pSync = (MSG_SYNCML_MESSAGE_S *)msg_struct->data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_SYNCML_INFO_MESSAGE_HND:
                *value = (void *)pSync->msg;
                break;
@@ -2285,6 +2001,7 @@ int msg_syncml_get_struct_handle(msg_struct_s *msg_struct, int field, void **val
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
@@ -2292,21 +2009,20 @@ int msg_thread_index_get_struct_handle(msg_struct_s *msg_struct, int field, void
 {
        msg_error_t err = MSG_SUCCESS;
 
-       if(!msg_struct || !value)
+       if (!msg_struct || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_THREAD_LIST_INDEX_INFO_S *pIndex = (MSG_THREAD_LIST_INDEX_INFO_S *)msg_struct->data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_THREAD_LIST_INDEX_ADDR_INFO_HND:
                *value = (void *)pIndex->msgAddrInfo;
                break;
        default:
                err = MSG_ERR_UNKNOWN;
                break;
-
        }
+
        return err;
 }
 
@@ -2315,21 +2031,20 @@ int msg_list_condition_get_struct_handle(msg_struct_s *msg_struct, int field, vo
 {
        msg_error_t err = MSG_SUCCESS;
 
-       if(!msg_struct || !value)
+       if (!msg_struct || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)msg_struct->data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_LIST_CONDITION_SORT_RULE_HND:
                *value = (void *)pCond->sortRule;
                break;
        default:
                err = MSG_ERR_UNKNOWN;
                break;
-
        }
+
        return err;
 }
 
@@ -2343,8 +2058,7 @@ int msg_address_info_get_int(void *addr_info, int field, int *value)
 
        MSG_ADDRESS_INFO_S *pAddr = (MSG_ADDRESS_INFO_S *)addr_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_ADDRESS_INFO_ADDRESS_TYPE_INT:
                *value = pAddr->addressType;
                break;
@@ -2371,8 +2085,7 @@ int msg_mms_sendopt_get_int(void *opt_info, int field, int *value)
 
        MMS_SENDINGOPT_S *pOpt = (MMS_SENDINGOPT_S *)opt_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_MMS_SENDOPTION_EXPIRY_TIME_INT:
                *value = pOpt->expiryTime;
                break;
@@ -2386,6 +2099,7 @@ int msg_mms_sendopt_get_int(void *opt_info, int field, int *value)
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
        }
+
        return ret;
 }
 
@@ -2398,8 +2112,7 @@ int msg_reject_message_get_int(void *msg_info, int field, int *value)
 
        MSG_REJECT_MSG_INFO_S *pMsg = (MSG_REJECT_MSG_INFO_S *)msg_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_REJECT_MESSAGE_MSGID_INT:
                *value = pMsg->msgId;
                break;
@@ -2410,21 +2123,24 @@ int msg_reject_message_get_int(void *msg_info, int field, int *value)
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
        }
+
        return ret;
 }
 
 int msg_address_info_get_str(void *addr_info, int field, char *value, int size)
 {
+       if (!addr_info)
+               return MSG_ERR_NULL_POINTER;
+
        MSG_ADDRESS_INFO_S *pAddr = (MSG_ADDRESS_INFO_S *)addr_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_ADDRESS_INFO_ADDRESS_VALUE_STR:
                strncpy(value, pAddr->addressVal, size);
                break;
        case MSG_ADDRESS_INFO_DISPLAYNAME_STR:
                strncpy(value, pAddr->displayName, size);
                break;
-
        default:
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -2434,9 +2150,12 @@ int msg_address_info_get_str(void *addr_info, int field, char *value, int size)
 
 int msg_reject_message_get_str(void *msg_info, int field, char *value, int size)
 {
+       if (!msg_info)
+               return MSG_ERR_NULL_POINTER;
+
        MSG_REJECT_MSG_INFO_S *pMsg = (MSG_REJECT_MSG_INFO_S *)msg_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_REJECT_MESSAGE_MSGTEXT_STR:
                strncpy(value, pMsg->msgText, size);
                break;
@@ -2456,8 +2175,7 @@ int msg_mms_sendopt_get_bool(void *opt_info, int field, bool *value)
 
        MMS_SENDINGOPT_S *pOpt = (MMS_SENDINGOPT_S *)opt_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_MMS_SENDOPTION_READ_REQUEST_BOOL:
                *value = pOpt->bReadReq;
                break;
@@ -2468,6 +2186,7 @@ int msg_mms_sendopt_get_bool(void *opt_info, int field, bool *value)
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
        }
+
        return ret;
 }
 
@@ -2479,8 +2198,8 @@ int msg_sms_sendopt_get_bool(void *opt_info, int field, bool *value)
        int ret = MSG_SUCCESS;
 
        SMS_SENDINGOPT_S *pOpt = (SMS_SENDINGOPT_S *)opt_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_SMS_SENDOPT_REPLYPATH_BOOL:
                *value = pOpt->bReplyPath;
                break;
@@ -2488,6 +2207,7 @@ int msg_sms_sendopt_get_bool(void *opt_info, int field, bool *value)
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
        }
+
        return ret;
 }
 
@@ -2495,12 +2215,13 @@ int msg_syncml_info_set_int(void *syncml_info, int field, int value)
 {
 
        msg_error_t err = MSG_SUCCESS;
-       if(!syncml_info)
+
+       if (!syncml_info)
                return MSG_ERR_NULL_POINTER;
 
        MSG_SYNCML_MESSAGE_S *pSync = (MSG_SYNCML_MESSAGE_S *)syncml_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_SYNCML_INFO_EXTID_INT:
                pSync->extId = value;
                break;
@@ -2518,13 +2239,13 @@ int msg_syncml_info_set_int(void *syncml_info, int field, int value)
 int msg_count_info_set_int(void *count_info, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!count_info)
+
+       if (!count_info)
                return MSG_ERR_NULL_POINTER;
 
        MSG_COUNT_INFO_S *pCount = (MSG_COUNT_INFO_S *)count_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_COUNT_INFO_READ_INT:
                pCount->nReadCnt = value;
                break;
@@ -2541,18 +2262,20 @@ int msg_count_info_set_int(void *count_info, int field, int value)
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
 int msg_thread_count_set_int(void *count_info, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!count_info)
+
+       if (!count_info)
                return MSG_ERR_NULL_POINTER;
 
        MSG_THREAD_COUNT_INFO_S *pCount = (MSG_THREAD_COUNT_INFO_S *)count_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_THREAD_COUNT_TOTAL_INT:
                pCount->totalCount = value;
                break;
@@ -2569,18 +2292,20 @@ int msg_thread_count_set_int(void *count_info, int field, int value)
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
 int msg_thread_index_set_int(void *index_info, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!index_info)
+
+       if (!index_info)
                return MSG_ERR_NULL_POINTER;
 
        MSG_THREAD_LIST_INDEX_S *pIndex = (MSG_THREAD_LIST_INDEX_S *)index_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_THREAD_LIST_INDEX_CONTACTID_INT:
                pIndex->contactId = value;
                break;
@@ -2596,12 +2321,12 @@ int msg_sortrule_set_int(void *sort_info, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
 
-       if(!sort_info)
+       if (!sort_info)
                return MSG_ERR_NULL_POINTER;
 
        MSG_SORT_RULE_S *pSort = (MSG_SORT_RULE_S *)sort_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_SORT_RULE_SORT_TYPE_INT:
                pSort->sortType = value;
                break;
@@ -2609,18 +2334,20 @@ int msg_sortrule_set_int(void *sort_info, int field, int value)
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
 int msg_folder_info_set_int(void *folder_info, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!folder_info)
+
+       if (!folder_info)
                return MSG_ERR_NULL_POINTER;
 
        MSG_FOLDER_INFO_S *pFolder = (MSG_FOLDER_INFO_S *)folder_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_FOLDER_INFO_ID_INT:
                pFolder->folderId = value;
                break;
@@ -2639,12 +2366,13 @@ int msg_folder_info_set_int(void *folder_info, int field, int value)
 int msg_list_condition_set_int(void *condition_info, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!condition_info)
+
+       if (!condition_info)
                return MSG_ERR_NULL_POINTER;
 
        MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)condition_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_LIST_CONDITION_FOLDER_ID_INT:
                pCond->folderId = value;
                break;
@@ -2684,12 +2412,13 @@ int msg_list_condition_set_int(void *condition_info, int field, int value)
 int msg_report_status_set_int(void *report_info, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!report_info)
+
+       if (!report_info)
        return MSG_ERR_NULL_POINTER;
 
        MSG_REPORT_STATUS_INFO_S *pReport = (MSG_REPORT_STATUS_INFO_S *)report_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_REPORT_TYPE_INT:
                pReport->type = value;
                break;
@@ -2703,19 +2432,23 @@ int msg_report_status_set_int(void *report_info, int field, int value)
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
 int msg_folder_info_set_str(void *folder_info, int field, char *value, int size)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!folder_info || !value)
+
+       if (!folder_info || !value)
                return MSG_ERR_NULL_POINTER;
+
        MSG_FOLDER_INFO_S *pFolder = (MSG_FOLDER_INFO_S *)folder_info;
+
        int _len = 0;
        (size > MAX_FOLDER_NAME_SIZE)? _len = MAX_FOLDER_NAME_SIZE : _len = size;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_FOLDER_INFO_NAME_STR:
                strncpy(pFolder->folderName, value, _len);
                break;
@@ -2731,25 +2464,26 @@ int msg_folder_info_set_str(void *folder_info, int field, char *value, int size)
 int msg_list_condition_set_str(void *condition_info, int field, char *value, int size)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!condition_info || !value)
+
+       if (!condition_info || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_LIST_CONDITION_S *cond = (MSG_LIST_CONDITION_S *)condition_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_LIST_CONDITION_ADDRESS_VALUE_STR:
-               if(size)
+               if (size)
                        cond->pAddressVal = value;
                break;
        case MSG_LIST_CONDITION_TEXT_VALUE_STR:
-               if(size)
+               if (size)
                        cond->pTextVal = value;
                break;
        default:
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
@@ -2757,12 +2491,13 @@ int msg_list_condition_set_str(void *condition_info, int field, char *value, int
 int msg_sendopt_set_bool(void *send_opt, int field, bool value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!send_opt)
+
+       if (!send_opt)
                return MSG_ERR_NULL_POINTER;
 
        MSG_SENDINGOPT_S *sendopt = (MSG_SENDINGOPT_S *)send_opt;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_SEND_OPT_SETTING_BOOL:
                sendopt->bSetting = value;
                break;
@@ -2776,18 +2511,20 @@ int msg_sendopt_set_bool(void *send_opt, int field, bool value)
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
 int msg_sortrule_set_bool(void *sort_rule, int field, bool value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!sort_rule)
+
+       if (!sort_rule)
                return MSG_ERR_NULL_POINTER;
 
        MSG_SORT_RULE_S *pSort = (MSG_SORT_RULE_S *)sort_rule;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_SORT_RULE_ACSCEND_BOOL:
                pSort->bAscending = value;
                break;
@@ -2795,6 +2532,7 @@ int msg_sortrule_set_bool(void *sort_rule, int field, bool value)
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
@@ -2802,12 +2540,13 @@ int msg_sortrule_set_bool(void *sort_rule, int field, bool value)
 int msg_list_condition_set_bool(void *data, int field, bool value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!data)
+
+       if (!data)
                return MSG_ERR_NULL_POINTER;
 
        MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)data;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_LIST_CONDITION_PROTECTED_BOOL:
                pCond->bProtected = value;
                break;
@@ -2821,6 +2560,7 @@ int msg_list_condition_set_bool(void *data, int field, bool value)
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
@@ -2828,14 +2568,14 @@ int msg_list_condition_set_bool(void *data, int field, bool value)
 int msg_sendopt_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!msg_struct || !value)
+
+       if (!msg_struct || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_SENDINGOPT_S *sendopt = (MSG_SENDINGOPT_S *)msg_struct->data;
        msg_struct_s *pTmp = NULL;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_SEND_OPT_MMS_OPT_HND:
                pTmp = (msg_struct_s *)sendopt->mmsSendOpt;
                memcpy(pTmp->data, value->data, sizeof(MMS_SENDINGOPT_INFO_S));
@@ -2848,6 +2588,7 @@ int msg_sendopt_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struc
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
@@ -2855,14 +2596,13 @@ int msg_syncml_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct
 {
        msg_error_t err = MSG_SUCCESS;
 
-       if(!msg_struct || !value)
+       if (!msg_struct || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_SYNCML_MESSAGE_S *pSync = (MSG_SYNCML_MESSAGE_S *)msg_struct->data;
        msg_struct_s *pTmp = NULL;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_SYNCML_INFO_MESSAGE_HND:
        {
                pTmp = (msg_struct_s *)pSync->msg;
@@ -2875,6 +2615,7 @@ int msg_syncml_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
@@ -2882,14 +2623,13 @@ int msg_thread_index_set_struct_handle(msg_struct_s *msg_struct, int field, msg_
 {
        msg_error_t err = MSG_SUCCESS;
 
-       if(!msg_struct || !value)
+       if (!msg_struct || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_THREAD_LIST_INDEX_INFO_S *pIndex = (MSG_THREAD_LIST_INDEX_INFO_S *)msg_struct->data;
        msg_struct_s *pTmp = NULL;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_THREAD_LIST_INDEX_ADDR_INFO_HND:
                pTmp = (msg_struct_s *)pIndex->msgAddrInfo;
                memcpy(pTmp->data, value->data, sizeof(MSG_ADDRESS_INFO_S));
@@ -2898,6 +2638,7 @@ int msg_thread_index_set_struct_handle(msg_struct_s *msg_struct, int field, msg_
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
@@ -2906,14 +2647,13 @@ int msg_list_condition_set_struct_handle(msg_struct_s *msg_struct, int field, ms
 {
        msg_error_t err = MSG_SUCCESS;
 
-       if(!msg_struct || !value)
+       if (!msg_struct || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_LIST_CONDITION_S *pCond = (MSG_LIST_CONDITION_S *)msg_struct->data;
        msg_struct_s *pTmp = NULL;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_LIST_CONDITION_SORT_RULE_HND:
                pTmp = (msg_struct_s *)pCond->sortRule;
                memcpy(pTmp->data, value->data, sizeof(MSG_SORT_RULE_S));
@@ -2922,6 +2662,7 @@ int msg_list_condition_set_struct_handle(msg_struct_s *msg_struct, int field, ms
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
@@ -2929,12 +2670,13 @@ int msg_list_condition_set_struct_handle(msg_struct_s *msg_struct, int field, ms
 int msg_address_info_set_int(void *addrinfo, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!addrinfo)
+
+       if (!addrinfo)
                return MSG_ERR_NULL_POINTER;
 
        MSG_ADDRESS_INFO_S *pAddr = (MSG_ADDRESS_INFO_S *)addrinfo;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_ADDRESS_INFO_ADDRESS_TYPE_INT:
                pAddr->addressType = value;
                break;
@@ -2956,12 +2698,13 @@ int msg_address_info_set_int(void *addrinfo, int field, int value)
 int msg_mms_sendopt_set_int(void *opt_info, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!opt_info)
+
+       if (!opt_info)
                return MSG_ERR_NULL_POINTER;
 
        MMS_SENDINGOPT_S *pOpt = (MMS_SENDINGOPT_S *)opt_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_MMS_SENDOPTION_EXPIRY_TIME_INT:
                pOpt->expiryTime = value;
                break;
@@ -2982,12 +2725,13 @@ int msg_mms_sendopt_set_int(void *opt_info, int field, int value)
 int msg_reject_message_set_int(void *msg_info, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!msg_info)
+
+       if (!msg_info)
                return MSG_ERR_NULL_POINTER;
 
        MSG_REJECT_MSG_INFO_S *pMsg = (MSG_REJECT_MSG_INFO_S *)msg_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_REJECT_MESSAGE_MSGID_INT:
                pMsg->msgId = value;
                break;
@@ -3005,14 +2749,14 @@ int msg_reject_message_set_int(void *msg_info, int field, int value)
 int msg_address_info_set_str(void *addr_info, int field, char *value, int size)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!addr_info || !value)
+
+       if (!addr_info || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_ADDRESS_INFO_S *pAddr = (MSG_ADDRESS_INFO_S *)addr_info;
        int _len = 0;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_ADDRESS_INFO_ADDRESS_VALUE_STR:
                (size > MAX_ADDRESS_VAL_LEN)? _len = MAX_ADDRESS_VAL_LEN : _len = size;
                memset(pAddr->addressVal, 0x00, sizeof(pAddr->addressVal));
@@ -3034,19 +2778,29 @@ int msg_address_info_set_str(void *addr_info, int field, char *value, int size)
 int msg_media_info_set_str(void *media_info, int field, char *value, int size)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!media_info || !value)
+
+       if (!media_info || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_MEDIA_INFO_S *pAddr = (MSG_MEDIA_INFO_S *)media_info;
        int _len = 0;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_MEDIA_ITEM_STR:
                (size > MSG_FILEPATH_LEN_MAX)? _len = MSG_FILEPATH_LEN_MAX : _len = size;
                memset(pAddr->media_item, 0x00, sizeof(pAddr->media_item));
                strncpy(pAddr->media_item, value, _len);
                break;
+       case MSG_MEDIA_MIME_TYPE_STR:
+               (size > MAX_MIME_TYPE_LEN)? _len = MAX_MIME_TYPE_LEN : _len = size;
+               memset(pAddr->mime_type, 0x00, sizeof(pAddr->mime_type));
+               strncpy(pAddr->mime_type, value, _len);
+               break;
+       case MSG_MEDIA_THUMB_PATH_STR:
+               (size > MSG_FILEPATH_LEN_MAX)? _len = MSG_FILEPATH_LEN_MAX : _len = size;
+               memset(pAddr->thumb_path, 0x00, sizeof(pAddr->thumb_path));
+               strncpy(pAddr->thumb_path, value, _len);
+               break;
        default:
                err = MSG_ERR_UNKNOWN;
                break;
@@ -3058,14 +2812,16 @@ int msg_media_info_set_str(void *media_info, int field, char *value, int size)
 int msg_reject_message_set_str(void *msg_info, int field, char *value, int size)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!msg_info || !value)
+
+       if (!msg_info || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_REJECT_MSG_INFO_S *pMsg = (MSG_REJECT_MSG_INFO_S *)msg_info;
+
        int _len = 0;
        (size > MAX_MSG_TEXT_LEN)? _len = MAX_MSG_TEXT_LEN : _len = size;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_REJECT_MESSAGE_MSGTEXT_STR:
                strncpy(pMsg->msgText, value, _len);
                break;
@@ -3080,12 +2836,13 @@ int msg_reject_message_set_str(void *msg_info, int field, char *value, int size)
 int msg_mms_sendopt_set_bool(void *option, int field, bool value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!option)
+
+       if (!option)
                return MSG_ERR_NULL_POINTER;
 
        MMS_SENDINGOPT_S *pOpt = (MMS_SENDINGOPT_S *)option;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_MMS_SENDOPTION_READ_REQUEST_BOOL:
                pOpt->bReadReq = value;
                break;
@@ -3096,18 +2853,20 @@ int msg_mms_sendopt_set_bool(void *option, int field, bool value)
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
 int msg_sms_sendopt_set_bool(void *option, int field, bool value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!option)
+
+       if (!option)
                return MSG_ERR_NULL_POINTER;
 
        SMS_SENDINGOPT_S *pOpt = (SMS_SENDINGOPT_S *)option;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_SMS_SENDOPT_REPLYPATH_BOOL:
                pOpt->bReplyPath = value;
                break;
@@ -3115,6 +2874,7 @@ int msg_sms_sendopt_set_bool(void *option, int field, bool value)
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
@@ -3123,30 +2883,23 @@ EXPORT_API int msg_add_push_event(msg_handle_t handle, const msg_struct_t push_e
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || push_event == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
        msg_struct_s *pPush = (msg_struct_s *)push_event;
        MSG_TYPE_CHECK(pPush->type, MSG_STRUCT_PUSH_CONFIG_INFO);
 
-       try
-       {
+       try {
                err = pHandle->addPushEvent((MSG_PUSH_EVENT_INFO_S *)pPush->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -3159,30 +2912,23 @@ EXPORT_API int msg_delete_push_event(msg_handle_t handle, const msg_struct_t pus
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || push_event == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
        msg_struct_s *pPush = (msg_struct_s *)push_event;
        MSG_TYPE_CHECK(pPush->type, MSG_STRUCT_PUSH_CONFIG_INFO);
 
-       try
-       {
+       try {
                err = pHandle->deletePushEvent((MSG_PUSH_EVENT_INFO_S *)pPush->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -3195,18 +2941,14 @@ EXPORT_API int msg_update_push_event(msg_handle_t handle, const msg_struct_t src
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || src_event == NULL || dst_event == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
@@ -3216,12 +2958,9 @@ EXPORT_API int msg_update_push_event(msg_handle_t handle, const msg_struct_t src
        msg_struct_s *pDst = (msg_struct_s *)dst_event;
        MSG_TYPE_CHECK(pDst->type, MSG_STRUCT_PUSH_CONFIG_INFO);
 
-       try
-       {
+       try {
                err = pHandle->updatePushEvent((MSG_PUSH_EVENT_INFO_S *)pSrc->data, (MSG_PUSH_EVENT_INFO_S *)pDst->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -3231,9 +2970,12 @@ EXPORT_API int msg_update_push_event(msg_handle_t handle, const msg_struct_t src
 
 int msg_push_config_get_str(void *event_info, int field, char *value, int size)
 {
+       if (!event_info)
+               return MSG_ERR_NULL_POINTER;
+
        MSG_PUSH_EVENT_INFO_S *pEvent = (MSG_PUSH_EVENT_INFO_S *)event_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_PUSH_CONFIG_CONTENT_TYPE_STR:
                strncpy(value, pEvent->contentType, size);
                break;
@@ -3243,7 +2985,6 @@ int msg_push_config_get_str(void *event_info, int field, char *value, int size)
        case MSG_PUSH_CONFIG_PACKAGE_NAME_STR:
                strncpy(value, pEvent->pkgName, size);
                break;
-
        default:
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -3260,8 +3001,7 @@ int msg_push_config_get_bool(void *event_info, int field, bool *value)
 
        MSG_PUSH_EVENT_INFO_S *pEvent = (MSG_PUSH_EVENT_INFO_S *)event_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_PUSH_CONFIG_LAUNCH_BOOL:
                *value = pEvent->bLaunch;
                break;
@@ -3269,20 +3009,21 @@ int msg_push_config_get_bool(void *event_info, int field, bool *value)
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
        }
+
        return ret;
 }
 
 int msg_push_config_set_str(void *event_info, int field, char *value, int size)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!event_info || !value)
+
+       if (!event_info || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_PUSH_EVENT_INFO_S *pEvent = (MSG_PUSH_EVENT_INFO_S *)event_info;
        int _len = 0;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_PUSH_CONFIG_CONTENT_TYPE_STR:
                (size > MAX_WAPPUSH_CONTENT_TYPE_LEN)? _len = MAX_WAPPUSH_CONTENT_TYPE_LEN : _len = size;
                strncpy(pEvent->contentType, value, _len);
@@ -3306,12 +3047,13 @@ int msg_push_config_set_str(void *event_info, int field, char *value, int size)
 int msg_push_config_set_bool(void *event, int field, bool value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!event)
+
+       if (!event)
                return MSG_ERR_NULL_POINTER;
 
        MSG_PUSH_EVENT_INFO_S *pEvent = (MSG_PUSH_EVENT_INFO_S *)event;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_PUSH_CONFIG_LAUNCH_BOOL:
                pEvent->bLaunch = value;
                break;
@@ -3319,15 +3061,18 @@ int msg_push_config_set_bool(void *event, int field, bool value)
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
 int msg_media_item_get_str(void *data, int field, char *value, int size)
 {
+       if (!data)
+               return MSG_ERR_NULL_POINTER;
+
        MSG_MEDIA_INFO_S *pMedia = (MSG_MEDIA_INFO_S *)data;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_MEDIA_ITEM_STR:
                strncpy(value, pMedia->media_item, size);
                break;
index c36a3ad..dc1eb24 100755 (executable)
@@ -44,8 +44,7 @@ EXPORT_API msg_struct_t msg_create_struct(int field)
        msg_struct->type = field;
        msg_struct->data = NULL;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_STRUCT_MESSAGE_INFO :
                msg_message_create_struct(msg_struct);
                break;
@@ -167,7 +166,7 @@ EXPORT_API msg_struct_t msg_create_struct(int field)
                memset(msg_struct->data, 0x00, sizeof(MSG_SMSC_LIST_HIDDEN_S));
 
                MSG_SMSC_LIST_HIDDEN_S *pTmp = (MSG_SMSC_LIST_HIDDEN_S *)msg_struct->data;
-               pTmp->simIndex = MSG_SIM_SLOT_ID_1; // default sim index
+               pTmp->simIndex = MSG_SIM_SLOT_ID_1; /* default sim index */
 
                msg_struct_list_s *smsc_list = (msg_struct_list_s *)new msg_struct_list_s;
                memset(smsc_list, 0x00, sizeof(msg_struct_list_s));
@@ -201,7 +200,7 @@ EXPORT_API msg_struct_t msg_create_struct(int field)
                memset(msg_struct->data, 0x00, sizeof(MSG_CBMSG_OPT_HIDDEN_S));
 
                MSG_CBMSG_OPT_HIDDEN_S *pTmp = (MSG_CBMSG_OPT_HIDDEN_S *)msg_struct->data;
-               pTmp->simIndex = MSG_SIM_SLOT_ID_1; // default sim index
+               pTmp->simIndex = MSG_SIM_SLOT_ID_1; /* default sim index */
 
                pTmp->channelData = (msg_struct_list_s *)new msg_struct_list_s;
                memset(pTmp->channelData, 0x00, sizeof(msg_struct_list_s));
@@ -257,7 +256,7 @@ EXPORT_API msg_struct_t msg_create_struct(int field)
                msg_struct->data = new MSG_VOICEMAIL_OPT_S;
                memset(msg_struct->data, 0x00, sizeof(MSG_VOICEMAIL_OPT_S));
                MSG_VOICEMAIL_OPT_S *pTmp = (MSG_VOICEMAIL_OPT_S *)msg_struct->data;
-               pTmp->simIndex = MSG_SIM_SLOT_ID_1; // default sim index
+               pTmp->simIndex = MSG_SIM_SLOT_ID_1; /* default sim index */
                break;
        }
        case MSG_STRUCT_SETTING_GENERAL_OPT :
@@ -354,8 +353,7 @@ static int _release_msg_struct(msg_struct_t *msg_struct_handle)
 
        msg_struct_s *msg_struct = (msg_struct_s *)*msg_struct_handle;
 
-       switch(msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MESSAGE_INFO :
        {
                msg_message_release(&msg_struct);
@@ -751,9 +749,6 @@ EXPORT_API int msg_release_struct(msg_struct_t *msg_struct_handle)
 
        int ret = _release_msg_struct(msg_struct_handle);
 
-       // Release Memory
-       MsgReleaseMemory();
-
        return ret;
 }
 
@@ -771,23 +766,20 @@ EXPORT_API int msg_release_list_struct(msg_struct_list_s *msg_struct_list)
                return MSG_ERR_NULL_POINTER;
        }
 
-       if(msg_struct_list->nCount > 0) {
+       if (msg_struct_list->nCount > 0) {
                int listCnt = msg_struct_list->nCount;
 
-               for(int i = 0; i < listCnt; i++) {
+               for (int i = 0; i < listCnt; i++) {
                        _release_msg_struct(&(msg_struct_list->msg_struct_info[i]));
                }
        }
 
-       //free peer info list
+       /* free peer info list */
        g_free(msg_struct_list->msg_struct_info);
        msg_struct_list->msg_struct_info = NULL;
 
        msg_struct_list->nCount = 0;
 
-       // Release Memory
-       MsgReleaseMemory();
-
        return err;
 }
 
@@ -799,14 +791,13 @@ EXPORT_API int msg_get_int_value(msg_struct_t msg_struct_handle, int field, int
        if (msg_struct_handle == NULL || value == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
+       msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
        MSG_TYPE_CHECK(msg_struct->type, field);
 
        if (msg_struct->data == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       switch (msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MESSAGE_INFO :
                err = msg_message_get_int_value(msg_struct->data, field, value);
                break;
@@ -908,13 +899,12 @@ EXPORT_API int msg_get_str_value(msg_struct_t msg_struct_handle, int field, char
        if (size < 0)
                return MSG_ERR_INVALID_PARAMETER;
 
-       msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
+       msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
        if (msg_struct->data == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       switch (msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MESSAGE_INFO :
                err = msg_message_get_str_value(msg_struct->data, field, value, size);
                break;
@@ -987,13 +977,12 @@ EXPORT_API int msg_get_bool_value(msg_struct_t msg_struct_handle, int field, boo
        if (msg_struct_handle == NULL || value == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
+       msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
        if (msg_struct->data == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       switch (msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_FILTER :
                err = msg_get_filter_info_bool(msg_struct->data, field, value);
                break;
@@ -1060,13 +1049,12 @@ EXPORT_API int msg_get_struct_handle(msg_struct_t msg_struct_handle, int field,
        if (msg_struct_handle == NULL || value == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
+       msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
        if (msg_struct->data == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       switch (msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MESSAGE_INFO :
                err = msg_message_get_struct_hnd(msg_struct->data, field, (void **)value);
                break;
@@ -1104,13 +1092,12 @@ EXPORT_API int msg_get_list_handle(msg_struct_t msg_struct_handle, int field, vo
        if (msg_struct_handle == NULL || value == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
+       msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
        if (msg_struct->data == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       switch (msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MESSAGE_INFO :
                err = msg_message_get_list_hnd(msg_struct->data, field, value);
                break;
@@ -1141,13 +1128,12 @@ EXPORT_API int msg_set_int_value(msg_struct_t msg_struct_handle, int field, int
        if (msg_struct_handle == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
+       msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
        if (msg_struct->data == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       switch (msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MESSAGE_INFO :
                err = msg_message_set_int_value(msg_struct->data, field, value);
                break;
@@ -1233,13 +1219,12 @@ EXPORT_API int msg_set_str_value(msg_struct_t msg_struct_handle, int field, char
        if (size < 0)
                return MSG_ERR_INVALID_PARAMETER;
 
-       msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
+       msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
        if (msg_struct->data == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       switch (msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MESSAGE_INFO :
                err = msg_message_set_str_value(msg_struct->data, field, value, size);
                break;
@@ -1298,13 +1283,12 @@ EXPORT_API int msg_set_bool_value(msg_struct_t msg_struct_handle, int field, boo
        if (msg_struct_handle == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
+       msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
        if (msg_struct->data == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       switch (msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_FILTER :
                err = msg_set_filter_info_bool(msg_struct->data, field, value);
                break;
@@ -1365,13 +1349,12 @@ EXPORT_API int msg_set_struct_handle(msg_struct_t msg_struct_handle, int field,
        if (msg_struct_handle == NULL || value == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
+       msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
        if (msg_struct->data == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       switch (msg_struct->type)
-       {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MESSAGE_INFO :
                err = msg_message_set_struct_hnd(msg_struct->data, field, (void *)value);
                break;
@@ -1409,12 +1392,12 @@ EXPORT_API int msg_set_list_handle(msg_struct_t msg_struct_handle, int field, vo
        if (msg_struct_handle == NULL || value == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       msg_struct_s *msg_struct = (msg_struct_s *) msg_struct_handle;
+       msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
        if (msg_struct->data == NULL)
                return MSG_ERR_NULL_POINTER;
 
-#if 0 // No operations
+#if 0 /* No operations */
        switch (msg_struct->type)
        {
        default :
@@ -1429,14 +1412,13 @@ EXPORT_API int msg_set_list_handle(msg_struct_t msg_struct_handle, int field, vo
 EXPORT_API int msg_list_add_item(msg_struct_t msg_struct_handle, int field, msg_struct_t *item)
 {
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
-       if (msg_struct_handle == NULL || item == NULL) {
+       if (msg_struct_handle == NULL || item == NULL)
                return MSG_ERR_NULL_POINTER;
-       }
 
        msg_error_t err = MSG_SUCCESS;
        msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MESSAGE_INFO:
        {
                err = msg_message_list_append(msg_struct_handle, field, item);
@@ -1459,11 +1441,10 @@ EXPORT_API int msg_list_add_item(msg_struct_t msg_struct_handle, int field, msg_
 EXPORT_API msg_struct_t msg_list_nth_data(msg_list_handle_t list_handle, int index)
 {
        CHECK_MSG_SUPPORTED_RETURN_NULL(MSG_TELEPHONY_SMS_FEATURE);
-       if (list_handle == NULL) {
+       if (list_handle == NULL)
                return NULL;
-       }
 
-       return (msg_struct_t)g_list_nth_data((GList *)list_handle,(guint)index);
+       return (msg_struct_t)g_list_nth_data((GList *)list_handle, (guint)index);
 }
 
 EXPORT_API int msg_list_length(msg_list_handle_t list_handle)
@@ -1479,25 +1460,18 @@ EXPORT_API int msg_list_length(msg_list_handle_t list_handle)
 EXPORT_API int msg_list_clear(msg_struct_t msg_struct_handle, int field)
 {
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
-       if (msg_struct_handle == NULL) {
+       if (msg_struct_handle == NULL)
                return MSG_ERR_NULL_POINTER;
-       }
 
        msg_error_t err = MSG_SUCCESS;
        msg_struct_s *msg_struct = (msg_struct_s *)msg_struct_handle;
 
-       switch(msg_struct->type) {
+       switch (msg_struct->type) {
        case MSG_STRUCT_MESSAGE_INFO:
        {
                err = msg_message_list_clear(msg_struct_handle, field);
        }
        break;
-//     case MSG_STRUCT_MMS:
-//     case MSG_STRUCT_MMS_PAGE:
-//     {
-//             err = msg_mms_list_append(msg_struct_handle, field, item);
-//     }
-//     break;
        default :
                err = MSG_ERR_INVALID_PARAMETER;
                break;
@@ -1509,9 +1483,8 @@ EXPORT_API int msg_list_clear(msg_struct_t msg_struct_handle, int field)
 EXPORT_API int msg_list_free(msg_list_handle_t list_handle)
 {
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
-       if (list_handle == NULL) {
+       if (list_handle == NULL)
                return MSG_ERR_NULL_POINTER;
-       }
 
        g_list_free_full((GList *)list_handle, __msg_release_list_item);
        list_handle = NULL;
@@ -1525,9 +1498,9 @@ EXPORT_API int msg_util_calculate_text_length(const char* msg_text, msg_encode_t
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       if (msg_text == NULL || text_size == NULL || segment_size == NULL || msg_encode_type_in == NULL) {
+       if (msg_text == NULL || text_size == NULL || segment_size == NULL || msg_encode_type_in == NULL)
                return MSG_ERR_INVALID_PARAMETER;
-       }
+
 #ifdef FEATURE_SMS_CDMA
        if (msg_encode_type_to > MSG_ENCODE_ASCII7BIT) {
 #else
@@ -1558,8 +1531,7 @@ EXPORT_API int msg_util_calculate_text_length(const char* msg_text, msg_encode_t
        *text_size = 0;
        *segment_size = 0;
 
-       switch (msg_encode_type_to)
-       {
+       switch (msg_encode_type_to) {
        case MSG_ENCODE_GSM7BIT :
                decodeLen = textCvt->convertUTF8ToGSM7bit(decodeData, bufSize, (const unsigned char*)msg_text, textSize, &langId, &bAbnormal);
                break;
@@ -1567,19 +1539,13 @@ EXPORT_API int msg_util_calculate_text_length(const char* msg_text, msg_encode_t
                decodeLen = textCvt->convertUTF8ToUCS2(decodeData, bufSize, (const unsigned char*)msg_text, textSize);
                break;
        case MSG_ENCODE_AUTO :
-#ifndef FEATURE_SMS_CDMA
-               decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (const unsigned char*)msg_text, textSize, &langId, &encodeType);
-#else
                decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (const unsigned char*)msg_text, textSize, &encodeType);
-#endif
                break;
        default :
-               err = MSG_ERR_INVALID_PARAMETER;
-               return err;
-               break;
+               return MSG_ERR_INVALID_PARAMETER;
        }
 
-       // calculate segment size.
+       /* calculate segment size. */
        int headerLen = 0;
        int concat = 5;
        int lang = 3;
@@ -1600,8 +1566,9 @@ EXPORT_API int msg_util_calculate_text_length(const char* msg_text, msg_encode_t
                        headerLen = 1;
                        segSize = ((140 - (headerLen + concat + headerSize)) * 8)/7;
                }
-               else
+               else {
                        segSize = ((140 - headerLen - headerSize) * 8) / 7;
+               }
 
                if (bAbnormal)
                        *msg_encode_type_in = MSG_ENCODE_GSM7BIT_ABNORMAL;
@@ -1611,15 +1578,25 @@ EXPORT_API int msg_util_calculate_text_length(const char* msg_text, msg_encode_t
        } else if (msg_encode_type_to == MSG_ENCODE_UCS2 || encodeType == MSG_ENCODE_UCS2) {
                MSG_DEBUG("MSG_ENCODE_UCS2");
 
-//             if (((decodeLen+headerSize)/140) > 1)
-//                     segSize = 140 - (headerLen + concat + headerSize);
                if (decodeLen > 140) {
                        headerLen = 1;
                        segSize = 140 - (headerLen + concat);
-               } else
+               } else {
                        segSize = 140;
+               }
 
                *msg_encode_type_in = MSG_ENCODE_UCS2;
+#ifdef FEATURE_SMS_CDMA
+       } else if (encodeType == MSG_ENCODE_ASCII7BIT) {
+               MSG_DEBUG("MSG_ENCODE_ASCII7BIT");
+
+               if(decodeLen > 160)
+                       segSize = ((140*8) - ((headerLen + concat)*8)) / 7;
+               else
+                       segSize = 160;
+
+               *msg_encode_type_in = MSG_ENCODE_GSM7BIT;
+#endif
 
        } else {
                MSG_DEBUG("Unsupported encode type.");
index 27af80f..cdc03ee 100755 (executable)
@@ -35,30 +35,23 @@ EXPORT_API int msg_submit_req(msg_handle_t handle, msg_struct_t req)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || req == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
        msg_struct_s *pStruct = (msg_struct_s *)req;
        MSG_TYPE_CHECK(pStruct->type, MSG_STRUCT_REQUEST_INFO);
 
-       try
-       {
+       try {
                err = pHandle->submitReq((MSG_REQUEST_S *)pStruct->data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_TRANSPORT_ERROR;
        }
@@ -72,27 +65,20 @@ EXPORT_API int msg_reg_sent_status_callback(msg_handle_t handle, msg_sent_status
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || cb == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->regSentStatusCallback(cb, user_param);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                if (e.errorCode() == MsgException::SERVER_READY_ERROR)
                        return MSG_ERR_PERMISSION_DENIED;
@@ -109,27 +95,20 @@ EXPORT_API int msg_reg_sms_message_callback(msg_handle_t handle, msg_sms_incomin
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || cb == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->regSmsMessageCallback(cb, port, user_param);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                if (e.errorCode() == MsgException::SERVER_READY_ERROR)
                        return MSG_ERR_PERMISSION_DENIED;
@@ -146,32 +125,23 @@ EXPORT_API int msg_reg_mms_conf_message_callback(msg_handle_t handle, msg_mms_co
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || cb == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        if (app_id && strlen(app_id) > MAX_MMS_JAVA_APPID_LEN)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->regMmsConfMessageCallback(cb, app_id, user_param);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                if (e.errorCode() == MsgException::SERVER_READY_ERROR)
                        return MSG_ERR_PERMISSION_DENIED;
@@ -188,27 +158,20 @@ EXPORT_API int msg_reg_syncml_message_callback(msg_handle_t handle,  msg_syncml_
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || cb == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->regSyncMLMessageCallback(cb, user_param);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                if (e.errorCode() == MsgException::SERVER_READY_ERROR)
                        return MSG_ERR_PERMISSION_DENIED;
@@ -225,27 +188,20 @@ EXPORT_API int msg_reg_lbs_message_callback(msg_handle_t handle, msg_lbs_msg_inc
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || cb == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->regLBSMessageCallback(cb, user_param);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                if (e.errorCode() == MsgException::SERVER_READY_ERROR)
                        return MSG_ERR_PERMISSION_DENIED;
@@ -262,27 +218,20 @@ EXPORT_API int msg_reg_syncml_message_operation_callback(msg_handle_t handle,  m
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || cb == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->regSyncMLMessageOperationCallback(cb, user_param);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                if (e.errorCode() == MsgException::SERVER_READY_ERROR)
                        return MSG_ERR_PERMISSION_DENIED;
@@ -299,32 +248,23 @@ EXPORT_API int msg_reg_push_message_callback(msg_handle_t handle,  msg_push_msg_
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || cb == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        if (app_id && strlen(app_id) > MAX_WAPPUSH_ID_LEN)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->regPushMessageCallback(cb, app_id, user_param);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                if (e.errorCode() == MsgException::SERVER_READY_ERROR)
                        return MSG_ERR_PERMISSION_DENIED;
@@ -340,27 +280,20 @@ EXPORT_API int msg_reg_cb_message_callback(msg_handle_t handle, msg_cb_incoming_
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || cb == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->regCBMessageCallback(cb, bsave, user_param);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                if (e.errorCode() == MsgException::SERVER_READY_ERROR)
                        return MSG_ERR_PERMISSION_DENIED;
@@ -377,27 +310,20 @@ EXPORT_API int msg_reg_report_message_callback(msg_handle_t handle, msg_report_m
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || cb == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->regReportMessageCallback(cb, user_param);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                if (e.errorCode() == MsgException::SERVER_READY_ERROR)
                        return MSG_ERR_PERMISSION_DENIED;
@@ -414,27 +340,20 @@ EXPORT_API int msg_syncml_message_operation(msg_handle_t handle, msg_message_id_
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_READ_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL || msgId < 1)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
        MsgHandle* pHandle = (MsgHandle*)handle;
 
-       try
-       {
+       try {
                err = pHandle->operateSyncMLMessage(msgId);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_TRANSPORT_ERROR;
        }
@@ -448,32 +367,30 @@ static msg_simple_sent_status_cb sentStatusCallback = NULL;
 
 static void sent_status_cb_func(msg_handle_t handle, msg_struct_t sent_status, void *user_param)
 {
-//     MSG_DEBUG("Sent Status [%d]", sent_status->status);
+/*     MSG_DEBUG("Sent Status [%d]", sent_status->status); */
 
        msg_simple_sent_status_cb pfunc = sentStatusCallback;
-// TODO : Fixme
+/*     TODO : Fixme */
        pfunc((msg_struct_t)sent_status, user_param);
 
        MSG_DEBUG("After entering callback function.");
 
-       // Close control handle instance
-       //      msg_close_msg_handle(&msgHandle);
-
-       //      MSG_DEBUG("After msg_close_msg_handle.");
-
+/*     Close control handle instance
+*      msg_close_msg_handle(&msgHandle);
+*
+*      MSG_DEBUG("After msg_close_msg_handle.");
+*/
 }
 
 
 static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param)
 {
-       if (phone_num == NULL || sms_text == NULL || cb == NULL)
-       {
+       if (phone_num == NULL || sms_text == NULL || cb == NULL) {
                MSG_SEC_DEBUG("Invalid parameter [%s] [%s] [%s]", phone_num, sms_text, cb);
                return MSG_ERR_INVALID_PARAMETER;
        }
 
-       if (strlen(phone_num) > MAX_PHONE_NUMBER_LEN)
-       {
+       if (strlen(phone_num) > MAX_PHONE_NUMBER_LEN) {
                MSG_SEC_DEBUG("Phone Number is too long [%s]", phone_num);
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -486,14 +403,12 @@ static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_
 
        msg_error_t retVal = MSG_SUCCESS;
 
-       // Open control handle instance
-       if ((retVal = msg_open_msg_handle(&msgHandle)) != MSG_SUCCESS)
-       {
+       /* Open control handle instance */
+       if ((retVal = msg_open_msg_handle(&msgHandle)) != MSG_SUCCESS) {
                MSG_DEBUG("MsgOpenMsgHandle is failed. Error Code = %d", retVal);
                return retVal;
        }
 
-       //msgReq.msg = msg_new_message();
        MSG_MESSAGE_HIDDEN_S msg_info = {0,};
        msg_struct_s msg = {0,};
 
@@ -558,17 +473,16 @@ static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_
 
        sentStatusCallback = cb;
 
-       // register sent status callback
+       /* register sent status callback */
        retVal = msg_reg_sent_status_callback(msgHandle, sent_status_cb_func, user_param);
 
-       if (retVal != MSG_SUCCESS)
-       {
+       if (retVal != MSG_SUCCESS) {
                MSG_DEBUG("msg_reg_sent_status_callback() is failed. Error Code = %d", retVal);
                msg_close_msg_handle(&msgHandle);
                return retVal;
        }
 
-       // sending message request
+       /* sending message request */
        msgReq.msg = (msg_struct_t)&msg;
        msgReq.sendOpt = (msg_struct_t)&sendOpt;
 
@@ -579,8 +493,7 @@ static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_
                addr_list.msg_struct_info = NULL;
        }
 
-       if (retVal != MSG_SUCCESS)
-       {
+       if (retVal != MSG_SUCCESS) {
                MSG_DEBUG("msg_submit_req() is failed. Error Code = %d", retVal);
                msg_close_msg_handle(&msgHandle);
                return retVal;
@@ -592,16 +505,13 @@ static int msg_send_single_sms(const char *phone_num, const char *sms_text, msg_
 EXPORT_API int msg_sms_send(const char *phone_num_list, const char *sms_text, msg_simple_sent_status_cb cb, void *user_param)
 {
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (phone_num_list == NULL || sms_text == NULL || cb == NULL)
-       {
+       if (phone_num_list == NULL || sms_text == NULL || cb == NULL) {
                MSG_SEC_DEBUG("Invalid parameter [%s] [%s] [%s]", phone_num_list, sms_text, cb);
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -612,13 +522,11 @@ EXPORT_API int msg_sms_send(const char *phone_num_list, const char *sms_text, ms
 
        msg_error_t retVal = msg_verify_number(phone_num_list, trimmed_num);
 
-       if ( retVal != MSG_SUCCESS )
+       if (retVal != MSG_SUCCESS)
                return retVal;
 
-       for( char* cur_num = strtok_r(trimmed_num,", ", &temp); cur_num ; cur_num = strtok_r(NULL,", ", &temp))
-       {
-               if (strlen(cur_num) > MAX_PHONE_NUMBER_LEN)
-               {
+       for (char* cur_num = strtok_r(trimmed_num,", ", &temp); cur_num ; cur_num = strtok_r(NULL,", ", &temp)) {
+               if (strlen(cur_num) > MAX_PHONE_NUMBER_LEN) {
                        MSG_SEC_DEBUG("Phone number is too long [%s], and sending is skipped", cur_num);
                        continue;
                }
@@ -640,16 +548,13 @@ EXPORT_API int msg_sms_send_message(msg_handle_t handle, msg_struct_t req)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_SMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL || req == NULL)
-       {
+       if (handle == NULL || req == NULL) {
                MSG_FATAL("handle or req is NULL");
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -681,7 +586,7 @@ EXPORT_API int msg_sms_send_message(msg_handle_t handle, msg_struct_t req)
                return MSG_ERR_INVALID_PARAMETER;
        }
 
-       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->folderId = MSG_OUTBOX_ID; /* outbox fixed */
        reqmsg->networkStatus = MSG_NETWORK_SENDING;
 
        MSG_DEBUG("Coding Scheme From App. = [%d]", reqmsg->encodeType);
@@ -702,16 +607,13 @@ EXPORT_API int msg_mms_send_message(msg_handle_t handle, msg_struct_t req)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL || req == NULL)
-       {
+       if (handle == NULL || req == NULL) {
                MSG_FATAL("handle or req is NULL");
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -728,15 +630,14 @@ EXPORT_API int msg_mms_send_message(msg_handle_t handle, msg_struct_t req)
 
        MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data;
 
-       if (reqmsg->mmsDataSize <= 0)
-       {
+       if (reqmsg->mmsDataSize <= 0) {
                MSG_FATAL("MMS data size is invalid");
                return MSG_ERR_INVALID_PARAMETER;
        }
 
        reqmsg->mainType = MSG_MMS_TYPE;
        reqmsg->subType = MSG_SENDREQ_MMS;
-       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->folderId = MSG_OUTBOX_ID; /* outbox fixed */
        reqmsg->networkStatus = MSG_NETWORK_SENDING;
 
        err = msg_submit_req(handle, req);
@@ -755,21 +656,16 @@ EXPORT_API int msg_mms_send_read_report(msg_handle_t handle, msg_message_id_t ms
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
        if (handle == NULL)
-       {
                return MSG_ERR_INVALID_PARAMETER;
-       }
 
-       if (mms_read_status < MSG_READ_REPORT_NONE || mms_read_status > MSG_READ_REPORT_REJECT_BY_USER)
-       {
+       if (mms_read_status < MSG_READ_REPORT_NONE || mms_read_status > MSG_READ_REPORT_REJECT_BY_USER) {
                MSG_FATAL("unsupported read report status [%d]", mms_read_status);
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -787,7 +683,7 @@ EXPORT_API int msg_mms_send_read_report(msg_handle_t handle, msg_message_id_t ms
 
        read_report_datasize = sizeof(msg_read_report_status_t);
        read_report_data = (void *)calloc(read_report_datasize, 1);
-       if(read_report_data == NULL) {
+       if (read_report_data == NULL) {
                msg_release_struct(&req_t);
                return MSG_ERR_MEMORY_ERROR;
        }
@@ -799,7 +695,7 @@ EXPORT_API int msg_mms_send_read_report(msg_handle_t handle, msg_message_id_t ms
 
        reqmsg->bPortValid = false;
        reqmsg->msgId = msgId;
-       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->folderId = MSG_OUTBOX_ID; /* outbox fixed */
        reqmsg->mainType = MSG_MMS_TYPE;
        reqmsg->subType = MSG_READREPLY_MMS;
 
@@ -827,16 +723,13 @@ EXPORT_API int msg_mms_forward_message(msg_handle_t handle, msg_struct_t req)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL || req == NULL )
-       {
+       if (handle == NULL || req == NULL ) {
                MSG_FATAL("handle or req is NULL");
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -854,7 +747,7 @@ EXPORT_API int msg_mms_forward_message(msg_handle_t handle, msg_struct_t req)
 
        reqmsg->mainType = MSG_MMS_TYPE;
        reqmsg->subType = MSG_FORWARD_MMS;
-       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->folderId = MSG_OUTBOX_ID; /* outbox fixed */
        reqmsg->networkStatus = MSG_NETWORK_SENDING;
 
        err = msg_submit_req(handle, req);
@@ -873,16 +766,13 @@ EXPORT_API int msg_mms_retrieve_message(msg_handle_t handle, msg_struct_t req)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL || req == NULL)
-       {
+       if (handle == NULL || req == NULL) {
                MSG_FATAL("handle or req is NULL");
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -899,7 +789,7 @@ EXPORT_API int msg_mms_retrieve_message(msg_handle_t handle, msg_struct_t req)
 
        reqmsg->mainType = MSG_MMS_TYPE;
        reqmsg->subType = MSG_RETRIEVE_MMS;
-       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->folderId = MSG_OUTBOX_ID; /* outbox fixed */
        reqmsg->networkStatus = MSG_NETWORK_RETRIEVING;
 
        err = msg_submit_req(handle, req);
@@ -919,16 +809,13 @@ EXPORT_API int msg_mms_reject_message(msg_handle_t handle, msg_struct_t req)
        CHECK_MSG_SUPPORTED(MSG_TELEPHONY_MMS_FEATURE);
        msg_error_t err = MSG_SUCCESS;
 
-       //Privilege check
+       /* Privilege check */
        int ret = PRIV_MGR_ERROR_SUCCESS;
        ret = privacy_checker_check_by_privilege(MSG_SERVICE_WRITE_PRIV_NAME);
        if (ret != PRIV_MGR_ERROR_SUCCESS)
-       {
                return MSG_ERR_PERMISSION_DENIED;
-       }
 
-       if (handle == NULL || req == NULL)
-       {
+       if (handle == NULL || req == NULL) {
                MSG_FATAL("handle or req is NULL");
                return MSG_ERR_INVALID_PARAMETER;
        }
@@ -945,7 +832,7 @@ EXPORT_API int msg_mms_reject_message(msg_handle_t handle, msg_struct_t req)
 
        reqmsg->mainType = MSG_MMS_TYPE;
        reqmsg->subType = MSG_NOTIFYRESPIND_MMS;
-       reqmsg->folderId = MSG_OUTBOX_ID; // outbox fixed
+       reqmsg->folderId = MSG_OUTBOX_ID; /* outbox fixed */
        reqmsg->networkStatus = MSG_NETWORK_SENDING;
 
        err = msg_submit_req(handle, req);
@@ -969,12 +856,10 @@ int msg_request_get_int(void *request_info, int field, int *value)
 
        MSG_REQUEST_S *pRequest = (MSG_REQUEST_S *)request_info;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_REQUEST_REQUESTID_INT:
                *value = pRequest->reqId;
                break;
-
        default:
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
@@ -988,12 +873,11 @@ int msg_request_get_struct_handle(msg_struct_s *msg_struct, int field, void **va
 {
        msg_error_t err = MSG_SUCCESS;
 
-       if(!msg_struct || !value)
+       if (!msg_struct || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_REQUEST_S *pRequest = (MSG_REQUEST_S *)msg_struct->data;
-       switch(field)
-       {
+       switch (field) {
        case MSG_REQUEST_MESSAGE_HND:
                *value = (void *)pRequest->msg;
                break;
@@ -1005,18 +889,20 @@ int msg_request_get_struct_handle(msg_struct_s *msg_struct, int field, void **va
                break;
 
        }
+
        return err;
 }
 
 int msg_request_set_int(void *request_info, int field, int value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!request_info)
+
+       if (!request_info)
                return MSG_ERR_NULL_POINTER;
 
        MSG_REQUEST_S *pRequest = (MSG_REQUEST_S *)request_info;
-       switch(field)
-       {
+
+       switch (field) {
        case MSG_REQUEST_REQUESTID_INT:
                pRequest->reqId = value;
                break;
@@ -1031,15 +917,15 @@ int msg_request_set_int(void *request_info, int field, int value)
 int msg_request_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struct_s *value)
 {
        msg_error_t err = MSG_SUCCESS;
-       if(!msg_struct || !value)
+
+       if (!msg_struct || !value)
                return MSG_ERR_NULL_POINTER;
 
        MSG_REQUEST_S *pRequest = (MSG_REQUEST_S *)msg_struct->data;
        msg_struct_s *pTmp = NULL;
 
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_REQUEST_MESSAGE_HND:
        {
                pTmp = (msg_struct_s *)pRequest->msg;
@@ -1075,6 +961,7 @@ int msg_request_set_struct_handle(msg_struct_s *msg_struct, int field, msg_struc
                err = MSG_ERR_UNKNOWN;
                break;
        }
+
        return err;
 }
 
@@ -1086,8 +973,7 @@ int msg_sent_status_get_int(MSG_SENT_STATUS_S *sent_status_info, int field, int
 
        int ret = MSG_SUCCESS;
 
-       switch(field)
-       {
+       switch (field) {
        case MSG_SENT_STATUS_REQUESTID_INT:
                *value = sent_status_info->reqId;
                break;
index 744e293..29ae7eb 100755 (executable)
@@ -5,8 +5,8 @@ License:        Apache-2.0
 Summary:        Messaging Framework Library
 Group:          System/Libraries
 Source0:        %{name}-%{version}.tar.gz
-Source1:       msg-server.service
-Source2:       msg-server.socket
+Source1:        msg-server.service
+Source2:        msg-server.socket
 
 %if "%{?tizen_profile_name}" == "tv"
 ExcludeArch: %{arm} %ix86 x86_64
@@ -23,43 +23,46 @@ BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(badge)
 BuildRequires: pkgconfig(bundle)
 BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-content-media-content)
+BuildRequires: pkgconfig(capi-media-image-util)
+BuildRequires: pkgconfig(capi-media-metadata-extractor)
+BuildRequires: pkgconfig(capi-media-thumbnail-util)
 BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(capi-system-device)
 BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-system-system-settings)
 BuildRequires: pkgconfig(capi-telephony)
 BuildRequires: pkgconfig(contacts-service2)
 BuildRequires: pkgconfig(cynara-client)
 BuildRequires: pkgconfig(cynara-creds-commons)
 BuildRequires: pkgconfig(cynara-creds-socket)
 BuildRequires: pkgconfig(cynara-session)
-BuildRequires: pkgconfig(db-util)
 BuildRequires: pkgconfig(deviced)
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(eventsystem)
 BuildRequires: pkgconfig(feedback)
 BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(gobject-2.0)
+BuildRequires: pkgconfig(icu-uc)
 BuildRequires: pkgconfig(iniparser)
 BuildRequires: pkgconfig(json-glib-1.0)
 BuildRequires: pkgconfig(lbs-dbus)
 BuildRequires: pkgconfig(libcurl)
-BuildRequires: pkgconfig(libsystemd-daemon)
+BuildRequires: pkgconfig(libresourced)
 BuildRequires: pkgconfig(libxml-2.0)
 BuildRequires: pkgconfig(libwbxml2)
-BuildRequires: pkgconfig(capi-media-thumbnail-util)
-BuildRequires: pkgconfig(capi-media-image-util)
+BuildRequires: pkgconfig(motion)
 BuildRequires: pkgconfig(mm-fileinfo)
 BuildRequires: pkgconfig(mm-player)
 BuildRequires: pkgconfig(mm-session)
 BuildRequires: pkgconfig(mm-sound)
-BuildRequires: pkgconfig(mmutil-imgp)
-BuildRequires: pkgconfig(mmutil-jpeg)
 BuildRequires: pkgconfig(notification)
 BuildRequires: pkgconfig(privacy-manager-client)
-BuildRequires: pkgconfig(sensor)
+BuildRequires: pkgconfig(security-server)
+BuildRequires: pkgconfig(sqlite3)
 BuildRequires: pkgconfig(storage)
 BuildRequires: pkgconfig(tapi)
 BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(libsmack)
 
 %description
 Description: Messaging Framework Library
index d3ffda1..d11059c 100755 (executable)
@@ -22,14 +22,12 @@ SET(MMS-PLUGIN-SRCS
        MmsPluginEventHandler.cpp
        MmsPluginStorage.cpp
        MmsPluginMessage.cpp
-       MmsPluginMIME.cpp
        MmsPluginConnManWrapper.cpp
        MmsPluginUserAgent.cpp
        MmsPluginHttp.cpp
        MmsPluginInternal.cpp
        MmsPluginDrm.cpp
        MmsPluginUtil.cpp
-#      MmsPluginTcs.cpp
        MmsPluginComposer.cpp
        MmsPluginAppBase.cpp
 )
@@ -44,7 +42,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(mms_plugin_pkgs REQUIRED glib-2.0 libcurl mm-fileinfo mmutil-imgp mmutil-jpeg vconf dlog capi-media-thumbnail-util capi-media-image-util capi-network-connection db-util)
+pkg_check_modules(mms_plugin_pkgs REQUIRED glib-2.0 libcurl vconf dlog capi-network-connection capi-telephony)
 
 FOREACH(flag ${mms_plugin_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 11e4a23..69d9271 100755 (executable)
 #include "MmsPluginDebug.h"
 #include "MmsPluginStorage.h"
 #include "MmsPluginMessage.h"
-#include "MmsPluginMIME.h"
 #include "MmsPluginAppBase.h"
 #include "MmsPluginUtil.h"
-#include "MmsPluginTcs.h"
 #include "MsgUtilFile.h"
+#include "MsgUtilMime.h"
 
 msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allow_malware, const char *raw_filepath);
 
@@ -72,7 +71,7 @@ void MmsPluginAppBase::getFirstPageTextFilePath(char *textBuf, int textBufSize)
        if (pMmsMsgData == NULL)
                return;
 
-       // Get the text data from the 1st slide.
+       /* Get the text data from the 1st slide. */
        if (pMmsMsgData->pageCnt > 0) {
 
                pPage = _MsgMmsGetPage(pMmsMsgData, 0);
@@ -87,25 +86,41 @@ void MmsPluginAppBase::getFirstPageTextFilePath(char *textBuf, int textBufSize)
 
                                        MimeType mimeType = MIME_UNKNOWN;
 
-                                       MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
+                                       MsgGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
 
                                        if (mimeType == MIME_TEXT_X_VCALENDAR || mimeType == MIME_TEXT_X_VCARD || mimeType == MIME_TEXT_X_VTODO || mimeType == MIME_TEXT_X_VNOTE) {
-                                               MSG_DEBUG("Media Type is Text, but Vobject file [%s]", pMedia->szFilePath);
+                                               MSG_SEC_DEBUG("Media Type is Text, but Vobject file [%s]", pMedia->szFilePath);
                                        } else {
-                                               MSG_DEBUG("Text path : [%s]", pMedia->szFilePath);
-                                               snprintf(textBuf, textBufSize, "%s", pMedia->szFilePath);//Set Text Filepath of First Pages
+                                               MSG_SEC_DEBUG("Text path : [%s]", pMedia->szFilePath);
+                                               snprintf(textBuf, textBufSize, "%s", pMedia->szFilePath); /* Set Text Filepath of First Pages */
                                        }
                                        break;
                                }
                        }
                }
+       } else {
+               /* (P151014-01246)
+                * Set filepath of the first text/plain attachment to display preview text on notification */
+               if (pMmsMsgData->attachlist) {
+                       GList *l = pMmsMsgData->attachlist;
+                       while (l) {
+                               MMS_ATTACH_S *attach = (MMS_ATTACH_S *)l->data;
+                               if (g_strcmp0(attach->szContentType, "text/plain") == 0) {
+                                       MSG_SEC_DEBUG("The first text filepath for multipart: (%s)", attach->szFilePath);
+                                       snprintf(textBuf, textBufSize, "%s", attach->szFilePath);
+                                       break;
+                               }
+
+                               l = g_list_next(l);
+                       }
+               }
        }
 
        return;
 }
 
 
-//FIXME::need to move AppBase
+/* FIXME::need to move AppBase */
 msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allow_malware, const char *raw_filepath)
 {
        MMS_PAGE_S *pPage = NULL;
@@ -118,9 +133,9 @@ msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allo
        if (pMmsMsg == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       MmsPluginStorage::instance()->removePreviewInfo(msgId); //remove exist previnfo
+       MmsPluginStorage::instance()->removePreviewInfo(msgId); /* remove exist previnfo */
 
-       //scan malware in raw file
+       /* scan malware in raw file */
        if (raw_filepath && strlen(raw_filepath) > 0 && MsgAccessFile(raw_filepath, F_OK) == true) {
                int tcs_ret = 0; // MmsPluginTcsScanFile(raw_filepath, &bc_level);
                if (tcs_ret == 0) {
@@ -131,17 +146,17 @@ msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allo
                }
        }
 
-       //check ref type and increase attach count
+       /* check ref type and increase attach count */
        if (pMmsMsg->pageCnt > 0) {
                for (int i = 0; i < pMmsMsg->pageCnt; i++) {
                        pPage = _MsgMmsGetPage(pMmsMsg, i);
                        if (pPage) {
                                for (int j = 0; j < pPage->mediaCnt; j++) {
                                        pMedia = _MsgMmsGetMedia(pPage, j);
-                                       if (pMedia) { //IF Vobject type add to Attach in Preview data
+                                       if (pMedia) { /* IF Vobject type add to Attach in Preview data */
 
                                                MimeType mimeType = MIME_UNKNOWN;
-                                               MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
+                                               MsgGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
                                                if (mimeType == MIME_TEXT_X_VCALENDAR || mimeType == MIME_TEXT_X_VCARD) {
 
                                                        MSG_DEBUG("Unsupported File [%s] It will be add to attach list", pMedia->szFilePath);
@@ -184,7 +199,7 @@ msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allo
                                        }
                                } else {
 
-                                       if (j == 0) { //First Page, First Media
+                                       if (j == 0) { /* First Page, First Media */
                                                MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_1ST_MEDIA, pMedia->szFilePath);
                                        }
 
@@ -196,7 +211,7 @@ msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allo
                                                memset(szFileName, 0x00, MSG_FILENAME_LEN_MAX+1);
                                                memset(thumbPath, 0x00, MSG_FILEPATH_LEN_MAX);
 
-                                               MSG_DEBUG("drm type = %d, %s", pMedia->drmType, pMedia->szFilePath);
+                                               MSG_SEC_DEBUG("drm type = %d, %s", pMedia->drmType, pMedia->szFilePath);
 
                                                if (pMedia->drmType == MSG_DRM_TYPE_NONE) {
 
@@ -208,7 +223,7 @@ msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allo
                                                                snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, "%s%s.jpg", MSG_THUMBNAIL_PATH, szFileName);
                                                        }
 
-                                                       if (MmsMakeImageThumbnail(pMedia->szFilePath, thumbPath) == true) {
+                                                       if (MakeThumbnail(pMedia->szFilePath, thumbPath) == true) {
                                                                if (pMedia->mediatype == MMS_SMIL_MEDIA_IMG) {
                                                                        MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_IMG, thumbPath);
                                                                } else {
@@ -223,7 +238,7 @@ msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allo
                                        }
                                }
                        }
-               } // end for
+               } /* end for */
        } else {
                MSG_DEBUG("There is no page");
        }
@@ -234,7 +249,7 @@ msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allo
                MMS_ATTACH_S *pAttach = _MsgMmsGetAttachment(pMmsMsg, 0);
 
                MmsPluginStorage::instance()->insertPreviewInfo(msgId, MSG_MMS_ITEM_TYPE_ATTACH, pAttach->szFileName, attachCnt);
-               MmsPluginStorage::instance()->updateMmsAttachCount(msgId, attachCnt); // for Get Message
+               MmsPluginStorage::instance()->updateMmsAttachCount(msgId, attachCnt); /* for Get Message */
 
                if (attachment_name == NULL) {
                        attachment_name = pAttach->szFileName;
index c8078d2..47610e1 100755 (executable)
@@ -17,7 +17,7 @@
 #include <ctype.h>
 #include "MmsPluginDebug.h"
 #include "MmsPluginCodecCommon.h"
-#include "MmsPluginMIME.h"
+#include "MsgUtilMime.h"
 #include "MmsPluginUtil.h"
 #include "MmsPluginTextConvert.h"
 
@@ -33,13 +33,12 @@ typedef struct {
 } MmsField;
 
 /* Reference : MMS-209-Encapsulation & WAP-203-WSP-20000504.pdf Table 39 */
-const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] =
-{
+const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] = {
        /* MMS Specific (MsgMmsMsg.h / MsgMmsUA.h) -----------------------*/
 
        /* MmsCodeFieldCode */
        {
-               {"Bcc", 0x01},                                                          //0
+               {"Bcc", 0x01},                                                          /* 0 */
                {"Cc", 0x02},
                {"X-Mms-Content-Location", 0x03},
                {"Content-Type", 0x04},
@@ -49,7 +48,7 @@ const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] =
                {"X-Mms-Expiry", 0x08},
                {"From", 0x09},
                {"X-Mms-Message-Class", 0x0A},
-               {"Message-ID", 0x0B},                                           // 10
+               {"Message-ID", 0x0B},                                           /* 10 */
                {"X-Mms-Message-Type", 0x0C},
                {"X-Mms-MMS-Version", 0x0D},
                {"X-Mms-Message-Size", 0x0E},
@@ -59,7 +58,7 @@ const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] =
                {"X-Mms-Response-Status", 0x12},
                {"X-Mms-Retrieve-Status", 0x19},                        /* Add by MMSENC v1.1 */
                {"X-Mms-Response-Text", 0x13},
-               {"X-Mms-Retrieve-Text", 0x1A},                          // 20   /* Add by MMSENC v1.1 */
+               {"X-Mms-Retrieve-Text", 0x1A},                          /* 20 */ /* Add by MMSENC v1.1 */
                {"X-Mms-Sender-Visibility", 0x14},
                {"X-Mms-Status", 0x15},
                {"Subject", 0x16},
@@ -69,7 +68,7 @@ const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] =
                /* Add by MMSENC v1.1 */
                {"X-Mms-Read-Status", 0x1B},
                {"X-Mms-Reply-Charging", 0x1C},
-               {"X-Mms-Reply-Charging-Deadline", 0x1D},        // 30
+               {"X-Mms-Reply-Charging-Deadline", 0x1D},        /* 30 */
                {"X-Mms-Reply-Charging-ID", 0x1E},
                {"X-Mms-Reply-Charging-Size", 0x1F},
                {"X-Mms-Previously-Sent-By", 0x20},
@@ -78,14 +77,14 @@ const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] =
 
        /* MmsCodeParameterCode ( By WSP Table 38. Wellknown parameter Assignments ) */
        {
-               {"Charset", 0x01},              // v1.1 base
-               {"Name", 0x05},                 // v1.1 base. 0x17 at v1.4
-               {"FileName", 0x06},             // v1.1 base. ox18 at v1.4
-               {"Type", 0x09},                 // v1.2 base
-               {"Start", 0x0A},                // v1.2 base. 0x19 at v1.4
-               {"Start-Info", 0x0B},   // v1.2 base. 0x1A at v1.4
-               {"boundary", 0xFF},             //laconic_javaParamFix
-               {"report-type", 0xFF},        // only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
+               {"Charset", 0x01},              /* v1.1 base */
+               {"Name", 0x05},                 /* v1.1 base. 0x17 at v1.4 */
+               {"FileName", 0x06},             /* v1.1 base. ox18 at v1.4 */
+               {"Type", 0x09},                 /* v1.2 base */
+               {"Start", 0x0A},                /* v1.2 base. 0x19 at v1.4 */
+               {"Start-Info", 0x0B},   /* v1.2 base. 0x1A at v1.4 */
+               {"boundary", 0xFF},             /* laconic_javaParamFix */
+               {"report-type", 0xFF},        /* only used as parameter of Content-Type: multipart/report; report-type=delivery-status; */
 #ifdef FEATURE_JAVA_MMS
                {"Application-ID", 0xFF},
                {"Reply-To-Application-ID", 0xFF},
@@ -94,11 +93,11 @@ const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] =
 
        /* MmsCodeMsgBodyHeaderCode ( By WSP Table 39. Header Field Name Assignments ) */
        {
-               {"Content-Transfer-Encoding", 0xFFFF},  // only text encoding, no binary number
-               {"Content-Disposition", 0x2E},                  // v1.1 base. 0x45 at v1.4
-               {"Content-ID", 0x40},                                   // v1.3 base
-               {"Content-Location", 0x0E},                             // v1.3 base
-               {"X-Oma-Drm-Separate-Delivery", 0xFF }, // DRM RO WAITING
+               {"Content-Transfer-Encoding", 0xFFFF},  /* only text encoding, no binary number */
+               {"Content-Disposition", 0x2E},                  /* v1.1 base. 0x45 at v1.4 */
+               {"Content-ID", 0x40},                                   /* v1.3 base */
+               {"Content-Location", 0x0E},                             /* v1.3 base */
+               {"X-Oma-Drm-Separate-Delivery", 0xFF }, /* DRM RO WAITING */
        },
 
        /* MmsCodeMsgType */
@@ -268,10 +267,10 @@ const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] =
        },
 
 
-//     OMNA WSP Content Type Numbers
-//     http://technical.openmobilealliance.org/tech/omna/omna-wsp-content-type.aspx
+/* OMNA WSP Content Type Numbers */
+/* http://technical.openmobilealliance.org/tech/omna/omna-wsp-content-type.aspx */
        {
-       //NOT USED THIS TABLE
+       /* NOT USED THIS TABLE */
        },
 
        /* MmsCodeMsgDisposition : Wsp Header (By Wsp 8.4.2.53) */
@@ -294,7 +293,7 @@ const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] =
 const char *MmsGetTextValue(MmsCode i, int j)
 {
        if (i == MmsCodeContentType) {
-               //apply UtyMime
+               /* apply UtyMime */
                return MimeGetMimeStringFromMimeInt(j);
        }
 
@@ -357,16 +356,14 @@ const char *MmsGetTextValuebyField(int field, int value)
 
 UINT16 MmsGetBinaryValue(MmsCode i, int j)
 {
-       if (i == MmsCodeContentType) {
+       if (i == MmsCodeContentType)
                return MimeGetBinaryValueFromMimeInt((MimeType)j);
-       }
 
        return gMmsField[i][j].binary;
 }
 
 int MmsGetBinaryType(MmsCode i, UINT16 value)
 {
-
        for (int j = 0; j < MMS_MAX_FIELD_VALUE_COUNT; j++) {
                if (gMmsField[i][j].binary == value) {
                        MSG_DEBUG("code [%d], value [0x%02x], ret type [%d]", i, value, j);
@@ -490,28 +487,28 @@ void *MsgDecodeBase64(unsigned char *pSrc, unsigned long srcLen, unsigned long *
                        }
                        continue;
                } else
-                       continue;                                       // Actually, never get here
+                       continue;                                       /* Actually, never get here */
 
                /* Pad 4*6bit character into 3*8bit character */
 
                switch (e++) {
                case 0:
-                       *d = c << 2;                    // byte 1: high 6 bits
+                       *d = c << 2;                    /* byte 1: high 6 bits */
                        break;
 
                case 1:
-                       *d++ |= c >> 4;                 // byte 1: low 2 bits
-                       *d = c << 4;                    // byte 2: high 4 bits
+                       *d++ |= c >> 4;                 /* byte 1: low 2 bits */
+                       *d = c << 4;                    /* byte 2: high 4 bits */
                        break;
 
                case 2:
-                       *d++ |= c >> 2;                 // byte 2: low 4 bits
-                       *d = c << 6;                    // byte 3: high 2 bits
+                       *d++ |= c >> 2;                 /* byte 2: low 4 bits */
+                       *d = c << 6;                    /* byte 3: high 2 bits */
                        break;
 
                case 3:
-                       *d++ |= c;                              // byte 3: low 6 bits
-                       e = 0;                                  // Calculate next unit.
+                       *d++ |= c;                              /* byte 3: low 6 bits */
+                       e = 0;                                  /* Calculate next unit. */
                        break;
 
                default:
@@ -520,7 +517,7 @@ void *MsgDecodeBase64(unsigned char *pSrc, unsigned long srcLen, unsigned long *
                }
        }
 
-       *len = d - (char *)ret;                 // Calculate the size of decoded string.
+       *len = d - (char *)ret;                 /* Calculate the size of decoded string. */
 
        return ret;
 }
@@ -649,10 +646,10 @@ bool MsgEncode2Base64(void *pSrc, unsigned long srcLen, unsigned long *len, unsi
 
        /* Convert 3*8bit into 4*6bit */
        for (i = 0; srcLen > 0; s += 3) {
-               *d++ = v[s[0] >> 2];                                                                                                                    // byte 1: high 6 bits of character-1
-               *d++ = v[((s[0] << 4) + (--srcLen ? (s[1] >> 4) : 0)) & 0x3f];                                  // byte 2: low 2 bits of character-1 and high 4 bits of character-2
-               *d++ = srcLen ? v[((s[1] << 2) + (--srcLen ? (s[2] >> 6) : 0)) & 0x3f] : '=';   // byte 3: low 4 bits of charcter-2 and high 2 bits of character-3
-               *d++ = srcLen ? v[s[2] & 0x3f] : '=';                                                                                   // byte 4: low 6 bits of character-3
+               *d++ = v[s[0] >> 2];                                                                                                                    /* byte 1: high 6 bits of character-1 */
+               *d++ = v[((s[0] << 4) + (--srcLen ? (s[1] >> 4) : 0)) & 0x3f];                                  /* byte 2: low 2 bits of character-1 and high 4 bits of character-2 */
+               *d++ = srcLen ? v[((s[1] << 2) + (--srcLen ? (s[2] >> 6) : 0)) & 0x3f] : '=';   /* byte 3: low 4 bits of charcter-2 and high 2 bits of character-3 */
+               *d++ = srcLen ? v[s[2] & 0x3f] : '=';                                                                                   /* byte 4: low 6 bits of character-3 */
 
                if (srcLen)
                        srcLen--;
@@ -689,13 +686,13 @@ int extract_encoded_word_param(char *encoded_word, char **charset,  char **encod
 
        start_ptr = encoded_word;
 
-       if ( (encoded_word[0] == '=' && encoded_word[1] == '?') //"=?"
-                        && ((q1_ptr = strchr(start_ptr + 2, MSG_CH_QUESTION)) != NULL) // '?'
-                        && ((q2_ptr = strchr(q1_ptr + 1, MSG_CH_QUESTION))!= NULL)             // '?'
-                        && ((end_ptr = strstr(q2_ptr + 1, MSG_STR_DEC_END))!= NULL)) //"?="
+       if ( (encoded_word[0] == '=' && encoded_word[1] == '?') /* "=?" */
+                        && ((q1_ptr = strchr(start_ptr + 2, MSG_CH_QUESTION)) != NULL) /* '?' */
+                        && ((q2_ptr = strchr(q1_ptr + 1, MSG_CH_QUESTION))!= NULL)             /* '?' */
+                        && ((end_ptr = strstr(q2_ptr + 1, MSG_STR_DEC_END))!= NULL)) /* "?=" */
        {
 
-               //extract character set
+               /* extract character set */
                if ( q1_ptr - (start_ptr + 2) > 0 ) {
 
                        char_set = (char*)calloc(1, q1_ptr - (start_ptr + 2) + 1);
@@ -712,7 +709,7 @@ int extract_encoded_word_param(char *encoded_word, char **charset,  char **encod
                        goto __CATCH;
                }
 
-               //extract encode type
+               /* extract encode type */
                if ((*(q2_ptr - 1) == MSG_CH_BASE64_UPPER) || (*(q2_ptr - 1) == MSG_CH_BASE64_LOWER)
                                || (*(q1_ptr + 1) == MSG_CH_BASE64_UPPER) || (*(q1_ptr + 1) == MSG_CH_BASE64_LOWER))
                {
@@ -720,7 +717,7 @@ int extract_encoded_word_param(char *encoded_word, char **charset,  char **encod
                } else if ((*(q2_ptr-1) == MSG_CH_QPRINT_UPPER) || (*(q2_ptr-1) == MSG_CH_QPRINT_LOWER)
                                || (*(q1_ptr+1) == MSG_CH_QPRINT_UPPER) || (*(q1_ptr+1) == MSG_CH_QPRINT_LOWER))
                {
-                       //QPRINT
+                       /* QPRINT */
                        l_encoding[0] = MSG_CH_QPRINT_UPPER;
 
                } else {
@@ -728,7 +725,7 @@ int extract_encoded_word_param(char *encoded_word, char **charset,  char **encod
                        goto __CATCH;
                }
 
-               //extract encoded text
+               /* extract encoded text */
                if (end_ptr - q2_ptr > 1) {
                        l_encoded_text = (char*)calloc(1, end_ptr - q2_ptr);
                        if (l_encoded_text == NULL)
@@ -782,7 +779,7 @@ char *MsgDecodeText(const char *pOri)
        unsigned int total_len = 0;
        unsigned int decoded_len = 0;
 
-       // copy original string
+       /* copy original string */
        if (pOri == NULL || strlen(pOri) <= 0) {
                MSG_DEBUG("Invalid parameter : [%s]", pOri);
                return NULL;
@@ -801,7 +798,7 @@ char *MsgDecodeText(const char *pOri)
 
                b_encoded_word = false;
 
-               //Find encoded word
+               /* Find encoded word */
                while (b_encoded_word == false && encoded_word_start_ptr != NULL ) {
 
                        if (extract_encoded_word_param(encoded_word_start_ptr, &charset, &encoding, &encoded_text, &encoded_word_size) == 0) {
@@ -818,13 +815,13 @@ char *MsgDecodeText(const char *pOri)
                                encoded_word_size = 0;
                        }
 
-                       encoded_word_start_ptr = strstr(encoded_word_start_ptr+1, MSG_STR_DEC_START); //find next encoded_start_ptr
+                       encoded_word_start_ptr = strstr(encoded_word_start_ptr+1, MSG_STR_DEC_START); /* find next encoded_start_ptr */
 
-               } // end of while
+               } /* end of while */
 
                if (b_encoded_word) {
 
-                       //copy normal text
+                       /* copy normal text */
                        if (encoded_word_start_ptr - normal_word_start_ptr > 0) {
                                result_string.append(normal_word_start_ptr, encoded_word_start_ptr - normal_word_start_ptr);
                                MSG_DEBUG("copy normal text : [%s]", result_string.c_str());
@@ -847,7 +844,7 @@ char *MsgDecodeText(const char *pOri)
                                                MSG_DEBUG("MmsPluginTextConvert Fail");
                                        }
 
-                                       if(result_text) {
+                                       if (result_text) {
                                                MSG_DEBUG("Text convert result [%s][%d]", result_text, strlen(result_text));
 
                                                result_string.append(result_text, result_text_len);
@@ -878,7 +875,7 @@ char *MsgDecodeText(const char *pOri)
                                                MSG_DEBUG("MmsPluginTextConvert Fail");
                                        }
 
-                                       if(result_text) {
+                                       if (result_text) {
                                                MSG_DEBUG("Text convert result [%s][%d]", result_text, strlen(result_text));
 
                                                result_string.append(result_text, result_text_len);
@@ -893,7 +890,7 @@ char *MsgDecodeText(const char *pOri)
                                MSG_FREE(decoded_text);
                        }
 
-                       normal_word_start_ptr = encoded_word_start_ptr+encoded_word_size; //next
+                       normal_word_start_ptr = encoded_word_start_ptr+encoded_word_size; /* next */
 
                        MSG_FREE(charset);
                        MSG_FREE(encoding);
@@ -901,7 +898,7 @@ char *MsgDecodeText(const char *pOri)
                        encoded_word_size = 0;
 
                } else {
-                       //copy remain normal text
+                       /* copy remain normal text */
 
                        MSG_DEBUG("last text : [%s]", normal_word_start_ptr);
 
@@ -910,7 +907,7 @@ char *MsgDecodeText(const char *pOri)
                        break;
                }
 
-       } //end of while
+       } /* end of while */
 
        if (result_string.length() > 0) {
                return_string = g_strdup(result_string.c_str());
@@ -1102,6 +1099,10 @@ const char *MmsDebugGetMimeType(MimeType mimeType)
                return "MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE";
        case MIME_AUDIO_X_WAV:
                return "MIME_AUDIO_X_WAV";
+       case MIME_AUDIO_MOBILE_XMF:
+               return "MIME_AUDIO_MOBILE_XMF";
+       case MIME_AUDIO_OGG:
+               return "MIME_AUDIO_OGG";
 
        case MIME_IMAGE_GIF:
                return "MIME_IMAGE_GIF";
@@ -1478,6 +1479,7 @@ bool MmsInitMsgType(MsgType *pMsgType)
        pMsgType->szOrgFilePath[0] = '\0';
        pMsgType->szContentID[0] = '\0';
        pMsgType->szContentLocation[0] = '\0';
+       pMsgType->szLocation[0] = '\0';
 
        MmsInitMsgContentParam(&pMsgType->param);
        MmsInitMsgDRMInfo(&pMsgType->drmInfo);
@@ -1511,7 +1513,7 @@ bool MmsInitMsgContentParam(MsgContentParam *pMsgContentParam)
        pMsgContentParam->szStart[0] = '\0';
        pMsgContentParam->szStartInfo[0] = '\0';
        pMsgContentParam->pPresentation = NULL;
-       pMsgContentParam->reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; // only used as parameter of Content-Type: multipart/report; report-type
+       pMsgContentParam->reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; /* only used as parameter of Content-Type: multipart/report; report-type */
 #ifdef FEATURE_JAVA_MMS
        pMsgContentParam->szApplicationID = NULL;
        pMsgContentParam->szReplyToApplicationID = NULL;
@@ -1660,7 +1662,7 @@ bool MmsReleaseMmsAttrib(MmsAttrib *pAttrib)
                pAttrib->szBcc = NULL;
        }
 
-       //check if pMultiStatus should be freed or not, because pMultiStatus is not allocated
+       /* check if pMultiStatus should be freed or not, because pMultiStatus is not allocated */
        if (pAttrib->pMultiStatus) {
                MmsMsgMultiStatus *pMultiStatus = pAttrib->pMultiStatus;
                MmsMsgMultiStatus *pCurStatus = NULL;
@@ -1678,7 +1680,6 @@ bool MmsReleaseMmsAttrib(MmsAttrib *pAttrib)
                pAttrib->pMultiStatus = NULL;
        }
 
-
        MSG_END();
 
        return true;
@@ -1704,49 +1705,47 @@ bool MmsReleaseMsgBody(MsgBody *pBody, int type)
        case MIME_MULTIPART_MIXED:
        case MIME_MULTIPART_RELATED:
        case MIME_MULTIPART_ALTERNATIVE:
-       case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE:
-               {
-                       MsgMultipart *pMulti = pBody->body.pMultipart;
-                       MsgMultipart *pCurrPart = NULL;
-                       MsgBody *pPresentation = pBody->pPresentationBody;
-                       while (pMulti != NULL) {
-                               pCurrPart = pMulti;
-
-                               pMulti = pMulti->pNext;
-
-                               if (pCurrPart) {
-                                       MmsReleaseMsgDRMInfo(&pCurrPart->type.drmInfo);
-
-                                       if (pCurrPart->pBody) {
-                                               if (pCurrPart->pBody->body.pText) {
-                                                       free(pCurrPart->pBody->body.pText);
-                                                       pCurrPart->pBody->body.pText = NULL;
-                                               }
-
-                                               free(pCurrPart->pBody);
-                                               pCurrPart->pBody = NULL;
+       case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE: {
+               MsgMultipart *pMulti = pBody->body.pMultipart;
+               MsgMultipart *pCurrPart = NULL;
+               MsgBody *pPresentation = pBody->pPresentationBody;
+               while (pMulti != NULL) {
+                       pCurrPart = pMulti;
+
+                       pMulti = pMulti->pNext;
+
+                       if (pCurrPart) {
+                               MmsReleaseMsgDRMInfo(&pCurrPart->type.drmInfo);
+
+                               if (pCurrPart->pBody) {
+                                       if (pCurrPart->pBody->body.pText) {
+                                               free(pCurrPart->pBody->body.pText);
+                                               pCurrPart->pBody->body.pText = NULL;
                                        }
-                                       free(pCurrPart);
-                                       pCurrPart = NULL;
-                               }
-                       }
 
-                       pBody->body.pMultipart = NULL;
-
-                       if (pPresentation) {
-                               if (pPresentation->body.pText) {
-                                       free(pPresentation->body.pText);
-                                       pPresentation->body.pText = NULL;
+                                       free(pCurrPart->pBody);
+                                       pCurrPart->pBody = NULL;
                                }
-                               free(pPresentation);
-                               pBody->pPresentationBody = NULL;
+                               free(pCurrPart);
+                               pCurrPart = NULL;
                        }
+               }
 
-                       MmsInitMsgType(&pBody->presentationType);
+               pBody->body.pMultipart = NULL;
 
-                       break;
+               if (pPresentation) {
+                       if (pPresentation->body.pText) {
+                               free(pPresentation->body.pText);
+                               pPresentation->body.pText = NULL;
+                       }
+                       free(pPresentation);
+                       pBody->pPresentationBody = NULL;
                }
 
+               MmsInitMsgType(&pBody->presentationType);
+
+               break;
+       }
        default:
                /* Any single part */
                if (pBody->body.pText) {
@@ -1831,16 +1830,16 @@ bool MmsIsVitemContent(int type, char *pszName)
        switch (type) {
        case MIME_TEXT_X_VCARD:
        case MIME_TEXT_X_VCALENDAR:
-       case MIME_TEXT_X_VNOTE: // vnt
+       case MIME_TEXT_X_VNOTE: /* vnt */
        case MIME_TEXT_X_VTODO:
-       case MIME_TEXT_PLAIN:   // vbm - It SHOULD be distinguished from a normal text file.
+       case MIME_TEXT_PLAIN:   /* vbm - It SHOULD be distinguished from a normal text file. */
        {
                char *pszExt = NULL;
 
                if (!pszName)
                        break;
 
-               // search file extension.
+               /* search file extension. */
                if ((pszExt = strrchr(pszName, '.')) == NULL)
                        break;
 
index dea1b2f..555b8ef 100755 (executable)
 #include "MmsPluginTypes.h"
 #include "MmsPluginDebug.h"
 #include "MmsPluginMessage.h"
-#include "MmsPluginMIME.h"
+#include "MsgUtilMime.h"
 #include "MmsPluginStorage.h"
 #include "MmsPluginUtil.h"
-#include "MmsPluginTcs.h"
 #include "MsgSmil.h"
 
 
@@ -60,13 +59,13 @@ void MmsPluginComposer::composeSendReq(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDING
 
        if (pMsgInfo->msgType.subType == MSG_SENDREQ_MMS) {
 
-               if (pMmsData->header == NULL) {//send req from user
+               if (pMmsData->header == NULL) { /* send req from user */
                        pMmsData->header = MsgMmsCreateHeader();
                }
 
                if (pMmsData->header) {
                        composeSendReqHeader(pMsgInfo, pSendOptInfo, pMmsData);
-                       //TODO:: apply MmsReplaceNonAsciiUtf8 to all multipart FileName;
+                       /* TODO:: apply MmsReplaceNonAsciiUtf8 to all multipart FileName; */
                }
 
                int len = g_list_length(pMmsData->multipartlist);
@@ -77,12 +76,17 @@ void MmsPluginComposer::composeSendReq(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDING
 
                        if (multipart) {
                                if (multipart->type == MIME_UNKNOWN && strlen(multipart->szContentType) == 0) {
+                                       MimeMainType mainType;
+
+                                       if (!MsgGetMainTypeFromMetaData(multipart->szFilePath, &mainType))
+                                               mainType = MIME_MAINTYPE_UNKNOWN;
+
                                        const char *content_type = NULL;
-                                       MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, multipart->szFileName, &multipart->type, &content_type);
+                                       MsgGetMimeTypeFromFileName(mainType, multipart->szFileName, &multipart->type, &content_type);
                                        snprintf(multipart->szContentType, sizeof(multipart->szContentType), "%s", content_type);
                                }
                        }
-               } //end for
+               } /* end for */
        }
 }
 
@@ -96,7 +100,7 @@ MMSList *getAddressList(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType)
 
        nAddressCnt = pMsgInfo->nAddressCnt;
 
-       // Calculate allocated buffer size
+       /* Calculate allocated buffer size */
        for (int i = 0; i < nAddressCnt; ++i) {
 
                MSG_SEC_DEBUG("recipientType: %d, address value: %s", pMsgInfo->addressList[i].recipientType, pMsgInfo->addressList[i].addressVal);
@@ -112,7 +116,7 @@ MMSList *getAddressList(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType)
                        } else if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_EMAIL) {
                                pAddressData = MsgMmsCreateAddress(MSG_ADDRESS_TYPE_EMAIL, pMsgInfo->addressList[i].addressVal);
                        } else
-                               ; // Need to consider IPV4, IPV6, and Alias formatted address
+                               ; /* Need to consider IPV4, IPV6, and Alias formatted address */
 
                        if (pAddressData)
                                addressList = g_list_append(addressList, pAddressData);
@@ -180,7 +184,7 @@ bool composeSendReqHeader(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *p
 
                msgClass = (MmsMsgClass)MsgSettingGetInt(MMS_SEND_MSG_CLASS);
 
-               //set Header
+               /* set Header */
                time(&RawTime);
                localtime_r(&RawTime, &timeInfo);
                nTimeInSecs = mktime(&timeInfo);
@@ -214,12 +218,10 @@ bool composeSendReqHeader(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *p
 
        snprintf(pHeaderData->szSubject, sizeof(pHeaderData->szSubject), "%s", pMsgInfo->subject);
 
-       //setting adddress
+       /* setting adddress */
        pHeaderData->to = getAddressList(pMsgInfo, MSG_RECIPIENTS_TYPE_TO);
        pHeaderData->cc = getAddressList(pMsgInfo, MSG_RECIPIENTS_TYPE_CC);
        pHeaderData->bcc = getAddressList(pMsgInfo, MSG_RECIPIENTS_TYPE_BCC);
 
-       //snprintf(pHeaderData->szFrom, sizeof(pHeaderData->szFrom), "%s", pMmsMsg->mmsAttrib.szFrom);
-
        return true;
 }
index bb02aa6..80039b5 100755 (executable)
@@ -415,6 +415,7 @@ MmsPluginCmAgent::MmsPluginCmAgent()
        home_url = NULL;
        interface_name = NULL;
        proxy_address = NULL;
+       dns_address_list = NULL;
        MSG_END();
 }
 
@@ -423,6 +424,7 @@ MmsPluginCmAgent::~MmsPluginCmAgent()
        MSG_FREE(home_url);
        MSG_FREE(interface_name);
        MSG_FREE(proxy_address);
+       MSG_FREE(dns_address_list);
 }
 
 bool MmsPluginCmAgent::open()
@@ -434,7 +436,7 @@ bool MmsPluginCmAgent::open()
        int time_ret = 0;
        lock();
 
-       //create connection
+       /* create connection */
        context_invoke(__connection_create, &bConnection);
 
        if (bConnection == false || g_connection == NULL) {
@@ -444,8 +446,8 @@ bool MmsPluginCmAgent::open()
 
        if (g_profile) {
                MSG_WARN("connection profile already exist");
-               //TODO:: get data;
-               //goto __RETURN;
+               /* TODO:: get data; */
+               /* goto __RETURN; */
        }
 
        waitProfileOpen = true;
@@ -459,10 +461,7 @@ bool MmsPluginCmAgent::open()
 
        MSG_INFO("## WAITING UNTIL __connection_profile_state CONNECT. ##");
 
-//     cv.wait(mx.pMutex());
-//     MSG_INFO("## WAKE by SIGNAL ##");
-
-       time_ret = cv.timedwait(mx.pMutex(), MMS_CONNECTION_API_WAIT_TIME); // isCmOpened will changed by processCBdatas
+       time_ret = cv.timedwait(mx.pMutex(), MMS_CONNECTION_API_WAIT_TIME); /* isCmOpened will changed by processCBdatas */
 
        if (time_ret == ETIMEDOUT) {
                MSG_WARN("## WAKE by timeout ##");
@@ -470,12 +469,12 @@ bool MmsPluginCmAgent::open()
                MSG_INFO("## WAKE by SIGNAL ##");
        }
 
-       if(isCmOpened == false) {
+       if (isCmOpened == false) {
                MSG_WARN("");
                goto __ERR_RETURN;
        }
 
-//__RETURN:
+/* __RETURN: */
        unlock();
        MSG_END();
        return isCmOpened;
@@ -533,13 +532,14 @@ __RETURN:
        MSG_FREE(this->home_url);
        MSG_FREE(this->interface_name);
        MSG_FREE(this->proxy_address);
+       MSG_FREE(this->dns_address_list);
 
        unlock();
 
        MSG_END();
 }
 
-//profile open callback
+/* profile open callback */
 void MmsPluginCmAgent::connection_profile_open_callback(connection_error_e result, void* user_data)
 {
        lock();
@@ -573,6 +573,7 @@ void MmsPluginCmAgent::connection_profile_open_callback(connection_error_e resul
                        MSG_FREE(this->home_url);
                        MSG_FREE(this->interface_name);
                        MSG_FREE(this->proxy_address);
+                       MSG_FREE(this->dns_address_list);
 
                        err = connection_profile_get_cellular_home_url(profile, &this->home_url);
                        if (err != CONNECTION_ERROR_NONE) {
@@ -591,10 +592,10 @@ void MmsPluginCmAgent::connection_profile_open_callback(connection_error_e resul
 
                        isCmOpened = true;
 
-                       goto __SIGNAL_RETURN; //open success
+                       goto __SIGNAL_RETURN; /* open success */
 
                } else {
-                       goto __NO_SIGNAL_RETURN; //Just open success
+                       goto __NO_SIGNAL_RETURN; /* Just open success */
                }
 
        } else {
@@ -604,17 +605,17 @@ void MmsPluginCmAgent::connection_profile_open_callback(connection_error_e resul
 
        }
 
-__NO_SIGNAL_RETURN: //Just Open
+__NO_SIGNAL_RETURN: /* Just Open */
        if (profile)
                connection_profile_destroy(profile);
        unlock();
        return;
 
-__SIGNAL_RETURN: //Error or Already connected
+__SIGNAL_RETURN: /* Error or Already connected */
        if (profile)
                connection_profile_destroy(profile);
 
-       if (waitProfileOpen == true) {//open fail
+       if (waitProfileOpen == true) { /* open fail */
                waitProfileOpen = false;
                MSG_INFO("## SIGNAL ##");
                signal();
@@ -669,6 +670,7 @@ void MmsPluginCmAgent::connection_profile_state_changed_cb(connection_profile_st
                MSG_FREE(this->home_url);
                MSG_FREE(this->interface_name);
                MSG_FREE(this->proxy_address);
+               MSG_FREE(this->dns_address_list);
 
                err = connection_profile_get_cellular_home_url(profile, &this->home_url);
                if (err != CONNECTION_ERROR_NONE) {
@@ -693,7 +695,7 @@ __NO_SIGNAL_RETURN://Default
        unlock();
        return;
 
-__SIGNAL_RETURN: //Error or connected
+__SIGNAL_RETURN: /* Error or connected */
        if (profile)
                connection_profile_destroy(profile);
 
@@ -745,3 +747,17 @@ bool MmsPluginCmAgent::getProxyAddr(const char **proxyAddr)
 
        return true;
 }
+
+
+bool MmsPluginCmAgent::getDnsAddrList(const char **dnsAddrList)
+{
+       if (!isCmOpened)
+               return false;
+
+       if (dnsAddrList == NULL)
+               return false;
+
+       *dnsAddrList = dns_address_list;
+
+       return true;
+}
index d204d11..73c0f85 100755 (executable)
@@ -21,6 +21,7 @@
 #include <errno.h>
 
 #include "MsgUtilFile.h"
+#include "MsgUtilMime.h"
 #include "MsgSmil.h"
 #include "MsgMmsMessage.h"
 
@@ -29,7 +30,6 @@
 #include "MmsPluginCodecCommon.h"
 #include "MmsPluginStorage.h"
 #include "MmsPluginDebug.h"
-#include "MmsPluginMIME.h"
 #include "MmsPluginTextConvert.h"
 #include "MmsPluginUtil.h"
 
@@ -73,7 +73,7 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
 static int __MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength);
 
 
-//util funcion
+/* util funcion */
 static void __MsgRemoveFilePath(char *pSrc);
 static bool __MsgChangeSpace(char *pOrg, char **ppNew);
 static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresentaionInfo *pPresentationInfo);
@@ -90,7 +90,7 @@ static char *__MsgSkipComment(char *s, long trim);
 
 static char *__MsgConvertLatin2UTF8FileName(char *pSrc);
 
-//static bool __MsgIsPercentSign(char *pSrc);
+/* static bool __MsgIsPercentSign(char *pSrc); */
 static bool __MsgIsMultipartRelated(int type);
 static bool __MsgIsPresentablePart(int type);
 static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody);
@@ -129,57 +129,56 @@ __thread char *gpMmsDecodeBuf2 = NULL;
 
 __thread MmsHeader mmsHeader =
 {
-       (MmsMsgType)MMS_MSGTYPE_ERROR,                  //MmsMsgType                    iType;
-       "",                                                                             //char[]                                szTrID;
-       //"",                                                                           //short int                             version;
-       0,                                                                              //short int                             version;
-       0,                                                                              //UINT32                                date;
-
-       NULL,                                                                   //MsgHeaderAddress*             pFrom;
-       NULL,                                                                   //MsgHeaderAddress*             pTo;
-       NULL,                                                                   //MsgHeaderAddress*             pCc;
-       NULL,                                                                   //MsgHeaderAddress*             pBcc;
-       "",                                                                             //char[]                                szSubject;
-       (MmsResponseStatus)MMS_RESPSTATUS_OK,   //MmsResponseStatus             iResponseStatus;
-       (MmsRetrieveStatus)MMS_RETRSTATUS_OK,   //MmsRetrieveStatus             iRetrieveStatus;
-       "",                                                                             //char[]                                szResponseText;
-       "",                                                                             //char[]                                szRetrieveText;
+       (MmsMsgType)MMS_MSGTYPE_ERROR,                  /* MmsMsgType                   iType; */
+       "",                                                                             /* char[]                               szTrID; */
+       0,                                                                              /* short int                            version; */
+       0,                                                                              /* UINT32                               date; */
+
+       NULL,                                                                   /* MsgHeaderAddress*            pFrom; */
+       NULL,                                                                   /* MsgHeaderAddress*            pTo; */
+       NULL,                                                                   /* MsgHeaderAddress*            pCc; */
+       NULL,                                                                   /* MsgHeaderAddress*            pBcc; */
+       "",                                                                             /* char[]                               szSubject; */
+       (MmsResponseStatus)MMS_RESPSTATUS_OK,   /* MmsResponseStatus            iResponseStatus; */
+       (MmsRetrieveStatus)MMS_RETRSTATUS_OK,   /* MmsRetrieveStatus            iRetrieveStatus; */
+       "",                                                                             /* char[]                               szResponseText; */
+       "",                                                                             /* char[]                               szRetrieveText; */
 
 
        /* has default value in specification */
 
-       (MmsMsgClass)MMS_MSGCLASS_PERSONAL,             //MmsMsgClass                   msgClass;
-       {MMS_TIMETYPE_RELATIVE, 0},                             //MmsTimeStruct                 expiryTime;
-       {MMS_TIMETYPE_RELATIVE, 0},                             //MmsTimeStruct                 deliveryTime;
-       (MmsPriority)MMS_PRIORITY_NORMAL,               //MmsPriority                   priority;               // Refer [OMA-MMS-ENC-v1_2-20030915-C]
-       (MmsSenderVisible)MMS_SENDER_SHOW,              //MmsSenderVisible              senderVisible;
-       (MmsReport)MMS_REPORT_NO,                               //MmsReport                             deliveryReport;
-       (MmsReport)MMS_REPORT_NO,                               //MmsReport                             readReply;
-       (MmsReportAllowed)MMS_REPORTALLOWED_NO,//MmsReportAllowed               iReportAllowed;
-       "",                                                                             //char[]                                szContentLocation;
+       (MmsMsgClass)MMS_MSGCLASS_PERSONAL,             /* MmsMsgClass                  msgClass; */
+       {MMS_TIMETYPE_RELATIVE, 0},                             /* MmsTimeStruct                        expiryTime; */
+       {MMS_TIMETYPE_RELATIVE, 0},                             /* MmsTimeStruct                        deliveryTime; */
+       (MmsPriority)MMS_PRIORITY_NORMAL,               /* MmsPriority                  priority; */ /* Refer [OMA-MMS-ENC-v1_2-20030915-C] */
+       (MmsSenderVisible)MMS_SENDER_SHOW,              /* MmsSenderVisible             senderVisible; */
+       (MmsReport)MMS_REPORT_NO,                               /* MmsReport                            deliveryReport; */
+       (MmsReport)MMS_REPORT_NO,                               /* MmsReport                            readReply; */
+       (MmsReportAllowed)MMS_REPORTALLOWED_NO, /* MmsReportAllowed             iReportAllowed; */
+       "",                                                                             /* char[]                               szContentLocation; */
 
 
        /* there is no right default value */
 
-       (msg_delivery_report_status_t)MSG_DELIVERY_REPORT_NONE,         //MmsMsgStatus                  iMsgStatus;
-       (msg_read_report_status_t)MSG_READ_REPORT_NONE,         //MmsReadStatus                 readStatus;
+       (msg_delivery_report_status_t)MSG_DELIVERY_REPORT_NONE,         /* MmsMsgStatus                 iMsgStatus; */
+       (msg_read_report_status_t)MSG_READ_REPORT_NONE,         /* MmsReadStatus                        readStatus; */
 
        /* MMS v1.1 ReplyCharge */
        {
-               (MmsReplyChargeType)MMS_REPLY_NONE,     //MmsReplyChargeType    chargeType;
-               {MMS_TIMETYPE_RELATIVE, 0},                     //MmsTimeStruct                 deadLine;
-               0,                                                                      //int                                   chargeSize;
-               "" ,                                                            //char                                  szChargeID;
+               (MmsReplyChargeType)MMS_REPLY_NONE,     /* MmsReplyChargeType   chargeType; */
+               {MMS_TIMETYPE_RELATIVE, 0},                     /* MmsTimeStruct                        deadLine; */
+               0,                                                                      /* int                                  chargeSize; */
+               "" ,                                                            /* char                                 szChargeID; */
        },
 
-       "",                                                                             //char[]                                szMsgID;
-       0,                                                                              //UINT32                                msgSize;
+       "",                                                                             /* char[]                               szMsgID; */
+       0,                                                                              /* UINT32                               msgSize; */
 };
 
 #define        MMS_DRM2_CONVERT_BUFFER_MAX     4*1024
-const UINT32 MMS_UINTVAR_LENGTH_1 =  0x0000007f;               //7bit
-const UINT32 MMS_UINTVAR_LENGTH_2 =  0x00003fff;               //14bit
-const UINT32 MMS_UINTVAR_LENGTH_3 =  0x001fffff;               //21bit
+const UINT32 MMS_UINTVAR_LENGTH_1 =  0x0000007f;               /* 7bit */
+const UINT32 MMS_UINTVAR_LENGTH_2 =  0x00003fff;               /* 14bit */
+const UINT32 MMS_UINTVAR_LENGTH_3 =  0x001fffff;               /* 21bit */
 
 static bool __MmsDecodeInitialize(void)
 {
@@ -219,7 +218,7 @@ void MmsInitHeader()
        mmsHeader.expiryTime.time = 0;
        mmsHeader.deliveryTime.type     = MMS_TIMETYPE_RELATIVE;
        mmsHeader.deliveryTime.time     = 0;
-       mmsHeader.priority = (MmsPriority)MMS_PRIORITY_NORMAL;  // Refer [OMA-MMS-ENC-v1_2-20030915-C]
+       mmsHeader.priority = (MmsPriority)MMS_PRIORITY_NORMAL;  /* Refer [OMA-MMS-ENC-v1_2-20030915-C] */
        mmsHeader.hideAddress =(MmsSenderVisible)MMS_SENDER_SHOW;
        mmsHeader.deliveryReport = (MmsReport)MMS_REPORT_NO;
        mmsHeader.readReply = (MmsReport)MMS_REPORT_NO;
@@ -384,8 +383,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                fieldCode = oneByte & 0x7f;
 
                switch (MmsGetBinaryType(MmsCodeFieldCode, fieldCode)) {
-               case MMS_CODE_RESPONSESTATUS:
-               {
+               case MMS_CODE_RESPONSESTATUS: {
                        MmsResponseStatus resposeStatus = MMS_RESPSTATUS_ERROR;
 
                        if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
@@ -395,8 +393,8 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
 
                        fieldValue = oneByte;
 
-                       // range 197 to 223 as it does to the value 192 (Error-transient-failure).
-                       // range 236 to 255 as it does to the value 224 (Error-permanent-failure).
+                       /* range 197 to 223 as it does to the value 192 (Error-transient-failure). */
+                       /* range 236 to 255 as it does to the value 224 (Error-permanent-failure). */
                        if (fieldValue >= 197 && fieldValue <= 223) {
                                fieldValue = 192;
                        } else if (fieldValue >= 236 && fieldValue <= 255) {
@@ -410,8 +408,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                        MSG_SEC_INFO("X-Mms-Response-Status = [0x%02x][0x%02x][%s]", oneByte, fieldValue, MmsDebugGetResponseStatus(mmsHeader.responseStatus));
                        break;
                }
-               case MMS_CODE_RETRIEVESTATUS:
-               {
+               case MMS_CODE_RETRIEVESTATUS: {
                        MmsRetrieveStatus RetrieveStatus = MMS_RETRSTATUS_ERROR;
 
                        if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
@@ -421,12 +418,12 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
 
                        fieldValue = oneByte;
 
-                       //195 to 223 as it does to the value 192 (Error-transient-failure).
-                       //228 to 255 as it does to the value 224 (Error-permanent-failure).
+                       /* 195 to 223 as it does to the value 192 (Error-transient-failure). */
+                       /* 228 to 255 as it does to the value 224 (Error-permanent-failure). */
                        if (fieldValue >= 195 && fieldValue <= 223) {
-                               fieldValue = 192; // 192; Error-transient-failure
+                               fieldValue = 192; /* 192; Error-transient-failure */
                        } else if (fieldValue >= 228 && fieldValue <= 255) {
-                               fieldValue = 224; //224; Error-permanent-failure
+                               fieldValue = 224; /* 224; Error-permanent-failure */
                        }
 
                        RetrieveStatus = (MmsRetrieveStatus)MmsGetBinaryType(MmsCodeRetrieveStatus, (UINT16)(fieldValue & 0x7F));
@@ -518,7 +515,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                goto __CATCH;
                        }
 
-                       // DRM_TEMPLATE - start
+                       /* DRM_TEMPLATE - start */
 
                        valueLength--;
 
@@ -546,7 +543,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                }
 
                                MSG_SEC_INFO("From = [%s]", mmsHeader.pFrom->szAddr);
-                               // DRM_TEMPLATE - end
+                               /* DRM_TEMPLATE - end */
                        } else if (oneByte == (MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN)|0x80)) {
                                /* Present Token only */
                                MSG_SEC_INFO("From = [insert token]");
@@ -669,7 +666,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                goto __CATCH;
                        }
 
-                       //DRM_TEMPLATE - start
+                       /* DRM_TEMPLATE - start */
                        valueLength--;
 
                        if (oneByte == (MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) {
@@ -681,7 +678,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                                goto __CATCH;
                                        }
                                }
-                       // DRM_TEMPLATE - end
+                       /* DRM_TEMPLATE - end */
                        } else {
                                mmsHeader.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
 
@@ -707,7 +704,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                goto __CATCH;
                        }
 
-                       // DRM_TEMPLATE - start
+                       /* DRM_TEMPLATE - start */
                        valueLength--;
 
                        if (oneByte == (MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) {
@@ -719,7 +716,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                                goto __CATCH;
                                        }
                                }
-                       // DRM_TEMPLATE - end
+                       /* DRM_TEMPLATE - end */
                        } else {
                                mmsHeader.expiryTime.type = MMS_TIMETYPE_RELATIVE;
 
@@ -903,7 +900,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                mmsHeader.replyCharge.deadLine.type = MMS_TIMETYPE_RELATIVE;
                        }
 
-                       // DRM_TEMPLATE - start
+                       /* DRM_TEMPLATE - start */
                        valueLength--;
 
                        if (valueLength > 0) {
@@ -914,7 +911,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                        }
 
                        MSG_SEC_INFO("X-Mms-Reply-Charging-Deadline : type = [%d], time = [%u]", mmsHeader.replyCharge.deadLine.type, mmsHeader.replyCharge.deadLine.time);
-                       // DRM_TEMPLATE - end
+                       /* DRM_TEMPLATE - end */
                        break;
 
                case MMS_CODE_REPLYCHARGINGID:
@@ -995,7 +992,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                        }
                        break;
 
-               default:
+               default: {
 
                        /*
                         * Application-header             = Token-text Application-specific-value
@@ -1007,32 +1004,32 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                         * Read one byte and check the value >= 0x80
                         * (check these value can be field code)
                         */
-                       {
-                               int             remainLength = 0;
 
-                               oneByte = 0x00;
+                       int remainLength = 0;
 
-                               offset = __MmsGetDecodeOffset();
-                               if (offset >= totalLength)
-                                       goto __RETURN;
+                       oneByte = 0x00;
 
-                               remainLength = totalLength - offset;
+                       offset = __MmsGetDecodeOffset();
+                       if (offset >= totalLength)
+                               goto __RETURN;
 
-                               while ((oneByte < 0x80) && (remainLength > 0)) {
-                                       if (__MmsBinaryDecodeCheckAndDecreaseLength(&remainLength, 1) == false) {
-                                               MSG_DEBUG("__MmsBinaryDecodeCheckAndDecreaseLength fail");
-                                               goto __CATCH;
-                                       }
-                                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                                               MSG_DEBUG("responseStatus GetOneByte fail");
-                                               goto __CATCH;
-                                       }
+                       remainLength = totalLength - offset;
+
+                       while ((oneByte < 0x80) && (remainLength > 0)) {
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&remainLength, 1) == false) {
+                                       MSG_DEBUG("__MmsBinaryDecodeCheckAndDecreaseLength fail");
+                                       goto __CATCH;
                                }
 
-                               gCurMmsDecodeBuffPos--;
+                               if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                                       MSG_DEBUG("responseStatus GetOneByte fail");
+                                       goto __CATCH;
+                               }
                        }
 
+                       gCurMmsDecodeBuffPos--;
                        break;
+               }
                }       /* switch */
 
                offset = __MmsGetDecodeOffset();
@@ -1090,9 +1087,9 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength)
        if (szFilePath != NULL)
                snprintf(mmsHeader.msgType.szOrgFilePath, sizeof(mmsHeader.msgType.szOrgFilePath), "%s", szFilePath);
 
-       mmsHeader.msgType.offset = __MmsGetDecodeOffset() - 1;          // + Content-Type code value
+       mmsHeader.msgType.offset = __MmsGetDecodeOffset() - 1;          /* + Content-Type code value */
 
-       // read data(2K) from msg file(/User/Msg/Inbox/5) to gpCurMmsDecodeBuff for decoding
+       /* read data(2K) from msg file(/User/Msg/Inbox/5) to gpCurMmsDecodeBuff for decoding */
        if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos,
                                                                        &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2,
                                                                        gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
@@ -1100,14 +1097,14 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength)
                goto __CATCH;
        }
 
-       // msg's type [ex] related, mixed, single part (jpg, amr and etc)
+       /* msg's type [ex] related, mixed, single part (jpg, amr and etc) */
        length = __MmsBinaryDecodeContentType(pFile, &mmsHeader.msgType, totalLength);
        if (length == -1) {
                MSG_DEBUG("MMS_CODE_CONTENTTYPE is fail");
                goto __CATCH;
        }
 
-       mmsHeader.msgType.size   = length + 1; // + Content-Type code value
+       mmsHeader.msgType.size   = length + 1; /* + Content-Type code value */
        mmsHeader.msgBody.offset = __MmsGetDecodeOffset();
 
        switch (mmsHeader.msgType.type) {
@@ -1190,7 +1187,7 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
                valueLength--;
 
                switch (paramCode) {
-               case 0x81: // charset
+               case 0x81: /* charset */
 
                        if (__MmsBinaryDecodeCharset(pFile, (UINT32*)&(pMsgType->param.charset), &charSetLen, totalLength) == false) {
                                MSG_DEBUG("__MmsBinaryDecodeCharset fail.");
@@ -1202,11 +1199,11 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
 
                        break;
 
-               case 0x85: //name = Text-string
-               case 0x97: //name = Text-value  = No-value | Token-text | Quoted-string
+               case 0x85: /* name = Text-string */
+               case 0x97: /* name = Text-value  = No-value | Token-text | Quoted-string */
                        memset(pMsgType->param.szName, 0, sizeof(pMsgType->param.szName));
                        length = __MmsDecodeGetFilename(pFile,  pMsgType->param.szName,
-                                                                                        MSG_FILENAME_LEN_MAX -5,               // MSG_LOCALE_FILENAME_LEN_MAX + 1, :  change @ 110(Ui code have to change for this instead of DM)
+                                                                                        MSG_FILENAME_LEN_MAX -5,               /* MSG_LOCALE_FILENAME_LEN_MAX + 1, :  change @ 110(Ui code have to change for this instead of DM) */
                                                                                         totalLength);
                        if (length < 0) {
                                MSG_DEBUG("__MmsDecodeGetFilename fail. (name parameter)");
@@ -1222,8 +1219,8 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
 
                        break;
 
-               case 0x86: //filename = Text-string
-               case 0x98: //filename = Text-value  = No-value | Token-text | Quoted-string
+               case 0x86: /* filename = Text-string */
+               case 0x98: /* filename = Text-value  = No-value | Token-text | Quoted-string */
                        memset(pMsgType->param.szFileName, 0, sizeof(pMsgType->param.szFileName));
                        length = __MmsDecodeGetFilename(pFile, pMsgType->param.szFileName, MSG_FILENAME_LEN_MAX -5, totalLength);
                        if (length < 0) {
@@ -1240,7 +1237,7 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
 
                        break;
 
-               case 0x89: //type = Constrained-encoding = Extension-Media | Short-integer
+               case 0x89: /* type = Constrained-encoding = Extension-Media | Short-integer */
 
                        if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
                                MSG_DEBUG("type _MmsBinaryDecodeGetOneByte fail");
@@ -1248,7 +1245,8 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
                        }
 
                        if (oneByte > 0x7f) {
-                               pMsgType->param.type = MimeGetMimeIntFromBi((UINT16)(oneByte & 0x7f));//MmsGetBinaryType(MmsCodeContentType,(UINT16)(oneByte & 0x7f));
+                               pMsgType->param.type = MimeGetMimeIntFromBi((UINT16)(oneByte & 0x7f));
+                               /* MmsGetBinaryType(MmsCodeContentType,(UINT16)(oneByte & 0x7f)); */
                                if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, 1) == false)
                                        goto __RETURN;
                        } else {
@@ -1268,8 +1266,8 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
 
                        break;
 
-               case 0x8A: //start encoding version 1.2
-               case 0x99: //start encoding version 1.4
+               case 0x8A: /* start encoding version 1.2 */
+               case 0x99: /* start encoding version 1.4 */
 
                        textLength       = 0;
                        szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
@@ -1285,8 +1283,8 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
 
                        break;
 
-               case 0x8B: //startInfo encoding version 1.2
-               case 0x9A: //startInfo encoding version 1.4
+               case 0x8B: /* startInfo encoding version 1.2 */
+               case 0x9A: /* startInfo encoding version 1.4 */
 
                        textLength       = 0;
                        szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
@@ -1309,7 +1307,7 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
                        if (paramCode > 0x7F) {
                                MSG_DEBUG("Unsupported parameter");
 
-                               // In case of the last byte of Parameter field, it should be returned without decreasing the gCurMmsDecodeBuffPos value.
+                               /* In case of the last byte of Parameter field, it should be returned without decreasing the gCurMmsDecodeBuffPos value. */
                                valueLength++;
                                if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, 1) == false)
                                        goto __RETURN;
@@ -1553,6 +1551,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
        char *szSrc = NULL;
        char *szTemp = NULL;
 
+       MSG_INFO("headerLen[%d] totalLength[%d]", headerLen, totalLength);
 
        if (pFile == NULL || pMsgType == NULL)
                return false;
@@ -1580,8 +1579,8 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
                        fieldCode = oneByte & 0x7f;
 
                        switch (fieldCode) {
-                       case 0x0E:      //Content-Location
-                       case 0x04:      //Content-Location
+                       case 0x0E:      /* Content-Location */
+                       case 0x04:      /* Content-Location */
                        {
                                pLatinBuff = (char *)calloc(1, MMS_CONTENT_ID_LEN + 1);
                                if (pLatinBuff == NULL)
@@ -1596,7 +1595,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
                                szSrc = __MsgConvertLatin2UTF8FileName(pLatinBuff);
                                if (szSrc) {
                                        snprintf(pMsgType->szContentLocation, sizeof(pMsgType->szContentLocation), "%s", szSrc);
-                                       MSG_DEBUG("Content Location : [%s]", pMsgType->szContentLocation);
+                                       MSG_SEC_DEBUG("Content Location : [%s]", pMsgType->szContentLocation);
                                        free(szSrc);
                                        szSrc = NULL;
                                }
@@ -1609,7 +1608,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
                        }
                                break;
 
-                       case 0x40:      // Content-ID
+                       case 0x40:      /* Content-ID */
                        {
                                char szContentID[MMS_CONTENT_ID_LEN + 1] = {0, };
 
@@ -1627,7 +1626,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
                                szSrc = __MsgConvertLatin2UTF8FileName(pLatinBuff);
                                if (szSrc) {
                                        snprintf(szContentID, sizeof(szContentID), "%s", szSrc);
-                                       MSG_DEBUG("Content ID : [%s]", szContentID);
+                                       MSG_SEC_DEBUG("Content ID : [%s]", szContentID);
                                        free(szSrc);
                                        szSrc = NULL;
                                }
@@ -1635,15 +1634,15 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
                                free(pLatinBuff);
                                pLatinBuff = NULL;
 
-                               MmsRemoveLessGreaterChar(szContentID, pMsgType->szContentID, sizeof(pMsgType->szContentID));//remove "< >"
+                               MmsRemoveLessGreaterChar(szContentID, pMsgType->szContentID, sizeof(pMsgType->szContentID)); /* remove "< >" */
 
                                if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false)
                                        goto __RETURN;
                        }
                                break;
 
-                       case 0x2E:      // Content-Disposition
-                       case 0x45:      // Content-Disposition
+                       case 0x2E:      /* Content-Disposition */
+                       case 0x45:      /* Content-Disposition */
 
                                /*
                                 * Content-disposition-value = Value-length Disposition *(Parameter)
@@ -1674,7 +1673,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
 
                                        if (pMsgType->disposition == -1) {
                                                MSG_DEBUG("Content-Disposition MmsGetBinaryType fail.");
-                                               pMsgType->disposition = MSG_DISPOSITION_ATTACHMENT;             // default
+                                               pMsgType->disposition = MSG_DISPOSITION_ATTACHMENT;             /* default */
                                        }
 
                                        if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, 1) == false)
@@ -1725,7 +1724,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
 
                                break;
 
-                       case 0x0B:      //Content-Encoding
+                       case 0x0B:      /* Content-Encoding */
 
                                if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
                                        MSG_DEBUG("Disposition value GetOneByte fail");
@@ -1737,7 +1736,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
 
                                break;
 
-                       case 0x0C:      //Content-Language
+                       case 0x0C:      /* Content-Language */
 
                                if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&tmpInt, &tmpIntLen, totalLength) == true) {
                                        if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, tmpIntLen) == false)
@@ -1765,7 +1764,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
 
                                break;
 
-                       case 0x0D:      //Content-Length
+                       case 0x0D:      /* Content-Length */
 
                                if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&tmpInt, &tmpIntLen, totalLength) == false) {
                                        MSG_DEBUG("__MmsBinaryDecodeInteger fail...");
@@ -1777,7 +1776,35 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
 
                                break;
 
-                       case 0x30:      //X-Wap-Content-URI skip this value
+                       case 0x1C:      /* Location */
+
+                               pLatinBuff = (char *)calloc(1, MMS_LOCATION_URL_LEN + 1);
+                               if (pLatinBuff == NULL)
+                                       goto __CATCH;
+
+                               length = __MmsBinaryDecodeText(pFile, pLatinBuff, MMS_LOCATION_URL_LEN, totalLength);
+                               if (length == -1) {
+                                       MSG_DEBUG("__MmsBinaryDecodeQuotedString fail.");
+                                       goto __CATCH;
+                               }
+
+                               szSrc = __MsgConvertLatin2UTF8FileName(pLatinBuff);
+                               if (szSrc) {
+                                       snprintf(pMsgType->szLocation, sizeof(pMsgType->szLocation), "%s", szSrc);
+                                       MSG_INFO("Location : [%s]", pMsgType->szLocation);
+                                       free(szSrc);
+                                       szSrc = NULL;
+                               }
+
+                               free(pLatinBuff);
+                               pLatinBuff = NULL;
+
+                               if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false)
+                                       goto __RETURN;
+
+                               break;
+
+                       case 0x30:      /* X-Wap-Content-URI skip this value */
 
                                MSG_DEBUG("X-Wap-Content-URI header.");
                                pLatinBuff = (char *)calloc(1, MMS_TEXT_LEN);
@@ -1802,8 +1829,8 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
 
                                break;
 
-                       case 0x01:      // Accept-charset
-                               //if (NvGetInt(NV_SI_ADM_GCF_STATE) == 1)
+                       case 0x01:      /* Accept-charset */
+/*                             if (NvGetInt(NV_SI_ADM_GCF_STATE) == 1) */
                                {
                                        /*      WAP-230-WSP-200010705-a.pdf
                                                8.4.2.8 Accept charset field
@@ -1830,7 +1857,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
                                        }
 
                                        if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&charset, &charSetLen, totalLength) == false) {
-                                               // We only support the well-known-charset format
+                                               /* We only support the well-known-charset format */
                                                MSG_DEBUG("__MmsBinaryDecodeInteger fail...");
                                                goto __CATCH;
                                        }
@@ -1921,11 +1948,11 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
                        }
 
                        switch (MmsGetTextType(MmsCodeMsgBodyHeaderCode, pCode)) {
-                       case MMS_BODYHDR_TRANSFERENCODING:              // Content-Transfer-Encoding
+                       case MMS_BODYHDR_TRANSFERENCODING:              /* Content-Transfer-Encoding */
                                pMsgType->encoding = MmsGetTextType(MmsCodeContentTransferEncoding, pValue);
                                break;
 
-                       case MMS_BODYHDR_CONTENTID:                             // Content-ID
+                       case MMS_BODYHDR_CONTENTID:                             /* Content-ID */
                        {
                                char szContentID[MMS_CONTENT_ID_LEN + 1];
 
@@ -1945,13 +1972,13 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
                                        goto __CATCH;
                                }
 
-                               MmsRemoveLessGreaterChar(szContentID, pMsgType->szContentID, sizeof(pMsgType->szContentID));//remove "< >"
+                               MmsRemoveLessGreaterChar(szContentID, pMsgType->szContentID, sizeof(pMsgType->szContentID)); /* remove "< >" */
 
                                free(pLatinBuff);
                                pLatinBuff = NULL;
                                break;
                        }
-                       case MMS_BODYHDR_CONTENTLOCATION:               // Content-Location
+                       case MMS_BODYHDR_CONTENTLOCATION:               /* Content-Location */
 
                                pLatinBuff = (char *)calloc(1, MMS_CONTENT_ID_LEN + 1);
                                if (pLatinBuff == NULL)
@@ -1969,11 +1996,11 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
                                pLatinBuff = NULL;
                                break;
 
-                       case MMS_BODYHDR_DISPOSITION:                   // Content-Disposition
+                       case MMS_BODYHDR_DISPOSITION:                   /* Content-Disposition */
                                pMsgType->disposition = MmsGetTextType(MmsCodeMsgDisposition, pValue);
                                break;
 
-                       case MMS_BODYHDR_X_OMA_DRM_SEPARATE_DELIVERY:   // DRM RO WAITING
+                       case MMS_BODYHDR_X_OMA_DRM_SEPARATE_DELIVERY:   /* DRM RO WAITING */
                                        break;
 
                        default:
@@ -1998,7 +2025,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
                                goto __RETURN;
 
                }
-       }       //while
+       } /* while */
 
 __RETURN:
 
@@ -2130,7 +2157,6 @@ static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *p
        UINT32 nEntries = 0;
        MsgMultipart *pMultipart = NULL;
        MsgMultipart *pLastMultipart = NULL;
-//     MsgMultipart *pPreMultipart     = NULL;
        int offset = 0;
        int     index = 0;
 
@@ -2175,6 +2201,10 @@ static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *p
                }
 
                if (pMultipart->type.type == MIME_APPLICATION_SMIL) {
+                       /* P151019-00477 : received mms message is type of multipart mixed, but among multiparts if there's smil part then set it multipart related */
+                       if (pMsgType->type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED)
+                               pMsgType->type = MIME_APPLICATION_VND_WAP_MULTIPART_RELATED;
+
                        factor = __MsgIsPresentationEx(&(pMultipart->type), pMsgType->param.szStart, (MimeType)pMsgType->param.type);
                        if (factor == MSG_PRESENTATION_NONE) {
                                factor = MSG_PRESENTATION_TYPE_BASE;
@@ -2183,9 +2213,9 @@ static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *p
                        factor = MSG_PRESENTATION_NONE;
                }
 
-               // priority 1 : content type match, 2: content location, 3: type
+               /* priority 1 : content type match, 2: content location, 3: type */
                if (presentationInfo.factor < factor) {
-                       // Presentation part
+                       /* Presentation part */
                        presentationInfo.factor = factor;
                        presentationInfo.pPrevPart = pLastMultipart;
                        presentationInfo.pCurPresentation = pMultipart;
@@ -2195,11 +2225,9 @@ static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *p
                if (pLastMultipart == NULL) {
                        pMsgBody->body.pMultipart = pMultipart;
                        pLastMultipart = pMultipart;
-//                     pPreMultipart = NULL;
                } else {
                        pLastMultipart->pNext = pMultipart;
                        pLastMultipart = pMultipart;
-//                     pPreMultipart = pMultipart;
                }
 
                pMsgType->contentSize += pMultipart->pBody->size;
@@ -2219,7 +2247,6 @@ static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *p
                goto __CATCH;
        }
 
-//__RETURN:
        return true;
 
 __CATCH:
@@ -2418,7 +2445,7 @@ bool __MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalL
                szBuff[i] = gpCurMmsDecodeBuff[gCurMmsDecodeBuffPos++];
        }
 
-       gCurMmsDecodeBuffPos++; //NULL
+       gCurMmsDecodeBuffPos++; /* NULL */
 
        return true;
 
@@ -2577,7 +2604,7 @@ static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int t
                goto __CATCH;
        }
 
-       gCurMmsDecodeBuffPos--; // - NULL
+       gCurMmsDecodeBuffPos--; /* - NULL */
 
        for (i= 0; i < length; i++)
                returner.seg[length - (i+1)] = pData[i];
@@ -2636,13 +2663,13 @@ static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen
                }
                memset(pData, 0, oneByte + 1);
 
-               // Even NULL is copied in the _MmsBinaryDecodeGetBytes
+               /* Even NULL is copied in the _MmsBinaryDecodeGetBytes */
                if (__MmsBinaryDecodeGetBytes(pFile, pData, oneByte + 1, totalLength) == false) {
                        MSG_DEBUG("GetBytes fail");
                        goto __CATCH;
                }
 
-               gCurMmsDecodeBuffPos--; // - NULL
+               gCurMmsDecodeBuffPos--; /* - NULL */
 
                int             length  = 0;
                if (oneByte > 4) {
@@ -2726,7 +2753,7 @@ static int __MmsDecodeValueLength(FILE *pFile, UINT32 *pValueLength, int totalLe
                        MSG_DEBUG(" __MmsBinaryDecodeUintvar fail..");
                        goto __CATCH;
                }
-               length ++;                                      // + length-quote
+               length ++;                                      /* + length-quote */
                *pValueLength = uintvar;
        } else {
                MSG_DEBUG("not a value length type data");
@@ -2784,7 +2811,7 @@ static int __MmsDecodeValueLength2(FILE *pFile, UINT32 *pValueLength, int totalL
                        MSG_DEBUG("__MmsBinaryDecodeUintvar fail..");
                        goto __CATCH;
                }
-               length ++;                                      // + length-quote
+               length ++;                                      /* + length-quote */
                *pValueLength = uintvar;
        } else {
                MSG_DEBUG("there is not length-quote, consider it as short length.");
@@ -2831,7 +2858,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen,
                goto __CATCH;
        }
 
-       length = strlen(gpCurMmsDecodeBuff) + 1;        // + NULL
+       length = strlen(gpCurMmsDecodeBuff) + 1;        /* + NULL */
 
        if (length == 0)
                goto __RETURN;
@@ -2888,7 +2915,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen,
                        MSG_DEBUG("fail to load to buffer");
                        goto __CATCH;
                }
-               length = strlen(gpCurMmsDecodeBuff) + 1;        // + NULL
+               length = strlen(gpCurMmsDecodeBuff) + 1;        /* + NULL */
        }       /* while */
 
        if (length > 0) {
@@ -2909,7 +2936,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen,
                                strncpy(szBuff + iPos, (char*)pData + 1, readBytes - 1);
                                iPos += (readBytes - 1);
                        } else {
-                               strncpy(szBuff + iPos, (char*)pData, readBytes - 1);    // + NULL
+                               strncpy(szBuff + iPos, (char*)pData, readBytes - 1);    /* + NULL */
                                iPos += readBytes;
                        }
                }
@@ -2977,7 +3004,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
                goto __CATCH;
        }
 
-       length = strlen(gpCurMmsDecodeBuff) + 1;        // + NULL
+       length = strlen(gpCurMmsDecodeBuff) + 1;        /* + NULL */
 
        if (length == 0)
                goto __RETURN;
@@ -3031,7 +3058,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
                        MSG_DEBUG("fail to load to buffer");
                        goto __CATCH;
                }
-               length = strlen(gpCurMmsDecodeBuff) + 1;        // + NULL
+               length = strlen(gpCurMmsDecodeBuff) + 1;        /* + NULL */
        }       /* while */
 
        if (length > 0) {
@@ -3053,7 +3080,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
                                iPos += (readBytes - 1);
                                bQuote = true;
                        } else {
-                               strncpy(szBuff + iPos, (char*)pData, readBytes - 1);    // + NULL
+                               strncpy(szBuff + iPos, (char*)pData, readBytes - 1);    /* + NULL */
                                iPos += readBytes;
                        }
                }
@@ -3063,7 +3090,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
                        pData = NULL;
                }
 
-               returnLength += length;         // + NULL
+               returnLength += length;         /* + NULL */
        }
 
        szBuff[bufLen - 1] = '\0';
@@ -3156,7 +3183,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
                } else {
                        szTempPtr = (char *)realloc(szBuff, curLen + gMmsDecodeBufLen + 1);
 
-                       //NULL pointer check for realloc
+                       /* NULL pointer check for realloc */
                        if (szTempPtr == NULL) {
                                goto __CATCH;
                        } else {
@@ -3194,8 +3221,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
                                                           gpMmsDecodeBuf2,
                                                           gMmsDecodeMaxLen,
                                                           &gMmsDecodeBufLen,
-                                                          totalLength) == false)
-               {
+                                                          totalLength) == false) {
                        MSG_DEBUG("fail to load to buffer");
                        goto __CATCH;
                }
@@ -3217,7 +3243,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
                } else {
                        szTempPtr = (char *)realloc(szBuff, curLen + length);
 
-                       //NULL pointer check for realloc
+                       /* NULL pointer check for realloc */
                        if (szTempPtr == NULL)
                                goto __CATCH;
                        else
@@ -3246,7 +3272,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
                        pData = NULL;
                }
 
-               *pLength += length;             // + NULL
+               *pLength += length;             /* + NULL */
        }
 
        return szBuff;
@@ -3394,7 +3420,7 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen
                        strncpy(szBuff, pData, bufLen - 1);
                }
 
-               {//temp brace
+               { /* temp brace */
 
                        nTemp = strlen(szBuff);
 
@@ -3606,7 +3632,7 @@ static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int tot
        textLength = 0;
        pLatinBuff  = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
 
-       //remove ""
+       /* remove "" */
        if (pLatinBuff) {
                szSrc = MsgRemoveQuoteFromFilename(pLatinBuff);
                if (szSrc) {
@@ -3628,7 +3654,7 @@ static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int tot
                        int             utf8BufSize = 0;
                        utf8BufSize = __MsgGetLatin2UTFCodeSize((unsigned char*)pLatinBuff, length);
                        if (utf8BufSize < 3)
-                               utf8BufSize = 3;//min value
+                               utf8BufSize = 3; /* min value */
 
                        pUTF8Buff = (char *)calloc(1, utf8BufSize + 1);
                        if (pUTF8Buff == NULL) {
@@ -3694,7 +3720,7 @@ __CATCH:
 
    ==========================================================*/
 
-//  to get message body this function should be modified from message raw file.
+/* to get message body this function should be modified from message raw file. */
 bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath)
 {
        FILE *pFile     = NULL;
@@ -3753,7 +3779,7 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe
        memcpy(&(pMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType));
        memcpy(&(pMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody));
 
-{//attribute convert mmsHeader -> mmsAttribute
+{ /* attribute convert mmsHeader -> mmsAttribute */
 
        pMsg->mmsAttrib.contentType = (MimeType)mmsHeader.msgType.type;
 
@@ -3789,11 +3815,11 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe
 
        pMsg->mmsAttrib.retrieveStatus = mmsHeader.retrieveStatus;
 
-       //FIXME:: mmsHeader will release after delete global mmsHeader
-       //memset(&(mmsHeader.msgBody), 0x00, sizeof(MsgBody));//After copy to MmsMsg
+       /* FIXME:: mmsHeader will release after delete global mmsHeader */
+       /* memset(&(mmsHeader.msgBody), 0x00, sizeof(MsgBody)); */ /* After copy to MmsMsg */
 }
        if (pMsg->msgBody.pPresentationBody) {
-               if(MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0)
+               if (MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0)
                        goto __CATCH;
 
                pMsg->msgBody.pPresentationBody->body.pText = (char *)calloc(1, pMsg->msgBody.pPresentationBody->size + 1);
@@ -3863,7 +3889,7 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe
                        partIndex ++;
                }
 
-       } else { //single part
+       } else { /* single part */
                if (pMsg->nPartCount > 0) {
 
                        if (bSavePartsAsTempFiles) {
@@ -4015,10 +4041,10 @@ char *MsgChangeHexString(char *pOrg)
 
        for (cIndex = 0; cIndex< cLen ; cIndex++) {
                if (pOrg[cIndex] == '%') {
-                       if (pOrg[cIndex+1] != 0 && pOrg[cIndex+2] != 0)         {
-                               snprintf(szBuf, sizeof(szBuf), "%c%c", pOrg[cIndex+1], pOrg[cIndex+2]); // read two chars after '%'
+                       if (pOrg[cIndex+1] != 0 && pOrg[cIndex+2] != 0) {
+                               snprintf(szBuf, sizeof(szBuf), "%c%c", pOrg[cIndex+1], pOrg[cIndex+2]); /* read two chars after '%' */
 
-                               if (__MsgIsHexChar(szBuf) == true) { // check the two character is between  0 ~ F
+                               if (__MsgIsHexChar(szBuf) == true) { /* check the two character is between  0 ~ F */
                                        OneChar = __MsgConvertHexValue(szBuf);
 
                                        pNew[index] = OneChar;
@@ -4087,7 +4113,7 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
                                if ((pTest = strchr(pValue, MSG_CH_QUOT)) != NULL)
                                        *pTest = MSG_CH_NULL;
 
-                               pDec = MsgDecodeText(pValue);           // Api is to long, consider Add to another file (MsgMIMECodec.c)
+                               pDec = MsgDecodeText(pValue);           /* Api is to long, consider Add to another file (MsgMIMECodec.c) */
                        } else {
                                pDec = MsgDecodeText(pName);
                        }
@@ -4144,7 +4170,7 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
                                                        szSrc = NULL;
                                                }
 
-                                               // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif"
+                                               /* Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" */
                                                __MsgRemoveFilePath(pType->param.szName);
                                        } else {
                                                MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec);
@@ -4184,7 +4210,7 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
                                                        szSrc = NULL;
                                                }
 
-                                               // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif"
+                                               /* Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" */
                                                __MsgRemoveFilePath(pType->param.szFileName);
                                        } else {
                                                MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec);
@@ -4214,7 +4240,7 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
 
                                        break;
 
-                               case MSG_PARAM_START_INFO :
+                               case MSG_PARAM_START_INFO:
 
                                        /* Only if content-type is multipart/related */
 
@@ -4225,11 +4251,11 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
 
                                        break;
 
-                               case MSG_PARAM_REPORT_TYPE :
+                               case MSG_PARAM_REPORT_TYPE:
 
-                                       //  only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
+                                       /* only used as parameter of Content-Type: multipart/report; report-type=delivery-status; */
 
-                                       if (pDec != NULL && strcasecmp(pDec, "delivery-status") == 0) {
+                                       if (strcasecmp(pDec, "delivery-status") == 0) {
                                                pType->param.reportType = MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS;
                                        } else {
                                                pType->param.reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN;
@@ -4271,11 +4297,11 @@ static char *__MsgSkipComment (char *s,long trim)
        char *s1 = s;
        char *t = NULL;
 
-       // ignore empty space
+       /* ignore empty space */
        for (ret = ++s1; *ret == ' '; ret++)
                ;
 
-       // handle '(', ')', '\',  '\0'
+       /* handle '(', ')', '\',  '\0' */
        do {
                switch (*s1) {
                case '(':
@@ -4314,10 +4340,10 @@ __NULL_RETURN:
 static char *__MsgConvertLatin2UTF8FileName(char *pSrc)
 {
        char *pUTF8Buff  = NULL;
-//     char *pData = NULL;
+/*     char *pData = NULL; */
 
 
-       //convert utf8 string
+       /* convert utf8 string */
        if (MmsIsUtf8String((unsigned char*)pSrc, strlen(pSrc)) == false) {
                int length  = 0;
                int utf8BufSize = 0;
@@ -4325,7 +4351,7 @@ static char *__MsgConvertLatin2UTF8FileName(char *pSrc)
                length = strlen(pSrc);
                utf8BufSize = __MsgGetLatin2UTFCodeSize((unsigned char*)pSrc, length);
                if (utf8BufSize < 3)
-                       utf8BufSize = 3; //min value
+                       utf8BufSize = 3; /* min value */
 
                pUTF8Buff = (char *)calloc(1, utf8BufSize + 1);
 
@@ -4350,14 +4376,16 @@ static char *__MsgConvertLatin2UTF8FileName(char *pSrc)
                memcpy(pUTF8Buff, pSrc, length);
        }
 
-       //convert hex string
-//     if (__MsgIsPercentSign(pUTF8Buff) == true) {
-//             pData = MsgChangeHexString(pUTF8Buff);
-//             if (pData) {
-//                     free(pUTF8Buff);
-//                     pUTF8Buff = pData;
-//             }
-//     }
+       /* convert hex string */
+/*
+       if (__MsgIsPercentSign(pUTF8Buff) == true) {
+               pData = MsgChangeHexString(pUTF8Buff);
+               if (pData) {
+                       free(pUTF8Buff);
+                       pUTF8Buff = pData;
+               }
+       }
+*/
 
        return pUTF8Buff;
 
@@ -4406,7 +4434,7 @@ static bool __MsgChangeSpace(char *pOrg, char **ppNew)
 
 static void __MsgRemoveFilePath(char *pSrc)
 {
-       // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif"
+       /* Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" */
        char *pTemp = NULL;
        char *tmp_name = NULL;
 
@@ -4417,9 +4445,9 @@ static void __MsgRemoveFilePath(char *pSrc)
                tmp_name = NULL;
        }
 
-       // Remove additional file information
-       // ex) Content-type: application/octet-stream; name="060728gibson_210.jpg?size=s"
-       // if "?size=" exist, insert NULL char.
+       /* Remove additional file information
+        * ex) Content-type: application/octet-stream; name="060728gibson_210.jpg?size=s"
+        * if "?size=" exist, insert NULL char. */
        {
                pTemp = strcasestr(pSrc, "?size=");
                if (pTemp != NULL)
@@ -4452,7 +4480,7 @@ static MsgPresentationFactor __MsgIsPresentationEx(MsgType *multipartType, char*
        char szTmpContentLO[MSG_MSG_ID_LEN + 3] = { 0, };
        int strLen = 0;
 
-       // remove '<' and '>' in Start Param : contentID ex] <0_1.jpg> or <1233445>
+       /* remove '<' and '>' in Start Param : contentID ex] <0_1.jpg> or <1233445> */
        if (szStart && szStart[0]) {
                int startLen = 0;
                startLen = strlen(szStart);
@@ -4463,7 +4491,7 @@ static MsgPresentationFactor __MsgIsPresentationEx(MsgType *multipartType, char*
                }
        }
 
-       // remove '<' and '>' in ContentID : contentID ex] <0_1.jpg> or <1233445>
+       /* remove '<' and '>' in ContentID : contentID ex] <0_1.jpg> or <1233445> */
        if (multipartType->szContentID[0])      {
                strLen = strlen(multipartType->szContentID);
                if (multipartType->szContentID[0] == '<' && multipartType->szContentID[strLen - 1] == '>') {
@@ -4473,7 +4501,7 @@ static MsgPresentationFactor __MsgIsPresentationEx(MsgType *multipartType, char*
                }
        }
 
-       // remove '<' and '>' in ContentLocation : contentID ex] <0_1.jpg> or <1233445>
+       /* remove '<' and '>' in ContentLocation : contentID ex] <0_1.jpg> or <1233445> */
        if (multipartType->szContentLocation[0]) {
                strLen = strlen(multipartType->szContentLocation);
                if (multipartType->szContentLocation[0] == '<' && multipartType->szContentLocation[strLen - 1] == '>') {
@@ -4486,9 +4514,9 @@ static MsgPresentationFactor __MsgIsPresentationEx(MsgType *multipartType, char*
        if ((szTmpContentID[0] == '\0') && (szTmpContentLO[0] == '\0') && (multipartType->type == MIME_UNKNOWN))
                return  MSG_PRESENTATION_NONE;
 
-       // exception handling
+       /* exception handling */
        if (szTmpStart[0] != '\0') {
-               // presentation part : 1.compare with contentID 2.compare with content Location 3. compare with type
+               /* presentation part : 1.compare with contentID 2.compare with content Location 3. compare with type */
                if (strcmp(szTmpStart, szTmpContentID) == 0) {
                        return MSG_PRESENTATION_ID;
                } else if (strcmp(szTmpStart, szTmpContentLO) == 0) {
@@ -4514,9 +4542,9 @@ static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, M
        MsgMultipart *pRemovePart = NULL;
 
        if (__MsgIsMultipartRelated(pMsgType->type)) {
-               // assign the multipart to presentation part
-               // remove the multipart(pCurPresentation) which is presentation part from the linked list.
-               // if there is no presentation part -> assign first multipart to presentation part by force.
+               /* assign the multipart to presentation part */
+               /* remove the multipart(pCurPresentation) which is presentation part from the linked list. */
+               /* if there is no presentation part -> assign first multipart to presentation part by force. */
                if (pPresentationInfo->pCurPresentation == NULL) {
                        pPresentationInfo->pCurPresentation     = pMsgBody->body.pMultipart;
                        pPresentationInfo->pPrevPart            = NULL;
@@ -4530,9 +4558,9 @@ static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, M
                        memcpy(&pMsgBody->presentationType, &pPresentationInfo->pCurPresentation->type, sizeof(MsgType));
                        pMsgBody->pPresentationBody = pPresentationInfo->pCurPresentation->pBody;
 
-                       // remove pCurPresentation from multipart linked list
+                       /* remove pCurPresentation from multipart linked list */
                        if ((pPresentationInfo->factor == MSG_PRESENTATION_NONE)||(pPresentationInfo->pPrevPart == NULL)) {
-                               // first part
+                               /* first part */
                                pMsgBody->body.pMultipart = pPresentationInfo->pCurPresentation->pNext;
                                pMsgType->contentSize -= pPresentationInfo->pCurPresentation->pBody->size;
                                pMsgBody->size -= pPresentationInfo->pCurPresentation->pBody->size;
@@ -4544,7 +4572,7 @@ static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, M
                                        pPresentationInfo->pCurPresentation = NULL;
                                }
                        } else {
-                               // not a first part
+                               /* not a first part */
                                pPresentationInfo->pPrevPart->pNext = pPresentationInfo->pCurPresentation->pNext;
                                pMsgType->contentSize -= pPresentationInfo->pCurPresentation->pBody->size;
                                pMsgBody->size -= pPresentationInfo->pCurPresentation->pBody->size;
@@ -4558,14 +4586,14 @@ static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, M
                         * In this case, leave the Presentation part as a multipart and remove other multiparts.
                         */
 
-                       // Backup the multipart link information
+                       /* Backup the multipart link information */
                        pNextPart = pMsgBody->body.pMultipart;
 
-                       // Copy presentation part as a main part
+                       /* Copy presentation part as a main part */
                        memcpy(pMsgType, &pPresentationInfo->pCurPresentation->type, sizeof(MsgType));
                        memcpy(pMsgBody, pPresentationInfo->pCurPresentation->pBody, sizeof(MsgBody));
 
-                       // Remove multipart linked list
+                       /* Remove multipart linked list */
                        while (pNextPart) {
                                pRemovePart = pNextPart;
                                pNextPart = pNextPart->pNext;
@@ -4635,7 +4663,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
 
                pSelectedPart = pPartBody->body.pMultipart;
 
-               // NULL Pointer check!!
+               /* NULL Pointer check!! */
                if (pSelectedPart == NULL) {
                        MSG_DEBUG("multipart(ALTERNATIVE) does not exist");
                        break;
@@ -4786,7 +4814,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
 
                                pFirstPart = pSelectedPart->pBody->body.pMultipart;
 
-                               // NULL Pointer check!!
+                               /* NULL Pointer check!! */
                                if (pFirstPart == NULL) {
                                        MSG_DEBUG("multipart does not exist");
                                        break;
@@ -4865,7 +4893,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
                        }
                } else {
                        if (pPrevPart == NULL) {
-                               // first part is selected
+                               /* first part is selected */
                                pRemoveList = pPartBody->body.pMultipart->pNext;
                        } else {
                                pRemoveList = pPartBody->body.pMultipart->pNext;
@@ -4971,7 +4999,7 @@ __CATCH:
 
 char *MsgRemoveQuoteFromFilename(char *pSrc)
 {
-       int cLen = 0;   // length of pBuff
+       int cLen = 0;   /* length of pBuff */
        char *pBuff = NULL;
 
        if (pSrc == NULL) {
@@ -4989,21 +5017,19 @@ char *MsgRemoveQuoteFromFilename(char *pSrc)
        }
        memset(pBuff, 0 , sizeof(char)*(cLen + 1));
 
-       // remove front quote
+       /* remove front quote */
        if (pSrc[0] == MSG_CH_QUOT) {
                cLen--;
                strncpy(pBuff, &pSrc[1], cLen);
                pBuff[cLen] = '\0';
-       }
-
-       if (pSrc[0] == MSG_CH_LF) {
+       } else if (pSrc[0] == MSG_CH_LF) {
                cLen--;
                strncpy(pBuff, &pSrc[1], cLen);
        } else {
                strncpy(pBuff, pSrc, cLen);
        }
 
-       // remove last qoute
+       /* remove last qoute */
        if (pBuff[cLen-1] == MSG_CH_QUOT) {
                pBuff[cLen-1] = '\0';
        }
@@ -5079,10 +5105,10 @@ static int __MsgConvertCharToInt(char ch)
 
 static bool __MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2)
 {
-       if(!pMsgType1 || !pMsgType2)
+       if (!pMsgType1 || !pMsgType2)
                return false;
 
-       //if (pMsgType1->section == INVALID_HOBJ)
+/*     if (pMsgType1->section == INVALID_HOBJ) */
                pMsgType1->section = pMsgType2->section;
 
        int length = 0;
@@ -5231,7 +5257,7 @@ static int __MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szS
        MSG_DEBUG("---------------");
 
        org = des;
-       outBufSize--;                   // NULL character
+       outBufSize--;                   /* NULL character */
 
        while ((nChar > 0) && (*szSrc != '\0')) {
                if (0x01 <= *szSrc && *szSrc <= 0x7F) {
@@ -5253,8 +5279,8 @@ static int __MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szS
                        if (outBufSize < 0)
                                goto __RETURN;
 
-                       t2 = (unsigned char) (*szSrc & 0x003F);                         //      right most 6 bit
-                       t1 = (unsigned char) ((*szSrc & 0xC0) >> 6);            //      right most 2 bit
+                       t2 = (unsigned char) (*szSrc & 0x003F);                         /* right most 6 bit */
+                       t1 = (unsigned char) ((*szSrc & 0xC0) >> 6);            /* right most 2 bit */
 
                        *des = 0xC0 | (t1 & 0x1F);
                        *(des + 1) = 0x80 | (t2 & 0x3F);
@@ -5319,37 +5345,36 @@ bool MmsAddrUtilRemovePlmnString(char *pszAddr)
                if (!pszStrEnd) {
                        char *pszStart = NULL;
                        char *pszEnd = NULL;
-                       // "/TYPE=PLMN" not found
+                       /* "/TYPE=PLMN" not found */
 
                        int remainedLen = strlen(pszStrStart);
 
                        if (remainedLen <= 0)
                                break;
 
-                       //Email address can occur with Sender Name<email-address> format
-                       //remove the Sender name and only retain the email address.
+                       /* Email address can occur with Sender Name<email-address> format */
+                       /* remove the Sender name and only retain the email address. */
                        pszStart = strstr(pszStrStart, "<");
                        if (pszStart) {
                                pszEnd = strstr(pszStrStart, ">");
 
                                if (pszEnd) {
-                                       pszStart++; //skip "<"
+                                       pszStart++; /* skip "<" */
                                        g_strlcat(pszAddr, pszStart, pszEnd - pszStart + 1);
                                        break;
                                }
                        }
 
-                       //strcat(pszAddr, pszStrStart);
                        g_strlcat(pszAddr, pszStrStart, strLen + 1);
                        break;
                }
 
-               // Get one address length
+               /* Get one address length */
                addressLen = pszStrEnd - pszStrStart;
 
                strncat(pszAddr, pszStrStart, addressLen);
 
-               // Find next address
+               /* Find next address */
                pszStrStart = pszStrEnd;
 
                pszStrTemp = strstr(pszStrStart, MSG_MMS_STR_ADDR_DELIMETER);
@@ -5361,12 +5386,12 @@ bool MmsAddrUtilRemovePlmnString(char *pszAddr)
                        pszStrStart += strlen(pszStrEnd);
                }
 
-               if (pszStrStart[0] == 0)        // end of string
+               if (pszStrStart[0] == 0)        /* end of string */
                        break;
 
 
-               g_strlcat(pszAddr, MSG_MMS_STR_ADDR_DELIMETER, strLen + 1);     // add ';'
-               pszStrStart++;  // remove ';'
+               g_strlcat(pszAddr, MSG_MMS_STR_ADDR_DELIMETER, strLen + 1);     /* add ';' */
+               pszStrStart++;  /* remove ';' */
        }
 
        if (pszAddr[0] == 0)
@@ -5384,7 +5409,7 @@ static int __MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *
        MSG_DEBUG("---------------");
 
        org = des;
-       outBufSize--;                   // NULL character
+       outBufSize--;                   /* NULL character */
 
        while ((nChar > 0) && (*szSrc != '\0')) {
                if (*szSrc < 0x80) {
@@ -5536,8 +5561,8 @@ static bool __MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, in
 static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *pszMailboxPath, char *pszMsgFilename, int index, bool bSave)
 {
        FILE *pFile = NULL;
-       char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, };        // file name of temp file
-       char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; // full absolute path of temp file.
+       char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, };        /* file name of temp file */
+       char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; /* full absolute path of temp file. */
        bool bFileExist = false;
        MSG_BEGIN();
 
@@ -5561,15 +5586,15 @@ static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody,
                }
        }
 
-       // make full path for save
-       __MsgMakeFileName(pPartType->type, szFileName, pPartType->drmInfo.drmType, 0, szFileName, sizeof(szFileName));  //FL & CD -> extension(.dm) SD -> extension(.dcf)
+       /* make full path for save */
+       __MsgMakeFileName(pPartType->type, szFileName, pPartType->drmInfo.drmType, 0, szFileName, sizeof(szFileName));  /* FL & CD -> extension(.dm) SD -> extension(.dcf) */
 
-       snprintf(szFullPath, MSG_FILEPATH_LEN_MAX, "%s%s.dir/%s", pszMailboxPath, pszMsgFilename, szFileName);  // get absolute path of each temp file of each part
+       snprintf(szFullPath, MSG_FILEPATH_LEN_MAX, "%s%s.dir/%s", pszMailboxPath, pszMsgFilename, szFileName);  /* get absolute path of each temp file of each part */
 
        if (pPartType->type == MIME_APPLICATION_OCTET_STREAM)
-               MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, szFullPath, (MimeType *)&pPartType->type, NULL);
+               MsgGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, szFullPath, (MimeType *)&pPartType->type, NULL);
 
-       // save file
+       /* save file */
        bFileExist = MsgAccessFile(szFullPath, F_OK);
 
        MSG_SEC_DEBUG("save flag  [%d],  filepath [%s], file exist [%d]", bSave, szFullPath, bFileExist);
@@ -5591,7 +5616,7 @@ static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody,
 
                snprintf(pPartBody->szOrgFilePath, sizeof(pPartBody->szOrgFilePath), "%s", szFullPath);
 
-               //IF DRM type Convert to dcf
+               /* IF DRM type Convert to dcf */
                if (pPartType->type == MIME_APPLICATION_VND_OMA_DRM_MESSAGE
                        || pPartType->type == MIME_APPLICATION_VND_OMA_DRM_CONTENT)
                {
@@ -5635,7 +5660,7 @@ static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody,
        } else {
                snprintf(pPartBody->szOrgFilePath, sizeof(pPartBody->szOrgFilePath), "%s", szFullPath);
 
-               //IF DRM type check dcf exist
+               /* IF DRM type check dcf exist */
                if (pPartType->type == MIME_APPLICATION_VND_OMA_DRM_MESSAGE
                        || pPartType->type == MIME_APPLICATION_VND_OMA_DRM_CONTENT)
                {
@@ -5661,9 +5686,9 @@ static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody,
                MSG_SEC_DEBUG("Set Part File to [%s]", pPartBody->szOrgFilePath);
        }
 
-       //file name fix
+       /* file name fix */
        if (szFileName[0]  != '\0') {
-               snprintf(pPartType->param.szFileName, MSG_FILENAME_LEN_MAX+1, "%s.dir/%s", pszMsgFilename, szFileName);// store relative path of each temp file of each part including sub folder.
+               snprintf(pPartType->param.szFileName, MSG_FILENAME_LEN_MAX+1, "%s.dir/%s", pszMsgFilename, szFileName); /* store relative path of each temp file of each part including sub folder. */
                snprintf(pPartType->param.szName, MSG_LOCALE_FILENAME_LEN_MAX+1, "%s", szFileName);
                MSG_SEC_DEBUG("Set Name : %s", pPartType->param.szName);
        }
@@ -5821,7 +5846,7 @@ char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int m
                        *npRead = nTemp;
                } else if (msgCharsetValue == MSG_CHARSET_UTF8) {
 
-                       // skip BOM (Byte Order Mark) bytes .. (Please refer to the http://www.unicode.org/faq/utf_bom.html#BOM)
+                       /* skip BOM (Byte Order Mark) bytes .. (Please refer to the http://www.unicode.org/faq/utf_bom.html#BOM) */
                        if (nTemp >= 3) {
                                if (((UINT8)pTemp[0]) == 0xEF && ((UINT8)pTemp[1]) == 0xBB && ((UINT8)pTemp[2]) == 0xBF) {
                                        pTemp += 3;
@@ -5850,7 +5875,7 @@ char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int m
                                        *npRead = nTemp;
                                }
 
-                       } else {//unsupported charset
+                       } else { /* unsupported charset */
                                MSG_DEBUG("unsupported charset");
                                pNewData = pTemp;
                                *npRead = nTemp;
@@ -5906,12 +5931,12 @@ static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType
        char szTempFileName[MSG_FILENAME_LEN_MAX+1]={0,};
        const char *pExt = NULL;
 
-       SECURE_SLOGD("Input : type  [0x%x], drmType [%d], filename [%s]", iMsgType, drmType, szFileName);
+       MSG_SEC_DEBUG("Input : type  [0x%x], drmType [%d], filename [%s]", iMsgType, drmType, szFileName);
 
        if (szFileName == NULL)
                return false;
 
-       //Filename
+       /* Filename */
        int inp_len = strlen(szFileName);
        if (inp_len > 0) {
 
@@ -5932,13 +5957,13 @@ static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType
                }
        }
 
-       //extension
+       /* extension */
        if (iMsgType == MIME_APPLICATION_VND_OMA_DRM_MESSAGE)
                pExt = "dm";
        else if (iMsgType == MIME_APPLICATION_VND_OMA_DRM_CONTENT)
                pExt = "dcf";
 
-       if (pExt == NULL) { // find ext from content type
+       if (pExt == NULL) { /* find ext from content type */
 
                if (iMsgType == MIME_APPLICATION_OCTET_STREAM || iMsgType == MIME_UNKNOWN) {
                        MSG_DEBUG("unsupported MsgType [%d]", iMsgType);
@@ -5948,7 +5973,7 @@ static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType
                pExt = MimeGetExtFromMimeInt((MimeType)iMsgType);
        }
 
-       //Filename + extension
+       /* Filename + extension */
        if (pExt) {
                snprintf(szTemp, sizeof(szTemp), "%s.%s", szTempFileName, pExt);
        } else {
@@ -5957,7 +5982,7 @@ static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType
        }
 
        snprintf(outBuf, outBufLen, "%s", szTemp);
-       SECURE_SLOGD("Result : filename [%s]", outBuf);
+       MSG_SEC_DEBUG("Result : filename [%s]", outBuf);
        return true;
 
 __CATCH:
@@ -6100,7 +6125,7 @@ void MmsPluginDecoder::decodeMmsPdu(MmsMsg *pMsg, msg_message_id_t msgID, const
        memcpy(&(pMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType));
        memcpy(&(pMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody));
 
-{//attribute convert mmsHeader -> mmsAttribute
+{ /* attribute convert mmsHeader -> mmsAttribute */
 
        pMsg->mmsAttrib.contentType = (MimeType)mmsHeader.msgType.type;
 
@@ -6138,11 +6163,11 @@ void MmsPluginDecoder::decodeMmsPdu(MmsMsg *pMsg, msg_message_id_t msgID, const
 
        pMsg->mmsAttrib.retrieveStatus = mmsHeader.retrieveStatus;
 
-       //FIXME:: mmsHeader will release after delete global mmsHeader
-       //memset(&(mmsHeader.msgBody), 0x00, sizeof(MsgBody));//After copy to MmsMsg
+       /* FIXME:: mmsHeader will release after delete global mmsHeader */
+       /* memset(&(mmsHeader.msgBody), 0x00, sizeof(MsgBody)); */ /* After copy to MmsMsg */
 }
        if (pMsg->msgBody.pPresentationBody) {
-               if(MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0)
+               if (MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0)
                        goto __CATCH;
 
                pMsg->msgBody.pPresentationBody->body.pText = (char *)calloc(1, pMsg->msgBody.pPresentationBody->size + 1);
@@ -6181,18 +6206,16 @@ void MmsPluginDecoder::decodeMmsPdu(MmsMsg *pMsg, msg_message_id_t msgID, const
                int partIndex = 0;
                pMultipart = pMsg->msgBody.body.pMultipart;
 
-               //if (bSavePartsAsTempFiles) {
-                       if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
-                               if (errno == EEXIST) {
-                                       MSG_SEC_DEBUG("exist dir : [%s]", szTempMediaDir);
-                               } else {
-                                       MSG_SEC_DEBUG("Fail to Create Dir [%s]", szTempMediaDir);
-                                       goto __CATCH;
-                               }
+               if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
+                       if (errno == EEXIST) {
+                               MSG_SEC_DEBUG("exist dir : [%s]", szTempMediaDir);
                        } else {
-                               MSG_SEC_DEBUG("make dir : [%s]", szTempMediaDir);
+                               MSG_SEC_DEBUG("Fail to Create Dir [%s]", szTempMediaDir);
+                               goto __CATCH;
                        }
-               //}
+               } else {
+                       MSG_SEC_DEBUG("make dir : [%s]", szTempMediaDir);
+               }
 
                if (pMsg->msgBody.pPresentationBody) {
                        if (__MmsMultipartSaveAsTempFile(&pMsg->msgBody.presentationType, pMsg->msgBody.pPresentationBody,
@@ -6212,21 +6235,19 @@ void MmsPluginDecoder::decodeMmsPdu(MmsMsg *pMsg, msg_message_id_t msgID, const
                        partIndex ++;
                }
 
-       } else { //single part
+       } else { /* single part */
                if (pMsg->nPartCount > 0) {
 
-                       //if (bSavePartsAsTempFiles) {
-                               if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
-                                       if (errno == EEXIST) {
-                                               MSG_DEBUG("exist dir : [%s]", szTempMediaDir);
-                                       } else {
-                                               MSG_DEBUG("Fail to Create Dir [%s]", szTempMediaDir);
-                                               goto __CATCH;
-                                       }
+                       if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
+                               if (errno == EEXIST) {
+                                       MSG_DEBUG("exist dir : [%s]", szTempMediaDir);
                                } else {
-                                       MSG_DEBUG("make dir : [%s]", szTempMediaDir);
+                                       MSG_DEBUG("Fail to Create Dir [%s]", szTempMediaDir);
+                                       goto __CATCH;
                                }
-                       //}
+                       } else {
+                               MSG_DEBUG("make dir : [%s]", szTempMediaDir);
+                       }
 
                        if (__MmsMultipartSaveAsTempFile(&pMsg->msgType, &pMsg->msgBody,
                                                                                        (char*)MSG_DATA_PATH, pMsg->szFileName, 0, true) == false)
@@ -6258,7 +6279,7 @@ __CATCH:
 
 }
 
-//CID 41989: Removed function decodeMmsPdu which is unused.
+/* CID 41989: Removed function decodeMmsPdu which is unused. */
 #if 0
 void MmsPluginDecoder::decodeMmsPdu(MMS_DATA_S *pMmsData, const char *pduFilePath)
 {
index 160abdb..c71c2e4 100755 (executable)
@@ -24,7 +24,6 @@
 #include "MsgDrmWrapper.h"
 #include "MmsPluginDrm.h"
 #include "MmsPluginCodec.h"
-#include "MmsPluginMIME.h"
 #include "MmsPluginDebug.h"
 
 bool MmsPluginDrmGetInfo(const char *szFilePath, MsgType *pMsgType)
index abf59b1..b6edf29 100755 (executable)
 
 #include "MsgCppTypes.h"
 #include "MsgUtilFile.h"
+#include "MsgUtilMime.h"
 
 #include "MmsPluginDebug.h"
 #include "MmsPluginEncode.h"
 #include "MmsPluginCodecTypes.h"
 #include "MmsPluginCodecCommon.h"
-#include "MmsPluginMIME.h"
 #include "MmsPluginUtil.h"
 
 using namespace std;
 
 /**  Sending message related variables  ------------------------ */
-static char gszMmsEncodeBuf[MSG_MMS_ENCODE_BUFFER_MAX] = {0, };
-static int gCurMmsEncodeBuffPos = 0;   /* number of characters on gpMmsEncodeBuf */
-static int     gMmsEncodeMaxLen = 0;
-static int     gMmsEncodeCurOffset = 0;        /* offset in file */
-static char *gpMmsEncodeBuf = NULL;
+static char gszMmsEncodeBuf[MSG_MMS_ENCODE_BUFFER_MAX] = {0, };
+static int gCurMmsEncodeBuffPos = 0;   /* number of characters on gpMmsEncodeBuf */
+static int     gMmsEncodeMaxLen = 0;
+static int     gMmsEncodeCurOffset = 0;        /* offset in file */
+static char *gpMmsEncodeBuf = NULL;
 
 /* Acknowledge.ind & NotifyResp.ind related variables ------------------------ */
-static char gszMmsEncodeBuf2[MSG_MMS_ENCODE_BUFFER_MAX] = {0, };
-static int     gCurMmsEncodeBuffPos2 = 0;      /* number of characters on gpMmsEncodeBuf */
-static int     gMmsEncodeMaxLen2 = 0;
-static int     gMmsEncodeCurOffset2 = 0;       /* offset in file */
-static char *gpMmsEncodeBuf2 = NULL;
+static char gszMmsEncodeBuf2[MSG_MMS_ENCODE_BUFFER_MAX] = {0, };
+static int     gCurMmsEncodeBuffPos2 = 0;      /* number of characters on gpMmsEncodeBuf */
+static int     gMmsEncodeMaxLen2 = 0;
+static int     gMmsEncodeCurOffset2 = 0;       /* offset in file */
+static char *gpMmsEncodeBuf2 = NULL;
 
 static int __MmsGetEncodeOffset(void);
 static void __MmsRegisterEncodeBuffer2(char *pInBuff, int maxLen);
 static void __MmsUnregisterEncodeBuffer2(void);
 
-static int __MmsBinaryEncodeUintvarLen(UINT32 integer);
-static bool __MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length);
-static int __MmsBinaryEncodeValueLengthLen(UINT32 integer);
-static bool __MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length);
-static int     __MmsBinaryEncodeIntegerLen(UINT32 integer);
-static bool __MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length);
-static int     __MmsBinaryEncodeLongIntegerLen(UINT32 integer);
-static bool __MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length);
-static int     __MmsBinaryEncodeTextStringLen(UINT8 *source);
-static bool __MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length);
-static int     __MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc);
-static bool __MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length);
-static int     __MmsBinaryEncodeEncodedStringLen(UINT8 *source);
-static bool __MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length);
+static int __MmsBinaryEncodeUintvarLen(UINT32 integer);
+static bool __MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length);
+static int __MmsBinaryEncodeValueLengthLen(UINT32 integer);
+static bool __MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length);
+static int     __MmsBinaryEncodeIntegerLen(UINT32 integer);
+static bool __MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length);
+static int     __MmsBinaryEncodeLongIntegerLen(UINT32 integer);
+static bool __MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length);
+static int     __MmsBinaryEncodeTextStringLen(UINT8 *source);
+static bool __MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length);
+static int     __MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc);
+static bool __MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length);
+static int     __MmsBinaryEncodeEncodedStringLen(UINT8 *source);
+static bool __MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length);
 
 static int __MmsBinaryEncodeContentTypeLen(MsgType *pType);
 static bool __MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength);
@@ -73,29 +73,29 @@ static bool __MmsBinaryEncodeContentHeader(FILE *pFile, MimeType contentType, Ms
 static bool __MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody);
 static bool __MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBody *pBody);
 
-static bool __MmsBinaryEncodeMmsVersion(FILE *pFile);
-static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen);
-static bool __MmsBinaryEncodeMsgID(FILE *pFile, const char *szMsgID);  /** 2005-05-24, added for read-reply PDU 1.2 */
-static bool __MmsBinaryEncodeFrom(FILE *pFile);
-static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeStruct time);
-static bool __MmsBinaryEncodeDate(FILE *pFile, time_t inpDateSec);
-static bool __MmsBinaryEncodeOneAddress(FILE *pFile, MmsFieldCode addrType, char *szAddrStr);
-static bool __MmsBinaryEncodeAddress(FILE *pFile, MmsFieldCode addrType, char *szAddr);
+static bool __MmsBinaryEncodeMmsVersion(FILE *pFile);
+static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen);
+static bool __MmsBinaryEncodeMsgID(FILE *pFile, const char *szMsgID);  /** 2005-05-24, added for read-reply PDU 1.2 */
+static bool __MmsBinaryEncodeFrom(FILE *pFile);
+static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeStruct time);
+static bool __MmsBinaryEncodeDate(FILE *pFile, time_t inpDateSec);
+static bool __MmsBinaryEncodeOneAddress(FILE *pFile, MmsFieldCode addrType, char *szAddrStr);
+static bool __MmsBinaryEncodeAddress(FILE *pFile, MmsFieldCode addrType, char *szAddr);
 
-static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue);
+static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue);
 static bool __MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg);
 static bool __MmsBinaryEncodeAckIndHdr(FILE *pFile, char *pTrID, bool bReportAllowed);
 static bool __MmsBinaryEncodeNotiRespIndHdr(FILE* pFile, char *pTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed);
 static bool __MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus);
 static bool __MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus);
 
-static bool __MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPartCount, bool bTemplate);//NEW_TEMPLATE
+static bool __MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPartCount, bool bTemplate); /* NEW_TEMPLATE */
 static bool __MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg, bool bIncludeSendReqHeader);
 
 /* Functions for Acknowledge.ind & NotifyResp.ind  ------------------------ */
-static bool __MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length);
-static bool __MmsBinaryEncodeMmsVersion2(FILE *pFile);
-static bool __MmsBinaryEncodeFieldCodeAndValue2(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue);
+static bool __MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length);
+static bool __MmsBinaryEncodeMmsVersion2(FILE *pFile);
+static bool __MmsBinaryEncodeFieldCodeAndValue2(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue);
 
 static char *_MsgSkipWS3(char *s);
 
@@ -103,7 +103,7 @@ static char *_MsgSkipWS3(char *s);
  *                                     M   M   S       E   N   C   O   D   E
  * * -----------------------------------------------------------------*/
 
-static void __MmsCleanEncodeBuff(void)
+static void __MmsCleanEncodeBuff(void)
 {
        memset(gpMmsEncodeBuf, 0, MSG_MMS_ENCODE_BUFFER_MAX);
        gCurMmsEncodeBuffPos = 0;
@@ -164,7 +164,7 @@ static bool __MmsEncodeSendReq(FILE* pFile, MmsMsg* pMsg, bool bIncludeSendReqHe
 
 /* Functions for Acknowledge.ind & NotifyResp.ind ------------------------ */
 
-static void __MmsCleanEncodeBuff2(void)
+static void __MmsCleanEncodeBuff2(void)
 {
        memset(gpMmsEncodeBuf2, 0, MSG_MMS_ENCODE_BUFFER_MAX);
        gCurMmsEncodeBuffPos2 = 0;
@@ -231,7 +231,7 @@ __CATCH:
        return false;
 }
 
-static bool __MmsBinaryEncodeFieldCodeAndValue2(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue)
+static bool __MmsBinaryEncodeFieldCodeAndValue2(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue)
 {
        if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < 2) {
                if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2,
@@ -543,14 +543,14 @@ bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t m
        time(&RawTime);
        localtime_r(&RawTime, &dateTime);
 
-       // get report message
+       /* get report message */
        if (mmsReadStatus == MSG_READ_REPORT_IS_DELETED) {
                pszReportMsg = (char*)"Your message has been deleted " ;
        } else {
                pszReportMsg = (char*)"Your message has been read " ;
        }
 
-       // make report body ..
+       /* make report body .. */
        maxLen = strlen (pszReportMsg) +16 /* date string */ + 8 /* enter chars */ ;
 
        if (maxLen > MSG_STDSTR_LONG) {
@@ -560,12 +560,12 @@ bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t m
                                                pszReportMsg, dateTime.tm_year+1900, dateTime.tm_mon+1, dateTime.tm_mday, dateTime.tm_hour, dateTime.tm_min);
        }
 
-       // make header
+       /* make header */
        msgType.type = MIME_APPLICATION_VND_WAP_MULTIPART_MIXED;
        msgType.contentSize = strlen(pText);
        msgType.param.charset = MSG_CHARSET_UNKNOWN;
 
-       // make body
+       /* make body */
        if ((pPart = MmsAllocMultipart()) == NULL) {
                MSG_DEBUG("MsgAllocMultipart Fail");
                goto __CATCH;
@@ -795,7 +795,8 @@ static bool __MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
        /* MMS-1.3-con-733 */
 
        /* Expiry Time  : Value-length Absolute-token Date-value */
-       if (pMsg->mmsAttrib.expiryTime.type != MMS_TIMETYPE_NONE) {     // for avoiding the creation of the expiry field in case the user selects the maximum
+       if (pMsg->mmsAttrib.expiryTime.type != MMS_TIMETYPE_NONE) {
+               /* for avoiding the creation of the expiry field in case the user selects the maximum */
                if (__MmsBinaryEncodeTime(pFile, MMS_CODE_EXPIRYTIME, pMsg->mmsAttrib.expiryTime) == false) {
                        MSG_DEBUG("expiryTime __MmsBinaryEncodeTime fail");
                        goto __CATCH;
@@ -875,7 +876,7 @@ static bool __MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
        if ((pMsg->mmsAttrib.replyCharge.chargeType == MMS_REPLY_REQUESTED) ||
                (pMsg->mmsAttrib.replyCharge.chargeType == MMS_REPLY_REQUESTED_TEXT_ONLY)) {
 
-               // reply charging
+               /* reply charging */
                fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGING)|0x80;
                fieldValue = MmsGetBinaryValue(MmsCodeReadReply, pMsg->mmsAttrib.replyCharge.chargeType)|0x80;
 
@@ -1394,7 +1395,7 @@ static int __MmsBinaryEncodeContentTypeLen(MsgType *pType)
                }
                totalLength += (length + 1);
        } else {
-               if (MmsIsTextType(contentType)) {       // Any-charset
+               if (MmsIsTextType(contentType)) {       /* Any-charset */
                        if (!MmsIsVitemContent (contentType, pType->param.szName))
                                totalLength += 2;
                }
@@ -1414,27 +1415,29 @@ static int __MmsBinaryEncodeContentTypeLen(MsgType *pType)
 
                pszName = g_strdup(pType->param.szName);
 
-               //change empty space to '_' in the file name
-               MmsReplaceSpaceChar(pszName);
+               if (pszName) {
+                       /* change empty space to '_' in the file name */
+                       MmsReplaceSpaceChar(pszName);
 
-               if (isAscii == false) {
-                       if (MsgEncode2Base64(pszName, strlen(pszName), &tmpLength, tmpFileName) == true) {
-                               g_free(pszName);
-                               pszName = g_strdup_printf("=?UTF-8?B?%s?=", tmpFileName);
-                               MSG_DEBUG("base64 encode filename=[%s]", pszName);
+                       if (isAscii == false) {
+                               if (MsgEncode2Base64(pszName, strlen(pszName), &tmpLength, tmpFileName) == true) {
+                                       g_free(pszName);
+                                       pszName = g_strdup_printf("=?UTF-8?B?%s?=", tmpFileName);
+                                       MSG_DEBUG("base64 encode filename=[%s]", pszName);
+                               }
                        }
-               }
 
-               length = __MmsBinaryEncodeTextStringLen((UINT8*)pszName);
+                       length = __MmsBinaryEncodeTextStringLen((UINT8*)pszName);
 
-               if (length == -1) {
-                       MSG_DEBUG("szName MmsBinaryEncodeIntegerLen fail");
-                       goto __CATCH;
-               }
+                       if (length == -1) {
+                               MSG_DEBUG("szName MmsBinaryEncodeIntegerLen fail");
+                               goto __CATCH;
+                       }
 
-               g_free(pszName);
+                       g_free(pszName);
 
-               totalLength += (length + 1);
+                       totalLength += (length + 1);
+               }
        }
 
 #ifdef FEATURE_JAVA_MMS
@@ -1606,7 +1609,7 @@ static bool __MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLe
 
                pszName = g_strdup(pType->param.szName);
 
-               //change empty space to '_' in the file name
+               /* change empty space to '_' in the file name */
                MmsReplaceSpaceChar(pszName);
 
                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_NAME) | 0x80;
@@ -1717,7 +1720,7 @@ static bool __MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLe
                if (MmsIsTextType(contentType)) {
                        if (!MmsIsVitemContent (contentType, pType->param.szName)) {
                                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_CHARSET) | 0x80;
-                               fieldValue = 0x0000;    //laconic_warning, just to remove warning message
+                               fieldValue = 0x0000;    /* laconic_warning, just to remove warning message */
                                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)fieldValue | 0x80;
                        }
                }
@@ -1847,12 +1850,12 @@ static bool __MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pTyp
                                        goto __CATCH;
                                }
                                pType->offset = __MmsGetEncodeOffset();
-                               if(MsgWriteFile(pData, sizeof(char), nRead, pFile) != (size_t)nRead) {
+                               if (MsgWriteFile(pData, sizeof(char), nRead, pFile) != (size_t)nRead) {
                                        MSG_DEBUG("MsgWriteFile failed");
                                        goto __CATCH;
                                }
                                gMmsEncodeCurOffset = MsgFtell(pFile);
-                               if(gMmsEncodeCurOffset < 0) {
+                               if (gMmsEncodeCurOffset < 0) {
                                        MSG_DEBUG("MsgFtell returns negative value [%ld]", gMmsEncodeCurOffset);
                                        goto __CATCH;
                                }
@@ -1963,7 +1966,7 @@ static int __MmsBinaryEncodeContentHeaderLen(MimeType contentType, MsgType *pTyp
 
        /* content-id ------------------------------------------------- */
        if (pType->szContentID[0]) {
-               if (bMultipart) { //Binary Encoding
+               if (bMultipart) { /* Binary Encoding */
                        totalLength++;
                } else {
                        /* content-id = Quoted-string */
@@ -1986,7 +1989,7 @@ static int __MmsBinaryEncodeContentHeaderLen(MimeType contentType, MsgType *pTyp
 
 
        if (pType->szContentLocation[0]) {
-               if (bMultipart) { //Binary Encoding
+               if (bMultipart) { /* Binary Encoding */
                        totalLength++;
                } else {
                        /* content-location = Quoted-string */
@@ -2023,7 +2026,7 @@ static int __MmsBinaryEncodeContentHeaderLen(MimeType contentType, MsgType *pTyp
                 * Inline = <Octet 130> : 0x82
                 */
 
-               if (bMultipart) { //Binary Encoding
+               if (bMultipart) { /* Binary Encoding */
                        totalLength += 3;
                } else {
                        /* content-disposition = Quoted-string */
@@ -2059,13 +2062,16 @@ static bool __MmsBinaryEncodeContentHeader(FILE *pFile, MimeType contentType, Ms
 {
        int     length = 0;
        const char *szTextValue = NULL;
+       bool isAscii = true;
+       unsigned long tmpLength = 0;
+       unsigned char tmpFileName[MSG_LOCALE_FILENAME_LEN_MAX+1];
 
        /* content-id ------------------------------------------------- */
        if (pType->szContentID[0]) {
 
                MSG_SEC_DEBUG("Content ID : %s", pType->szContentID);
 
-               if (bMultipart) { //Binary Encoding
+               if (bMultipart) { /* Binary Encoding */
                        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTID) | 0x80;
                } else {
                        /* content-id = Quoted-string */
@@ -2094,10 +2100,16 @@ static bool __MmsBinaryEncodeContentHeader(FILE *pFile, MimeType contentType, Ms
        }
 
        if (pType->szContentLocation[0]) {
-
                MSG_SEC_DEBUG("Content Location : %s", pType->szContentLocation);
 
-               if (bMultipart) { //Binary Encoding
+               if (MmsIsAsciiString (pType->szContentLocation)) {
+                       MSG_DEBUG("Name is consisted of ascii char-set chars.");
+               } else {
+                       isAscii = false;
+                       MSG_DEBUG("Name is NOT consisted of ascii char-set chars.");
+               }
+
+               if (bMultipart) { /* Binary Encoding */
                        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTLOCATION) | 0x80;
                } else {
                        /* content-location = Quoted-string */
@@ -2113,16 +2125,31 @@ static bool __MmsBinaryEncodeContentHeader(FILE *pFile, MimeType contentType, Ms
                        }
                }
 
-               length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->szContentLocation);
+               char* pszName = g_strdup(pType->szContentLocation);
+               MmsReplaceSpaceChar(pszName);
+
+               if (isAscii == false) {
+                       if (MsgEncode2Base64(pszName, strlen(pszName), &tmpLength, tmpFileName) == true) {
+                               g_free(pszName);
+                               pszName = g_strdup_printf("=?UTF-8?B?%s?=", tmpFileName);
+                               MSG_DEBUG("base64 encode filename=[%s]", pszName);
+                       }
+               }
+
+               length = __MmsBinaryEncodeTextStringLen((UINT8*)pszName);
                if (length == -1) {
                        MSG_DEBUG("pType->szContentLocation MmsBinaryEncodeTextStringLen fail.");
+                       g_free(pszName);
                        goto __CATCH;
                }
 
-               if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pType->szContentLocation, length) == false) {
+               if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pszName, length) == false) {
                        MSG_DEBUG("pType->szContentLocation MmsBinaryEncodeTextString fail.");
+                       g_free(pszName);
                        goto __CATCH;
                }
+
+               g_free(pszName);
        }
 
        /* MIME_APPLICATION_VND_WAP_MULTIPART_RELATED requires always "inline" */
@@ -2140,7 +2167,7 @@ static bool __MmsBinaryEncodeContentHeader(FILE *pFile, MimeType contentType, Ms
                 * Inline = <Octet 130> : 0x82
                 */
 
-               if (bMultipart) {//Binary Encoding
+               if (bMultipart) { /* Binary Encoding */
 
                        UINT8 fieldValue  = 0xff;
                        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_DISPOSITION) | 0x80;
@@ -2208,7 +2235,7 @@ static bool __MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody)
                        goto __CATCH;
 
                pBody->offset = __MmsGetEncodeOffset();
-               if(MsgWriteFile(pData, sizeof(char), nRead, pFile) != (size_t)nRead) {
+               if (MsgWriteFile(pData, sizeof(char), nRead, pFile) != (size_t)nRead) {
                        MSG_DEBUG("MsgWriteFile failed");
                        goto __CATCH;
                }
@@ -2231,7 +2258,7 @@ static bool __MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody)
                }
                gMmsEncodeCurOffset = MsgFtell(pFile);
 
-               if(gMmsEncodeCurOffset < 0) {
+               if (gMmsEncodeCurOffset < 0) {
                        MSG_DEBUG("MsgFtell returns negative value [%ld]", gMmsEncodeCurOffset);
                        goto __CATCH;
                }
@@ -2272,7 +2299,7 @@ static int __MmsBinaryEncodeIntegerLen(UINT32 integer)
                        integer = (integer >> 8);
                }
 
-               length++;       // + Short-length
+               length++;       /* + Short-length */
 
                return length;
        }
@@ -2314,7 +2341,7 @@ static bool __MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length)
                 * The Short-length indicates the length of the Multi-octet-integer
                 */
                changer.integer = integer;
-               length--;                                       // - "Short-length"
+               length--;                                       /* - "Short-length" */
 
                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)length;
 
@@ -2348,7 +2375,7 @@ static int __MmsBinaryEncodeLongIntegerLen(UINT32 integer)
                integer = (integer >> 8);
        }
 
-       length++;       // + Short-length
+       length++;       /* + Short-length */
 
        return length;
 }
@@ -2386,7 +2413,7 @@ static bool __MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length
        }
 
        changer.integer = integer;
-       length--;                                       // - "Short-length"
+       length--;                                       /* - "Short-length" */
 
        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)length;
 
@@ -2412,9 +2439,9 @@ static int __MmsBinaryEncodeTextStringLen(UINT8 *source)
 
        length = (int)strlen((char*)source);
        if (source[0] > 0x7F) {
-               length += 2;                    // + NULL
+               length += 2;                    /* + NULL */
        } else {
-               length++;                               // + NULL
+               length++;                               /* + NULL */
        }
 
        return length;
@@ -2455,8 +2482,8 @@ static bool __MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length)
                length--;
        }
 
-       strncpy(gpMmsEncodeBuf + gCurMmsEncodeBuffPos, (char*)source, (length - 1));    // except NULL
-       gCurMmsEncodeBuffPos += (length - 1);                   // except NULL
+       strncpy(gpMmsEncodeBuf + gCurMmsEncodeBuffPos, (char*)source, (length - 1));    /* except NULL */
+       gCurMmsEncodeBuffPos += (length - 1);                   /* except NULL */
        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)NULL;
 
        return true;
@@ -2471,9 +2498,9 @@ __CATCH:
  * @param      interger [in] integer to be encoded
  * @return     encoded UINTVAR stream
 */
-const UINT32 UINTVAR_LENGTH_1 =  0x0000007f;           //7bit
-const UINT32 UINTVAR_LENGTH_2 =  0x00003fff;           //14bit
-const UINT32 UINTVAR_LENGTH_3 =  0x001fffff;           //21bit
+const UINT32 UINTVAR_LENGTH_1 =  0x0000007f;           /* 7bit */
+const UINT32 UINTVAR_LENGTH_2 =  0x00003fff;           /* 14bit */
+const UINT32 UINTVAR_LENGTH_3 =  0x001fffff;           /* 21bit */
 
 
 static int __MmsBinaryEncodeUintvarLen(UINT32 integer)
@@ -2530,7 +2557,7 @@ static bool __MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length)
        szReverse[0] = source.bytes[0];
        szReverse[0] = szReverse[0] & 0x7f;
 
-       while (length >= i) { // initially, i = 2
+       while (length >= i) { /* initially, i = 2 */
                /* Move integer bit to proper position */
                source.integer = source.integer << 1;
                source.integer = source.integer >> 8;
@@ -2558,7 +2585,7 @@ static int __MmsBinaryEncodeValueLengthLen(UINT32 integer)
        if (integer < 0x1f) {
                length = 1;
        } else {
-               length = __MmsBinaryEncodeUintvarLen(integer) + 1;              //LENGTH_QUOTE
+               length = __MmsBinaryEncodeUintvarLen(integer) + 1;              /* LENGTH_QUOTE */
        }
 
        return length;
@@ -2597,7 +2624,7 @@ static bool __MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length
                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)integer;
        } else {
                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)LENGTH_QUOTE;
-               if (__MmsBinaryEncodeUintvar(pFile, integer, length - 1) == false) {    // LENGTH_QUOTE
+               if (__MmsBinaryEncodeUintvar(pFile, integer, length - 1) == false) {    /* LENGTH_QUOTE */
                        MSG_DEBUG("MmsBinaryEncodeUintvar fail");
                        goto __CATCH;
                }
@@ -2616,7 +2643,7 @@ static int __MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc)
                goto __CATCH;
        }
 
-       return (strlen((char*)pSrc) + 2);       // QUOTE + NULL
+       return (strlen((char*)pSrc) + 2);       /* QUOTE + NULL */
 
 __CATCH:
        return -1;
@@ -2647,7 +2674,7 @@ static bool __MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length
        }
 
        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = '\"';
-       strncpy(gpMmsEncodeBuf + gCurMmsEncodeBuffPos, (char*)source, length - 2);              // except '\"' & NULL
+       strncpy(gpMmsEncodeBuf + gCurMmsEncodeBuffPos, (char*)source, length - 2);              /* except '\"' & NULL */
        gCurMmsEncodeBuffPos += (length - 2);
        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)NULL;
 
@@ -2659,7 +2686,7 @@ __CATCH:
 
 static int __MmsBinaryEncodeEncodedStringLen(UINT8 *source)
 {
-       UINT32 charset = 0x6A;          // default = utf-8
+       UINT32 charset = 0x6A;          /* default = utf-8 */
        int charLeng            = 0;
        int textLeng            = 0;
        int valueLengthLen      = 0;
@@ -2698,7 +2725,7 @@ __CATCH:
  */
 static bool __MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length)
 {
-       UINT32 charset = 0x6A;          // default = utf-8
+       UINT32 charset = 0x6A;          /* default = utf-8 */
        int charLeng = 0;
        int textLeng = 0;
        int valLengthLen = 0;
@@ -2766,7 +2793,7 @@ __CATCH:
        return false;
 }
 
-static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue)
+static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue)
 {
        if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 2) {
                if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
@@ -2953,7 +2980,7 @@ static bool __MmsBinaryEncodeDate(FILE *pFile, time_t inpDateSec)
                int     length  = 0;
                length = __MmsBinaryEncodeLongIntegerLen(dateSec);
 
-               if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) { // + fieldCode
+               if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) { /* + fieldCode */
                        if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
                                                                                                gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
                                MSG_DEBUG("MsgWriteDataFromEncodeBuffer fail");
@@ -3128,13 +3155,13 @@ static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeSt
                goto __CATCH;
        }
 
-       length = __MmsBinaryEncodeValueLengthLen(timeLen + 1);  //time length + time type token
+       length = __MmsBinaryEncodeValueLengthLen(timeLen + 1);  /* time length + time type token */
        if (length == -1) {
                MSG_DEBUG("MmsBinaryEncodeValueLengthLen fail");
                goto __CATCH;
        }
 
-       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + timeLen + 2)) {       // + fieldCode + timeType
+       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + timeLen + 2)) {       /* + fieldCode + timeType */
 
                if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
                                                                                        gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
@@ -3229,7 +3256,7 @@ static bool __EncodeMmsMessage(MmsMsg *pMmsMsg, const char *raw_filepath)
                break;
        }
 
-       MsgFsync(pFile);        //file is written to device immediately, it prevents missing file data from unexpected power off
+       MsgFsync(pFile);        /* file is written to device immediately, it prevents missing file data from unexpected power off */
        MsgCloseFile(pFile);
 
        return true;
index 15c4490..0a4893d 100755 (executable)
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <ITapiCall.h>
+#include <ITapiNetwork.h>
+#include <tapi_common.h>
 
 #include "MmsPluginTypes.h"
 #include "MmsPluginDebug.h"
 #include "MmsPluginEventHandler.h"
 #include "MmsPluginInternal.h"
+#include "MsgGconfWrapper.h"
 
 /*==================================================================================================
                                      IMPLEMENTATION OF MmsPluginEventHandler - Member Functions
 ==================================================================================================*/
+
+typedef struct {
+       int count;
+       TapiHandle *handle[MAX_TELEPHONY_HANDLE_CNT]; /* max is 3 */
+} SMS_TELEPHONY_HANDLE_LIST_S;
+
+SMS_TELEPHONY_HANDLE_LIST_S handle_list;
+
 MmsPluginEventHandler *MmsPluginEventHandler::pInstance = NULL;
 
 
@@ -54,25 +66,84 @@ void MmsPluginEventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
        listener = *pListener;
 }
 
+int MmsPluginEventHandler::initTelHandle()
+{
+       int cnt = 0;
+       memset(&handle_list, 0x00, sizeof(handle_list));
+
+       char **cp_list = NULL;
+       cp_list = tel_get_cp_name_list();
+
+       if (!cp_list) {
+               MSG_FATAL("tel_get_cp_name_list returns null");
+               goto FINISH;
+       }
+
+       while (cp_list[cnt] && cnt < MAX_TELEPHONY_HANDLE_CNT) {
+               MSG_SEC_INFO("cp_list[%d]:[%s]", cnt, cp_list[cnt]);
+               handle_list.handle[cnt]= tel_init(cp_list[cnt]);
+               cnt++;
+       }
+
+       g_strfreev(cp_list);
+       cp_list = NULL;
+
+FINISH:
+       handle_list.count = cnt;
+       return cnt;
+}
+
+void MmsPluginEventHandler::deinitTelHandle()
+{
+       int ret = 0;
+
+       for (int i = 0; i < handle_list.count; i++) {
+               ret = tel_deinit(handle_list.handle[i]);
+               MSG_DEBUG("tel_deinit ret=[%d]", ret);
+               handle_list.handle[i] = NULL;
+       }
+
+       handle_list.count = 0;
+       return;
+}
+
+TapiHandle *MmsPluginEventHandler::getTelHandle(int sim_idx)
+{
+       if (sim_idx > 0 && sim_idx < MAX_TELEPHONY_HANDLE_CNT) {
+               return handle_list.handle[sim_idx-1];
+       } else {
+               int SIM_Status = 0;
+               SIM_Status = MsgSettingGetInt(VCONFKEY_TELEPHONY_SIM_SLOT);
+               if (SIM_Status == 1) {
+                       return handle_list.handle[0];
+               }
+
+               SIM_Status = MsgSettingGetInt(VCONFKEY_TELEPHONY_SIM_SLOT2);
+               if (SIM_Status == 1) {
+                       return handle_list.handle[1];
+               }
+       }
+
+       return handle_list.handle[handle_list.count - 1];
+}
 
 void MmsPluginEventHandler::handleMmsReceivedData(mmsTranQEntity *pRequest, char *pRetrievedFilePath)
 {
        MSG_MESSAGE_INFO_S msgInfo = {0,};
 
        switch (pRequest->eMmsPduType) {
-       // received data is send-conf
+       /* received data is send-conf */
        case eMMS_SEND_CONF:
                MmsPluginInternal::instance()->processSendConf(&msgInfo, pRequest);
 
-               // callback to MSG FW
+               /* callback to MSG FW */
                listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
 
-               //MsgDeleteFile(pRetrievedFilePath + strlen(MSG_DATA_PATH)); // not ipc
                if (remove(pRetrievedFilePath) != 0)
                        MSG_DEBUG("remove fail");
                break;
 
-       // received data is retrieve-conf
+       /* received data is retrieve-conf */
        case eMMS_RETRIEVE_AUTO_CONF:
        case eMMS_RETRIEVE_MANUAL_CONF:
                MSG_ADDRESS_INFO_S addrInfo;
@@ -81,7 +152,7 @@ void MmsPluginEventHandler::handleMmsReceivedData(mmsTranQEntity *pRequest, char
 
                MmsPluginInternal::instance()->processRetrieveConf(&msgInfo, pRequest, pRetrievedFilePath);
 
-               // callback to MSG FW
+               /* callback to MSG FW */
                listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
                break;
 
@@ -114,12 +185,13 @@ void MmsPluginEventHandler::handleMmsError(mmsTranQEntity *pRequest)
        curTime = time(NULL);
 
        msgInfo.displayTime = curTime;
+       msgInfo.sim_idx = pRequest->simId;
 
        switch (pRequest->eMmsPduType) {
        case eMMS_SEND_REQ:
        case eMMS_SEND_CONF:
                msgInfo.msgId = pRequest->msgId;
-               //Set only changed members
+               /* Set only changed members */
                msgInfo.msgType.mainType = MSG_MMS_TYPE;
 
                if (pRequest->eMmsPduType == eMMS_SEND_REQ)
@@ -131,41 +203,70 @@ void MmsPluginEventHandler::handleMmsError(mmsTranQEntity *pRequest)
 
                msgInfo.folderId = MSG_OUTBOX_ID;
 
-               listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
                break;
 
        case eMMS_RETRIEVE_AUTO:
        case eMMS_RETRIEVE_AUTO_CONF:
                msgInfo.msgId = pRequest->msgId;
-               //Set only changed members
+               /* Set only changed members */
                msgInfo.msgType.mainType = MSG_MMS_TYPE;
                msgInfo.msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
 
                msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
                msgInfo.folderId = MSG_INBOX_ID;
 
-               err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
-
                break;
 
        case eMMS_RETRIEVE_MANUAL:
        case eMMS_RETRIEVE_MANUAL_CONF:
                msgInfo.msgId = pRequest->msgId;
-               //Set only changed members
+               /* Set only changed members */
                msgInfo.msgType.mainType = MSG_MMS_TYPE;
                msgInfo.msgType.subType = MSG_RETRIEVE_MANUALCONF_MMS;
 
                msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
                msgInfo.folderId = MSG_INBOX_ID;
 
-               err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
-
                break;
 
        default:
-               break;
+               MSG_WARN("No matching MMS pdu type [%d]", pRequest->eMmsPduType);
+               return;
        }
 
+       int dnet_state = 0;
+       if (msgInfo.sim_idx == 1)
+               dnet_state = MsgSettingGetInt(VCONFKEY_DNET_STATE);
+       else if (msgInfo.sim_idx == 2)
+               dnet_state = MsgSettingGetInt(VCONFKEY_DNET_STATE2);
+
+       int net_cell_type = 0;
+
+       initTelHandle();
+
+       TapiHandle *handle = getTelHandle(msgInfo.sim_idx);
+       tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &net_cell_type);
+
+       deinitTelHandle();
+
+       bool data_enable = FALSE;
+       int call_status = MsgSettingGetInt(MSG_MESSAGE_DURING_CALL);
+
+       MsgSettingGetBool(VCONFKEY_3G_ENABLE, &data_enable);
+
+       MSG_INFO("Call[%d], Data[%d], SubType[%d]", call_status, data_enable, msgInfo.msgType.subType);
+       MSG_INFO("sim_idx[%d], dnet_state[%d], net_cell_type[%d]", msgInfo.sim_idx, dnet_state, net_cell_type);
+
+       if (pRequest->eMmsTransactionStatus == eMMS_CM_DISCONNECTED || ((call_status || net_cell_type <= TAPI_NETWORK_SERVICE_TYPE_SEARCH || dnet_state <= VCONFKEY_DNET_OFF) && data_enable)) {
+               MSG_INFO("MMS network status goes to pending for subtype [%d]", msgInfo.msgType.subType);
+               if (msgInfo.msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || msgInfo.msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS)
+                       msgInfo.networkStatus = MSG_NETWORK_RETRIEVE_PENDING;
+               else if (msgInfo.msgType.subType == MSG_SENDREQ_MMS)
+                       msgInfo.networkStatus = MSG_NETWORK_SEND_PENDING;
+       }
+
+       err = listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
+
        MSG_DEBUG("Error value of MsgMmsConfIncomingListner [%d]", err);
 
        MSG_END();
index 9eb8398..73c03e2 100755 (executable)
@@ -34,15 +34,10 @@ static void __httpGetHost(char *szUrl, char *szHost, int nBufferLen);
 /*==================================================================================================
                                      FUNCTION IMPLEMENTATION
 ==================================================================================================*/
-//static int __http_progress_cb(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
-//{
-//     MSG_INFO("download(%.0f/%.0f) : upload(%.0f/%.0f)", dlnow, dltotal, ulnow, ultotal);
-//     return 0;
-//}
 
 static int __http_debug_cb (CURL *input_curl, curl_infotype input_info_type, char *input_data , size_t input_size, void *input_void)
 {
-       MSG_INFO("curl_infotype [%d] : %s", input_info_type, input_data);
+       MSG_SEC_INFO("curl_infotype [%d] : %s", input_info_type, input_data);
        return 0;
 }
 
@@ -68,15 +63,15 @@ static void __http_print_profile(CURL *curl)
 
        MSG_DEBUG("**************************************************************************************************");
 
-       //time
+       /* time */
        curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total_time);
        MSG_SEC_INFO("profile http Time: total %.3f seconds", total_time);
 
-       //url
+       /* url */
        curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
        MSG_SEC_INFO("profile http Url: %s", url);
 
-       //size
+       /* size */
        curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD, &size_up);
        MSG_SEC_INFO("profile http Size: upload %.3f bytes", size_up);
 
@@ -89,14 +84,14 @@ static void __http_print_profile(CURL *curl)
        curl_easy_getinfo(curl, CURLINFO_REQUEST_SIZE, &size);
        MSG_SEC_INFO("profile http Size: request %ld bytes", size);
 
-       //speed
+       /* speed */
        curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &speed_upload);
        MSG_SEC_INFO("profile http Speed: upload %.3f bytes/sec", speed_upload);
 
        curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD, &speed_download);
        MSG_SEC_INFO("profile http Speed: download %.3f bytes/sec", speed_download);
 
-       //content
+       /* content */
        curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &content_type);
        MSG_SEC_INFO("profile http Content: type %s", content_type);
 
@@ -106,7 +101,7 @@ static void __http_print_profile(CURL *curl)
        curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_UPLOAD, &content_length);
        MSG_SEC_INFO("profile http Content: length upload %.3f", content_length);
 
-       //ip & port
+       /* ip & port */
        curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip);
        MSG_SEC_INFO("profile http primary: ip %s", ip);
 
@@ -205,7 +200,7 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int
        nResult = __httpGetHeaderField(MMS_HH_UA_PROFILE, szBuffer);
        if (nResult) {
                snprintf(pcheader, HTTP_REQUEST_LEN, "X-wap-profile: %s", szBuffer);
-               MSG_INFO("%s", pcheader);
+               MSG_SEC_INFO("%s", pcheader);
                *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
        }
 
@@ -214,10 +209,10 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int
        memset(pcheader, 0, HTTP_REQUEST_LEN);
        nResult = __httpGetHeaderField(MMS_HH_MDN, szBuffer);
 
-       // TODO : if it needs to check http header mdn value, add code to below.
+       /* TODO : if it needs to check http header mdn value, add code to below. */
 #endif
 
-       if (ulContentLen > 0)//if post transaction then Disable 'Expect: 100-contine' option
+       if (ulContentLen > 0) /* if post transaction then Disable 'Expect: 100-contine' option */
                *responseHeaders = curl_slist_append(*responseHeaders, "Expect:");
 }
 
@@ -240,7 +235,11 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s
 
                case MMS_HH_ACCEPT_CHARSET:
                        snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_CHARSET);
+#if defined(FEATURE_SMS_CDMA)
+                       result = false;
+#else
                        result = true;
+#endif
                        break;
 
                case MMS_HH_ACCEPT_LANGUAGE:
@@ -253,8 +252,7 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s
                        result = true;
                        break;
 
-               case MMS_HH_USER_AGENT:
-                       {
+               case MMS_HH_USER_AGENT: {
 #if 0
                                char szUserAgent[1024 + 1];
                                char *uagent = NULL;
@@ -282,8 +280,7 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s
                        }
                        break;
 
-               case MMS_HH_UA_PROFILE:
-                       {
+               case MMS_HH_UA_PROFILE: {
                                char *szUAProfile = MsgSettingGetString(MSG_MMS_UA_PROFILE);
 
                                snprintf((char *)szHeaderBuffer, 1024, "%s", szUAProfile);
@@ -296,22 +293,22 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s
                        break;
 
 #if defined(FEATURE_SMS_CDMA)
-               case MMS_HH_MDN:
-//                     {
-//                             char *mdn = MsgSettingGetString(MSG_SIM_MSISDN);
-//
-//                             if (mdn != NULL && strlen(mdn) > 0) {
-//                                     result = true;
-//                                     snprintf((char *)szHeaderBuffer, 1024, "%s", mdn);
-//                             } else {
-//                                     result = false;
-//                             }
-//                             if (mdn) {
-//                                     free(mdn);
-//                                     mdn = NULL;
-//                             }
-//                     }
+               case MMS_HH_MDN: {
+/*
+                       char *mdn = MsgSettingGetString(MSG_SIM_MSISDN);
+                       if (mdn != NULL && strlen(mdn) > 0) {
+                               result = true;
+                               snprintf((char *)szHeaderBuffer, 1024, "%s", mdn);
+                       } else {
+                               result = false;
+                       }
+                       if (mdn) {
+                               free(mdn);
+                               mdn = NULL;
+                       }
                        break;
+*/
+               }
 #endif
                default:
                        MSG_WARN("invalid param [%d]", httpHeaderItem);
@@ -335,34 +332,34 @@ static void __httpGetHost(char *szUrl, char *szHost, int nBufferLen)
        char *startPtr = szUrl;
        char *movePtr = NULL;
 
-       MSG_DEBUG("startPtr(%s)", startPtr);
+       MSG_SEC_DEBUG("startPtr(%s)", startPtr);
 
        if (strncasecmp(startPtr, prefixString, prefixLength) == 0) {
-               MSG_DEBUG("(%s) exist", prefixString);
+               MSG_SEC_DEBUG("(%s) exist", prefixString);
                startPtr += prefixLength;
                movePtr = startPtr;
                movePtr = strpbrk(movePtr, delim);
-               MSG_DEBUG("strpbrk --> movePtr(%s)", movePtr);
+               MSG_SEC_DEBUG("strpbrk --> movePtr(%s)", movePtr);
                if (movePtr == NULL) {
                        strncpy(szHost, startPtr, nBufferLen);
-                       MSG_DEBUG("szHost(%s)", szHost);
+                       MSG_SEC_DEBUG("szHost(%s)", szHost);
                } else {
                        int nCopyLen = movePtr - startPtr;
                        strncpy(szHost, startPtr, nCopyLen);
-                       MSG_DEBUG("szHost(%s)", szHost);
+                       MSG_SEC_DEBUG("szHost(%s)", szHost);
                }
        } else {
-               MSG_DEBUG("(%s) not exist", prefixString);
+               MSG_SEC_DEBUG("(%s) not exist", prefixString);
                movePtr = startPtr;
                movePtr = strpbrk(movePtr, delim);
-               MSG_DEBUG("strpbrk --> movePtr(%s)", movePtr);
+               MSG_SEC_DEBUG("strpbrk --> movePtr(%s)", movePtr);
                if (movePtr == NULL) {
                        strncpy(szHost, startPtr, nBufferLen);
-                       MSG_DEBUG("szHost(%s)", szHost);
+                       MSG_SEC_DEBUG("szHost(%s)", szHost);
                } else {
                        int nCopyLen = movePtr - startPtr;
                        strncpy(szHost, startPtr, nCopyLen);
-                       MSG_DEBUG("szHost(%s)", szHost);
+                       MSG_SEC_DEBUG("szHost(%s)", szHost);
                }
        }
 }
@@ -394,54 +391,35 @@ static int __http_multi_perform(void *session)
        MSG_INFO("curl_multi_perform first end : rcm = %d, still_running = %d", rcm, still_running);
 
        do {
+               int retval;
                struct timeval timeout;
-               int rc; /* select() return code */
 
-               fd_set fdread;
-               fd_set fdwrite;
-               fd_set fdexcep;
-               int maxfd = -1;
+               int max_fd = -1;
+               fd_set fd_r;
+               fd_set fd_w;
+               fd_set fd_excp;
 
-//             long curl_timeo = -1;
+               FD_ZERO(&fd_r);
+               FD_ZERO(&fd_w);
+               FD_ZERO(&fd_excp);
 
-               FD_ZERO(&fdread);
-               FD_ZERO(&fdwrite);
-               FD_ZERO(&fdexcep);
-
-               /* set a suitable timeout to play around with */
                timeout.tv_sec = 120;
                timeout.tv_usec = 0;
 
-//             curl_multi_timeout(multi_handle, &curl_timeo);
-//             if(curl_timeo >= 0) {
-//                     MSG_DEBUG("curl_timeo = %ld", curl_timeo);
-//                     timeout.tv_sec = curl_timeo / 1000;
-//                     if(timeout.tv_sec > 1)
-//                             timeout.tv_sec = 1;
-//                     else
-//                             timeout.tv_usec = (curl_timeo % 1000) * 1000;
-//             }
-
-               curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
-
-               /* In a real-world program you OF COURSE check the return code of the
-               function calls.  On success, the value of maxfd is guaranteed to be
-               greater or equal than -1.  We call select(maxfd + 1, ...), specially in
-               case of (maxfd == -1), we call select(0, ...), which is basically equal
-               to sleep. */
+               curl_multi_fdset(multi_handle, &fd_r, &fd_w, &fd_excp, &max_fd);
 
-               rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+               retval = select(max_fd+1, &fd_r, &fd_w, &fd_excp, &timeout);
 
-               if (rc == -1){/* select error */
+               if (retval == -1){ /* select error */
                        MSG_ERR("select error");
                        ret = -1;
                        break;
-               } else if (rc == 0){    /* timeout */
+               } else if (retval == 0){        /* timeout */
                        MSG_ERR("time out");
                        ret = -1;
                        break;
-               } else {/* action */
-                       MSG_DEBUG("rc = %d", rc);
+               } else { /* action */
+                       MSG_DEBUG("retval = %d", retval);
                        rcm = curl_multi_perform(multi_handle, &still_running);
                }
 
@@ -453,7 +431,7 @@ static int __http_multi_perform(void *session)
 
                MSG_INFO("curl_multi_perform end : rcm = %d, still_running = %d, cm_open = %d", rcm, still_running, connection_open_flag);
 
-       } while(still_running && (connection_open_flag == true));
+       } while (still_running && (connection_open_flag == true));
 
        while ((msg = curl_multi_info_read(multi_handle, &msgs_left))) {
                if (msg->msg == CURLMSG_DONE) {
@@ -583,7 +561,7 @@ MMS_HTTP_ERROR_E MmsPluginHttpAgent::setSession(http_request_info_s &request_inf
        int content_len = 0;
        char *url = NULL;
 
-       // Verify request info
+       /* Verify request info */
        if (request_info.transaction_type != MMS_HTTP_TRANSACTION_TYPE_GET
                        && request_info.transaction_type != MMS_HTTP_TRANSACTION_TYPE_POST)
        {
@@ -607,14 +585,14 @@ MMS_HTTP_ERROR_E MmsPluginHttpAgent::setSession(http_request_info_s &request_inf
                goto __CATCH;
        }
 
-       //Set type
+       /* Set type */
        this->transaction_type = request_info.transaction_type;
        MSG_DEBUG("set transaction type [%d]", this->transaction_type);
 
-       //Set http Headers
+       /* Set http Headers */
        if (this->transaction_type == MMS_HTTP_TRANSACTION_TYPE_POST) {
                content_len = request_info.post_data_len;
-       } else { //MMS_HTTP_TRANSACTION_TYPE_GET
+       } else { /* MMS_HTTP_TRANSACTION_TYPE_GET */
                content_len = 0;
        }
 
@@ -636,7 +614,7 @@ MMS_HTTP_ERROR_E MmsPluginHttpAgent::setSession(http_request_info_s &request_inf
        }
 
 
-       //Set curl option
+       /* Set curl option */
        session_option = curl_easy_init();
        if (session_option == NULL) {
                MSG_ERR("curl_easy_init() failed");
@@ -651,7 +629,6 @@ MMS_HTTP_ERROR_E MmsPluginHttpAgent::setSession(http_request_info_s &request_inf
        curl_easy_setopt(session_option, CURLOPT_HTTPHEADER, session_header);
        curl_easy_setopt(session_option, CURLOPT_DEBUGFUNCTION , __http_debug_cb);
        curl_easy_setopt(session_option, CURLOPT_INTERFACE, request_info.interface);
-       //curl_easy_setopt(httpConfigData.session, CURLOPT_PROGRESSFUNCTION, __http_progress_cb); //for debug
 
        if (respfile) {
                curl_easy_setopt(session_option, CURLOPT_WRITEFUNCTION, __http_write_response_cb);
@@ -662,14 +639,14 @@ MMS_HTTP_ERROR_E MmsPluginHttpAgent::setSession(http_request_info_s &request_inf
                curl_easy_setopt(session_option, CURLOPT_POST, true);
                curl_easy_setopt(session_option, CURLOPT_POSTFIELDS, request_info.post_data);
                curl_easy_setopt(session_option, CURLOPT_POSTFIELDSIZE, request_info.post_data_len);
-       //      curl_easy_setopt(session_option, CURLOPT_TCP_NODELAY, 1);
+/*             curl_easy_setopt(session_option, CURLOPT_TCP_NODELAY, 1); */
        }
 
        MSG_END();
        return http_error;
 
 __CATCH:
-       //CID 338211: freeing url (with check) in case of error
+       /* CID 338211: freeing url (with check) in case of error */
        if (url) {
                free(url);
                url = NULL;
@@ -709,14 +686,14 @@ MMS_HTTP_ERROR_E MmsPluginHttpAgent::httpRequest(http_request_info_s &request_in
 
        respfile = fopen(conf_filename, "wb");
 
-       //set session
+       /* set session */
        http_error = this->setSession(request_info);
        if (http_error != MMS_HTTP_ERROR_NONE) {
                MSG_ERR("Fail to setSession");
                goto __CATCH;
        }
 
-       //transaction
+       /* transaction */
        http_error = this->startTransaction();
 
        if (http_error != MMS_HTTP_ERROR_NONE) {
@@ -724,7 +701,7 @@ MMS_HTTP_ERROR_E MmsPluginHttpAgent::httpRequest(http_request_info_s &request_in
                goto __CATCH;
        }
 
-       //close conf file & load response data
+       /* close conf file & load response data */
        if (respfile) {
 
                fclose(respfile);
index 4d4cb87..e704e72 100755 (executable)
@@ -27,6 +27,7 @@
 #include "MsgStorageHandler.h"
 #include "MsgSerialize.h"
 #include "MsgSpamFilter.h"
+#include "MsgUtilMime.h"
 
 #include "MmsPluginDebug.h"
 #include "MmsPluginTypes.h"
@@ -34,7 +35,6 @@
 #include "MmsPluginInternal.h"
 #include "MmsPluginStorage.h"
 #include "MmsPluginAppBase.h"
-#include "MmsPluginMIME.h"
 
 /*==================================================================================================
                                      IMPLEMENTATION OF MmsPluginInternal - Member Functions
@@ -70,12 +70,12 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ
        if (pMsgInfo->bTextSms == true) {
                char fullPath[MAX_FULL_PATH_SIZE+1] = {0,};
 
-               if(MsgCreateFileName(fileName) == false)
+               if (MsgCreateFileName(fileName) == false)
                        THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
 
                MSG_SEC_DEBUG("File name = %s", fileName);
 
-               if(MsgWriteIpcFile(fileName, pMsgInfo->msgText, pMsgInfo->dataSize) == false)
+               if (MsgWriteIpcFile(fileName, pMsgInfo->msgText, pMsgInfo->dataSize) == false)
                        THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
 
                snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s%s", MSG_IPC_DATA_PATH, fileName);
@@ -93,7 +93,7 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ
        if ((pFile = MsgOpenFile(pMsgInfo->msgData, "rb+")) == NULL) {
                MSG_DEBUG("File Open Error: %s", pMsgInfo->msgData);
        } else {
-               //Decode Header
+               /* Decode Header */
                if (!MmsBinaryDecodeMsgHeader(pFile, pMsgInfo->dataSize))
                        MSG_DEBUG("Decoding Header Failed \r\n");
 
@@ -105,7 +105,7 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ
                switch (mmsHeader.type) {
                case MMS_MSGTYPE_NOTIFICATION_IND:
                        MSG_DEBUG("process noti.ind\n");
-                       // For Set Value pMsgInfo
+                       /* For Set Value pMsgInfo */
                        if (processNotiInd(pMsgInfo, pRequest) == false)
                                *bReject = true;
                        else
@@ -114,7 +114,7 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ
 
                case MMS_MSGTYPE_DELIVERY_IND:
                        MSG_DEBUG("process delivery.ind\n");
-                       // For Set Value pMsgInfo
+                       /* For Set Value pMsgInfo */
                        processDeliveryInd(pMsgInfo);
                        break;
 
@@ -149,14 +149,16 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
 
        MSG_DEBUG("pMsgInfo->subject [%s]", pMsgInfo->subject);
 
+#if 0  // P150826-01612, P150910-05427 : we do not need to add empty subject text any more.
        if (strlen(pMsgInfo->subject) < 1)
                snprintf(pMsgInfo->subject, MAX_SUBJECT_LEN, "MMS Notification Message.");
+#endif
 
        attrib.expiryTime = mmsHeader.expiryTime;
 
        if (mmsHeader.pFrom) {
                MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
-               // From
+               /* From */
                strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN);
                if (MmsAddrUtilCheckEmailAddress(pMsgInfo->addressList[0].addressVal)) {
                        pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_EMAIL;
@@ -164,7 +166,8 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
        }
 
        MMS_DATA_S *mms_data = MsgMmsCreate();
-       if (mms_data == NULL) return false;
+       if (mms_data == NULL)
+               return false;
        {
                mms_data->header = MsgMmsCreateHeader();
 
@@ -181,24 +184,24 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
 
                pHeader->mmsVersion = mmsHeader.version;
 
-               //From
+               /* From */
                if (mmsHeader.pFrom) {
                        MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
                        snprintf(pHeader->szFrom, sizeof(pHeader->szFrom), "%s", mmsHeader.pFrom->szAddr);
                }
 
-               //Subject
+               /* Subject */
                snprintf(pHeader->szSubject, sizeof(pHeader->szSubject), "%s", mmsHeader.szSubject);
-               //Delivery Report
+               /* Delivery Report */
                pHeader->bDeliveryReport = (mmsHeader.deliveryReport != MMS_REPORT_YES);
-               //Message Class
+               /* Message Class */
                pHeader->messageClass = mmsHeader.msgClass;
 
-               //Priority
+               /* Priority */
                pHeader->mmsPriority = mmsHeader.priority;
 
-               //Message Size : pMmsMsg->mmsAttrib.msgSize = mmsHeader.msgSize;
-               //Expiry
+               /* Message Size : pMmsMsg->mmsAttrib.msgSize = mmsHeader.msgSize; */
+               /* Expiry */
                pHeader->expiry.type = mmsHeader.expiryTime.type;
                pHeader->expiry.time = mmsHeader.expiryTime.time;
 
@@ -209,9 +212,9 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
                        pHeader->expiry.time += curTime;
                }
 
-               //Charge
-               //contentclass
-               //int contentClass;//text | image-basic| image-rich | video-basic | video-rich | megapixel | content-basic | content-rich
+               /* Charge */
+               /* contentclass */
+               /* int contentClass;//text | image-basic| image-rich | video-basic | video-rich | megapixel | content-basic | content-rich */
                strncpy(pHeader->contentLocation, mmsHeader.szContentLocation, MMS_LOCATION_LEN);
 
                pHeader->messageSize = mmsHeader.msgSize;
@@ -230,11 +233,11 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
                        if (MsgCreateFileName(pTempFileName) == true) {
                                pMsgInfo->bTextSms = false;
 
-                               snprintf(pTempFilePath, sizeof(pTempFilePath), MSG_IPC_DATA_PATH"%s", pTempFileName);
+                               snprintf(pTempFilePath, sizeof(pTempFilePath), "%s%s", MSG_IPC_DATA_PATH, pTempFileName);
 
                                MsgOpenCreateAndOverwriteFile(pTempFilePath, pSerializedMms, serializeDataSize);
 
-                               //set file name
+                               /* set file name */
                                snprintf(pMsgInfo->msgData, sizeof(pMsgInfo->msgData), "%s", pTempFileName);
                        }
 
@@ -243,7 +246,7 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
        }
        MsgMmsRelease(&mms_data);
 
-       // Check contents-location is in noti.ind
+       /* Check contents-location is in noti.ind */
        if (mmsHeader.szContentLocation[0] == '\0') {
                THROW(MsgException::INCOMING_MSG_ERROR, "######## Contents-location is empty in MMS-Noti-Ind  #######");
                return false;
@@ -266,7 +269,7 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
                return false;
        }
 
-       if (MsgCheckFilter(dbHandle, pMsgInfo)){
+       if (MsgCheckFilter(dbHandle, pMsgInfo)) {
                encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pPduFilePath);
 
                pMsgInfo->dataSize = strlen(pPduFilePath);
@@ -276,7 +279,7 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
                memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
 
                snprintf(pRequest->msgInfo.msgData, sizeof(pRequest->msgInfo.msgData), "%s", pPduFilePath);
-               MSG_DEBUG("pRequest->msgInfo.msgData = %s", pRequest->msgInfo.msgData);
+               MSG_SEC_DEBUG("pRequest->msgInfo.msgData = %s", pRequest->msgInfo.msgData);
                pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
                pRequest->msgInfo.folderId = MSG_SPAMBOX_ID;
 
@@ -292,7 +295,7 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
 
                if (retrieveType == MSG_ABROAD_RESTRICTED) {
                        MSG_DEBUG("MMS Receiving Setting Restricted was selected.");
-                       // m-notify-resp-ind encoding process
+                       /* m-notify-resp-ind encoding process */
                        encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pPduFilePath);
 
                        pMsgInfo->dataSize = strlen(pPduFilePath);
@@ -309,10 +312,10 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
                }
        }
 
-       // should send http 'GET'
+       /* should send http 'GET' */
        if (retrieveType == MSG_HOME_AUTO_DOWNLOAD || retrieveType == MSG_ABROAD_AUTO_DOWNLOAD) {
-               //Check if current request sim index is different from default network SIM
-               //Convert auto-retrieve to manual retrieve in case sim indexes are different
+               /* Check if current request sim index is different from default network SIM */
+               /* Convert auto-retrieve to manual retrieve in case sim indexes are different */
                int default_sim = 0;
                default_sim = MsgSettingGetInt(MSG_NETWORK_SIM);
 
@@ -333,6 +336,9 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
 
                        MSG_SEC_DEBUG("MSG SUBTYPE = %d msg data %s bTextsms %d", pRequest->msgInfo.msgType.subType, pRequest->msgInfo.msgData, pRequest->msgInfo.bTextSms);
                } else {
+                       /* should send m-notify-resp-ind */
+                       MSG_DEBUG("=========== START MANUAL RETRIEVE MODE ===========");
+                       /* m-notify-resp-ind encoding process */
                        encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pPduFilePath);
 
                        pMsgInfo->dataSize = strlen(pPduFilePath);
@@ -343,12 +349,13 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
 
                        snprintf(pRequest->msgInfo.msgData, sizeof(pRequest->msgInfo.msgData), "%s", pPduFilePath);
                        MSG_SEC_DEBUG("pRequest->msgInfo.msgData = %s", pRequest->msgInfo.msgData);
+                       snprintf(pRequest->msgInfo.msgURL, sizeof(pRequest->msgInfo.msgURL), "%s", mmsHeader.szContentLocation);
                        pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
                }
        } else {
-               // should send m-notify-resp-ind
+               /* should send m-notify-resp-ind */
                MSG_DEBUG("=========== START MANUAL RETRIEVE MODE ===========");
-               // m-notify-resp-ind encoding process
+               /* m-notify-resp-ind encoding process */
 
                if (retrieveType == MSG_HOME_MANUAL || retrieveType == MSG_ABROAD_MANUAL) {
                        encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_DEFERRED, bReportAllowed, pPduFilePath);
@@ -361,7 +368,8 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST
                memcpy(&pRequest->msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
 
                snprintf(pRequest->msgInfo.msgData, sizeof(pRequest->msgInfo.msgData), "%s", pPduFilePath);
-               MSG_DEBUG("pRequest->msgInfo.msgData = %s", pRequest->msgInfo.msgData);
+               MSG_SEC_DEBUG("pRequest->msgInfo.msgData = %s", pRequest->msgInfo.msgData);
+               snprintf(pRequest->msgInfo.msgURL, sizeof(pRequest->msgInfo.msgURL), "%s", mmsHeader.szContentLocation);
                pRequest->msgInfo.msgType.subType = MSG_NOTIFYRESPIND_MMS;
        }
 
@@ -381,7 +389,7 @@ void MmsPluginInternal::processDeliveryInd(MSG_MESSAGE_INFO_S *pMsgInfo)
        status.bDeliveyrReportIsLast= true;
 
        MmsAddrUtilRemovePlmnString(mmsHeader.pTo->szAddr);
-       MSG_DEBUG("[INFO] [ADDR: %s, MMSID: %s]",mmsHeader.pTo->szAddr, mmsHeader.szMsgID);
+       MSG_SEC_DEBUG("[INFO] [ADDR: %s, MMSID: %s]",mmsHeader.pTo->szAddr, mmsHeader.szMsgID);
 
        pMsgInfo->msgType.mainType      = MSG_MMS_TYPE;
        pMsgInfo->msgType.subType       = MSG_DELIVERYIND_MMS;
@@ -399,7 +407,7 @@ void MmsPluginInternal::processDeliveryInd(MSG_MESSAGE_INFO_S *pMsgInfo)
        if (tmpId > 0) {
                MSG_DEBUG("Found MSG_ID = %d", tmpId);
 
-               //Insert to Delievery DB
+               /* Insert to Delievery DB */
                MmsPluginStorage::instance()->insertDeliveryReport(tmpId, mmsHeader.pTo->szAddr, &status);
 
                pMsgInfo->msgId = (msg_message_id_t)tmpId;
@@ -433,7 +441,7 @@ void MmsPluginInternal::processReadOrgInd(MSG_MESSAGE_INFO_S *pMsgInfo)
        strncpy(pMsgInfo->msgData, getMmsReadStatus(mmsHeader.readStatus), MAX_MSG_DATA_LEN);
        pMsgInfo->dataSize  = strlen(pMsgInfo->msgData);
 
-       MSG_DEBUG("read Status = %s", pMsgInfo->msgData);
+       MSG_SEC_DEBUG("read Status = %s", pMsgInfo->msgData);
        strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN);
 
        int tmpId = MmsPluginStorage::instance()->searchMsgId(mmsHeader.pFrom->szAddr, mmsHeader.szMsgID);
@@ -462,7 +470,7 @@ void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEn
 
        pMsgInfo->msgId = pRequest->msgId;
 
-       //Set only changed members
+       /* Set only changed members */
        pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
        pMsgInfo->msgType.subType = MSG_SENDCONF_MMS;
 
@@ -486,12 +494,15 @@ void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEn
        }
 
        MSG_ADDRESS_INFO_S addressinfo = {0,};
-       char *msisdn = NULL;
-       msisdn = MsgSettingGetString(MSG_SIM_MSISDN);
+       char keyName[MAX_VCONFKEY_NAME_LEN];
+       memset(keyName, 0x00, sizeof(keyName));
+
+       snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, pMsgInfo->sim_idx);
+       char *msisdn = MsgSettingGetString(keyName);
 
        MmsPluginStorage::instance()->getAddressInfo(pMsgInfo->msgId, &addressinfo);
 
-       MSG_MMS_VLD_INFO("%d, MMS Send End %s->%s %s", pMsgInfo->msgId
+       MSG_SEC_DEBUG("%d, MMS Send End %s->%s %s", pMsgInfo->msgId
                                                                                                        , (msisdn == NULL)?"ME":msisdn
                                                                                                        , addressinfo.addressVal
                                                                                                        , (pMsgInfo->networkStatus == MSG_NETWORK_SEND_SUCCESS)?"Success":"Fail");
@@ -501,7 +512,7 @@ void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEn
                msisdn = NULL;
        }
 
-       // set message-id from mmsc
+       /* set message-id from mmsc */
        strncpy(recvData.szMsgID, mmsHeader.szMsgID, MMS_MSG_ID_LEN);
        strncpy(recvData.szTrID, mmsHeader.szTrID, MMS_TR_ID_LEN);
 
@@ -538,7 +549,7 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
        attrib.bAskDeliveryReport = getMmsReport(mmsHeader.deliveryReport);
        attrib.bAskReadReply = getMmsReport(mmsHeader.readReply);
 
-       //Set only changed members
+       /* Set only changed members */
        pMsgInfo->msgId = pRequest->msgId;
        MSG_DEBUG("@@@@@ msgId = %d @@@@@", pMsgInfo->msgId);
        pMsgInfo->msgType.mainType = MSG_MMS_TYPE;
@@ -563,18 +574,21 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
        } else {
                pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
                pMsgInfo->folderId = MSG_INBOX_ID;
-               // If failed MMS Retrieve, then saved as MMS Noti Ind Message.
-               // It will changed in MsgHandleMmsConfIncomingMsg
-               //pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
+               /* If failed MMS Retrieve, then saved as MMS Noti Ind Message.
+                * It will changed in MsgHandleMmsConfIncomingMsg */
+/*             pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS; */
        }
 
-       char *msisdn = NULL;
-       msisdn = MsgSettingGetString(MSG_SIM_MSISDN);
+       char keyName[MAX_VCONFKEY_NAME_LEN];
+       memset(keyName, 0x00, sizeof(keyName));
+
+       snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, pMsgInfo->sim_idx);
+       char *msisdn = MsgSettingGetString(keyName);
 
        if (mmsHeader.pFrom)
                MmsAddrUtilRemovePlmnString(mmsHeader.pFrom->szAddr);
 
-       MSG_MMS_VLD_INFO("%d, MMS Receive %s End %s->%s %s", pMsgInfo->msgId
+       MSG_SEC_DEBUG("%d, MMS Receive %s End %s->%s %s", pMsgInfo->msgId
                                                                                                                , (pRequest->eMmsPduType == eMMS_RETRIEVE_AUTO_CONF)?"Auto":"Manual"
                                                                                                                , (mmsHeader.pFrom)?mmsHeader.pFrom->szAddr:"YOU"
                                                                                                                , (msisdn == NULL)?"ME":msisdn
@@ -594,7 +608,7 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
 
        pMsgInfo->dataSize = pRequest->getDataLen;
 
-       // set message-id & MMS TPDU file path
+       /* set message-id & MMS TPDU file path */
        snprintf(recvData.szMsgID, sizeof(recvData.szMsgID), "%s", mmsHeader.szMsgID);
 
        if (pRetrievedFilePath)
@@ -626,10 +640,10 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
 #endif
        memcpy(pMsgInfo->msgData, &recvData, sizeof(MMS_RECV_DATA_S));
 
-       MSG_DEBUG("@@@@@ MsgData = %s @@@@@", pMsgInfo->msgData);
-       MSG_DEBUG("@@@@@ retrievedFilePath = %s @@@@@", recvData.retrievedFilePath);
+       MSG_SEC_DEBUG("@@@@@ MsgData = %s @@@@@", pMsgInfo->msgData);
+       MSG_SEC_DEBUG("@@@@@ retrievedFilePath = %s @@@@@", recvData.retrievedFilePath);
        MSG_DEBUG("@@@@@ szMsgID = %s @@@@@", recvData.szMsgID);
-       //update delivery report, read reply
+       /* update delivery report, read reply */
 
        MmsPluginStorage *pStorage = MmsPluginStorage::instance();
 
@@ -637,7 +651,7 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
 
        MSG_DEBUG("Error value of updateMmsAttrib [%d]", err);
 
-       {//make MmsData & insert multipart
+       { /* make MmsData & insert multipart */
        MmsMsg *pMmsMsg = NULL;
        MmsPluginStorage::instance()->getMmsMessage(&pMmsMsg);
 
@@ -650,11 +664,12 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
        pMmsData->header = MsgMmsCreateHeader();
 
        MmsConvertMmsData(pMmsMsg, pMmsData);
-       //CID 41996 : MmsConvertMmsData always returns true
-       /*if (MmsConvertMmsData(pMmsMsg, pMmsData) != true) {
+       /* CID 41996 : MmsConvertMmsData always returns true */
+       /*
+       if (MmsConvertMmsData(pMmsMsg, pMmsData) != true) {
                MSG_DEBUG("Fail to Compose MMS Message");
                goto __CATCH;
-       }*/
+       } */
 
        bool bFiltered = checkFilterMmsBody(pMmsData);
        if (bFiltered == true) {
@@ -673,7 +688,7 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
                MmsPluginStorage::instance()->insertMultipart(pMsgInfo->msgId, pMultipart);
        }
 
-       {//make Preview info for APP
+       { /* make Preview info for APP */
                MmsPluginAppBase *appBase;
                appBase = new MmsPluginAppBase(pMmsData);
                appBase->makePreviewInfo(pMsgInfo->msgId, false, pRetrievedFilePath);
@@ -687,7 +702,7 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
                MSG_SEC_DEBUG("Fail to get mms file size [%s]", pRetrievedFilePath);
                goto __CATCH;
        }
-       }//make MmsData & insert multipart
+       } /* make MmsData & insert multipart */
 
 __CATCH:
        {
@@ -700,7 +715,7 @@ __CATCH:
        }
        MSG_END();
 }
-#else //NEW process RetrieveConf
+#else /* NEW process RetrieveConf */
 void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest, char *pRetrievedFilePath)
 {
        MSG_BEGIN();
@@ -729,9 +744,9 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
        } else {
                pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_FAIL;
                pMsgInfo->folderId = MSG_INBOX_ID;
-               // If failed MMS Retrieve, then saved as MMS Noti Ind Message.
-               // It will changed in MsgHandleMmsConfIncomingMsg
-               //pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS;
+               /* If failed MMS Retrieve, then saved as MMS Noti Ind Message.
+                * It will changed in MsgHandleMmsConfIncomingMsg */
+/*             pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS; */
        }
 
        char *msisdn = NULL;
@@ -845,7 +860,7 @@ bool MmsPluginInternal::encodeNotifyRespInd(char *szTrID, msg_delivery_report_st
        MsgCloseFile(pFile);
 
        if (pSendFilePath) {
-               //CID 41993: replaced size 'MAX_MSG_DATA_LEN+1' with MAX_FULL_PATH_SIZE
+               /* CID 41993: replaced size 'MAX_MSG_DATA_LEN+1' with MAX_FULL_PATH_SIZE */
                snprintf(pSendFilePath, MAX_FULL_PATH_SIZE, "%s.mms", pTempFilePath);
        } else {
                MSG_DEBUG("[ERROR] pSendFilePath is NULL");
@@ -877,12 +892,12 @@ bool MmsPluginInternal::encodeAckInd(char *szTrID, bool bReportAllowed, char *pS
 
        pFile = MsgOpenMMSFile(pTempFilePath);
        if (!pFile) {
-               MSG_DEBUG("[ERROR] MsgOpenMMSFile fail \n" );
+               MSG_ERR("MsgOpenMMSFile fail \n" );
                return false;
        }
 
        if (MmsEncodeAckInd(pFile, szTrID, bReportAllowed) == false) {
-               MSG_DEBUG("MmsEncodeAckInd: MmsEncodeAckInd fail \n" );
+               MSG_ERR("MmsEncodeAckInd: MmsEncodeAckInd fail \n" );
                MsgCloseFile(pFile);
                return false;
        }
@@ -892,7 +907,7 @@ bool MmsPluginInternal::encodeAckInd(char *szTrID, bool bReportAllowed, char *pS
        if (pSendFilePath) {
                snprintf(pSendFilePath, MAX_MSG_DATA_LEN+1, "%s.mms", pTempFilePath);
        } else {
-               MSG_DEBUG("[ERROR] pSendFilePath is NULL");
+               MSG_ERR("pSendFilePath is NULL");
                return false;
        }
 
@@ -911,7 +926,7 @@ bool MmsPluginInternal::checkRejectNotiInd(int roamState, bool bReportAllowed, c
        MsgSettingGetBool(MMS_RECV_REJECT_UNKNOWN, &bRejectAnonymous);
        MsgSettingGetBool(MMS_RECV_REJECT_ADVERTISE, &bRejectAdvertisement);
 
-       // Anonymous Reject
+       /* Anonymous Reject */
        if (bRejectAnonymous &&
                (mmsHeader.pFrom == NULL || mmsHeader.pFrom->szAddr[0] == '\0')) {
                MSG_DEBUG("Anonymous Reject... ");
@@ -920,7 +935,7 @@ bool MmsPluginInternal::checkRejectNotiInd(int roamState, bool bReportAllowed, c
                return true;
        }
 
-       // Advertisement Reject
+       /* Advertisement Reject */
        if (bRejectAdvertisement && mmsHeader.msgClass == MMS_MSGCLASS_ADVERTISEMENT) {
                MSG_DEBUG("Advertisement Reject... ");
                encodeNotifyRespInd(mmsHeader.szTrID, MSG_DELIVERY_REPORT_REJECTED, bReportAllowed, pSendFilePath);
@@ -928,7 +943,7 @@ bool MmsPluginInternal::checkRejectNotiInd(int roamState, bool bReportAllowed, c
                return true;
        }
 
-       // Message Reject - Roaming Case
+       /* Message Reject - Roaming Case */
        if (roamState == VCONFKEY_TELEPHONY_SVC_ROAM_ON) {
                retrieveType = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
                if (retrieveType == MSG_ABROAD_REJECT) {
@@ -947,7 +962,7 @@ bool MmsPluginInternal::checkRejectNotiInd(int roamState, bool bReportAllowed, c
                }
        }
 
-       //Duplicate MMS notification
+       /* Duplicate MMS notification */
        int msgId = 0;
 
        msgId = MmsPluginStorage::instance()->checkDuplicateNotification(mmsHeader.szTrID, mmsHeader.szContentLocation);
@@ -956,7 +971,7 @@ bool MmsPluginInternal::checkRejectNotiInd(int roamState, bool bReportAllowed, c
        if (msgId > 0)
                return true;
 
-       // Not Rejected
+       /* Not Rejected */
        MSG_END();
        return false;
 
@@ -983,7 +998,7 @@ bool MmsPluginInternal::checkFilterMmsBody(MMS_DATA_S *pMmsData)
 
        MsgMmsConvertMmsDataToMmsMessageData(pMmsData, mmsMsg);
 
-       // Get the text data from the 1st slide.
+       /* Get the text data from the 1st slide. */
        if (mmsMsg->pageCnt <= 0) {
                MSG_WARN("pageCnt : %d", mmsMsg->pageCnt);
                MsgMmsReleaseMmsLists(mmsMsg);
@@ -1003,10 +1018,10 @@ bool MmsPluginInternal::checkFilterMmsBody(MMS_DATA_S *pMmsData)
 
                if (pMedia && pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) {
 
-                       MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
+                       MsgGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
 
                        if (mimeType == MIME_TEXT_X_VCALENDAR || mimeType == MIME_TEXT_X_VCARD || mimeType == MIME_TEXT_X_VTODO || mimeType == MIME_TEXT_X_VNOTE) {
-                               MSG_DEBUG("Media Type is Text, but Vobject file [%s]", pMedia->szFilePath);
+                               MSG_SEC_DEBUG("Media Type is Text, but Vobject file [%s]", pMedia->szFilePath);
                        } else {
                                strncpy(filePath, pMedia->szFilePath, MSG_FILEPATH_LEN_MAX);
 
index f3db2cf..c3471dc 100755 (executable)
@@ -77,8 +77,8 @@ msg_error_t MmsInitialize()
 {
        MSG_BEGIN();
 
-       // remove temp files
-       //MsgMmsInitDir();
+       /* remove temp files */
+/*     MsgMmsInitDir(); */
 
        MSG_END();
 
@@ -181,14 +181,14 @@ msg_error_t MmsUpdateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S
        msg_error_t err = MSG_SUCCESS;
 
        try {
-               if (pMsgInfo->networkStatus == MSG_NETWORK_NOT_SEND || pMsgInfo->networkStatus == MSG_NETWORK_SENDING) { //draft update
+               if (pMsgInfo->networkStatus == MSG_NETWORK_NOT_SEND || pMsgInfo->networkStatus == MSG_NETWORK_SENDING) { /* draft update */
                        err = MmsPluginStorage::instance()->updateMessage(pMsgInfo, pSendOptInfo, pFileData);
                } else {
-                       //[Update Message ID & File path only in case of retrieve. Else update Message ID]
-                       if (pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { //retrieve conf
+                       /* [Update Message ID & File path only in case of retrieve. Else update Message ID] */
+                       if (pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS) { /* retrieve conf */
                                err = MmsPluginStorage::instance()->updateConfMessage(pMsgInfo);
                        } else {
-                               err = MmsPluginStorage::instance()->updateMsgServerID(pMsgInfo, pSendOptInfo); //update send conf
+                               err = MmsPluginStorage::instance()->updateMsgServerID(pMsgInfo, pSendOptInfo); /* update send conf */
                        }
                }
        } catch (MsgException& e) {
@@ -285,7 +285,7 @@ msg_error_t MmsComposeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo)
        return MSG_SUCCESS;
 }
 
-//FIXME::It used for kies but not now
+/* FIXME::It used for kies but not now */
 msg_error_t MmsRestoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char *pRcvBody, int rcvdBodyLen, char *filePath)
 {
        MSG_BEGIN();
@@ -299,7 +299,7 @@ msg_error_t MmsRestoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char *pRcvBody, int rcvd
                if ((pFile = MsgOpenFile(pMsgInfo->msgData, "rb+")) == NULL) {
                        MSG_DEBUG("File Open Error: %s", pMsgInfo->msgData);
                } else {
-                       //Decode Header
+                       /* Decode Header */
                        if (!MmsBinaryDecodeMsgHeader(pFile, rcvdBodyLen))
                                MSG_DEBUG("Decoding Header Failed \r\n");
 
@@ -314,7 +314,7 @@ msg_error_t MmsRestoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char *pRcvBody, int rcvd
                        return MSG_ERR_NULL_POINTER;
                }
 
-               // create temp file
+               /* create temp file */
                if (!MsgOpenCreateAndOverwriteFile(filePath, (char*)pRcvBody,rcvdBodyLen))
                        return MSG_ERR_PLUGIN_STORAGE;
        }
index 0e6a4e0..5e27b6c 100755 (executable)
 #include "MmsPluginTypes.h"
 #include "MmsPluginDebug.h"
 #include "MmsPluginMessage.h"
-#include "MmsPluginMIME.h"
+#include "MsgUtilMime.h"
 #include "MmsPluginStorage.h"
 #include "MmsPluginUtil.h"
-#include "MmsPluginTcs.h"
 #include "MsgSmil.h"
 #include "MmsPluginAppBase.h"
+#include "MsgUtilFunction.h"
 
 #define PRINT_KEY_VAL_STR(key, val)\
 if (val) {\
@@ -109,7 +109,7 @@ char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType)
 
        nAddressCnt = pMsgInfo->nAddressCnt;
 
-       // Calculate allocated buffer size
+       /* Calculate allocated buffer size */
        for (int i = 0; i < nAddressCnt; ++i) {
 
                MSG_SEC_DEBUG("recipientType: %d, address value: %s", pMsgInfo->addressList[i].recipientType, pMsgInfo->addressList[i].addressVal);
@@ -124,7 +124,7 @@ char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType)
                        } else if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_EMAIL) {
                                addrLen += strlen(pMsgInfo->addressList[i].addressVal);
                        } else
-                               ; // Need to consider IPV4, IPV6, and Alias formatted address
+                               ; /* Need to consider IPV4, IPV6, and Alias formatted address */
 
                        nRecpCnt++;
                }
@@ -134,7 +134,7 @@ char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType)
                addrLen = addrLen + nRecpCnt - 1;
        szCompose = (char *)calloc(addrLen + 1, 1);
 
-       // Address String copy
+       /* Address String copy */
        for (int i = 0; i < nAddressCnt; ++i) {
                if (pMsgInfo->addressList[i].recipientType == recipientType) {
                        if (szCompose && strlen(szCompose) > 0)
@@ -147,7 +147,7 @@ char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType)
                        } else if (pMsgInfo->addressList[i].addressType == MSG_ADDRESS_TYPE_EMAIL) {
                                snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s", pMsgInfo->addressList[i].addressVal);
                        } else
-                               ; // Need to consider IPV4, IPV6, and Alias formatted address
+                               ; /* Need to consider IPV4, IPV6, and Alias formatted address */
 
                        g_strlcat(szCompose, pString, addrLen + 1);
                }
@@ -187,7 +187,7 @@ bool MmsInsertPresentation(MmsMsg *pMsg, MimeType mimeType, const char *content_
        if (content_id && strlen(content_id) > 0) {
                snprintf(pMsg->msgBody.presentationType.szContentID, MSG_MSG_ID_LEN + 1, "%s", content_id);
        } else {
-               snprintf(pMsg->msgBody.presentationType.szContentID, MSG_MSG_ID_LEN + 1, "<_S_>");//default
+               snprintf(pMsg->msgBody.presentationType.szContentID, MSG_MSG_ID_LEN + 1, "<_S_>"); /* default */
        }
 
        snprintf(pMsg->msgType.param.szStart, MSG_MSG_ID_LEN + 1, "%s", pMsg->msgBody.presentationType.szContentID);
@@ -226,7 +226,17 @@ MsgMultipart *MmsMakeMultipart(MimeType mimeType, char *szTitleName, char *szOrg
 
        if (szTitleName && szTitleName[0]) {
                memset(pMultipart->type.param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1);
-               strncpy(pMultipart->type.param.szName, szTitleName, MSG_LOCALE_FILENAME_LEN_MAX);
+
+               gchar *tmpTitleName = msg_replace_non_ascii_char(szTitleName, '_');
+               if (tmpTitleName) {
+                       MSG_SEC_DEBUG("tmpTitleName = [%s]", tmpTitleName);
+                       snprintf(pMultipart->type.param.szName, MSG_LOCALE_FILENAME_LEN_MAX + 1, "%s", tmpTitleName);
+                       g_free(tmpTitleName);
+                       tmpTitleName = NULL;
+               } else {
+                       MSG_WARN("tmpTitleName is NULL.");
+                       snprintf(pMultipart->type.param.szName, MSG_LOCALE_FILENAME_LEN_MAX + 1, "%s", szTitleName);
+               }
        }
 
        if (szContentID && szContentID[0]) {
@@ -236,7 +246,14 @@ MsgMultipart *MmsMakeMultipart(MimeType mimeType, char *szTitleName, char *szOrg
 
        if (szContentLocation && szContentLocation[0]) {
                memset(pMultipart->type.szContentLocation, 0, MSG_MSG_ID_LEN + 1);
-               snprintf(pMultipart->type.szContentLocation, MSG_MSG_ID_LEN + 1, "%s", szContentLocation);
+
+               gchar *tmpContentLocation = msg_replace_non_ascii_char(szContentLocation, '_');
+               if (tmpContentLocation ) {
+                       MSG_SEC_DEBUG("tmpContentLocation = [%s]", tmpContentLocation);
+                       snprintf(pMultipart->type.szContentLocation, MSG_MSG_ID_LEN + 1, "%s", tmpContentLocation);
+                       g_free(tmpContentLocation);
+                       tmpContentLocation = NULL;
+               }
        }
 
        if (MmsIsTextType(mimeType) == true) {
@@ -273,7 +290,7 @@ void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID)
 
        pMmsMsg->mmsAttrib.version = mmsHeader.version;
 
-       // setting date
+       /* setting date */
        time(&RawTime);
        localtime_r(&RawTime, &timeInfo);
        nTimeInSecs = mktime(&timeInfo);
@@ -325,7 +342,7 @@ void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsg
        MmsInitMsgType(&pMmsMsg->msgType);
        MmsInitMsgBody(&pMmsMsg->msgBody);
 
-       // setting mmsMsg structure
+       /* setting mmsMsg structure */
        pMmsMsg->mailbox = pMsgInfo->folderId;
        pMmsMsg->msgID = pMsgInfo->msgId;
 
@@ -335,19 +352,19 @@ void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsg
 
        pMmsMsg->mmsAttrib.dataType = MMS_DATATYPE_DRAFT;
 
-       // setting date
+       /* setting date */
        time(&RawTime);
        localtime_r(&RawTime, &timeInfo);
        nTimeInSecs = mktime(&timeInfo);
        pMmsMsg->mmsAttrib.date = nTimeInSecs;
 
-       // setting szMsgId
+       /* setting szMsgId */
        MmsPluginStorage::instance()->getMmsMessageId(selectedMsgId, pMmsMsg);
 
-       //setting subject
+       /* setting subject */
        snprintf(pMmsMsg->mmsAttrib.szSubject, sizeof(pMmsMsg->mmsAttrib.szSubject), "%s", pMsgInfo->subject);
 
-       //setting adddress
+       /* setting adddress */
        MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo);
 
        if (pMmsMsg->mmsAttrib.szTo)
@@ -359,8 +376,10 @@ msg_error_t MmsMakeMultipartThumbnailInfo(MMS_MULTIPART_DATA_S *pMultipart, char
        if (pMultipart == NULL || thumbnail_path == NULL)
                return MSG_ERR_NULL_POINTER;
 
-//     if (MimeGetMainTypeString(MimeGetMimeStringFromMimeInt(pMultipart->type)) != MIME_MAINTYPE_VIDEO)
-//             return MSG_ERR_INVALID_PARAMETER;
+/*
+       if (MimeGetMainTypeString(MimeGetMimeStringFromMimeInt(pMultipart->type)) != MIME_MAINTYPE_VIDEO)
+               return MSG_ERR_INVALID_PARAMETER;
+*/
 
        char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, };
        char szFileNameWoExt[MSG_FILENAME_LEN_MAX+1] = {0, };
@@ -371,32 +390,40 @@ msg_error_t MmsMakeMultipartThumbnailInfo(MMS_MULTIPART_DATA_S *pMultipart, char
        memset(szFileName, 0x00, MSG_FILENAME_LEN_MAX+1);
        memset(thumbPath, 0x00, MSG_FILEPATH_LEN_MAX);
 
-       MSG_DEBUG("drm type = %d, %s", pMultipart->drmType, pMultipart->szFilePath);
+       MSG_SEC_DEBUG("drm type = %d, %s", pMultipart->drmType, pMultipart->szFilePath);
 
        if (pMultipart->drmType == MSG_DRM_TYPE_NONE) {
                pszOrgFileName = strrchr(pMultipart->szFilePath, '/');
-               pszExt = strrchr(pMultipart->szFilePath, '.');
 
-               if (NULL == pszOrgFileName || NULL == pszExt) {
+               if (pszOrgFileName) {
+                       pszExt = strrchr(pszOrgFileName, '.');
+               } else {
                        MSG_DEBUG("Fail in getting filename without extension string");
                        return MSG_ERR_PLUGIN_STORAGE;
                }
 
-               strncpy(szFileNameWoExt, pszOrgFileName + 1, strlen(pszOrgFileName + 1) - strlen(pszExt));
+               if (pszExt) {
+                       strncpy(szFileNameWoExt, pszOrgFileName + 1, strlen(pszOrgFileName + 1) - strlen(pszExt));
+               } else {
+                       if (strlen(pszOrgFileName + 1) <= sizeof(szFileNameWoExt))
+                               strncpy(szFileNameWoExt, pszOrgFileName + 1, strlen(pszOrgFileName + 1));
+                       else
+                               strncpy(szFileNameWoExt, pszOrgFileName + 1, sizeof(szFileNameWoExt));
+               }
                snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "thumb_msg_%s", szFileNameWoExt);
 
-               if (!strcasecmp(pszExt, ".png")) {
+               if (pszExt && !strcasecmp(pszExt, ".png")) {
                        snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, MSG_THUMBNAIL_PATH"%s.png", szFileName);
                } else {
                        snprintf(thumbPath, MSG_FILEPATH_LEN_MAX, MSG_THUMBNAIL_PATH"%s.jpg", szFileName);
                }
 
-               if (MmsMakeImageThumbnail(pMultipart->szFilePath, thumbPath) == true) {
+               if (MakeThumbnail(pMultipart->szFilePath, thumbPath) == true) {
                        memcpy(thumbnail_path, &thumbPath, strlen(thumbPath));
-                       MSG_DEBUG("Generated thumbnail: %s ", thumbnail_path);
+                       MSG_SEC_DEBUG("Generated thumbnail: %s ", thumbnail_path);
                        return MSG_SUCCESS;
                } else {
-                       MSG_DEBUG("Fail of generating thumbnail: %s to %s", pMultipart->szFilePath, thumbPath);
+                       MSG_SEC_DEBUG("Fail of generating thumbnail: %s to %s", pMultipart->szFilePath, thumbPath);
                }
        }
 
@@ -433,8 +460,8 @@ void MmsPrintFileInfoForVLD(MMS_MESSAGE_DATA_S *pMmsMsg)
        int attachCnt = _MsgMmsGetAttachCount(pMmsMsg);
        if (attachCnt > 0) {
                for (int i = 0; i < pMmsMsg->attachCnt; i++) {
-               MMS_ATTACH_S *pAttach = _MsgMmsGetAttachment(pMmsMsg, i);
-               MSG_MMS_VLD_FILE("[%s], %d", pAttach->szFilePath, MsgGetFileSize(pAttach->szFilePath));
+                       MMS_ATTACH_S *pAttach = _MsgMmsGetAttachment(pMmsMsg, i);
+                       MSG_SEC_DEBUG("[%s], %d", pAttach->szFilePath, MsgGetFileSize(pAttach->szFilePath));
                }
        }
 }
@@ -465,7 +492,7 @@ bool IsMatchedMedia(MMS_MEDIA_S *media, MMS_MULTIPART_DATA_S *pMultipart)
                }
        }
 
-       MSG_DEBUG("There is not matched media cid [%s], cl, [%s], multipart cid [%s], cl, [%s]", media->szContentID, media->szContentLocation, pMultipart->szContentID, pMultipart->szContentLocation);
+       MSG_SEC_DEBUG("There is not matched media cid [%s], cl, [%s], multipart cid [%s], cl, [%s]", media->szContentID, media->szContentLocation, pMultipart->szContentID, pMultipart->szContentLocation);
        return false;
 }
 
@@ -509,13 +536,14 @@ bool MmsFindAndInsertPart(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DATA_S *pM
 
                                        MMS_MEDIA_S *media = (MMS_MEDIA_S *)g_list_nth_data(page->medialist, mediaIdx);
 
-                                       if (media) { // add media
-                                               if (IsMatchedMedia(media, pMultipart) == true) { //matched media
-
-//                                                     if (media->mediatype == MMS_SMIL_MEDIA_IMG_OR_VIDEO) { // ref type is not insert part
-//                                                             MSG_DEBUG("## Matched but media type is ref ##");
-//                                                             return false;
-//                                                     }
+                                       if (media) { /* add media */
+                                               if (IsMatchedMedia(media, pMultipart) == true) { /* matched media */
+#if 0
+                                                       if (media->mediatype == MMS_SMIL_MEDIA_IMG_OR_VIDEO) { /* ref type is not insert part */
+                                                               MSG_DEBUG("## Matched but media type is ref ##");
+                                                               return false;
+                                                       }
+#endif
 
                                                        insert_media = true;
                                                        media->drmType = pMultipart->drmType;
@@ -529,9 +557,9 @@ bool MmsFindAndInsertPart(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DATA_S *pM
                                                                        , pageIdx, mediaIdx, media, media->szFilePath, media->szFileName, media->szContentID, media->szContentLocation, media->szContentType);
                                                }
                                        }
-                               } //end for media list
+                               } /* end for media list */
                        }
-               } //end for page list
+               } /* end for page list */
        }
 
        return insert_media;
@@ -604,7 +632,7 @@ bool MmsInsertMixedPartToMmsData(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DAT
        case MIME_MAINTYPE_VIDEO:
                mediatype = MMS_SMIL_MEDIA_VIDEO;
                break;
-       default :
+       default:
                mediatype = MMS_SMIL_MEDIA_INVALID;
                break;
        }
@@ -636,8 +664,8 @@ bool MmsInsertMixedPartToMmsData(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DAT
                                return false;
                        }
                } else {
-                       if (pPage) g_free(pPage);
-                       if (media) g_free(media);
+                       g_free(pPage);
+                       g_free(media);
                        return false;
                }
        } else {
@@ -725,7 +753,7 @@ bool MmsConvertMsgData(MmsMsg *pMsg, MMS_MESSAGE_DATA_S *pMmsMsg)
 {
        MSG_BEGIN();
 
-       //bzero(pMmsMsg, sizeof(MMS_MESSAGE_DATA_S));
+/*     bzero(pMmsMsg, sizeof(MMS_MESSAGE_DATA_S)); */
        pMmsMsg->regionCnt = 0;
        pMmsMsg->pageCnt = 0;
        pMmsMsg->attachCnt = 0;
@@ -919,7 +947,7 @@ int MmsUpdatePreviewData(MSG_MESSAGE_INFO_S *pMsgInfo)
        MmsPluginStorage::instance()->getMmsRawFilePath(pMsgInfo->msgId, szFullPath, sizeof(szFullPath));
        MmsPluginDecoder::instance()->decodeMmsPdu(mmsMsg, pMsgInfo->msgId, szFullPath);
 
-       {//make Preview info for APP
+       { /* make Preview info for APP */
                MmsPluginAppBase appBase(mmsMsg);
                appBase.makePreviewInfo(pMsgInfo->msgId, true, szFullPath);
                appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText));
@@ -929,7 +957,7 @@ int MmsUpdatePreviewData(MSG_MESSAGE_INFO_S *pMsgInfo)
        return 0;
 }
 
-//MmsMsg -> MMS_DATA_S
+/* MmsMsg -> MMS_DATA_S */
 bool MmsConvertMmsData(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData)
 {
        MSG_BEGIN();
@@ -1014,12 +1042,12 @@ bool MmsConvertMmsData(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData)
        return true;
 }
 
-//For Encode raw file
+/* For Encode raw file */
 bool MmsConvertMmsMsg(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData)
 {
        MSG_BEGIN();
 
-       // Initialize mmsMsg structure
+       /* Initialize mmsMsg structure */
        MmsInitMsgAttrib(&pMmsMsg->mmsAttrib);
        MmsInitMsgType(&pMmsMsg->msgType);
        MmsInitMsgBody(&pMmsMsg->msgBody);
@@ -1066,7 +1094,7 @@ bool MmsConvertMmsMsg(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData)
                pMmsMsg->mmsAttrib.szBcc = MmsConvertAddressToOldStyle(pHeaderData->bcc);
 
                snprintf(pMmsMsg->mmsAttrib.szFrom, sizeof(pMmsMsg->mmsAttrib.szFrom), "%s", pHeaderData->szFrom);
-       } //CID 41988: Moving all de-referencing of pHeaderData inside null-check block
+       } /* CID 41988: Moving all de-referencing of pHeaderData inside null-check block */
 
        printMmsAttribute(&pMmsMsg->mmsAttrib);
 
@@ -1117,7 +1145,7 @@ bool MmsConvertMmsMsg(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData)
                                        return false;
                                }
                        }
-               } //end for
+               } /* end for */
        }
 
        MSG_END();
@@ -1134,7 +1162,7 @@ char *MmsConvertAddressToOldStyle(MMSList *pAddressList)
 
        nAddressCnt = g_list_length(pAddressList);
 
-       // Calculate allocated buffer size
+       /* Calculate allocated buffer size */
        for (int i = 0; i < nAddressCnt; ++i) {
 
                MMS_ADDRESS_DATA_S * pAddressData = (MMS_ADDRESS_DATA_S *)g_list_nth_data(pAddressList, i);
@@ -1155,13 +1183,13 @@ char *MmsConvertAddressToOldStyle(MMSList *pAddressList)
        szCompose = (char *)calloc(addrLen + 1, 1);
 
        if (szCompose) {
-               // Address String copy
+               /* Address String copy */
                for (int i = 0; i < nAddressCnt; ++i) {
                        MMS_ADDRESS_DATA_S * pAddressData = (MMS_ADDRESS_DATA_S *)g_list_nth_data(pAddressList, i);
 
                        if (pAddressData) {
                                if (strlen(szCompose) > 0)
-                                       g_strlcat(szCompose, MSG_STR_ADDR_DELIMETER, addrLen + 1 - strlen(szCompose));
+                                       g_strlcat(szCompose, MSG_STR_ADDR_DELIMETER, addrLen + 1);
 
                                memset(pString, 0x00, (MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3) * sizeof(char));
                                if (pAddressData->address_type == MSG_ADDRESS_TYPE_PLMN) {
@@ -1171,7 +1199,7 @@ char *MmsConvertAddressToOldStyle(MMSList *pAddressList)
                                        snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s", pAddressData->address_val);
                                }
 
-                               g_strlcat(szCompose, pString, addrLen + 1 - strlen(szCompose));
+                               g_strlcat(szCompose, pString, addrLen + 1);
                        }
                }
        }
@@ -1274,7 +1302,7 @@ bool convertMediaToMultipart(MMS_MEDIA_S *pSrcMedia, MMS_MULTIPART_DATA_S *pDest
                else if (pSrcMedia->mediatype == MMS_SMIL_MEDIA_TEXT)
                        mainType = MIME_MAINTYPE_TEXT;
 
-               MmsGetMimeTypeFromFileName(mainType, pSrcMedia->szFilePath, &pMimeType, &pszMimeType);
+               MsgGetMimeTypeFromFileName(mainType, pSrcMedia->szFilePath, &pMimeType, &pszMimeType);
 
                if (pszMimeType) {
                        snprintf(pDestMultipart->szContentType, sizeof(pDestMultipart->szContentType), "%s", pszMimeType);
@@ -1304,7 +1332,7 @@ bool convertAttachToMultipart(MMS_ATTACH_S *pSrcMedia, MMS_MULTIPART_DATA_S *pDe
                MimeType pMimeType = MIME_UNKNOWN;
                const char *pszMimeType = NULL;
 
-               MmsGetMimeTypeFromFileName(mainType, pSrcMedia->szFilePath, &pMimeType, &pszMimeType);
+               MsgGetMimeTypeFromFileName(mainType, pSrcMedia->szFilePath, &pMimeType, &pszMimeType);
 
                if (pszMimeType) {
                        snprintf(pDestMultipart->szContentType, sizeof(pDestMultipart->szContentType), "%s", pszMimeType);
@@ -1342,15 +1370,15 @@ gint __compare_str(gconstpointer a, gconstpointer b)
        return g_strcmp0((char *)a, (char *)b);
 }
 
-// change file name to Ascii & space -> '_'
-// If replaced filename is duplicated, then it append number
+/* change file name to Ascii & space -> '_' */
+/* If replaced filename is duplicated, then it append number */
 bool MmsChangeFileNameToAscii(MMS_MESSAGE_DATA_S *pMsgData)
 {
        int pageCnt;
        int mediaCnt;
        int attachCnt;
 
-       GList *r_list = NULL;//renamed file list
+       GList *r_list = NULL; /* renamed file list */
 
        pageCnt = g_list_length(pMsgData->pagelist);
 
@@ -1358,7 +1386,7 @@ bool MmsChangeFileNameToAscii(MMS_MESSAGE_DATA_S *pMsgData)
                MMS_PAGE_S *pPage = NULL;
                pPage = (MMS_PAGE_S *)g_list_nth_data(pMsgData->pagelist, i);
                if (pPage == NULL) {
-                       //CID 355351: Freeing r_list in case of error too to prevent memory leak
+                       /* CID 355351: Freeing r_list in case of error too to prevent memory leak */
                        if (r_list != NULL)
                                g_list_free(r_list);
                        return false;
@@ -1369,7 +1397,7 @@ bool MmsChangeFileNameToAscii(MMS_MESSAGE_DATA_S *pMsgData)
                        MMS_MEDIA_S *pMedia = NULL;
                        pMedia = (MMS_MEDIA_S *)g_list_nth_data(pPage->medialist, j);
                        if (pMedia == NULL) {
-                               //CID 355351: Freeing r_list in case of error too to prevent memory leak
+                               /* CID 355351: Freeing r_list in case of error too to prevent memory leak */
                                if (r_list != NULL)
                                        g_list_free(r_list);
                                return false;
@@ -1408,23 +1436,23 @@ bool MmsChangeFileNameToAscii(MMS_MESSAGE_DATA_S *pMsgData)
 
                                        snprintf(pMedia->szFileName, sizeof(pMedia->szFileName), "%s", str2);
 
-                                       MSG_DEBUG("replace filename [%s]", pMedia->szFileName);
+                                       MSG_SEC_DEBUG("replace filename [%s]", pMedia->szFileName);
 
                                        r_list = g_list_append(r_list, pMedia->szFileName);
 
                                        g_free(str2);
                                }
                        }
-               }//end for media
-       }//end for page
+               } /* end for media */
+       } /* end for page */
 
        attachCnt = g_list_length(pMsgData->attachlist);
        for (int i = 0; i < attachCnt; i++) {
                MMS_ATTACH_S *pAttach = NULL;
                pAttach = (MMS_ATTACH_S *)g_list_nth_data(pMsgData->attachlist, i);
                if (pAttach == NULL) {
-                       //CID 355351: Freeing r_list in case of error too to prevent memory leak
-                       if(r_list != NULL)
+                       /* CID 355351: Freeing r_list in case of error too to prevent memory leak */
+                       if (r_list != NULL)
                                g_list_free(r_list);
                        return false;
                }
@@ -1461,13 +1489,13 @@ bool MmsChangeFileNameToAscii(MMS_MESSAGE_DATA_S *pMsgData)
 
                                snprintf(pAttach->szFileName, sizeof(pAttach->szFileName), "%s", str2);
 
-                               MSG_DEBUG("replace filename [%s]", pAttach->szFileName);
+                               MSG_SEC_DEBUG("replace filename [%s]", pAttach->szFileName);
 
                                g_free(str2);
                        }
                }
 
-       }//end for attach
+       } /* end for attach */
 
        g_list_free(r_list);
 
index 3c5ab54..40cf869 100755 (executable)
@@ -408,57 +408,51 @@ MSG_SMIL_ERR_E  _MsgMMSValidateSMILPage(MMS_MESSAGE_DATA_S *pMsgData, bool bRegA
                        MSG_RETURN_VAL_IF_FAIL((strlen(pMedia->szFilePath) > 0), MSG_SMIL_ERR_INVALID_PAGE_INFO);
 
                        switch (pMedia->mediatype) {
-                       case MMS_SMIL_MEDIA_IMG:
-                               {
-                                       if ((bImgExists == true) || (bVidExists == true) ||
-                                               (bImgOrVidExists== true)) {
-                                               eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
-                                       } else
-                                               bImgExists = true;
-                               }
+                       case MMS_SMIL_MEDIA_IMG: {
+                               if ((bImgExists == true) || (bVidExists == true) ||
+                                       (bImgOrVidExists== true)) {
+                                       eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
+                               } else
+                                       bImgExists = true;
                                break;
-                       case MMS_SMIL_MEDIA_AUDIO:
-                               {
-                                       if ((bAudExists == true) || (bVidExists == true) ||
-                                               (bImgOrVidExists== true)) {
-                                               eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
-                                       } else
-                                               bAudExists = true;
-                               }
+                       }
+                       case MMS_SMIL_MEDIA_AUDIO: {
+                               if ((bAudExists == true) || (bVidExists == true) ||
+                                       (bImgOrVidExists== true)) {
+                                       eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
+                               } else
+                                       bAudExists = true;
                                break;
-                       case MMS_SMIL_MEDIA_VIDEO:
-                               {
-                                       if ((bImgExists == true) || (bVidExists == true) ||
-                                               (bImgOrVidExists== true)) {
-                                               eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
-                                       } else
-                                               bVidExists = true;
-                               }
+                       }
+                       case MMS_SMIL_MEDIA_VIDEO: {
+                               if ((bImgExists == true) || (bVidExists == true) ||
+                                       (bImgOrVidExists== true)) {
+                                       eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
+                               } else
+                                       bVidExists = true;
                                break;
-                       case MMS_SMIL_MEDIA_TEXT:
-                               {
-                                       if (bTxtExists == true) {
-                                               eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
-                                       } else
-                                               bTxtExists = true;
-                               }
+                       }
+                       case MMS_SMIL_MEDIA_TEXT: {
+                               if (bTxtExists == true) {
+                                       eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
+                               } else
+                                       bTxtExists = true;
                                break;
-                       case MMS_SMIL_MEDIA_IMG_OR_VIDEO:
-                               {
-                                       if ((bImgExists == true) || (bVidExists == true) ||
-                                               (bImgOrVidExists== true)) {
-                                               eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
-                                       } else
-                                               bImgOrVidExists = true;
-                               }
+                       }
+                       case MMS_SMIL_MEDIA_IMG_OR_VIDEO: {
+                               if ((bImgExists == true) || (bVidExists == true) ||
+                                       (bImgOrVidExists== true)) {
+                                       eRet = MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS;
+                               } else
+                                       bImgOrVidExists = true;
                                break;
-                       default:
-                               {
-                                       MSG_DEBUG("_MsgMMSValidateSMILRegion: Invalid Media Information\n");
-                                       return eRet;
-                               }
+                       }
+                       default: {
+                               MSG_DEBUG("_MsgMMSValidateSMILRegion: Invalid Media Information\n");
+                               return eRet;
                                break;
                        }
+                       }
 
                        if (eRet == MSG_SMIL_ERR_SIMILAR_MEDIA_EXISTS) {
                                MSG_DEBUG("_MsgMMSValidateSMILRegion: Similar Media Exists\n");
@@ -489,4 +483,3 @@ MSG_SMIL_ERR_E  _MsgMMSValidateSMILPage(MMS_MESSAGE_DATA_S *pMsgData, bool bRegA
 
        return eRet;
 }
-
index 3ac92f5..1579755 100755 (executable)
 #include "MsgStorageTypes.h"
 #include "MsgSmil.h"
 #include "MsgSerialize.h"
+#include "MsgUtilMime.h"
 
 #include "MmsPluginDebug.h"
 #include "MmsPluginStorage.h"
 #include "MmsPluginMessage.h"
 #include "MmsPluginDrm.h"
-#include "MmsPluginMIME.h"
-#include "MmsPluginTcs.h"
 #include "MmsPluginUtil.h"
 #include "MmsPluginComposer.h"
 #include "MmsPluginAppBase.h"
@@ -116,7 +115,7 @@ msg_error_t MmsPluginStorage::addMmsMsgToDB(MmsMsg *pMmsMsg, const char *raw_fil
 
        char sqlQuery[MAX_QUERY_LEN + 1];
 
-       // Add Message
+       /* Add Message */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, '%s', '%s', '%s', '%s', '%s', %d, %d, %ld, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d);",
                        MMS_PLUGIN_MESSAGE_TABLE_NAME, pMmsMsg->msgID, pMmsMsg->szTrID, pMmsMsg->szMsgID, pMmsMsg->szForwardMsgID, pMmsMsg->szContentLocation,
@@ -124,7 +123,7 @@ msg_error_t MmsPluginStorage::addMmsMsgToDB(MmsMsg *pMmsMsg, const char *raw_fil
                        pMmsMsg->mmsAttrib.bAskDeliveryReport, pMmsMsg->mmsAttrib.bReportAllowed, pMmsMsg->mmsAttrib.readReportAllowedType,
                        pMmsMsg->mmsAttrib.bAskReadReply, pMmsMsg->mmsAttrib.bRead, pMmsMsg->mmsAttrib.readReportSendStatus, pMmsMsg->mmsAttrib.bReadReportSent,
                        pMmsMsg->mmsAttrib.priority, pMmsMsg->mmsAttrib.bLeaveCopy, pMmsMsg->mmsAttrib.msgSize, pMmsMsg->mmsAttrib.msgClass,
-                       pMmsMsg->mmsAttrib.expiryTime.time,     0/*pMmsMsg->mmsAttrib.bUseDeliveryCustomTime*/, pMmsMsg->mmsAttrib.deliveryTime.time, pMmsMsg->mmsAttrib.msgStatus);
+                       pMmsMsg->mmsAttrib.expiryTime.time,     0 /*pMmsMsg->mmsAttrib.bUseDeliveryCustomTime*/, pMmsMsg->mmsAttrib.deliveryTime.time, pMmsMsg->mmsAttrib.msgStatus);
 
        MSG_DEBUG("\n!!!!!!!!! QUERY : %s\n", sqlQuery);
 
@@ -136,7 +135,7 @@ msg_error_t MmsPluginStorage::addMmsMsgToDB(MmsMsg *pMmsMsg, const char *raw_fil
        return MSG_SUCCESS;
 }
 
-#if 1 //old
+#if 1 /* old */
 msg_error_t MmsPluginStorage::updateConfMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
 {
        MSG_BEGIN();
@@ -147,13 +146,13 @@ msg_error_t MmsPluginStorage::updateConfMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
 
        MMS_RECV_DATA_S *pMmsRecvData = (MMS_RECV_DATA_S *)pMsgInfo->msgData;
 
-       MSG_DEBUG("###### pMsgInfo->msgData = %s #######", pMmsRecvData->retrievedFilePath);
+       MSG_SEC_DEBUG("###### pMsgInfo->msgData = %s #######", pMmsRecvData->retrievedFilePath);
 
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MESSAGE_ID = '%s', FILE_PATH = '%s' WHERE MSG_ID = %d;",
                        MMS_PLUGIN_MESSAGE_TABLE_NAME, pMmsRecvData->szMsgID, pMmsRecvData->retrievedFilePath, pMsgInfo->msgId);
 
-       MSG_DEBUG("SQLQuery = %s", sqlQuery);
+       MSG_SEC_DEBUG("SQLQuery = %s", sqlQuery);
 
        if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS)
                return MSG_ERR_DB_EXEC;
@@ -163,7 +162,7 @@ msg_error_t MmsPluginStorage::updateConfMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
        return MSG_SUCCESS;
 }
 
-#else //new
+#else /* new */
 
 msg_error_t MmsPluginStorage::updateRetriveConf(msg_message_id_t msgId, MMS_DATA_S *pMmsData)
 {
@@ -208,7 +207,7 @@ msg_error_t MmsPluginStorage::updateConfMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
        char working_dir[MSG_FILENAME_LEN_MAX+1] = {0,};
        MMS_DATA_S *pMmsData = NULL;
 
-       //pMsgInfo->msgData is Filepath of json
+       /* pMsgInfo->msgData is Filepath of json */
        g_file_get_contents((gchar*)pMsgInfo->msgData, (gchar**)&pSerializedMms, (gsize*)&pSerializedMmsSize, NULL);
 
        if (MsgDeserializeMmsData(pSerializedMms, strlen(pSerializedMms), &pMmsData) != 0) {
@@ -220,9 +219,9 @@ msg_error_t MmsPluginStorage::updateConfMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
 
        snprintf(working_dir, sizeof(working_dir), MSG_DATA_PATH"%d.mms.dir", pMsgInfo->msgId);
 
-       MsgMmsSetMultipartListData(pMmsData);//app file -> data
+       MsgMmsSetMultipartListData(pMmsData); /* app file -> data */
 
-       MsgMmsSetMultipartListFilePath(working_dir, pMmsData);//data -> svc file
+       MsgMmsSetMultipartListFilePath(working_dir, pMmsData); /* data -> svc file */
 
        MMS_MULTIPART_DATA_S *pSmilMultipart = pMmsData->smil;
        if (pSmilMultipart) {
@@ -236,7 +235,7 @@ msg_error_t MmsPluginStorage::updateConfMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
                MmsPluginStorage::instance()->insertMultipart(pMsgInfo->msgId, pMultipart);
        }
 
-       {//make Preview info for APP
+       { /* make Preview info for APP */
                MmsPluginAppBase appBase(pMmsData);
                appBase.makePreviewInfo(pMsgInfo->msgId, true, NULL);
                appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText));
@@ -281,8 +280,6 @@ msg_error_t MmsPluginStorage::updateMsgServerID(MSG_MESSAGE_INFO_S *pMsgInfo, MS
                }
        }
 
-       //dbHandle->finalizeQuery();
-
        MSG_END();
 
        return MSG_SUCCESS;
@@ -295,7 +292,7 @@ msg_error_t MmsPluginStorage::insertDeliveryReport(msg_message_id_t msgId, char
        char sqlQuery[MAX_QUERY_LEN + 1];
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
-       //( MSG_ID INTEGER , ADDRESS_VAL TEXT , STATUS_TYPE INTEGER , STATUS INTEGER DEFAULT 0 , TIME DATETIME);
+       /* ( MSG_ID INTEGER , ADDRESS_VAL TEXT , STATUS_TYPE INTEGER , STATUS INTEGER DEFAULT 0 , TIME DATETIME); */
        snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s "
                        "(MSG_ID, ADDRESS_VAL, STATUS_TYPE, STATUS, TIME) "
                        "VALUES (%d, '%s', %d, %d, %d);",
@@ -316,7 +313,7 @@ msg_error_t MmsPluginStorage::insertReadReport(msg_message_id_t msgId, char *add
        char sqlQuery[MAX_QUERY_LEN + 1];
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
-       //( MSG_ID INTEGER , ADDRESS_VAL TEXT , STATUS_TYPE INTEGER , STATUS INTEGER DEFAULT 0 , TIME DATETIME);
+       /* ( MSG_ID INTEGER , ADDRESS_VAL TEXT , STATUS_TYPE INTEGER , STATUS INTEGER DEFAULT 0 , TIME DATETIME); */
        snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s "
                        "(MSG_ID, ADDRESS_VAL, STATUS_TYPE, STATUS, TIME) "
                        "VALUES (%d, '%s', %d, %d, %d);",
@@ -415,7 +412,7 @@ void MmsPluginStorage::getMmsFromDB(msg_message_id_t msgId, MmsMsg *pMmsMsg)
                pMmsMsg->mmsAttrib.msgSize = dbHandle->columnInt(i++);
                pMmsMsg->mmsAttrib.msgClass = (MmsMsgClass)dbHandle->columnInt(i++);
                pMmsMsg->mmsAttrib.expiryTime.time = dbHandle->columnInt(i++);
-               i++;//CUSTOM_DELIVERY_TIME
+               i++; /* CUSTOM_DELIVERY_TIME */
                pMmsMsg->mmsAttrib.deliveryTime.time = dbHandle->columnInt(i++);
                pMmsMsg->mmsAttrib.msgStatus = (msg_delivery_report_status_t)dbHandle->columnInt(i++);
                snprintf(pMmsMsg->szMsgID, sizeof(pMmsMsg->szMsgID), "%s", dbHandle->columnText(i++));
@@ -540,7 +537,7 @@ msg_error_t MmsPluginStorage::getAddressInfo(msg_message_id_t msgId, MSG_ADDRESS
 
        char sqlQuery[MAX_QUERY_LEN+1];
 
-       // Add Address
+       /* Add Address */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
        snprintf(sqlQuery, sizeof(sqlQuery), "SELECT "
@@ -644,7 +641,7 @@ msg_error_t MmsPluginStorage::getMsgText(MMS_MESSAGE_DATA_S *pMmsMsg, char *pMsg
        if (pMmsMsg == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       // Get the text data from the 1st slide.
+       /* Get the text data from the 1st slide. */
        if (pMmsMsg->pageCnt > 0) {
                pPage = _MsgMmsGetPage(pMmsMsg, 0);
 
@@ -657,7 +654,7 @@ msg_error_t MmsPluginStorage::getMsgText(MMS_MESSAGE_DATA_S *pMmsMsg, char *pMsg
                                if (pMedia && pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) {
 
                                        MimeType mimeType = MIME_UNKNOWN;
-                                       MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
+                                       MsgGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL);
 
                                        if (mimeType == MIME_TEXT_X_VCALENDAR || mimeType == MIME_TEXT_X_VCARD || mimeType == MIME_TEXT_X_VTODO || mimeType == MIME_TEXT_X_VNOTE) {
                                                MSG_DEBUG("Media Type is Text, but Vobject file [%s]", pMedia->szFilePath);
@@ -687,7 +684,7 @@ msg_error_t MmsPluginStorage::insertPreviewInfo(int msgId, int type, const char
                        "VALUES (%d, %d, \"%s\", %d);",
                        MSGFW_MMS_PREVIEW_TABLE_NAME, msgId, type, value, count);
 
-       MSG_DEBUG("QUERY : [%s]", sqlQuery);
+       MSG_SEC_DEBUG("QUERY : [%s]", sqlQuery);
 
        if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS)
                return MSG_ERR_DB_EXEC;
@@ -702,7 +699,7 @@ msg_error_t MmsPluginStorage::removePreviewInfo(int msgId)
        char sqlQuery[MAX_QUERY_LEN + 1];
        char filePath[MSG_FILEPATH_LEN_MAX + 1] = {0,};
 
-       // remove thumbnail file
+       /* remove thumbnail file */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery),
                        "SELECT VALUE FROM %s "
@@ -726,7 +723,7 @@ msg_error_t MmsPluginStorage::removePreviewInfo(int msgId)
        dbHandle->finalizeQuery();
 
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
-       //(MSG_ID INTEGER, TYPE INTEGER, INFO TEXT)
+       /* (MSG_ID INTEGER, TYPE INTEGER, INFO TEXT) */
        snprintf(sqlQuery, sizeof(sqlQuery),
                        "DELETE FROM %s WHERE MSG_ID= %d;",
                        MSGFW_MMS_PREVIEW_TABLE_NAME, msgId);
@@ -747,7 +744,7 @@ msg_error_t MmsPluginStorage::deleteMmsMessage(int msgId)
        char filePath[MSG_FILEPATH_LEN_MAX + 1] = {0,};
        char dirPath[MSG_FILEPATH_LEN_MAX + 1]= {0,};
 
-       //remove DB Preview
+       /* remove DB Preview */
        removePreviewInfo(msgId);
 
        deleteMultipartList(msgId);
@@ -765,16 +762,16 @@ msg_error_t MmsPluginStorage::deleteMmsMessage(int msgId)
 
                snprintf(dirPath, MSG_FILEPATH_LEN_MAX, "%s.dir", filePath);
 
-               //delete pdu file
+               /* delete pdu file */
                if (remove(filePath) == -1)
                        MSG_SEC_DEBUG("Fail to delete file [%s]", filePath);
                else
                        MSG_SEC_DEBUG("Success to delete file [%s]", filePath);
 
-               //delete multipart files
+               /* delete multipart files */
                MsgRmRf(dirPath);
 
-               //delete multipart dir
+               /* delete multipart dir */
                rmdir(dirPath);
 
        } else {
@@ -786,7 +783,7 @@ msg_error_t MmsPluginStorage::deleteMmsMessage(int msgId)
        dbHandle->finalizeQuery();
 
 
-       // Delete Data from MMS table
+       /* Delete Data from MMS table */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;",
                        MMS_PLUGIN_MESSAGE_TABLE_NAME, msgId);
@@ -795,7 +792,7 @@ msg_error_t MmsPluginStorage::deleteMmsMessage(int msgId)
                return MSG_ERR_DB_EXEC;
        }
 
-       // Delete Data from MMS STATUS table
+       /* Delete Data from MMS STATUS table */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;",
                        MSGFW_REPORT_TABLE_NAME, msgId);
@@ -822,14 +819,14 @@ msg_error_t MmsPluginStorage::insertMultipart(msg_message_id_t msgId, MMS_MULTIP
        }
 
 #if 0
-       //( MSG_ID INTEGER NOT NULL , SEQ INTEGER DEFAULT 0, CONTENT_TYPE TEXT,         NAME TEXT, CHARSET INTEGER,     CONTENT_ID TEXT, CONTENT_LOCATION TEXT, FILE_PATH TEXT, TEXT TEXT,);
-       if (pMultipart->type == MIME_APPLICATION_SMIL) {//Smil
+       /* ( MSG_ID INTEGER NOT NULL , SEQ INTEGER DEFAULT 0, CONTENT_TYPE TEXT,        NAME TEXT, CHARSET INTEGER,     CONTENT_ID TEXT, CONTENT_LOCATION TEXT, FILE_PATH TEXT, TEXT TEXT,); */
+       if (pMultipart->type == MIME_APPLICATION_SMIL) { /* Smil */
                snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s "
                                "(MSG_ID, SEQ, CONTENT_TYPE, NAME, CONTENT_ID, CONTENT_LOCATION, TEXT) "
                                "VALUES (%d, -1, '%s', '%s', '%s', '%s' , '%s');",
                                MSGFW_MMS_MULTIPART_TABLE_NAME, msgId, pMultipart->szContentType, pMultipart->szFileName, pMultipart->szContentID, pMultipart->szContentLocation, (char *)pMultipart->data);
 
-       } else if (MmsIsText(pMultipart->type)) {//Text
+       } else if (MmsIsText(pMultipart->type)) { /* Text */
                snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s "
                                "(MSG_ID, CONTENT_TYPE, NAME, CHARSET, CONTENT_ID, CONTENT_LOCATION, TEXT) "
                                "VALUES (%d, '%s', '%s', %d, '%s', '%s' ,'%s');",
@@ -842,27 +839,31 @@ msg_error_t MmsPluginStorage::insertMultipart(msg_message_id_t msgId, MMS_MULTIP
        }
 #else
 
-       if (pMultipart->type == MIME_APPLICATION_SMIL) {//Smil
+       if (pMultipart->type == MIME_APPLICATION_SMIL) { /* Smil */
                snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s "
                                                "(MSG_ID, SEQ, CONTENT_TYPE, NAME, CONTENT_ID, CONTENT_LOCATION, FILE_PATH) "
                                                "VALUES (%d, -1, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\");",
                                                MSGFW_MMS_MULTIPART_TABLE_NAME, msgId, pMultipart->szContentType, pMultipart->szFileName, pMultipart->szContentID, pMultipart->szContentLocation, (char *)pMultipart->szFilePath);
 
+               MSG_SEC_DEBUG("QUERY : [%s]", sqlQuery);
+
+               if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS)
+                       return MSG_ERR_DB_EXEC;
        } else {
                const char *pszMimeType = NULL;
 
                if (strlen(pMultipart->szContentType) == 0) {
-                       MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMultipart->szFilePath, &pMultipart->type, &pszMimeType);
+                       MsgGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMultipart->szFilePath, &pMultipart->type, &pszMimeType);
                        snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", pszMimeType);
                        MSG_DEBUG("pMultipart->szContentType = %s", pMultipart->szContentType);
                }
 
                /* make tcs_bc_level & malware_allow value */
                pMultipart->tcs_bc_level = -1;
-               //CID 41991: pMultipart->szFilePath is an array, hence checking for null is not required
+               /* CID 41991: pMultipart->szFilePath is an array, hence checking for null is not required */
                if (strlen(pMultipart->szFilePath) > 0 && MsgAccessFile(pMultipart->szFilePath, F_OK) == true) {
                        int bc_level = -1;
-                       int tcs_ret = 0; // MmsPluginTcsScanFile(pMultipart->szFilePath, &bc_level);
+                       int tcs_ret = 0; // MsgTcsScanFile(pMultipart->szFilePath, &bc_level);
                        if (tcs_ret == 0) {
                                if (bc_level > -1) {
                                        MSG_DEBUG("This content is malware, level = %d", bc_level);
@@ -874,7 +875,7 @@ msg_error_t MmsPluginStorage::insertMultipart(msg_message_id_t msgId, MMS_MULTIP
 
                if (pMultipart->tcs_bc_level < 0 || pMultipart->malware_allow) {
 
-                       if (g_str_has_prefix(pMultipart->szContentType, "video")) {
+                       if (g_str_has_prefix(pMultipart->szContentType, "video") || g_str_has_prefix(pMultipart->szContentType, "image")) {
                                char thumbPath[MSG_FILEPATH_LEN_MAX+1] = {0, };
 
                                if (MmsMakeMultipartThumbnailInfo(pMultipart, thumbPath) == MSG_SUCCESS)
@@ -882,16 +883,52 @@ msg_error_t MmsPluginStorage::insertMultipart(msg_message_id_t msgId, MMS_MULTIP
                        }
                }
 
-               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s "
+               if (!g_strcmp0(pMultipart->szContentType, "text/plain")) {
+                       gchar *contents = NULL;
+                       gsize length = 0;
+
+                       if (MsgAccessFile(pMultipart->szFilePath, F_OK))
+                               g_file_get_contents((gchar*)pMultipart->szFilePath, (gchar**)&contents, (gsize*)&length, NULL);
+
+                       if (contents) {
+                               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s "
+                                                       "(MSG_ID, CONTENT_TYPE, NAME, CONTENT_ID, CONTENT_LOCATION, FILE_PATH, TCS_LEVEL, MALWARE_ALLOW, TEXT) "
+                                                       "VALUES (%d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", '%d', '%d', ?);",
+                                                       MSGFW_MMS_MULTIPART_TABLE_NAME, msgId, pMultipart->szContentType, pMultipart->szFileName, pMultipart->szContentID, pMultipart->szContentLocation, pMultipart->szFilePath, pMultipart->tcs_bc_level, pMultipart->malware_allow);
+
+                               MSG_SEC_DEBUG("QUERY : [%s]", sqlQuery);
+
+                               if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
+                                       g_free(contents);
+                                       return MSG_ERR_DB_EXEC;
+                               }
+
+                               dbHandle->bindText(contents, 1);
+
+                               if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
+                                       dbHandle->finalizeQuery();
+                                       g_free(contents);
+                                       return MSG_ERR_DB_EXEC;
+                               }
+
+                               dbHandle->finalizeQuery();
+                               g_free(contents);
+                       } else {
+                               MSG_ERR("file contents is null!");
+                       }
+               } else {
+                       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s "
                                                "(MSG_ID, CONTENT_TYPE, NAME, CONTENT_ID, CONTENT_LOCATION, FILE_PATH, TCS_LEVEL, MALWARE_ALLOW, THUMB_FILE_PATH) "
                                                "VALUES (%d, \"%s\", \"%s\", \"%s\", \"%s\" ,\"%s\", '%d', '%d', \"%s\");",
-                                               MSGFW_MMS_MULTIPART_TABLE_NAME, msgId, pMultipart->szContentType, pMultipart->szFileName, pMultipart->szContentID, pMultipart->szContentLocation, (char *)pMultipart->szFilePath, pMultipart->tcs_bc_level, pMultipart->malware_allow, (char *)pMultipart->szThumbFilePath);
+                                               MSGFW_MMS_MULTIPART_TABLE_NAME, msgId, pMultipart->szContentType, pMultipart->szFileName, pMultipart->szContentID, pMultipart->szContentLocation, pMultipart->szFilePath, pMultipart->tcs_bc_level, pMultipart->malware_allow, pMultipart->szThumbFilePath);
+
+                       MSG_SEC_DEBUG("QUERY : [%s]", sqlQuery);
+
+                       if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS)
+                               return MSG_ERR_DB_EXEC;
+               }
        }
 #endif
-       MSG_DEBUG("QUERY : [%s]", sqlQuery);
-
-       if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS)
-               return MSG_ERR_DB_EXEC;
 
        MSG_END();
        return MSG_SUCCESS;
@@ -917,7 +954,7 @@ msg_error_t MmsPluginStorage::updateMultipart(msg_message_id_t msgId, int allow_
 
                if (pMultipart->tcs_bc_level >= 0 || pMultipart->malware_allow) {
 
-                       if (!strcasecmp(pMultipart->szContentType, "video")) {
+                       if (!strcasecmp(pMultipart->szContentType, "video") || !strcasecmp(pMultipart->szContentType, "image")) {
                                char thumbPath[MSG_FILEPATH_LEN_MAX+1] = {0, };
 
                                if (MmsMakeMultipartThumbnailInfo(pMultipart, thumbPath) == MSG_SUCCESS)
@@ -946,8 +983,8 @@ msg_error_t MmsPluginStorage::deleteMultipartList(int msgId)
        MsgDbHandler *dbHandle = getDbHandle();
 
        char sqlQuery[MAX_QUERY_LEN + 1];
-       //char filePath[MSG_FILEPATH_LEN_MAX + 1] = {0,};
-       const char * filePath = NULL;
+/*     char filePath[MSG_FILEPATH_LEN_MAX + 1] = {0,}; */
+       const char *filePath = NULL;
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILE_PATH FROM %s WHERE MSG_ID = %d;",
                        MSGFW_MMS_MULTIPART_TABLE_NAME, msgId);
@@ -994,7 +1031,7 @@ msg_error_t MmsPluginStorage::deleteMultipartList(int msgId)
 
        dbHandle->finalizeQuery();
 
-       // Delete Data from Multipart table
+       /* Delete Data from Multipart table */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;",
                        MSGFW_MMS_MULTIPART_TABLE_NAME, msgId);
@@ -1085,17 +1122,17 @@ msg_error_t MmsPluginStorage::addMmsData(msg_message_id_t msgId, const char *raw
                        , MMS_PLUGIN_MESSAGE_TABLE_NAME
                        , msgId, pHeader->trID, pHeader->messageID, "", pHeader->contentLocation
                        , raw_filepath, pHeader->mmsVersion, MMS_DATATYPE_NONE, pHeader->date, pHeader->bHideAddress
-                       , pHeader->bDeliveryReport, 0 /*pMmsMsg->mmsAttrib.bReportAllowed*/, 0/*pMmsMsg->mmsAttrib.readReportAllowedType*/
-                       , pHeader->bReadReport, 0 /*pMmsMsg->mmsAttrib.bRead*/, 0/*pMmsMsg->mmsAttrib.readReportSendStatus*/, 0 /*pMmsMsg->mmsAttrib.bReadReportSent*/
-                       , pHeader->mmsPriority, true/*pMmsMsg->mmsAttrib.bLeaveCopy*/,pHeader->messageSize, pHeader->messageClass
+                       , pHeader->bDeliveryReport, 0 /*pMmsMsg->mmsAttrib.bReportAllowed*/, 0 /*pMmsMsg->mmsAttrib.readReportAllowedType*/
+                       , pHeader->bReadReport, 0 /*pMmsMsg->mmsAttrib.bRead*/, 0 /*pMmsMsg->mmsAttrib.readReportSendStatus*/, 0 /*pMmsMsg->mmsAttrib.bReadReportSent*/
+                       , pHeader->mmsPriority, true /*pMmsMsg->mmsAttrib.bLeaveCopy*/,pHeader->messageSize, pHeader->messageClass
                        , pHeader->expiry.time, 0, pHeader->delivery.time, pHeader->mmsStatus);
 
        msg_error_t db_err = dbHandle->execQuery(sqlQuery);
        if (db_err != MSG_SUCCESS) {
-               MSG_ERR("execute query fail [%s], err = [%d]", sqlQuery, db_err);
+               MSG_SEC_ERR("execute query fail [%s], err = [%d]", sqlQuery, db_err);
                return MSG_ERR_DB_EXEC;
        } else {
-               MSG_DEBUG("execute query success [%s]", sqlQuery);
+               MSG_SEC_DEBUG("execute query success [%s]", sqlQuery);
        }
 
        MMS_MULTIPART_DATA_S *smil = pMmsData->smil;
@@ -1153,34 +1190,33 @@ msg_error_t MmsPluginStorage::getMmsData(msg_message_id_t msgId, MMS_DATA_S *pMm
 
        if (db_err != MSG_SUCCESS) {
                MSG_ERR("prepare query fail [%s], err = [%d]", sqlQuery, db_err);
-               //dbHandle->finalizeQuery();
                return MSG_ERR_PLUGIN_STORAGE;
        }
 
        if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
                int i = 0;
                pHeader->mmsVersion = dbHandle->columnInt(i++);
-               i++;//pMmsMsg->mmsAttrib.dataType = (MmsDataType)dbHandle->columnInt(i++);
+               i++; /* pMmsMsg->mmsAttrib.dataType = (MmsDataType)dbHandle->columnInt(i++); */
                pHeader->date = dbHandle->columnInt(i++);
                pHeader->bHideAddress = dbHandle->columnInt(i++);
                pHeader->bDeliveryReport = dbHandle->columnInt(i++);
-               i++;//pMmsMsg->mmsAttrib.bReportAllowed = dbHandle->columnInt(i++);
-               i++;//pMmsMsg->mmsAttrib.readReportAllowedType = (MmsRecvReadReportType)dbHandle->columnInt(i++);
+               i++; /* pMmsMsg->mmsAttrib.bReportAllowed = dbHandle->columnInt(i++); */
+               i++; /* pMmsMsg->mmsAttrib.readReportAllowedType = (MmsRecvReadReportType)dbHandle->columnInt(i++); */
                pHeader->bReadReport = dbHandle->columnInt(i++);
-               i++;//pMmsMsg->mmsAttrib.bRead = dbHandle->columnInt(i++);
-               i++;//pMmsMsg->mmsAttrib.readReportSendStatus = (MmsRecvReadReportSendStatus)dbHandle->columnInt(i++);
-               i++;//pMmsMsg->mmsAttrib.bReadReportSent = dbHandle->columnInt(i++);
+               i++; /* pMmsMsg->mmsAttrib.bRead = dbHandle->columnInt(i++); */
+               i++; /* pMmsMsg->mmsAttrib.readReportSendStatus = (MmsRecvReadReportSendStatus)dbHandle->columnInt(i++); */
+               i++; /* pMmsMsg->mmsAttrib.bReadReportSent = dbHandle->columnInt(i++); */
                pHeader->mmsPriority = (MmsPriority)dbHandle->columnInt(i++);
                pHeader->messageSize = dbHandle->columnInt(i++);
                pHeader->messageClass = (MmsMsgClass)dbHandle->columnInt(i++);
                pHeader->expiry.time = dbHandle->columnInt(i++);
-               i++;//CUSTOM_DELIVERY_TIME
+               i++; /* CUSTOM_DELIVERY_TIME */
                pHeader->delivery.time = dbHandle->columnInt(i++);
-               i++;//pMmsMsg->mmsAttrib.msgStatus = (msg_delivery_report_status_t)dbHandle->columnInt(i++);
+               i++; /* pMmsMsg->mmsAttrib.msgStatus = (msg_delivery_report_status_t)dbHandle->columnInt(i++); */
                snprintf(pHeader->messageID, sizeof(pHeader->messageID), "%s", dbHandle->columnText(i++));
                snprintf(pHeader->trID, sizeof(pHeader->trID), "%s", dbHandle->columnText(i++));
                snprintf(pHeader->contentLocation, sizeof(pHeader->contentLocation), "%s", dbHandle->columnText(i++));
-               i++;//snprintf(pMmsMsg->szFileName, sizeof(pMmsMsg->szFileName), "%s", dbHandle->columnText(i++));
+               i++; /* snprintf(pMmsMsg->szFileName, sizeof(pMmsMsg->szFileName), "%s", dbHandle->columnText(i++)); */
        }
 
        dbHandle->finalizeQuery();
@@ -1206,7 +1242,7 @@ msg_error_t MmsPluginStorage::getMmsData(msg_message_id_t msgId, MMS_DATA_S *pMm
                                        gchar *contents = NULL;
                                        gsize length = 0;
 
-                                       g_file_get_contents ((gchar*)smil_multipart->szFilePath, (gchar**)&contents, (gsize*)&length, NULL);
+                                       g_file_get_contents((gchar*)smil_multipart->szFilePath, (gchar**)&contents, (gsize*)&length, NULL);
 
                                        smil_multipart->pMultipartData = contents;
                                        smil_multipart->nMultipartDataLen = length;
@@ -1232,7 +1268,7 @@ msg_error_t MmsPluginStorage::getMmsData(msg_message_id_t msgId, MMS_DATA_S *pMm
 }
 
 msg_error_t MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pSerializedMms)
-{//send request or notification ind
+{ /* send request or notification ind */
        MSG_BEGIN();
 
        msg_error_t     err = MSG_SUCCESS;
@@ -1248,33 +1284,33 @@ msg_error_t MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDI
                char raw_filepath[MSG_FILENAME_LEN_MAX+1] = {0,};
                char working_dir[MSG_FILENAME_LEN_MAX+1] = {0,};
 
-               //compose
+               /* compose */
                MmsPluginComposer::instance()->composeSendReq(pMsgInfo, pSendOptInfo, pMmsData);
 
-               //encode
+               /* encode */
                snprintf(working_dir, sizeof(working_dir), MSG_DATA_PATH"%d.mms.dir", pMsgInfo->msgId);
 
-               MsgMmsSetMultipartListData(pMmsData);//app file -> data
+               MsgMmsSetMultipartListData(pMmsData); /* app file -> data */
 
-               MsgMmsSetMultipartListFilePath(working_dir, pMmsData);//data -> svc file
+               MsgMmsSetMultipartListFilePath(working_dir, pMmsData); /* data -> svc file */
 
                snprintf(raw_filepath, sizeof(raw_filepath), "%s%d.mms", MSG_DATA_PATH, pMsgInfo->msgId);
 
                MmsPluginEncoder::instance()->encodeMmsPdu(pMmsData, pMsgInfo->msgId, raw_filepath);
 
-               //add to db
+               /* add to db */
                if (addMmsData(pMsgInfo->msgId, raw_filepath, pMmsData) != MSG_SUCCESS) {
                        MSG_DEBUG("Fail to add db message");
                        goto __CATCH;
                }
 
-               //set
+               /* set */
                if (MsgGetFileSize(raw_filepath, (int *)&pMsgInfo->dataSize) == false) {
                        MSG_SEC_DEBUG("Fail to get mms file size [%s]", raw_filepath);
                        goto __CATCH;
                }
 
-               {//make Preview info for APP
+               { /* make Preview info for APP */
                        MmsPluginAppBase appBase(pMmsData);
                        appBase.makePreviewInfo(pMsgInfo->msgId, true, raw_filepath);
                        appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText));
@@ -1287,33 +1323,33 @@ msg_error_t MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDI
                char raw_filepath[MSG_FILENAME_LEN_MAX+1] = {0,};
                char working_dir[MSG_FILENAME_LEN_MAX+1] = {0,};
 
-               //compose
+               /* compose */
                MmsPluginComposer::instance()->composeRetrieveConf(pMsgInfo, pSendOptInfo, pMmsData);
 
-               //encode
+               /* encode */
                snprintf(working_dir, sizeof(working_dir), MSG_DATA_PATH"%d.mms.dir", pMsgInfo->msgId);
 
-               MsgMmsSetMultipartListData(pMmsData);//app file -> data
+               MsgMmsSetMultipartListData(pMmsData); /* app file -> data */
 
-               MsgMmsSetMultipartListFilePath(working_dir, pMmsData);//data -> svc file
+               MsgMmsSetMultipartListFilePath(working_dir, pMmsData); /* data -> svc file */
 
                snprintf(raw_filepath, sizeof(raw_filepath), "%s%d.mms", MSG_DATA_PATH, pMsgInfo->msgId);
 
                MmsPluginEncoder::instance()->encodeMmsPdu(pMmsData, pMsgInfo->msgId, raw_filepath);
 
-               //add to db
+               /* add to db */
                if (addMmsData(pMsgInfo->msgId, raw_filepath, pMmsData) != MSG_SUCCESS) {
                        MSG_DEBUG("Fail to add db message");
                        goto __CATCH;
                }
 
-               //set
+               /* set */
                if (MsgGetFileSize(raw_filepath, (int *)&pMsgInfo->dataSize) == false) {
                        MSG_SEC_DEBUG("Fail to get mms file size [%s]", raw_filepath);
                        goto __CATCH;
                }
 
-               {//make Preview info for APP
+               { /* make Preview info for APP */
                        MmsPluginAppBase *appBase;
                        appBase = new MmsPluginAppBase(pMmsData);
                        appBase->makePreviewInfo(pMsgInfo->msgId, true, raw_filepath);
@@ -1359,7 +1395,8 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
 
        MMS_DATA_S *pMmsData = NULL;
 
-       if (MsgDeserializeMmsData(pSerializedMms, strlen(pSerializedMms), &pMmsData) != 0) {
+       /* CID 12917: strlen will give exception in case of NULL, hence the check of pSerializedMms */
+       if (pSerializedMms == NULL || MsgDeserializeMmsData(pSerializedMms, strlen(pSerializedMms), &pMmsData) != 0) {
                MSG_DEBUG("Fail to Deserialize Message Data");
                goto __CATCH;
        }
@@ -1370,15 +1407,15 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
                char raw_filepath[MSG_FILENAME_LEN_MAX+1] = {0,};
                char working_dir[MSG_FILENAME_LEN_MAX+1] = {0,};
 
-               //compose
+               /* compose */
                MmsPluginComposer::instance()->composeSendReq(pMsgInfo, pSendOptInfo, pMmsData);
 
-               //encode
+               /* encode */
                snprintf(raw_filepath, sizeof(raw_filepath), "%s%d.mms", MSG_DATA_PATH, pMsgInfo->msgId);
 
                MmsPluginEncoder::instance()->encodeMmsPdu(pMmsData, pMsgInfo->msgId, raw_filepath);
 
-               //add to db
+               /* add to db */
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET ASK_DELIVERY_REPORT = %d, KEEP_COPY = %d, ASK_READ_REPLY = %d, EXPIRY_TIME = %d, CUSTOM_DELIVERY_TIME = %d, DELIVERY_TIME= %d, PRIORITY = %d \
                                WHERE MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, pSendOptInfo->bDeliverReq, pSendOptInfo->bKeepCopy, pSendOptInfo->option.mmsSendOptInfo.bReadReq,
@@ -1386,20 +1423,20 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
                                pSendOptInfo->option.mmsSendOptInfo.priority, pMsgInfo->msgId);
 
                if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
-                       //CID 41997: Releasing pMmsDta in case of failure
+                       /* CID 41997: Releasing pMmsDta in case of failure */
                        MsgMmsRelease(&pMmsData);
                        return MSG_ERR_DB_EXEC;
                }
 
                snprintf(working_dir, sizeof(working_dir), MSG_DATA_PATH"%d.mms.dir", pMsgInfo->msgId);
 
-               MsgMmsSetMultipartListData(pMmsData);//app file -> data
+               MsgMmsSetMultipartListData(pMmsData); /* app file -> data */
 
-               MmsPluginStorage::instance()->deleteMultipartList(pMsgInfo->msgId); //remove exist multipart
+               MmsPluginStorage::instance()->deleteMultipartList(pMsgInfo->msgId); /* remove exist multipart */
 
-               MsgMmsSetMultipartListFilePath(working_dir, pMmsData);//data -> svc file
+               MsgMmsSetMultipartListFilePath(working_dir, pMmsData); /* data -> svc file */
 
-               {//add multipart list
+               { /* add multipart list */
                        if (pMmsData->smil) {
                                pMmsData->smil->type = MIME_APPLICATION_SMIL;
                                insertMultipart(pMsgInfo->msgId, pMmsData->smil);
@@ -1419,15 +1456,15 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
                        }
                }
 
-               //set
+               /* set */
                if (MsgGetFileSize(raw_filepath, (int *)&pMsgInfo->dataSize) == false) {
                        MSG_SEC_DEBUG("Fail to get mms file size [%s]", raw_filepath);
-                       //CID 41997: Releasing pMmsDta in case of failure
+                       /* CID 41997: Releasing pMmsDta in case of failure */
                        MsgMmsRelease(&pMmsData);
                        goto __CATCH;
                }
 
-               {//make Preview info for APP
+               { /* make Preview info for APP */
                        MmsPluginAppBase *appBase;
                        appBase = new MmsPluginAppBase(pMmsData);
                        appBase->makePreviewInfo(pMsgInfo->msgId, true, raw_filepath);
@@ -1471,29 +1508,29 @@ msg_error_t MmsPluginStorage::getMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOP
        pMmsData->header = pHeader;
 
        switch(pMsg->msgType.subType) {
-               case MSG_SENDREQ_MMS:
-                       pHeader->messageType = MMS_MSGTYPE_SEND_REQ;
-                       break;
-               case MSG_SENDCONF_MMS:
-                       pHeader->messageType = MMS_MSGTYPE_SEND_CONF;
-                       break;
-               case MSG_RETRIEVE_MMS:
-                       pHeader->messageType = MMS_MSGTYPE_RETRIEVE_CONF;
-                       break;
-               case MSG_RETRIEVE_AUTOCONF_MMS:
-                       pHeader->messageType = MMS_MSGTYPE_RETRIEVE_CONF;
-                       break;
-               case MSG_RETRIEVE_MANUALCONF_MMS:
-                       pHeader->messageType = MMS_MSGTYPE_RETRIEVE_CONF;
-                       break;
-               case MSG_NOTIFICATIONIND_MMS:
-                       pHeader->messageType = MMS_MSGTYPE_NOTIFICATION_IND;
-                       break;
-               default:
-                       break;
+       case MSG_SENDREQ_MMS:
+               pHeader->messageType = MMS_MSGTYPE_SEND_REQ;
+               break;
+       case MSG_SENDCONF_MMS:
+               pHeader->messageType = MMS_MSGTYPE_SEND_CONF;
+               break;
+       case MSG_RETRIEVE_MMS:
+               pHeader->messageType = MMS_MSGTYPE_RETRIEVE_CONF;
+               break;
+       case MSG_RETRIEVE_AUTOCONF_MMS:
+               pHeader->messageType = MMS_MSGTYPE_RETRIEVE_CONF;
+               break;
+       case MSG_RETRIEVE_MANUALCONF_MMS:
+               pHeader->messageType = MMS_MSGTYPE_RETRIEVE_CONF;
+               break;
+       case MSG_NOTIFICATIONIND_MMS:
+               pHeader->messageType = MMS_MSGTYPE_NOTIFICATION_IND;
+               break;
+       default:
+               break;
        }
 
-       err = getMmsData(pMsg->msgId, pMmsData); // get MmsData Info from DB
+       err = getMmsData(pMsg->msgId, pMmsData); /* get MmsData Info from DB */
 
        if (err == MSG_SUCCESS) {
 
@@ -1507,7 +1544,7 @@ msg_error_t MmsPluginStorage::getMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOP
                        pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time = pHeader->delivery.time;
                }
 
-               //MsgMmsSetMultipartListData(pMmsData);
+               /* MsgMmsSetMultipartListData(pMmsData); */
                int mmsDataSize = MsgSerializeMms(pMmsData, pSerializedMms);
                if (mmsDataSize > 0) {
                        pMsg->dataSize = mmsDataSize;
@@ -1519,7 +1556,7 @@ msg_error_t MmsPluginStorage::getMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOP
                MSG_ERR("getMmsData fail, err = [%d]",  err);
        }
 
-       //Release pMmsData
+       /* Release pMmsData */
        MsgMmsRelease(&pMmsData);
        MSG_END();
 
@@ -1530,7 +1567,7 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
 {
        MSG_BEGIN();
 
-       //update multipart list
+       /* update multipart list */
        MMSList *multipart_list = NULL;
        if (MmsPluginStorage::instance()->getMultipartList(pMsgInfo->msgId, &multipart_list) != MSG_SUCCESS)
                return -1;
@@ -1540,7 +1577,7 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
                MmsPluginStorage::instance()->updateMultipart(pMsgInfo->msgId, true, pMultipart);
        }
 
-       //update preview
+       /* update preview */
        char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, };
        MmsMsg *mmsMsg = NULL;
        unique_ptr<MmsMsg*, void(*)(MmsMsg**)> buf(&mmsMsg, unique_ptr_deleter);
@@ -1549,7 +1586,7 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
 
        MmsPluginStorage::instance()->getMmsRawFilePath(pMsgInfo->msgId, szFullPath, sizeof(szFullPath));
        MmsPluginDecoder::instance()->decodeMmsPdu(mmsMsg, pMsgInfo->msgId, szFullPath);
-       {//make Preview info for APP
+       { /* make Preview info for APP */
                MmsPluginAppBase *appBase;
                appBase = new MmsPluginAppBase(mmsMsg);
                appBase->makePreviewInfo(pMsgInfo->msgId, true, szFullPath);
@@ -1569,10 +1606,10 @@ int MmsPluginStorage::checkDuplicateNotification(char* pszTrID, char* pszContent
        if (!pszTrID || strlen(pszTrID) == 0)
                return 0;
 
-       if(!pszContentLocation || strlen(pszContentLocation) == 0)
+       if (!pszContentLocation || strlen(pszContentLocation) == 0)
                return 0;
 
-       MSG_DEBUG("Trans Id = %s, Content Loc = %s", pszTrID, pszContentLocation);
+       MSG_SEC_DEBUG("Trans Id = %s, Content Loc = %s", pszTrID, pszContentLocation);
 
        int msgId = 0;
        msg_error_t err = MSG_SUCCESS;
@@ -1588,7 +1625,7 @@ int MmsPluginStorage::checkDuplicateNotification(char* pszTrID, char* pszContent
                        WHERE TRANSACTION_ID LIKE '%s' AND CONTENTS_LOCATION LIKE '%s'",
                        MMS_PLUGIN_MESSAGE_TABLE_NAME, pszTrID, pszContentLocation);
 
-       MSG_DEBUG("sqlQuery [%s]", sqlQuery);
+       MSG_SEC_DEBUG("sqlQuery [%s]", sqlQuery);
 
        err = dbHandle->getTable(sqlQuery, &rowCnt, NULL);
 
diff --git a/plugin/mms_plugin/MmsPluginTcs.cpp b/plugin/mms_plugin/MmsPluginTcs.cpp
deleted file mode 100755 (executable)
index 5a9ca7b..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include "TCSImpl.h"
-#include "TCSErrorCodes.h"
-#include "MmsPluginDebug.h"
-#include "MsgUtilFile.h"
-#include "MmsPluginTcs.h"
-
-int MmsPluginTcsScanFile(const char *filepath, int *bLevel)
-{
-       MSG_BEGIN();
-       TCSLIB_HANDLE hLib;
-       TCSScanResult result;
-       TCSDetected* pDetected;
-       int rtn, i;
-       int ret_b_level = -1;
-
-       if (MsgAccessFile(filepath, R_OK) == false) {
-               MSG_SEC_DEBUG("not exist source file [%s]", filepath);
-               return -1;
-       }
-
-       MSG_SEC_DEBUG("Scanning file name : %s\n", filepath);
-
-       hLib = TCSLibraryOpen();
-       if(hLib == INVALID_TCSLIB_HANDLE) {
-               MSG_DEBUG("TCSLibraryOpen error\n");
-               return -1;
-       }
-
-       rtn = TCSScanFile(hLib, filepath, TCS_DTYPE_UNKNOWN, TCS_SA_SCANONLY, 1, &result);
-       if(rtn == 0)
-       {
-               MSG_DEBUG("Detected malware number: %d\n", result.iNumDetected);
-               i = result.iNumDetected;
-               pDetected = result.pDList;
-               while(i && pDetected)
-               {
-                       int temp_b_level;
-                       int temp_s_class;
-                       MSG_SEC_DEBUG(" +-- Malware [%d] Name: %s\n", i, pDetected->pszName);
-                       MSG_DEBUG(" +-- Malware [%d] uAction: %u : 0x%04x\n", i, pDetected->uAction, pDetected->uAction);
-
-                       temp_b_level  = (pDetected->uAction & 0xFF00) >> 8;
-                       MSG_DEBUG(" +-- Malware [%d] Behavior level: %u\n", i, temp_b_level);
-
-                       if (ret_b_level == -1 || ret_b_level < temp_b_level) {
-                               ret_b_level = temp_b_level;
-                       }
-
-                       temp_s_class  = (pDetected->uAction & 0x00FF);
-                       MSG_DEBUG(" +-- Malware [%d] Severity class: %u\n", i, temp_s_class);
-
-                       pDetected = pDetected->pNext;
-                       i --;
-               }
-
-               result.pfFreeResult(&result);
-       } else {
-               MSG_DEBUG("TCSScanFile fail: err = %d\n", rtn);
-       }
-
-       TCSLibraryClose(hLib);
-
-       if (bLevel)
-               *bLevel = ret_b_level;
-
-       MSG_END();
-
-       return 0;
-}
index bd79ac6..9369296 100755 (executable)
@@ -16,7 +16,7 @@
 
 #include <glib.h>
 #include "MmsPluginDebug.h"
-#include "MmsPluginMIME.h"
+#include "MsgUtilMime.h"
 #include "MmsPluginCodec.h"
 #include "MmsPluginTextConvert.h"
 #include "MmsPluginUtil.h"
@@ -51,7 +51,7 @@ bool MmsPluginTextConvert(const char *pToCodeSet, const char *pFromCodeset, cons
                goto __CATCH;
        }
 
-       if (strcasecmp("utf-16", pFromCodeset) == 0) {//check utf-8 str though utf-16
+       if (strcasecmp("utf-16", pFromCodeset) == 0) { /* check utf-8 str though utf-16 */
 
                MSG_DEBUG("Codeset [%s] check utf-8 type", pFromCodeset);
 
index 5af58cf..5b79262 100755 (executable)
@@ -57,8 +57,11 @@ void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo)
        reqItem.reqID = pReqInfo->reqId;
        reqItem.simId = pReqInfo->msgInfo.sim_idx;
 
-       char *msisdn = NULL;
-       msisdn = MsgSettingGetString(MSG_SIM_MSISDN);
+       char keyName[MAX_VCONFKEY_NAME_LEN];
+       memset(keyName, 0x00, sizeof(keyName));
+
+       snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, pReqInfo->msgInfo.sim_idx);
+       char *msisdn = MsgSettingGetString(keyName);
 
        MSG_DEBUG("pReqInfo->msgInfo.msgType.subType [%d]", pReqInfo->msgInfo.msgType.subType);
 
@@ -82,16 +85,18 @@ void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo)
                reqItem.pGetData = (char *)malloc(reqItem.getDataLen);
                if (reqItem.pGetData)
                        memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen);
+               memcpy(reqItem.url, pReqInfo->msgInfo.msgURL, MMS_LOCATION_LEN);
                MSG_MMS_VLD_INFO("%d, MMS Receive Auto Start %s->%s, Success", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.addressList[0].addressVal, (msisdn == NULL)?"ME":msisdn);
                break;
 
-       case MSG_NOTIFYRESPIND_MMS: //reject
+       case MSG_NOTIFYRESPIND_MMS: /* reject */
        {
                MSG_DEBUG("######### MANUAL RETRIEVE : SEND NOTIFY RESPONSE IND");
                reqItem.msgId = pReqInfo->msgInfo.msgId;
                reqItem.eMmsPduType = eMMS_NOTIFYRESP_IND;
                reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
                reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
+               memcpy(reqItem.url, pReqInfo->msgInfo.msgURL, MMS_LOCATION_LEN);
                int ret = remove(pReqInfo->msgInfo.msgData);
                if (ret != 0) {
                        MSG_DEBUG("remove fail\n");
@@ -107,31 +112,30 @@ void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo)
                reqItem.pGetData = (char *)malloc(reqItem.getDataLen);
                if (reqItem.pGetData)
                        memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen);
+               memcpy(reqItem.url, pReqInfo->msgInfo.msgData, MMS_LOCATION_LEN);
                MSG_MMS_VLD_INFO("%d, MMS Receive Manual Start %s->%s, Success", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.addressList[0].addressVal, (msisdn == NULL)?"ME":msisdn);
                break;
 
-       case MSG_READREPLY_MMS:
-       {
+       case MSG_READREPLY_MMS: {
                MSG_DEBUG("######### SEND READ REPORT : POST TRANSACTION");
                reqItem.msgId = pReqInfo->msgInfo.msgId;
                reqItem.eMmsPduType = eMMS_READREPORT_REQ;
                reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
                reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
-               // remove x-Read-Rec.ind file
+               /* remove x-Read-Rec.ind file */
                int ret = remove(pReqInfo->msgInfo.msgData);
                if (ret != 0) {
                        MSG_DEBUG("remove fail\n");
                }
                break;
        }
-       case MSG_READRECIND_MMS:
-       {
+       case MSG_READRECIND_MMS: {
                MSG_DEBUG("######### SEND READREC IND : POST TRANSACTION");
                reqItem.msgId = pReqInfo->msgInfo.msgId;
                reqItem.eMmsPduType = eMMS_READREC_IND;
                reqItem.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
                reqItem.pPostData = MsgOpenAndReadMmsFile(pReqInfo->msgInfo.msgData, 0, -1, &reqItem.postDataLen);
-               // remove x-Read-Rec.ind file
+               /* remove x-Read-Rec.ind file */
                int ret = remove(pReqInfo->msgInfo.msgData);
                if (ret != 0) {
                        MSG_DEBUG("remove fail\n");
index ff4d13b..b7ce3ff 100755 (executable)
@@ -124,7 +124,7 @@ void PRINT_QUEUE_ENTITY(mmsTranQEntity *entity)
        MSG_DEBUG("Entity: eMmsPduType: %d", entity->eMmsPduType);
        MSG_DEBUG("Entity: eHttpCmdType: %d", entity->eHttpCmdType);
        MSG_DEBUG("Entity: GetLen: %d", entity->getDataLen);
-       MSG_DEBUG("Entity: GetData: (%s)", entity->pGetData);
+       MSG_SEC_DEBUG("Entity: GetData: (%s)", entity->pGetData);
        MSG_DEBUG("Entity: postLen: %d", entity->postDataLen);
        MSG_DEBUG("Entity: pPostData: (%s)", entity->pPostData);
 }
@@ -227,7 +227,7 @@ MmsPluginUaManager *MmsPluginUaManager::instance()
 
 void MmsPluginUaManager::start()
 {
-//     bool bStart = true;
+/*     bool bStart = true; */
 
        MutexLocker lock(mx);
 
@@ -247,6 +247,7 @@ MMS_NET_ERROR_T MmsPluginUaManager::submitHandler(mmsTranQEntity *qEntity)
        char *http_url = NULL;
        const char *home_url = NULL;
        const char *proxy_addr = NULL;
+       const char *dns_list = NULL;
        const char *interfaceName = NULL;
        bool cm_ret;
 
@@ -267,6 +268,10 @@ MMS_NET_ERROR_T MmsPluginUaManager::submitHandler(mmsTranQEntity *qEntity)
        if (cm_ret == false)
                return eMMS_EXCEPTIONAL_ERROR;
 
+       cm_ret = MmsPluginCmAgent::instance()->getDnsAddrList(&dns_list);
+       if (cm_ret == false)
+               return eMMS_EXCEPTIONAL_ERROR;
+
        memset(&request_info, 0x00, sizeof(request_info));
 
        if (qEntity->eHttpCmdType == eHTTP_CMD_POST_TRANSACTION) {
@@ -277,6 +282,8 @@ MMS_NET_ERROR_T MmsPluginUaManager::submitHandler(mmsTranQEntity *qEntity)
 
                request_info.proxy = proxy_addr;
 
+               request_info.dns_list = dns_list;
+
                request_info.interface = interfaceName;
 
                request_info.post_data = qEntity->pPostData;
@@ -295,6 +302,8 @@ MMS_NET_ERROR_T MmsPluginUaManager::submitHandler(mmsTranQEntity *qEntity)
 
                request_info.proxy = proxy_addr;
 
+               request_info.dns_list = dns_list;
+
                request_info.interface = interfaceName;
        }
 
@@ -314,8 +323,14 @@ MMS_NET_ERROR_T MmsPluginUaManager::submitHandler(mmsTranQEntity *qEntity)
                qEntity->getDataLen = request_info.response_data_len;
                ret = eMMS_SUCCESS;
        } else {
-               MSG_DEBUG("Unexpected Error http_ret = [%d]", http_ret);
-               ret = eMMS_HTTP_ERROR_NETWORK;
+               bool cm_status = MmsPluginCmAgent::instance()->getCmStatus();
+               if (cm_status == false) {
+                       MSG_INFO("PDP disconnected while MMS transaction in progress. cm status [%d]", cm_status);
+                       ret = eMMS_CM_DISCONNECTED;
+               } else {
+                       MSG_DEBUG("Unexpected Error http_ret = [%d]", http_ret);
+                       ret = eMMS_HTTP_ERROR_NETWORK;
+               }
        }
 
        if (http_url)
@@ -343,16 +358,15 @@ void MmsPluginUaManager::run()
                }
                unlock();
 
-               // Request CM Open
+               /* Request CM Open */
                if (!(cmAgent->open())) {
                        MSG_FATAL("Cm Open Failed");
-                       // delete all request from reqQEntities
+                       /* delete all request from reqQEntities */
                        lock();
                        int qSize = mmsTranQ.size();
                        unlock();
                        if (qSize > 0) {
-                               MSG_DEBUG("CLEANUP");
-                               MSG_DEBUG("clear mmsTranQ");
+                               MSG_DEBUG("remove an entity from mmsTranQ");
 
                                mmsTranQEntity reqEntity;
                                memset(&reqEntity, 0, sizeof(mmsTranQEntity));
@@ -360,7 +374,7 @@ void MmsPluginUaManager::run()
                                lock();
                                mmsTranQ.front(&reqEntity);
                                unlock();
-                               // notify send fail to APP
+                               /* notify send fail to APP */
                                MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
 
                                if (reqEntity.pGetData) {
@@ -376,13 +390,11 @@ void MmsPluginUaManager::run()
                                }
                                lock();
                                mmsTranQ.remove(reqEntity, compare_func_for_removal);
-                               //mmsTranQ.pop_front();
+/*                             mmsTranQ.pop_front(); */
                                unlock();
                        }
-                       lock();
-                       running = false;
-                       unlock();
-                       break;
+
+                       continue;
                }
 
                bool transaction = true;
@@ -407,20 +419,22 @@ void MmsPluginUaManager::run()
 
                        PRINT_QUEUE_ENTITY(&reqEntity);
 
-                       // MMS Transaction
+                       /* MMS Transaction */
                        MSG_DEBUG("\n\n ===================  MMS Transaction Start ========================");
 
                        do {
 
-                               if (submitHandler(&reqEntity) != eMMS_SUCCESS) {
+                               MMS_NET_ERROR_T mms_net_status = submitHandler(&reqEntity);
+                               reqEntity.eMmsTransactionStatus = mms_net_status;
+                               if (mms_net_status != eMMS_SUCCESS) {
                                        MSG_DEBUG("Transaction Error: submit failed");
 
                                        MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
                                        lock();
                                        mmsTranQ.remove(reqEntity, compare_func_for_removal);
-                                       //mmsTranQ.pop_front();
+/*                                     mmsTranQ.pop_front(); */
                                        unlock();
-                                       //try to next mmsTranQ
+                                       /* try to next mmsTranQ */
                                        break;
                                }
 
@@ -435,19 +449,19 @@ void MmsPluginUaManager::run()
                                        reqEntity.isCompleted = true;
                                        lock();
                                        mmsTranQ.remove(reqEntity, compare_func_for_removal);
-                                       //mmsTranQ.pop_front();
+/*                                     mmsTranQ.pop_front(); */
                                        unlock();
                                        MSG_DEBUG("Transaction Completed");
                                        break;
                                } else {
-                                       // change MmsPduType from XXX.req to XXX.conf for waiting
+                                       /* change MmsPduType from XXX.req to XXX.conf for waiting */
                                        MSG_DEBUG("Update Pdutype");
                                        updatePduType(&reqEntity);
                                        MSG_DEBUG("Waiting Conf");
                                }
                                lock();
                                mmsTranQ.remove(reqEntity, compare_func_for_removal);
-                               //mmsTranQ.pop_front();
+/*                             mmsTranQ.pop_front(); */
                                unlock();
                                //////// Waiting Conf //////////////////////
                                MMS_NET_ERROR_T networkErr;
@@ -456,7 +470,7 @@ void MmsPluginUaManager::run()
                                        bool bReportAllowed;
                                        char retrievedFilePath[MAX_FULL_PATH_SIZE+1] = {0,};
 
-                                       // process Http data
+                                       /* process Http data */
                                        try {
                                                if (processReceivedData(reqEntity.msgId, reqEntity.pGetData, reqEntity.getDataLen, retrievedFilePath) == false) {
                                                        MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
@@ -498,21 +512,21 @@ void MmsPluginUaManager::run()
                                        MSG_DEBUG("conf received successfully -2");
                                        MSG_DEBUG("reqEntity.eMmsPduType [%d]", reqEntity.eMmsPduType);
 
-                                       // send NotifyResponseInd
+                                       /* send NotifyResponseInd */
                                        if (reqEntity.eMmsPduType == eMMS_RETRIEVE_AUTO_CONF) {
                                                char filepath[MAX_FULL_PATH_SIZE] = {0};
-                                               // change MmsPduType for ind or ack
-                                               // make the PDU and then attach to reqEntity also.
+                                               /* change MmsPduType for ind or ack */
+                                               /* make the PDU and then attach to reqEntity also. */
                                                updatePduType(&reqEntity);
 
                                                MSG_DEBUG("#### eMmsPduType:%d ####", reqEntity.eMmsPduType);
 
-                                               //update http command type & encode m-notify-response-ind
+                                               /* update http command type & encode m-notify-response-ind */
                                                reqEntity.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
 
                                                try {
                                                        MmsPluginInternal::instance()->encodeNotifyRespInd(reqEntity.transactionId, MMS_MSGSTATUS_RETRIEVED, bReportAllowed, filepath);
-                                                       //m-notification-resp-ind encoding      if err is not MSG_SUCCESS then should set x-mms-status to deferred
+                                                       /* m-notification-resp-ind encoding     if err is not MSG_SUCCESS then should set x-mms-status to deferred */
                                                        if (MsgGetFileSize(filepath, &reqEntity.postDataLen) == false) {
                                                                MSG_DEBUG("MsgGetFileSize: failed");
                                                                break;
@@ -539,19 +553,17 @@ void MmsPluginUaManager::run()
                                                }
 
                                                MSG_DEBUG("Submit Ind");
-                                       }
-                                       else if (reqEntity.eMmsPduType == eMMS_RETRIEVE_MANUAL_CONF)
-                                       {
-                                               /* saved msg trId should be checked  */
-                                               // Send Acknowledge Ind
+                                       } else if (reqEntity.eMmsPduType == eMMS_RETRIEVE_MANUAL_CONF) {
+                                               /* saved msg trId should be checked
+                                                * Send Acknowledge Ind */
                                                char filepath[MAX_FULL_PATH_SIZE] = {0};
-                                               // change MmsPduType for ind or ack
-                                               // make the PDU and then attach to reqEntity also.
+                                               /* change MmsPduType for ind or ack
+                                                * make the PDU and then attach to reqEntity also. */
                                                updatePduType(&reqEntity);
 
                                                MSG_DEBUG("#### eMmsPduType:%d ####", reqEntity.eMmsPduType);
 
-                                               //update http command type & encode m-notify-response-ind
+                                               /* update http command type & encode m-notify-response-ind */
                                                reqEntity.eHttpCmdType = eHTTP_CMD_POST_TRANSACTION;
 
                                                try {
@@ -577,7 +589,7 @@ void MmsPluginUaManager::run()
                                                lock();
                                                mmsTranQ.push_front(reqEntity);
                                                unlock();
-                                               remove(filepath); // not ipc
+                                               remove(filepath); /* not ipc */
 
                                                MSG_DEBUG("Submit Ack");
                                        } else {
@@ -606,7 +618,7 @@ void MmsPluginUaManager::run()
 
                }
 
-               // Request CM Close
+               /* Request CM Close */
                cmAgent->close();
 
        }
@@ -642,12 +654,11 @@ bool MmsPluginUaManager::processReceivedData(int msgId, char *pRcvdBody, int rcv
 {
        MSG_BEGIN();
 
-       //CID 317909 : replacing MSG_FILENAME_LEN_MAX with MAX_FULL_PATH_SIZE as the latter is max length for internal file path
-       //                              and size of retrievedFilePath in calling function is same i.e. MAX_FULL_PATH_SIZE+1
-       //CID 358483 : Making fileName smaller causes buffer overflow in MsgCreateFileName function.
-       //                      So We will keep it 1024 as before but only copy 320 out of it which is the size of retrievedFilePath buffer.
+       /CID 317909 : replacing MSG_FILENAME_LEN_MAX with MAX_FULL_PATH_SIZE as the latter is max length for internal file path
+        * and size of retrievedFilePath in calling function is same i.e. MAX_FULL_PATH_SIZE+1
+        * CID 358483 : Making fileName smaller causes buffer overflow in MsgCreateFileName function.
+        * So We will keep it 1024 as before but only copy 320 out of it which is the size of retrievedFilePath buffer. */
        char fileName[MSG_FILENAME_LEN_MAX] = {0};
-       //char fileName[MAX_FULL_PATH_SIZE] = {0};
 
        MSG_DEBUG(":::%d :%s ", rcvdBodyLen, pRcvdBody);
 
@@ -657,19 +668,19 @@ bool MmsPluginUaManager::processReceivedData(int msgId, char *pRcvdBody, int rcv
        if (MsgCreateFileName(fileName) == false)
                return false;
 
-       //CID 317909 : replacing MSG_FILENAME_LEN_MAX with MAX_FULL_PATH_SIZE as the latter is max length for internal file path
-       //                              and size of retrievedFilePath in calling function is same i.e. MAX_FULL_PATH_SIZE+1
-       //snprintf(retrievedFilePath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_DATA_PATH, fileName);
+       /CID 317909 : replacing MSG_FILENAME_LEN_MAX with MAX_FULL_PATH_SIZE as the latter is max length for internal file path
+        * and size of retrievedFilePath in calling function is same i.e. MAX_FULL_PATH_SIZE+1
+        * snprintf(retrievedFilePath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_DATA_PATH, fileName); */
        snprintf(retrievedFilePath, MAX_FULL_PATH_SIZE, "%s%s", MSG_DATA_PATH, fileName);
 
-       MSG_INFO("retrievedFilePaths [%s]", retrievedFilePath);
+       MSG_SEC_INFO("retrievedFilePaths [%s]", retrievedFilePath);
 
-       // create temp file
+       /* create temp file */
        if (!MsgOpenCreateAndOverwriteFile(retrievedFilePath, (char *)pRcvdBody, rcvdBodyLen)) {
                MSG_ERR( "_MmsUaInitMsgDecoder: creating temporary file failed(msgID=%d)\n", msgId);
                return false;
        }
-#if 1 //
+#if 1
        MmsMsg *pMsg;
 
        MmsPluginStorage::instance()->getMmsMessage(&pMsg);
@@ -677,7 +688,7 @@ bool MmsPluginUaManager::processReceivedData(int msgId, char *pRcvdBody, int rcv
        memset(pMsg, 0, sizeof(MmsMsg));
 
        MmsPluginDecoder::instance()->decodeMmsPdu(pMsg, msgId, retrievedFilePath);
-#else //
+#else
        if (MmsReadMsgBody(msgId, true, true, retrievedFilePath) == false) {
                MSG_INFO("The MMS Message might include drm contents!!!");
 
index 6db2c2c..1753b5f 100755 (executable)
  * limitations under the License.
 */
 
-#include <mm_file.h>
-#include <mm_util_jpeg.h>
-#include <mm_util_imgp.h>
-#include <thumbnail_util.h>
-#include <image_util.h>
-
 #include <ctype.h>
 #include <errno.h>
 #include <sys/stat.h>
+#include <glib.h>
 #include "MsgUtilFile.h"
-#include "MsgMutex.h"
 #include "MmsPluginDebug.h"
 #include "MmsPluginUtil.h"
 #include <string>
 
 using namespace std;
 
-Mutex g_mx;
-CndVar g_cv;
-
-void thumbnail_completed_cb(thumbnail_util_error_e error, const char *request_id,
-                                                                       int thumb_width, int thumb_height,
-                                                                       unsigned char *thumb_data, int thumb_size, void *user_data)
-{
-       if (!user_data) {
-               MSG_DEBUG("dstPath is NULL");
-               return;
-       }
-
-       MSG_BEGIN();
-
-       g_mx.lock();
-       MSG_DEBUG("=================[RESULT]");
-       MSG_DEBUG("error_code [%d]", error);
-       MSG_DEBUG("request id [%s]", request_id);
-       MSG_DEBUG("width [%d], height [%d]", thumb_width, thumb_height);
-       MSG_DEBUG("raw_data [0x%x], size [%d]", *thumb_data, thumb_size);
-
-       int ret = 0;
-       ret = image_util_encode_jpeg(thumb_data, thumb_width, thumb_height, IMAGE_UTIL_COLORSPACE_BGRA8888, 90, (char *)user_data);;
-       if (ret != IMAGE_UTIL_ERROR_NONE)
-               MSG_DEBUG("image_util_encode_jpeg() is failed");
-
-       g_cv.signal();
-       g_mx.unlock();
-
-       MSG_END();
-}
-
-bool MmsMakeImageThumbnail(char *srcPath, char *dstPath)
-{
-       if (srcPath == NULL || dstPath == NULL) {
-               MSG_DEBUG(MMS_DEBUG_STR_INVALID_PARAM" src = %p, dst = %p", srcPath, dstPath);
-               return false;
-       }
-
-       if (MsgAccessFile(srcPath, R_OK) == false) {
-               MSG_DEBUG("not exist source file [%s]", srcPath);
-               return false;
-       }
-
-       g_mx.lock();
-
-       int time_ret = 0;
-
-       int ret = THUMBNAIL_UTIL_ERROR_NONE;
-       char *req_id = NULL;
-       thumbnail_h thumb_h;
-       thumbnail_util_create(&thumb_h);
-//     thumbnail_util_set_size(thumb_h, 240, 240);
-       thumbnail_util_set_path(thumb_h, srcPath);
-       MSG_DEBUG("thumbnail_util_extract");
-
-       ret = thumbnail_util_extract(thumb_h, thumbnail_completed_cb, dstPath, &req_id);
-       thumbnail_util_destroy(thumb_h);
-       if (req_id) {
-               g_free(req_id);
-               req_id = NULL;
-       }
-
-       if (ret != THUMBNAIL_UTIL_ERROR_NONE) {
-               MSG_DEBUG("thumbnail_util_extract is failed");
-               g_mx.unlock();
-               return false;
-       }
-
-       time_ret = g_cv.timedwait(g_mx.pMutex(), 5);
-
-       g_mx.unlock();
-
-       if (time_ret == ETIMEDOUT) {
-               MSG_INFO("@@ WAKE by timeout@@");
-               return false;
-       }
-
-       if (MsgAccessFile(dstPath, F_OK) == false) {
-               MSG_DEBUG("not exist result file [%s]", dstPath);
-               return false;
-       }
-
-       MSG_DEBUG("Make thumbnail: success [%s]", dstPath);
-       return true;
-}
-
-bool MmsMakeVideoThumbnail(char *srcPath, char *dstPath)
-{
-       MMHandleType content_attrs = (MMHandleType)NULL;
-       char *err_attr_name = NULL;
-       int fileRet = 0;
-       int trackCount = 0;
-
-       if (srcPath == NULL || dstPath == NULL) {
-               MSG_DEBUG(MMS_DEBUG_STR_INVALID_PARAM" src = %p, dst = %p", srcPath, dstPath);
-               return false;
-       }
-
-       if (MsgAccessFile(srcPath, R_OK) == false) {
-               MSG_DEBUG("not exist source file [%s]", srcPath);
-               return false;
-       }
-
-       fileRet = mm_file_create_content_attrs(&content_attrs, srcPath);
-       if (fileRet != 0) {
-               mm_file_destroy_content_attrs(content_attrs);
-               MSG_DEBUG("mm_file_create_content_attrs fail [%d]", fileRet);
-               return false;
-       }
-
-       fileRet = mm_file_get_attrs(content_attrs, &err_attr_name, MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &trackCount, NULL);
-       if (fileRet != 0) {
-               MSG_SEC_DEBUG("mm_file_get_attrs fails [%s]", err_attr_name);
-
-               if (err_attr_name) {
-                       free(err_attr_name);
-                       err_attr_name = NULL;
-               }
-
-               mm_file_destroy_content_attrs(content_attrs);
-
-               return false;
-       }
-
-       MSG_DEBUG("video track num: %d", trackCount);
-
-       if (trackCount <= 0) {
-               mm_file_destroy_content_attrs(content_attrs);
-               return false;
-       }
-
-
-       int thumbnailWidth = 0;
-       int thumbnailHeight = 0;
-       int thumbnailSize = 0;
-       void *thumbnail = NULL;
-
-       fileRet = mm_file_get_attrs(content_attrs, &err_attr_name, MM_FILE_CONTENT_VIDEO_WIDTH, &thumbnailWidth,
-                                                                                                                               MM_FILE_CONTENT_VIDEO_HEIGHT, &thumbnailHeight,
-                                                                                                                               MM_FILE_CONTENT_VIDEO_THUMBNAIL, &thumbnail, &thumbnailSize,
-                                                                                                                               NULL);
-
-       if (fileRet != 0) {
-               MSG_SEC_DEBUG("mm_file_get_attrs fails [%s]", err_attr_name);
-               if (err_attr_name) {
-                       free(err_attr_name);
-                       err_attr_name = NULL;
-               }
-
-               mm_file_destroy_content_attrs(content_attrs);
-               return false;
-       }
-
-       MSG_DEBUG("video width: %d", thumbnailWidth);
-       MSG_DEBUG("video height: %d", thumbnailHeight);
-       MSG_DEBUG("video thumbnail: %p", thumbnail);
-
-       if (thumbnail == NULL) {
-               mm_file_destroy_content_attrs(content_attrs);
-               return false;
-       }
-
-       fileRet = mm_util_jpeg_encode_to_file (dstPath, thumbnail, thumbnailWidth, thumbnailHeight, MM_UTIL_JPEG_FMT_RGB888, 70);
-       if (fileRet != 0) {
-               MSG_DEBUG("mm_util_jpeg_encode_to_file fails [%d]", fileRet);
-               mm_file_destroy_content_attrs(content_attrs);
-               return false;
-       }
-
-       if (MsgAccessFile(dstPath, F_OK) == false) {
-               MSG_DEBUG("not exist result file [%s]", dstPath);
-               mm_file_destroy_content_attrs(content_attrs);
-               return false;
-       }
-
-       MSG_DEBUG("Make thumbnail: success [%s]", dstPath);
-       mm_file_destroy_content_attrs(content_attrs);
-       return true;
-}
 
 FILE *MmsFileOpen(char *pFileName)
 {
@@ -326,7 +140,7 @@ bool MmsRemoveMarkup(const char *src, char *dst, int dstsize)
        return true;
 }
 
-//change character ' ' to '_'
+/* change character ' ' to '_' */
 bool MmsReplaceSpaceChar(char *pszText)
 {
        if (!pszText) {
@@ -365,16 +179,16 @@ char *MmsReplaceNonAsciiUtf8(const char *szSrc, char replaceChar)
 
        ptr = (const unsigned char*)szSrc;
 
-       while(offset < srcLen && *(ptr) != '\0') {
+       while (offset < srcLen && *(ptr) != '\0') {
 
                b1 = *(ptr);
 
-               if ((b1 & 0x80) == 0) { //1byte : 0xxx xxxx
+               if ((b1 & 0x80) == 0) { /* 1byte : 0xxx xxxx */
                        offset += 1;
                        ptr += 1;
 
                        str += b1;
-               } else  if ((b1 & 0xE0) == 0xC0) { //2byte : 110x xxxx
+               } else if ((b1 & 0xE0) == 0xC0) { /* 2byte : 110x xxxx */
                        offset += 2;
 
                        if (offset > srcLen)
@@ -382,14 +196,14 @@ char *MmsReplaceNonAsciiUtf8(const char *szSrc, char replaceChar)
 
                        b2 = *(ptr + 1);
 
-                       if (b2 >= 0x80) { //10xx xxxx
+                       if (b2 >= 0x80) { /* 10xx xxxx */
                                ptr += 2;
                                str += replaceChar;
                        } else {
                                return NULL;
                        }
 
-               } else  if ((b1 & 0xF0) == 0xE0) { //3byte : 1110 xxxx
+               } else if ((b1 & 0xF0) == 0xE0) { /* 3byte : 1110 xxxx */
 
                        offset += 3;
 
@@ -399,14 +213,14 @@ char *MmsReplaceNonAsciiUtf8(const char *szSrc, char replaceChar)
                        b2 = *(ptr + 1);
                        b3 = *(ptr + 2);
 
-                       if (b2 >= 0x80 && b3 >= 0x80) { //10xx xxxx
+                       if (b2 >= 0x80 && b3 >= 0x80) { /* 10xx xxxx */
                                ptr += 3;
                                str += replaceChar;
                        } else {
                                return NULL;
                        }
 
-               } else  if ((b1 & 0xF8) == 0xF0) { //4byte : 1111 xxxx
+               } else if ((b1 & 0xF8) == 0xF0) { /* 4byte : 1111 xxxx */
 
                        offset += 4;
 
@@ -417,7 +231,7 @@ char *MmsReplaceNonAsciiUtf8(const char *szSrc, char replaceChar)
                        b3 = *(ptr + 2);
                        b4 = *(ptr + 3);
 
-                       if (b2 >= 0x80 && b3 >= 0x80 && b4 >= 0x80) { //10xx xxxx
+                       if (b2 >= 0x80 && b3 >= 0x80 && b4 >= 0x80) { /* 10xx xxxx */
                                ptr += 4;
                                str += replaceChar;
 
@@ -458,14 +272,14 @@ bool MmsIsUtf8String(const unsigned char *szSrc, int nChar)
 
        ptr = (const unsigned char*)szSrc;
 
-       while(offset < srcLen && *(ptr) != '\0') {
+       while (offset < srcLen && *(ptr) != '\0') {
 
                b1 = *(ptr);
 
-               if ((b1 & 0x80) == 0) { //1byte : 0xxx xxxx
+               if ((b1 & 0x80) == 0) { /* 1byte : 0xxx xxxx */
                        offset += 1;
                        ptr += 1;
-               } else  if ((b1 & 0xE0) == 0xC0) { //2byte : 110x xxxx
+               } else if ((b1 & 0xE0) == 0xC0) { /* 2byte : 110x xxxx */
                        offset += 2;
 
                        if (offset > srcLen)
@@ -473,13 +287,13 @@ bool MmsIsUtf8String(const unsigned char *szSrc, int nChar)
 
                        b2 = *(ptr + 1);
 
-                       if (b2 >= 0x80) { //10xx xxxx
+                       if (b2 >= 0x80) { /* 10xx xxxx */
                                ptr += 2;
                        } else {
                                return false;
                        }
 
-               } else  if ((b1 & 0xF0) == 0xE0) { //3byte : 1110 xxxx
+               } else if ((b1 & 0xF0) == 0xE0) { /* 3byte : 1110 xxxx */
 
                        offset += 3;
 
@@ -489,13 +303,13 @@ bool MmsIsUtf8String(const unsigned char *szSrc, int nChar)
                        b2 = *(ptr + 1);
                        b3 = *(ptr + 2);
 
-                       if (b2 >= 0x80 && b3 >= 0x80) { //10xx xxxx
+                       if (b2 >= 0x80 && b3 >= 0x80) { /* 10xx xxxx */
                                ptr += 3;
                        } else {
                                return false;
                        }
 
-               } else  if ((b1 & 0xF8) == 0xF0) { //4byte : 1111 xxxx
+               } else if ((b1 & 0xF8) == 0xF0) { /* 4byte : 1111 xxxx */
 
                        offset += 4;
 
@@ -506,7 +320,7 @@ bool MmsIsUtf8String(const unsigned char *szSrc, int nChar)
                        b3 = *(ptr + 2);
                        b4 = *(ptr + 3);
 
-                       if (b2 >= 0x80 && b3 >= 0x80 && b4 >= 0x80) { //10xx xxxx
+                       if (b2 >= 0x80 && b3 >= 0x80 && b4 >= 0x80) { /* 10xx xxxx */
                                ptr += 4;
                        } else {
                                return false;
@@ -514,7 +328,7 @@ bool MmsIsUtf8String(const unsigned char *szSrc, int nChar)
                } else {
                        return false;
                }
-       }//while
+       } /* while */
 
        return true;
 }
index f1e2c28..0dc81ea 100755 (executable)
@@ -19,7 +19,7 @@
 
 #include "MmsPluginTypes.h"
 
-//Set Data for Message App
+/* Set Data for Message App */
 class MmsPluginAppBase {
 public:
        MmsPluginAppBase();
@@ -36,4 +36,4 @@ public:
 private:
        MMS_MESSAGE_DATA_S mmsMsgData;
 };
-#endif //MMS_PLUGIN_APPBASE_H
+#endif /* MMS_PLUGIN_APPBASE_H */
index 0633099..aca21fe 100755 (executable)
@@ -22,4 +22,4 @@
 #include "MmsPluginEncode.h"
 #include "MmsPluginDecode.h"
 
-#endif //MMS_PLUGIN_CODEC_H
+#endif /* MMS_PLUGIN_CODEC_H */
index 4b5006b..335682e 100755 (executable)
@@ -114,7 +114,7 @@ enum {
        MSG_FIELD_MIME_VERSION,
        MSG_FIELD_CONTENT_TYPE,
        MSG_FIELD_CONTENT_TRANSFER_ENCODING,
-       MSG_FIELD_CONTENT_DISPOSITION, //If start param is given in multipart/related, this field will be ignored
+       MSG_FIELD_CONTENT_DISPOSITION, /* If start param is given in multipart/related, this field will be ignored */
        MSG_FIELD_CONTENT_ID,
        MSG_FIELD_CONTENT_LOCATION,
        MSG_FIELD_CONTENT_NAME,
@@ -140,11 +140,11 @@ enum {
        MSG_PARAM_CHARSET,
        MSG_PARAM_NAME,
        MSG_PARAM_FILENAME,
-       MSG_PARAM_TYPE,                 // only used as parameter of Content-Type: multipart/related
-       MSG_PARAM_START,                // Only if content-type is multipart/related
-       MSG_PARAM_START_INFO,   // Only if content-type is multipart/related
+       MSG_PARAM_TYPE,                 /* only used as parameter of Content-Type: multipart/related */
+       MSG_PARAM_START,                /* Only if content-type is multipart/related */
+       MSG_PARAM_START_INFO,   /* Only if content-type is multipart/related */
        MSG_PARAM_BOUNDARY,
-       MSG_PARAM_REPORT_TYPE,  // only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
+       MSG_PARAM_REPORT_TYPE,  /* only used as parameter of Content-Type: multipart/report; report-type=delivery-status; */
 #ifdef FEATURE_JAVA_MMS
        MSG_PARAM_APPLICATION_ID,
        MSG_PARAM_REPLY_TO_APPLICATION_ID,
@@ -194,4 +194,4 @@ bool MmsIsVitemContent(int type, char *pszName);
 
 MsgMultipart *MmsAllocMultipart(void);
 bool MmsPrintMulitpart(MsgMultipart *pMultipart, int index);
-#endif //MMS_PLUGIN_CODEC_COMMON_H
+#endif /* MMS_PLUGIN_CODEC_COMMON_H */
index 0be998b..569b356 100755 (executable)
 #define        MSG_MMS_DECODE_BUFFER_MAX       (2 * 1024)
 #define        MSB                                                             0x80
 #define        QUOTE                                                   0x7F
-#define        MARK                                                    0x22    // "
+#define        MARK                                                    0x22    /* " */
 #define        LENGTH_QUOTE                                    0x1F
 #define        MSG_STDSTR_LONG                         0xFF
 #define        INVALID_VALUE                                   -1
 
 #define        MMS_CONTENT_ID_LEN                              100
+#define        MMS_LOCATION_URL_LEN                    1024
+
 #define        MSG_DATE_LEN                                            50
 #define        MSG_SUBJ_LEN                                            40
 #define        MSG_LOCALE_SUBJ_LEN                             (3 * MSG_SUBJ_LEN)
@@ -125,16 +127,16 @@ enum {
        MMS_BODYHDR_DISPOSITION,
        MMS_BODYHDR_CONTENTID,
        MMS_BODYHDR_CONTENTLOCATION,
-       MMS_BODYHDR_X_OMA_DRM_SEPARATE_DELIVERY,        // DRM RO WAITING
+       MMS_BODYHDR_X_OMA_DRM_SEPARATE_DELIVERY,        /* DRM RO WAITING */
 };
 
 typedef enum {
-       //code
+       /* code */
        MmsCodeFieldCode,
        MmsCodeParameterCode,
        MmsCodeMsgBodyHeaderCode,
 
-       //Data
+       /* Data */
        MmsCodeMsgType,
        MmsCodeDeliveryReport,
        MmsCodeTimeType,
@@ -168,12 +170,12 @@ typedef enum {
        MMS_DATATYPE_RETRIEVING = 7,
        MMS_DATATYPE_UNRETV = 8,
        MMS_DATATYPE_TEMPLATE = 9,
-       MMS_DATATYPE_DRM_RO_WAITING = 10        // DRM RO WAITING
+       MMS_DATATYPE_DRM_RO_WAITING = 10        /* DRM RO WAITING */
 } MmsDataType;
 
 typedef enum {
-       MMS_MSGTYPE_ERROR = -1, // error return in Get method
-       MMS_MSGTYPE_SEND_REQ = 0,       // default
+       MMS_MSGTYPE_ERROR = -1, /* error return in Get method */
+       MMS_MSGTYPE_SEND_REQ = 0,       /* default */
        MMS_MSGTYPE_SEND_CONF = 1,
        MMS_MSGTYPE_NOTIFICATION_IND = 2,
        MMS_MSGTYPE_NOTIFYRESP_IND = 3,
@@ -184,31 +186,31 @@ typedef enum {
        MMS_MSGTYPE_READORG_IND = 8,
        MMS_MSGTYPE_FORWARD_REQ = 9,
        MMS_MSGTYPE_FORWARD_CONF = 10,
-       MMS_MSGTYPE_READ_REPLY = 11,    // for internal use
+       MMS_MSGTYPE_READ_REPLY = 11,    /* for internal use */
        MMS_MSGTYPE_MAX
 } MmsMsgType;
 
 typedef enum {
-       MMS_PRIORITY_ERROR = -1,                        // error return in Get method
-       MMS_PRIORITY_LOW = 0,                   // default
+       MMS_PRIORITY_ERROR = -1,                        /* error return in Get method */
+       MMS_PRIORITY_LOW = 0,                   /* default */
        MMS_PRIORITY_NORMAL = 1,
        MMS_PRIORITY_HIGH = 2
 } MmsPriority;
 
 typedef enum {
-       MMS_SENDER_VISIBLE_ERROR = -1,  // error return in Get method
+       MMS_SENDER_VISIBLE_ERROR = -1,  /* error return in Get method */
        MMS_SENDER_SHOW = 0,
        MMS_SENDER_HIDE = 1
 } MmsSenderVisible;
 
 typedef enum {
-       MMS_REPORT_ERROR = -1,  // error return in Get method
+       MMS_REPORT_ERROR = -1,  /* error return in Get method */
        MMS_REPORT_YES = 0,
        MMS_REPORT_NO = 1
 } MmsReport;
 
 typedef enum {
-       MMS_REPORTALLOWED_ERROR = -1,   // error return in Get method
+       MMS_REPORTALLOWED_ERROR = -1,   /* error return in Get method */
        MMS_REPORTALLOWED_YES = 0,
        MMS_REPORTALLOWED_NO = 1
 } MmsReportAllowed;
@@ -220,22 +222,22 @@ typedef enum {
 } MmsRecvReadReportType ;
 
 typedef enum {
-       MMS_MSGSTATUS_NONE = -1,        // backward compatibility
-       MMS_MSGSTATUS_ERROR = -1,       // error return in Get method
-       MMS_MSGSTATUS_EXPIRED = 0,      // This value SHOULD not be used in the M-NotifyResp.ind PDU.
+       MMS_MSGSTATUS_NONE = -1,        /* backward compatibility */
+       MMS_MSGSTATUS_ERROR = -1,       /* error return in Get method */
+       MMS_MSGSTATUS_EXPIRED = 0,      /* This value SHOULD not be used in the M-NotifyResp.ind PDU. */
        MMS_MSGSTATUS_RETRIEVED = 1,
        MMS_MSGSTATUS_REJECTED = 2,
        MMS_MSGSTATUS_DEFERRED = 3,
-       MMS_MSGSTATUS_UNRECOGNISED = 4, // This value SHALL not be used in the M-Delivery.ind PDU.
+       MMS_MSGSTATUS_UNRECOGNISED = 4, /* This value SHALL not be used in the M-Delivery.ind PDU. */
        MMS_MSGSTATUS_INDETERMINATE = 5,
        MMS_MSGSTATUS_FORWARDED = 6,
        MMS_MSGSTATUS_UNREACHABLE = 7
 } MmsMsgStatus;
 
 typedef enum {
-       MMS_READSTATUS_NONE = -1,                       // no touch status
+       MMS_READSTATUS_NONE = -1,                       /* no touch status */
        MMS_IS_READ = 0,
-       MMS_IS_DELETED = 1      // Deleted without being read
+       MMS_IS_DELETED = 1      /* Deleted without being read */
 } MmsReadStatus;
 
 typedef enum {
@@ -251,8 +253,8 @@ typedef enum {
 
 /* Response status */
 typedef enum {
-       MMS_RESPSTATUS_ERROR = -1,      // error return in Get method
-       MMS_RESPSTATUS_OK = 0,  // default value
+       MMS_RESPSTATUS_ERROR = -1,      /* error return in Get method */
+       MMS_RESPSTATUS_OK = 0,  /* default value */
        MMS_RESPSTAUTS_ERROR_UNSPECIFIED = 1,
        MMS_RESPSTAUTS_ERROR_SERVICEDENIED = 2,
        MMS_RESPSTAUTS_ERROR_MESSAGEFORMATCORRUPT = 3,
@@ -280,7 +282,7 @@ typedef enum {
 } MmsResponseStatus;
 
 typedef enum {
-       MMS_RETRSTATUS_ERROR = -1,      // error return in Get method
+       MMS_RETRSTATUS_ERROR = -1,      /* error return in Get method */
        MMS_RETRSTATUS_OK = 0,
        MMS_RETRSTATUS_TRANSIENT_FAILURE = 1,
        MMS_RETRSTATUS_TRANSIENT_MESSAGE_NOT_FOUND = 2,
@@ -292,7 +294,7 @@ typedef enum {
 } MmsRetrieveStatus;
 
 typedef enum {
-       MMS_REPLY_NONE = -1,    // error return in Get method
+       MMS_REPLY_NONE = -1,    /* error return in Get method */
        MMS_REPLY_REQUESTED = 0,
        MMS_REPLY_REQUESTED_TEXT_ONLY = 1,
        MMS_REPLY_ACCEPTED = 2,
@@ -300,8 +302,8 @@ typedef enum {
 } MmsReplyChargeType;
 
 typedef enum {
-       MMS_MSGCLASS_ERROR = -1,        // error return in Get method
-       MMS_MSGCLASS_PERSONAL = 0,      // default
+       MMS_MSGCLASS_ERROR = -1,        /* error return in Get method */
+       MMS_MSGCLASS_PERSONAL = 0,      /* default */
        MMS_MSGCLASS_ADVERTISEMENT = 1,
        MMS_MSGCLASS_INFORMATIONAL = 2,
        MMS_MSGCLASS_AUTO = 3
@@ -340,7 +342,7 @@ typedef struct _MMS_ATTRIB_S {
        UINT32 date;
        UINT8 version;
 
-       char szFrom[MSG_LOCALE_ADDR_LEN + 11];          //"/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6"
+       char szFrom[MSG_LOCALE_ADDR_LEN + 11];          /* "/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6" */
        char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
        char *szTo;
        char *szCc;
@@ -356,7 +358,7 @@ typedef struct _MMS_ATTRIB_S {
        MmsRecvReadReportType readReportAllowedType;
 
        bool bAskReadReply;
-       bool bRead;//FIXME : remove this value
+       bool bRead; /* FIXME : remove this value */
 
        MmsRecvReadReportSendStatus readReportSendStatus;
 
@@ -369,7 +371,7 @@ typedef struct _MMS_ATTRIB_S {
        MmsTimeStruct expiryTime;
        MmsTimeStruct deliveryTime;
 
-       //for ReadMsg, When Sending notifyResp.ind
+       /* for ReadMsg, When Sending notifyResp.ind */
        msg_delivery_report_status_t msgStatus;
 
        MmsResponseStatus responseStatus;
@@ -397,7 +399,7 @@ typedef struct _MsgContentParam {
        char szStart[MSG_MSG_ID_LEN + 1];
        char szStartInfo[MSG_MSG_ID_LEN + 1];
 
-       MsgParamReportType reportType; //only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
+       MsgParamReportType reportType; /* only used as parameter of Content-Type: multipart/report; report-type=delivery-status; */
 } MsgContentParam;
 
 typedef struct _MsgDRMInfo {
@@ -409,7 +411,7 @@ typedef struct _MsgDRMInfo {
        char *szContentVendor;
        char *szRightIssuer;
        char *szDrm2FullPath;
-       int roWaitingTimerMax;          // DRM RO WAITING
+       int roWaitingTimerMax;          /* DRM RO WAITING */
        bool bFwdLock;
        char *pszContentType;
        bool bNoRingTone;
@@ -429,6 +431,7 @@ typedef struct _MsgType {
        int disposition;
        char szContentID[MSG_MSG_ID_LEN + 1];
        char szContentLocation[MSG_MSG_ID_LEN + 1];
+       char szLocation[MSG_MSG_ID_LEN + 1];
        char szOrgFilePath[MSG_FILEPATH_LEN_MAX + 1];
 
        MsgContentParam param;
@@ -456,7 +459,7 @@ struct _MsgMultipart {
 typedef struct _MMS_MESSAGE_S {
        MmsAttrib mmsAttrib;
        msg_message_id_t msgID;
-       int mailbox;            // mailbox type,MMS_MAILBOX_XXX
+       int mailbox;            /* mailbox type,MMS_MAILBOX_XXX */
        char szFileName[MSG_FILENAME_LEN_MAX];
        char szTrID[MMS_TR_ID_LEN + 1];
        char szMsgID[MMS_MSG_ID_LEN + 1];
@@ -467,4 +470,4 @@ typedef struct _MMS_MESSAGE_S {
        MsgBody msgBody;
 } MmsMsg;
 
-#endif //MMS_PLUGIN_CODEC_TYPE_H
+#endif /* MMS_PLUGIN_CODEC_TYPE_H */
index c354d28..f82ed7e 100755 (executable)
@@ -20,7 +20,7 @@
 #include "MmsPluginTypes.h"
 #include "MmsPluginCodec.h"
 
-//make MMS_DATA_S for DB & Encoding
+/* make MMS_DATA_S for DB & Encoding */
 class MmsPluginComposer {
 public:
        static MmsPluginComposer *instance();
@@ -43,4 +43,4 @@ private:
        ~MmsPluginComposer();
 
 };
-#endif //MMS_PLUGIN_COMPOSER_H
+#endif /* MMS_PLUGIN_COMPOSER_H */
index f8402d1..a6e66b0 100755 (executable)
@@ -25,8 +25,7 @@ typedef enum {
        MSG_CM_ERR_UNKNOWN,
  } cm_error_e;
 
-class MmsPluginCmAgent
-{
+class MmsPluginCmAgent {
 public:
        static MmsPluginCmAgent *instance();
 
@@ -41,6 +40,8 @@ public:
        bool getInterfaceName(const char **deviceName);
        bool getProxyAddr(const char **proxyAddr);
        bool getHomeUrl(const char **homeURL);
+       bool getDnsAddrList(const char **dnsAddrList);
+
 private:
        MmsPluginCmAgent();
        ~MmsPluginCmAgent();
@@ -54,14 +55,15 @@ private:
        void setCmStatus() { isCmOpened = true; }
        void resetCmStatus() { isCmOpened = false; }
 
-       bool isCmOpened; //connection & profile connect
+       bool isCmOpened; /* connection & profile connect */
        bool waitProfileOpen;
        char *home_url;
        char *interface_name;
        char *proxy_address;
+       char *dns_address_list;
        Mutex mx;
        CndVar cv;
 
 };
 
-#endif //MMS_PLUGIN_CONNMAN_H
+#endif /* MMS_PLUGIN_CONNMAN_H */
index d77485e..da0518d 100755 (executable)
@@ -25,4 +25,4 @@
 #define MMS_DEBUG_STR_FILE_NOT_EXIST "File not exist"
 
 
-#endif //MMS_PLUGIN_DEBUG_H
+#endif /* MMS_PLUGIN_DEBUG_H */
index ddd3b3e..e85057e 100755 (executable)
@@ -26,10 +26,10 @@ typedef int MmsMsgID;
 
 typedef enum {
        MSG_PRESENTATION_NONE = -1,
-       MSG_PRESENTATION_FIRSTPART,             //Content-type == type parameter
-       MSG_PRESENTATION_TYPE_BASE,             //Content-type == type parameter
-       MSG_PRESENTATION_LOCATION,              //Content-Location == start parameter
-       MSG_PRESENTATION_ID,                    //Content-ID == start parameter
+       MSG_PRESENTATION_FIRSTPART,             /* Content-type == type parameter */
+       MSG_PRESENTATION_TYPE_BASE,             /* Content-type == type parameter */
+       MSG_PRESENTATION_LOCATION,              /* Content-Location == start parameter */
+       MSG_PRESENTATION_ID,                    /* Content-ID == start parameter */
 } MsgPresentationFactor;
 
 typedef struct {
@@ -43,14 +43,14 @@ struct _MsgHeaderAddress {
        MsgHeaderAddress *pNext;
 };
 
-// for Decoding & Encoding
+/* for Decoding & Encoding */
 typedef struct {
        MmsMsgType type;
        char szTrID[MMS_TR_ID_LEN+1];
        UINT8 version;
        UINT32 date;
 
-       MsgHeaderAddress *pFrom;                //"/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6"
+       MsgHeaderAddress *pFrom;                /* "/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6" */
        MsgHeaderAddress *pTo;
        MsgHeaderAddress *pCc;
        MsgHeaderAddress *pBcc;
@@ -75,13 +75,13 @@ typedef struct {
 
        MmsReplyCharge replyCharge;
 
-       // only used at Decoding module
+       /* only used at Decoding module */
        char szMsgID[MMS_MSG_ID_LEN + 1];
        UINT32 msgSize;
 
        MsgDrmType drmType;
 
-       // dependent to Client implementation
+       /* dependent to Client implementation */
        MsgType msgType;
        MsgBody msgBody;
 } MmsHeader;
@@ -120,4 +120,4 @@ private:
        ~MmsPluginDecoder();
 
 };
-#endif //MMS_PLUGIN_DECODE_H
+#endif /* MMS_PLUGIN_DECODE_H */
index f40112b..fff050c 100755 (executable)
@@ -21,4 +21,4 @@
 
 bool MmsPluginDrmGetInfo(const char *szFilePath, MsgType *pMsgType);
 
-#endif //MMS_PLUGIN_DRM_H
+#endif /* MMS_PLUGIN_DRM_H */
index 235b45b..3a7ee31 100755 (executable)
@@ -47,4 +47,4 @@ private:
        ~MmsPluginEncoder();
 
 };
-#endif //MMS_PLUGIN_ENCODE_H
+#endif /* MMS_PLUGIN_ENCODE_H */
index 2aa676b..0421770 100755 (executable)
@@ -19,9 +19,9 @@
 
 #include "MsgPluginInterface.h"
 #include "MmsPluginTypes.h"
+#include <tapi_common.h>
 
-class MmsPluginEventHandler
-{
+class MmsPluginEventHandler {
 public:
        static MmsPluginEventHandler *instance();
 
@@ -32,10 +32,13 @@ public:
 private:
        MmsPluginEventHandler();
        virtual ~MmsPluginEventHandler();
+       int initTelHandle();
+       void deinitTelHandle();
+       TapiHandle *getTelHandle(int sim_idx);
 
        static MmsPluginEventHandler *pInstance;
 
        MSG_PLUGIN_LISTENER_S listener;
 };
 
-#endif //MMS_PLUGIN_EVENT_HANDLER_H
+#endif /* MMS_PLUGIN_EVENT_HANDLER_H */
index 2292337..239ff85 100755 (executable)
@@ -23,7 +23,7 @@
 
 #define MSG_MMS_HH_CONTENT_TYPE     "application/vnd.wap.mms-message"
 #define MSG_MMS_HH_ACCEPT           "application/vnd.wap.mms-message, */*"
-#define MSG_MMS_HH_CHARSET          "utf-8"
+#define MSG_MMS_HH_CHARSET          "utf-8, us-ascii"
 #define MSG_MMS_HH_LANGUAGE         "zh-cn, en"
 #define MSG_MMS_HH_ENCODING         "deflate,gzip"
 
@@ -63,6 +63,7 @@ typedef struct _http_session_info_s {
        MMS_HTTP_TRANSACTION_TYPE_E transaction_type;
        const char *url;
        const char *proxy;
+       const char *dns_list;
        const char *interface;
        const char *post_data;
        unsigned int post_data_len;
@@ -70,8 +71,7 @@ typedef struct _http_session_info_s {
        unsigned int response_data_len;
 } http_request_info_s;
 
-class MmsPluginHttpAgent
-{
+class MmsPluginHttpAgent {
        public:
                static MmsPluginHttpAgent *instance();
 
@@ -113,4 +113,4 @@ class MmsPluginHttpAgent
                Mutex mx;
 };
 
-#endif //MMS_PLUGIN_HTTP_H
+#endif /* MMS_PLUGIN_HTTP_H */
index 53550f3..8bed1c4 100755 (executable)
@@ -20,8 +20,7 @@
 #include "MmsPluginTypes.h"
 #include "MmsPluginCodecTypes.h"
 
-class MmsPluginInternal
-{
+class MmsPluginInternal {
        public:
                static MmsPluginInternal *instance();
 
@@ -48,4 +47,4 @@ class MmsPluginInternal
                const char *getMmsReadStatus(msg_read_report_status_t readStatus);
 };
 
-#endif //MMS_PLUGIN_INTERNAL_H
+#endif /* MMS_PLUGIN_INTERNAL_H */
index 527dff8..3deac7c 100755 (executable)
@@ -54,5 +54,5 @@ msg_error_t MmsDeleteMessage(msg_message_id_t msgId);
 }
 #endif
 
-#endif //MMS_PLUGIN_MAIN_H
+#endif /* MMS_PLUGIN_MAIN_H */
 
index a12ad04..06501fe 100755 (executable)
 void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID);
 
 void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, msg_message_id_t selectedMsgId);
+/*
+int MmsUpdatePreviewData(MSG_MESSAGE_INFO_S *pMsgInfo);
 
-//int MmsUpdatePreviewData(MSG_MESSAGE_INFO_S *pMsgInfo);
-//
-//int MmsUpdateMultipartList(MSG_MESSAGE_INFO_S *pMsgInfo);
+int MmsUpdateMultipartList(MSG_MESSAGE_INFO_S *pMsgInfo);
 
-//void MmsPrintFileInfoForVLD(MMS_MESSAGE_DATA_S *pMmsMsg);
-//
-//bool MmsChangeFileNameToAscii(MMS_MESSAGE_DATA_S *pMsgData);
+void MmsPrintFileInfoForVLD(MMS_MESSAGE_DATA_S *pMmsMsg);
 
+bool MmsChangeFileNameToAscii(MMS_MESSAGE_DATA_S *pMsgData);
+*/
 bool MmsConvertMsgData(MmsMsg *pMsg, MMS_MESSAGE_DATA_S *pMmsMsg);
 
-bool MmsConvertMmsData(MmsMsg *pMsg, MMS_DATA_S *pMmsData);//temp func for supporting new mmsdata
+bool MmsConvertMmsData(MmsMsg *pMsg, MMS_DATA_S *pMmsData); /* temp func for supporting new mmsdata */
 
 bool MmsConvertMmsMsg(MmsMsg *pMmsMsg, MMS_DATA_S *pMsgData);
 
 msg_error_t MmsMakeMultipartThumbnailInfo(MMS_MULTIPART_DATA_S *pMultipart, char *thumbnail_path);
 
-#endif //MMS_PLUGIN_MESSAGE_H
+#endif /* MMS_PLUGIN_MESSAGE_H */
index 8086d2f..c260c47 100755 (executable)
 #include "MsgSqliteWrapper.h"
 #include "MmsPluginCodecTypes.h"
 
-class MmsPluginStorage
-{
+class MmsPluginStorage {
 public:
        static MmsPluginStorage *instance();
 
        MmsPluginStorage();
        ~MmsPluginStorage();
 
-       //MMS message operation
+       /* MMS message operation */
        msg_error_t addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pSerializedMms);
        msg_error_t getMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char **pSerializedMms);
        msg_error_t updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pSerializedMms);
-       msg_error_t updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo);//malware allowed
+       msg_error_t updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo); /* malware allowed */
 
        msg_error_t deleteMmsMessage(int msgId);
 
-       //MMS message preview info
+       /* MMS message preview info */
        msg_error_t insertPreviewInfo(int msgId, int type, const char *value, int count = 0);
        msg_error_t removePreviewInfo(int msgId);
 
-       //MMS message multipart list
+       /* MMS message multipart list */
        msg_error_t insertMultipart(msg_message_id_t msgId, MMS_MULTIPART_DATA_S *pMultipart);
        msg_error_t updateMultipart(msg_message_id_t msgId, int allow_malware, MMS_MULTIPART_DATA_S *pMultipart);
        msg_error_t getMultipartList(msg_message_id_t msgId, MMSList **multipart_list);
        msg_error_t deleteMultipartList(int msgId);
 
-       //MMS message report
+       /* MMS message report */
        msg_error_t insertDeliveryReport(msg_message_id_t msgId, char *address, MmsMsgMultiStatus *pStatus);
        msg_error_t insertReadReport(msg_message_id_t msgId, char *address, MmsMsgMultiStatus *pStatus);
 
-       //etc
+       /* etc */
        void getMmsMessage(MmsMsg **pMmsMsg);
        msg_error_t getMmsMessageId(msg_message_id_t selectedMsgId, MmsMsg *pMmsMsg);
        void composeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo);
@@ -87,5 +86,5 @@ private:
        MmsMsg mmsMsg;
 };
 
-#endif //MMS_PLUGIN_STORAGE_H
+#endif /* MMS_PLUGIN_STORAGE_H */
 
diff --git a/plugin/mms_plugin/include/MmsPluginTcs.h b/plugin/mms_plugin/include/MmsPluginTcs.h
deleted file mode 100755 (executable)
index 449a000..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef MMS_PLUGIN_TCS_H
-#define MMS_PLUGIN_TCS_H
-
-//Scan content on file system.
-int MmsPluginTcsScanFile(const char *filepath, int *bLevel);
-
-#endif //MMS_PLUGIN_TCS_H
index 50cf1d0..2da1f63 100755 (executable)
@@ -21,4 +21,4 @@ const char *MmsPluginTextConvertGetCharSet(int MIBEnum);
 
 bool MmsPluginTextConvert(const char *pToCodeSet, const char *pFromCodeSet, const char *pSrc, int srcLen, char **ppDest, int *pDestLen);
 
-#endif //MMS_PLUGIN_TEXT_CONVERT_H
+#endif /* MMS_PLUGIN_TEXT_CONVERT_H */
index 28cc34e..d3b2f1c 100755 (executable)
@@ -19,8 +19,7 @@
 
 #include "MmsPluginTypes.h"
 
-class MmsPluginTransport
-{
+class MmsPluginTransport {
        public:
                static MmsPluginTransport *instance();
 
@@ -34,4 +33,4 @@ class MmsPluginTransport
                static MmsPluginTransport *pInstance;
 };
 
-#endif //MMS_PLUGIN_TRANSPORT_H
+#endif /* MMS_PLUGIN_TRANSPORT_H */
index 8cafe1a..9b9bf05 100755 (executable)
@@ -37,23 +37,24 @@ enum _MMS_NET_ERROR_E {
        eMMS_CM_OPEN_FAILED,
        eMMS_CM_CLOSE_IND,
        eMMS_CM_CLOSE_RSP,
-       eMMS_CM_CLOSE_FAILED,   //5
+       eMMS_CM_CLOSE_FAILED,   /* 5 */
        eMMS_CM_KILL_RSP,
        eMMS_CM_KILL_FAILED,
+       eMMS_CM_DISCONNECTED,
 
        eMMS_HTTP_SESSION_INIT,
        eMMS_HTTP_SESSION_CLOSED,
-       eMMS_HTTP_SESSION_OPEN_FAILED, //10
+       eMMS_HTTP_SESSION_OPEN_FAILED, /* 11 */
        eMMS_HTTP_SENT_SUCCESS,
        eMMS_HTTP_CONF_SUCCESS,
        eMMS_HTTP_ERROR_NETWORK,
        eMMS_HTTP_CONF_RECEIVED_TIMEOUT,
-       eMMS_HTTP_RECV_DATA,    //15
+       eMMS_HTTP_RECV_DATA,    /* 16 */
        eMMS_HTTP_EVENT_RECV_DATA_PROGRESS,
        eMMS_HTTP_EVENT_RECV_DATA_ERROR,
        eMMS_HTTP_EVENT_SENT_ACK_COMPLETED,
        eMMS_HTTP_ERROR_UNKNOWN,
-       eMMS_EXCEPTIONAL_ERROR, //20
+       eMMS_EXCEPTIONAL_ERROR, /* 21 */
 
        eMMS_UNKNOWN
 };
@@ -69,7 +70,7 @@ enum _MMS_PDU_TYPE_E {
        eMMS_READREC_IND,
        eMMS_READORIG_IND,
        eMMS_READREPORT_REQ,
-       eMMS_READREPORT_CONF,   //10
+       eMMS_READREPORT_CONF,   /* 10 */
        eMMS_FORWARD_REQ,
        eMMS_FORWARD_CONF,
        eMMS_RETRIEVE_AUTO,
@@ -79,7 +80,7 @@ enum _MMS_PDU_TYPE_E {
        eMMS_CANCEL_CONF,
        eMMS_DELETE_REQ,
        eMMS_DELETE_CONF,
-       eMMS_MBOX_STORE_REQ,    // 20
+       eMMS_MBOX_STORE_REQ,    /* 20 */
        eMMS_MBOX_STORE_CONF,
        eMMS_MBOX_VIEW_REQ,
        eMMS_MBOX_VIEW_CONF,
@@ -112,14 +113,15 @@ typedef struct _mmsTranQEntity {
        MMS_PDU_TYPE_T eMmsPduType;
        MMS_HTTP_CMD_TYPE_T eHttpCmdType;
 
-       MMS_PDU_TYPE_T eMmsTransactionStatus;
+       MMS_NET_ERROR_T eMmsTransactionStatus;
 
        int postDataLen;
        char *pPostData;
 
        int getDataLen;
        char *pGetData;
+       char url[MMS_LOCATION_LEN+1];
 } mmsTranQEntity;
 
-#endif //MMS_PLUGIN_TYPES_H
+#endif /* MMS_PLUGIN_TYPES_H */
 
index 3df0340..8368d4a 100755 (executable)
@@ -22,8 +22,7 @@
 #include "MsgQueue.h"
 #include "MmsPluginTypes.h"
 
-class MmsPluginUaManager: public MsgThread
-{
+class MmsPluginUaManager: public MsgThread {
        public:
                static MmsPluginUaManager *instance();
                virtual void start();
@@ -50,10 +49,10 @@ class MmsPluginUaManager: public MsgThread
                MMS_NET_ERROR_T submitHandler(mmsTranQEntity *qEntity);
                MMS_NET_ERROR_T waitingConf(mmsTranQEntity *qEntity);
 
-               // condition values
-               bool running;           // flag for thread running
+               /* condition values */
+               bool running;           /* flag for thread running */
 
-               MsgSimpleQ<mmsTranQEntity> mmsTranQ; // transaction q for mms plugin
+               MsgSimpleQ<mmsTranQEntity> mmsTranQ; /* transaction q for mms plugin */
 };
 
-#endif //MMS_PLUGIN_USERAGENT_H
+#endif /* MMS_PLUGIN_USERAGENT_H */
index 1e08034..7b9068c 100755 (executable)
 
 #include <stdio.h>
 
-//File Util
-bool MmsMakeImageThumbnail(char *srcPath, char *dstPath);
-
-bool MmsMakeVideoThumbnail(char *srcPath, char *dstPath);
-
+/* File Util */
 FILE *MmsFileOpen(char *pFileName);
 
-//Text Util
+/* Text Util */
 bool MmsIsAsciiString(const char *szSrc);
 
 bool MmsIsUtf8String(const unsigned char *szSrc, int nChar);
@@ -39,4 +35,4 @@ bool MmsReplaceSpaceChar(char *pszText);
 
 char *MmsReplaceNonAsciiUtf8(const char *szSrc, char replaceChar);
 
-#endif //MMS_PLUGIN_UTIL_H
+#endif /* MMS_PLUGIN_UTIL_H */
index bac61c7..35a7fbe 100755 (executable)
@@ -36,7 +36,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(sms_plugin_pkgs REQUIRED db-util glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0)
+pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0)
 
 FOREACH(flag ${sms_plugin_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 5a5cc48..d374c7c 100755 (executable)
@@ -79,14 +79,13 @@ void SmsPluginCallback::registerEvent()
                MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SIM_REFRESHED);
 
        MsgSettingRegVconfCBCommon(VCONFKEY_DNET_STATE, _dnet_state_changed_cb);
-//     MsgSettingRegVconfCBCommon(VCONFKEY_TELEPHONY_MDN, _TapiMdnChangedCb);
+       /* MsgSettingRegVconfCBCommon(VCONFKEY_TELEPHONY_MDN, _TapiMdnChangedCb); */
 }
 
 
 void SmsPluginCallback::deRegisterEvent()
 {
 
-
 }
 
 
@@ -94,18 +93,15 @@ void TapiEventDeviceReady(TapiHandle *handle, const char *noti_id, void *data, v
 {
        MSG_DEBUG("TapiEventDeviceReady is called. : noti_id = [%d]", noti_id);
 
-       try
-       {
-               // Call Event Handler
+       try {
+               /* Call Event Handler */
                SmsPluginEventHandler::instance()->setDeviceStatus();
 
                if (SmsPluginEventHandler::instance()->getNeedInitConfig() == true) {
                        SmsPluginEventHandler::instance()->setNeedInitConfig(false);
                        SmsPluginSetting::instance()->SimRefreshCb();
                }
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
@@ -142,7 +138,8 @@ void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, v
        sms_trans_msg_s sms_trans_msg;
        memset(&sms_trans_msg, 0x00, sizeof(sms_trans_msg_s));
 
-       if (pDataPackage->format == (TelSmsNetType_t)0x03) {                            // voice mail notification
+       if (pDataPackage->format == (TelSmsNetType_t)0x03) {
+               /* voice mail notification */
                sms_trans_msg.data.p2p_msg.telesvc_msg.type = SMS_TYPE_DELIVER;
                sms_trans_msg.data.p2p_msg.telesvc_id = SMS_TRANS_TELESVC_VMN_95;
 
@@ -164,21 +161,20 @@ void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, v
        } else {
                bool bInvalid = SmsPluginMsgCodec::checkInvalidPDU(pDataPackage->szData, pDataPackage->MsgLength);
                if (bInvalid == true) {
-                       // Decode Incoming Message
+                       /* Decode Incoming Message */
                        SmsPluginMsgCodec::decodeMsg(pDataPackage->szData, pDataPackage->MsgLength, &sms_trans_msg);
 
                        if (sms_trans_msg.data.cb_msg.telesvc_msg.data.deliver.cmas_data.is_wrong_recode_type) {
                                MSG_WARN("Invalid CMAS Record Type");
                                return;
                        }
-               }
-               else {
+               } else {
                        MSG_WARN("Invalid PDU");
                        return;
                }
        }
 
-       /// Print tpdu
+       /* Print tpdu */
        if (sms_trans_msg.type == SMS_TRANS_P2P_MSG) {
                MSG_DEBUG("############# SMS_TRANS_P2P_MSG Incoming decoded tpdu values ####################");
                MSG_DEBUG("------------------------------ transport layer data -----------------------------");
@@ -217,8 +213,7 @@ void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, v
                MSG_DEBUG("deliver_msg->callback_number.number_type= [%d]", deliver_msg->callback_number.number_type);
                MSG_DEBUG("deliver_msg->callback_number.szData= [%s]", deliver_msg->callback_number.szData);
                MSG_DEBUG("#####################################################");
-       }
-       else if (sms_trans_msg.type == SMS_TRANS_BROADCAST_MSG) {
+       } else if (sms_trans_msg.type == SMS_TRANS_BROADCAST_MSG) {
                MSG_DEBUG("############# SMS_TRANS_BROADCAST_MSG Incoming decoded tpdu values ####################");
                MSG_DEBUG("------------------------------ transport layer data -----------------------------");
                MSG_DEBUG("sms_trans_msg.data.cb_msg.svc_ctg = [%d]", sms_trans_msg.data.cb_msg.svc_ctg);
@@ -253,27 +248,26 @@ void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, v
                MSG_DEBUG("deliver_msg->callback_number.szData= [%s]", deliver_msg->callback_number.szData);
                MSG_DEBUG("#####################################################");
        } else if (sms_trans_msg.type == SMS_TRANS_ACK_MSG) {
-               // DLOG
+               /* DLOG */
                MSG_DEBUG("#####################################################");
        }
 
-       try
-       {
+       try {
                if (sms_trans_msg.type == SMS_TRANS_P2P_MSG) {
                        if (sms_trans_msg.data.p2p_msg.telesvc_id == SMS_TRANS_TELESVC_WAP) {
                                SmsPluginEventHandler::instance()->handleWapMsgIncoming(&(sms_trans_msg.data.p2p_msg));
-                       }
-                       else {
-                               SmsPluginEventHandler::instance()->handleMsgIncoming(&(sms_trans_msg.data.p2p_msg)); // Call Event Handler
+                       } else {
+                               /* Call Event Handler */
+                               SmsPluginEventHandler::instance()->handleMsgIncoming(&(sms_trans_msg.data.p2p_msg));
                        }
                } else if (sms_trans_msg.type == SMS_TRANS_BROADCAST_MSG) {
-                       SmsPluginEventHandler::instance()->handleCbMsgIncoming(&(sms_trans_msg.data.cb_msg)); // Call Event Handler
+                       /* Call Event Handler */
+                       SmsPluginEventHandler::instance()->handleCbMsgIncoming(&(sms_trans_msg.data.cb_msg));
                } else if (sms_trans_msg.type == SMS_TRANS_ACK_MSG) {
-                       //SmsPluginEventHandler::instance()->handleAckMsgIncoming(&(sms_trans_msg.data.ack_msg)); // Call Event Handler
+                       /* Call Event Handler */
+                       /* SmsPluginEventHandler::instance()->handleAckMsgIncoming(&(sms_trans_msg.data.ack_msg)); */
                }
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
@@ -293,9 +287,9 @@ void TapiEventNetworkStatusChange(TapiHandle *handle, const char *noti_id, void
 
        MSG_DEBUG("network status type [%d]", *type);
 
-       if(*type > TAPI_NETWORK_SERVICE_TYPE_SEARCH)
-       {
-               SmsPluginEventHandler::instance()->handleResendMessage(); // Call Event Handler
+       if (*type > TAPI_NETWORK_SERVICE_TYPE_SEARCH) {
+               /* Call Event Handler */
+               SmsPluginEventHandler::instance()->handleResendMessage();
        }
 }
 
@@ -311,8 +305,7 @@ void TapiEventSimRefreshed(TapiHandle *handle, const char *noti_id, void *data,
 void TapiEventMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data)
 {
        MSG_DEBUG("Tapi result is [%d]", result);
-       if(result == TAPI_API_SUCCESS)
-       {
+       if (result == TAPI_API_SUCCESS) {
                isMemAvailable = true;
        }
 }
@@ -326,42 +319,41 @@ void TapiEventSentStatus(TapiHandle *handle, int result, void *data, void *user_
 
        /* Convert TAPI status -> SMS network status */
        switch ((TelSmsResponse_t)result) {
-               case TAPI_NETTEXT_SENDSMS_SUCCESS :
-                       sentStatus = SMS_NETWORK_SEND_SUCCESS;
-                       break;
-               case TAPI_NETTEXT_INVALID_MANDATORY_INFO :
-                       sentStatus = SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING;
-                       break;
-               case TAPI_NETTEXT_DESTINAITION_OUTOFSERVICE :
-               case TAPI_NETTEXT_TEMPORARY_FAILURE :
-               case TAPI_NETTEXT_CONGESTION :
-               case TAPI_NETTEXT_RESOURCES_UNAVAILABLE :
-               case TAPI_NETTEXT_MESSAGE_NOT_COMPAT_PROTOCOL :
-                       sentStatus = SMS_NETWORK_SEND_FAIL_TEMPORARY;
-                       break;
-               case TAPI_NETTEXT_DEST_ADDRESS_FDN_RESTRICTED :
-               case TAPI_NETTEXT_SCADDRESS_FDN_RESTRICTED :
-                       sentStatus = SMS_NETWORK_SEND_FAIL_FDN_RESTRICED;
-                       break;
-               default :
-                       sentStatus = SMS_NETWORK_SEND_FAIL;
-                       break;
+       case TAPI_NETTEXT_SENDSMS_SUCCESS:
+               sentStatus = SMS_NETWORK_SEND_SUCCESS;
+               break;
+       case TAPI_NETTEXT_INVALID_MANDATORY_INFO:
+               sentStatus = SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING;
+               break;
+       case TAPI_NETTEXT_DESTINAITION_OUTOFSERVICE:
+       case TAPI_NETTEXT_TEMPORARY_FAILURE:
+       case TAPI_NETTEXT_CONGESTION:
+       case TAPI_NETTEXT_RESOURCES_UNAVAILABLE:
+       case TAPI_NETTEXT_MESSAGE_NOT_COMPAT_PROTOCOL:
+               sentStatus = SMS_NETWORK_SEND_FAIL_TEMPORARY;
+               break;
+       case TAPI_NETTEXT_DEST_ADDRESS_FDN_RESTRICTED:
+       case TAPI_NETTEXT_SCADDRESS_FDN_RESTRICTED:
+               sentStatus = SMS_NETWORK_SEND_FAIL_FDN_RESTRICED;
+               break;
+       default:
+               sentStatus = SMS_NETWORK_SEND_FAIL;
+               break;
        }
 
        MSG_DEBUG("SMS Network Status = [%d]", sentStatus);
 
-       if(sentStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY ||
-                       sentStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD ||
+       if (sentStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY ||
+                       sentStatus == SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING ||
                        sentStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED) {
                SmsPluginTransport::instance()->setNetStatus(sentStatus);
                return;
        }
 
-       if(sentStatus == SMS_NETWORK_SEND_FAIL)
-       {
+       if (sentStatus == SMS_NETWORK_SEND_FAIL) {
                int svc_type;
                tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
-               if(svc_type < TAPI_NETWORK_SERVICE_TYPE_2G){
+               if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G){
                        sentStatus = SMS_NETWORK_SEND_PENDING;
                }
        }
@@ -385,14 +377,11 @@ void TapiEventSentStatus(TapiHandle *handle, int result, void *data, void *user_
                netStatus = MSG_NETWORK_SEND_FAIL;
        }
 
-       try
-       {
+       try {
                SmsPluginEventHandler::instance()->handleSentStatus(netStatus);
 
                SmsPluginTransport::instance()->setNetStatus(sentStatus);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
@@ -412,8 +401,7 @@ void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *us
 {
        MSG_DEBUG("TapiEventSetConfigData is called.");
 
-       if (data == NULL)
-       {
+       if (data == NULL) {
                MSG_DEBUG("Error. data is NULL.");
                return;
        }
@@ -422,30 +410,24 @@ void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *us
 
        MSG_DEBUG("responseType : [%d]", *responseType);
 
-       switch (*responseType)
-       {
-               case TAPI_NETTEXT_SETPREFERREDBEARER_RSP :
-                       MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
+       switch (*responseType) {
+       case TAPI_NETTEXT_SETPREFERREDBEARER_RSP:
+               MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
                break;
-
-               case TAPI_NETTEXT_SETPARAMETERS_RSP :
-                       MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
+       case TAPI_NETTEXT_SETPARAMETERS_RSP:
+               MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
                break;
-
-               case TAPI_NETTEXT_CBSETCONFIG_RSP :
-                       MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
+       case TAPI_NETTEXT_CBSETCONFIG_RSP:
+               MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
                break;
-
-               case TAPI_NETTEXT_SETMEMORYSTATUS_RSP :
-                       MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
+       case TAPI_NETTEXT_SETMEMORYSTATUS_RSP:
+               MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
                break;
-
-               case TAPI_NETTEXT_SETMESSAGESTATUS_RSP :
-                       MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
+       case TAPI_NETTEXT_SETMESSAGESTATUS_RSP:
+               MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
                break;
-
-               default :
-                       MSG_DEBUG("Unknown Response is called [%d]", *responseType);
+       default:
+               MSG_DEBUG("Unknown Response is called [%d]", *responseType);
                break;
        }
 
@@ -466,8 +448,7 @@ void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user
 
        MSG_CBMSG_OPT_S cbOpt = {0};
 
-       if (result != TAPI_API_SUCCESS || data == NULL)
-       {
+       if (result != TAPI_API_SUCCESS || data == NULL) {
                MSG_DEBUG("Error. data is NULL.");
 
                SmsPluginSetting::instance()->setCbConfigEvent(NULL, false);
@@ -479,23 +460,21 @@ void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user
 
        cbOpt.bReceive = (bool)pCBConfig->CBEnabled;
 
-//     cbOpt.maxSimCnt = pCBConfig->MsgIdMaxCount;
+       /* cbOpt.maxSimCnt = pCBConfig->MsgIdMaxCount; */
+       /* MSG_DEBUG("Receive [%d], Max SIM Count [%d]", cbOpt.bReceive, cbOpt.maxSimCnt); */
 
-//     MSG_DEBUG("Receive [%d], Max SIM Count [%d]", cbOpt.bReceive, cbOpt.maxSimCnt);
        MSG_DEBUG("Receive [%d]", cbOpt.bReceive);
 
        cbOpt.channelData.channelCnt = pCBConfig->MsgIdRangeCount;
 
-       if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX)
-       {
+       if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX) {
                MSG_DEBUG("Channel Count [%d] from TAPI is over MAX", cbOpt.channelData.channelCnt);
                cbOpt.channelData.channelCnt = CB_CHANNEL_MAX;
        }
 
        MSG_DEBUG("Channel Count [%d]", cbOpt.channelData.channelCnt);
 
-       for (int i = 0; i < cbOpt.channelData.channelCnt; i++)
-       {
+       for (int i = 0; i < cbOpt.channelData.channelCnt; i++) {
                cbOpt.channelData.channelInfo[i].bActivate = pCBConfig->MsgIDs[i].Net3gpp2.Selected;
                cbOpt.channelData.channelInfo[i].ctg = pCBConfig->MsgIDs[i].Net3gpp2.CBCategory;
                cbOpt.channelData.channelInfo[i].lang = pCBConfig->MsgIDs[i].Net3gpp2.CBLanguage;
@@ -507,6 +486,7 @@ void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user
        SmsPluginSetting::instance()->setCbConfigEvent(&cbOpt, true);
 }
 
+
 void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data)
 {
        MSG_DEBUG("TapiEventGetMsisdnInfo is called.");
@@ -542,15 +522,18 @@ void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *us
        SmsPluginSetting::instance()->setResultFromSim(bRet);
 }
 
+
 void _dnet_state_changed_cb(keynode_t *key, void* data)
 {
        int dnet_state = MsgSettingGetInt(VCONFKEY_DNET_STATE);
 
        if (dnet_state > VCONFKEY_DNET_OFF) {
-               SmsPluginEventHandler::instance()->handleResendMessage(); // Call Event Handler
+               /* Call Event Handler */
+               SmsPluginEventHandler::instance()->handleResendMessage();
        }
 }
 
+
 void _TapiMdnChangedCb(keynode_t *key, void *data)
 {
        MSG_INFO("_TapiMdnChangedCb is called.");
@@ -562,11 +545,13 @@ void _TapiMdnChangedCb(keynode_t *key, void *data)
                MSG_INFO("bNeedToUpdateVoicemail:%d, mdn:[%s]", bNeedToUpdateVoicemail, mdn);
 
                if (bNeedToUpdateVoicemail) {
-                       if (MsgSettingSetString(VOICEMAIL_NUMBER, mdn) != MSG_SUCCESS)
-                               MSG_DEBUG("MsgSettingSetInt is failed!!");
+                       char keyName[MAX_VCONFKEY_NAME_LEN];
+                       int sim_idx = 1;
 
-                       if (MsgSettingSetString(VOICEMAIL_DEFAULT_NUMBER, mdn) != MSG_SUCCESS)
-                               MSG_DEBUG("Error to set config data [%s]", VOICEMAIL_DEFAULT_NUMBER);
+                       memset(keyName, 0x00, sizeof(keyName));
+                       snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
+                       if (MsgSettingSetString(keyName, mdn) != MSG_SUCCESS)
+                               MSG_DEBUG("Error to set config data [%s]", keyName);
                }
 
                free(mdn);
index 8ed6c16..b5fe7a7 100755 (executable)
@@ -24,9 +24,9 @@
 #include "SmsCdmaPluginCodec.h"
 
 
-
 SmsPluginMsgCodec* SmsPluginMsgCodec::pInstance = NULL;
 
+
 SmsPluginMsgCodec::SmsPluginMsgCodec()
 {
 
@@ -96,28 +96,27 @@ int UnpackGSM7bitData(unsigned char *src, unsigned char *dest, unsigned int data
 
        MSG_DEBUG("dataLen = %d", dataLen);
 
-       for (; dstIdx < dataLen; dstIdx++)
-       {
-               if (shift == 0)
-               {
+       for (; dstIdx < dataLen; dstIdx++) {
+               if (shift == 0) {
                        dest[dstIdx] = src[srcIdx] & 0x7F;
 
                        shift = 7;
                        srcIdx++;
                        dstIdx++;
 
-                       if (dstIdx >= dataLen) break;
+                       if (dstIdx >= dataLen)
+                               break;
                }
 
-               if (shift > 0)
-               {
+               if (shift > 0) {
                        dest[dstIdx] = (src[srcIdx-1] >> shift) + (src[srcIdx] << (8 - shift));
 
                        dest[dstIdx] &= 0x7F;
 
                        shift--;
 
-                       if (shift > 0) srcIdx++;
+                       if (shift > 0)
+                               srcIdx++;
                }
        }
 
@@ -132,30 +131,26 @@ int PackGSM7bitData(const unsigned char *pUserData, unsigned char *pPackData, in
        if (shift > 0)
                dstIdx = 1;
 
-       while (srcIdx < dataLen)
-       {
-               if (shift == 0)
-               {
+       while (srcIdx < dataLen) {
+               if (shift == 0) {
                        pPackData[dstIdx] = pUserData[srcIdx];
 
                        shift = 7;
                        srcIdx++;
                        dstIdx++;
 
-                       if (srcIdx >= dataLen) break;
+                       if (srcIdx >= dataLen)
+                               break;
                }
 
-               if (shift > 1)
-               {
+               if (shift > 1) {
                        pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
                        pPackData[dstIdx] = pUserData[srcIdx] >> (8-shift);
                        shift--;
 
                        srcIdx++;
                        dstIdx++;
-               }
-               else if (shift == 1)
-               {
+               } else if (shift == 1) {
                        pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
 
                        srcIdx++;
@@ -182,15 +177,15 @@ bool SmsPluginMsgCodec::checkInvalidPDU(const unsigned char *p_pkg_str, const in
 
        while (offset < p_pkg_len) {
                switch (p_pkg_str[offset]) {
-               case 0x00 :
-               case 0x01 :
-               case 0x02 :
-               case 0x03 :
-               case 0x04 :
-               case 0x05 :
-               case 0x06 :
-               case 0x07 :
-               case 0x08 :
+               case 0x00:
+               case 0x01:
+               case 0x02:
+               case 0x03:
+               case 0x04:
+               case 0x05:
+               case 0x06:
+               case 0x07:
+               case 0x08:
                        offset += (p_pkg_str[offset+1]+2);
                        break;
                default:
@@ -213,18 +208,18 @@ int SmsPluginMsgCodec::encodeMsg(const sms_trans_msg_s *p_msg, unsigned char *p_
 
        int encode_size = 0;
 
-       switch(p_msg->type) {
-               case SMS_TRANS_P2P_MSG:
-                       encode_size = encodeP2PMsg(&(p_msg->data.p2p_msg), p_pkg_str);
-                       break;
-               case SMS_TRANS_BROADCAST_MSG:
-                       encode_size = encodeCBMsg(&(p_msg->data.cb_msg), p_pkg_str);
-                       break;
-               case SMS_TRANS_ACK_MSG :
-                       encode_size = encodeAckMsg(&(p_msg->data.ack_msg), p_pkg_str);
-                       break;
-               default :
-                       break;
+       switch (p_msg->type) {
+       case SMS_TRANS_P2P_MSG:
+               encode_size = encodeP2PMsg(&(p_msg->data.p2p_msg), p_pkg_str);
+               break;
+       case SMS_TRANS_BROADCAST_MSG:
+               encode_size = encodeCBMsg(&(p_msg->data.cb_msg), p_pkg_str);
+               break;
+       case SMS_TRANS_ACK_MSG:
+               encode_size = encodeAckMsg(&(p_msg->data.ack_msg), p_pkg_str);
+               break;
+       default:
+               break;
        }
 
 
@@ -244,29 +239,32 @@ int SmsPluginMsgCodec::encodeP2PMsg(const sms_trans_p2p_msg_s *p_msg, unsigned c
 
        p_pkg_str[offset++] = SMS_TRANS_P2P_MSG;
 
-       // 1. teleservice id
+       /* 1. teleservice id */
        p_pkg_str[offset++] = SMS_TRANS_PARAM_TELESVC_IDENTIFIER;
-       p_pkg_str[offset++] = 2; // fixed
-       //memcpy(p_pkg_str+offset, &(p_msg->telesvc_id), sizeof(sms_trans_telesvc_id_t));
+       p_pkg_str[offset++] = 2;
+       /* fixed */
+       /* memcpy(p_pkg_str+offset, &(p_msg->telesvc_id), sizeof(sms_trans_telesvc_id_t)); */
        _copy_short_to_char(p_pkg_str+offset, &(p_msg->telesvc_id));
        offset += sizeof(sms_trans_telesvc_id_t);
 
-       // 2. Service category
-       if(p_msg->svc_ctg < SMS_TRANS_SVC_CTG_UNDEFINED) {
+       /* 2. Service category */
+       if (p_msg->svc_ctg < SMS_TRANS_SVC_CTG_UNDEFINED) {
                p_pkg_str[offset++] = SMS_TRANS_PARAM_SERVICE_CATEGORY;
-               p_pkg_str[offset++] = 0x02; // fixed
+               p_pkg_str[offset++] = 0x02;
+               /* fixed */
                _copy_short_to_char(&p_pkg_str[offset],&(p_msg->svc_ctg));
        }
 
-       // 3. Address
+       /* 3. Address */
        p_pkg_str[offset++] = SMS_TRANS_PARAM_DEST_ADDRESS;
 
-       len_index = offset++; // Will be set to param length
+       /* Will be set to param length */
+       len_index = offset++;
 
        p_pkg_str[offset] = p_msg->address.digit_mode ? 0x80 : 0x00;
        p_pkg_str[offset] |= (p_msg->address.number_mode ? 0x40 : 0x00);
 
-       if(p_msg->address.digit_mode == false) {
+       if (p_msg->address.digit_mode == false) {
                index = offset++;
                p_pkg_str[offset++] = p_msg->address.addr_len;
 
@@ -279,11 +277,10 @@ int SmsPluginMsgCodec::encodeP2PMsg(const sms_trans_p2p_msg_s *p_msg, unsigned c
                offset += addr_len;
 
                _shiftNBit(&p_pkg_str[index], offset-index+1, 6);
-       }
-       else if(p_msg->address.digit_mode == true) {
+       } else if (p_msg->address.digit_mode == true) {
                p_pkg_str[offset] |= p_msg->address.number_type << 3;
 
-               if(p_msg->address.number_mode == false) {
+               if (p_msg->address.number_mode == false) {
                        p_pkg_str[offset++] |= p_msg->address.number_plan >> 1;
                        p_pkg_str[offset++] |= p_msg->address.number_plan << 7;
                        index = offset-1;
@@ -294,8 +291,7 @@ int SmsPluginMsgCodec::encodeP2PMsg(const sms_trans_p2p_msg_s *p_msg, unsigned c
                        offset += p_msg->address.addr_len;
 
                        _shiftNBit(&p_pkg_str[index], offset-index+1, 7);
-               }
-               else if(p_msg->address.number_mode == true) {
+               } else if (p_msg->address.number_mode == true) {
                        index = offset++;
                        p_pkg_str[offset++] = p_msg->address.addr_len;
                        memcpy(p_pkg_str+offset, p_msg->address.szData, p_msg->address.addr_len);
@@ -309,8 +305,8 @@ int SmsPluginMsgCodec::encodeP2PMsg(const sms_trans_p2p_msg_s *p_msg, unsigned c
        p_pkg_str[len_index] = offset - len_index - 1 ;
        MSG_DEBUG("Address subparam length field = [%d]", p_pkg_str[len_index]);
 
-       // 4. Sub address (optional)
-       if(p_msg->sub_address.addr_len > 0) {
+       /* 4. Sub address (optional) */
+       if (p_msg->sub_address.addr_len > 0) {
                p_pkg_str[offset++] = SMS_TRANS_PARAM_ORG_SUB_ADDRESS;
                p_pkg_str[offset] = p_msg->sub_address.addr_len + 2;
                index = offset++;
@@ -319,27 +315,29 @@ int SmsPluginMsgCodec::encodeP2PMsg(const sms_trans_p2p_msg_s *p_msg, unsigned c
                p_pkg_str[offset++] = p_msg->sub_address.addr_len;
                memcpy(p_pkg_str+offset, p_msg->sub_address.szData, p_msg->sub_address.addr_len);
 
-               offset+=p_msg->sub_address.addr_len;
+               offset += p_msg->sub_address.addr_len;
 
                _shiftNBit(&p_pkg_str[index], offset-index+1, 4);
        }
 
-       // 5. Bearer reply option (optional)
-       if(p_msg->reply_seq > 0) {
+       /* 5. Bearer reply option (optional) */
+       if (p_msg->reply_seq > 0) {
                p_pkg_str[offset++] = SMS_TRANS_PARAM_BEARER_REPLY_OPTION;
                p_pkg_str[offset++] = 1;
                p_pkg_str[offset++] = (unsigned char)(p_msg->reply_seq << 2);
                MSG_DEBUG("Reply sequnce number = [%d]", p_msg->reply_seq);
        }
 
-       // 6. Bearer data
+       /* 6. Bearer data */
     p_pkg_str[offset++] = SMS_TRANS_PARAM_BEARER_DATA;
-       index = offset++; // PARAMETER_LEN field should be filled at the last part.
+    /* PARAMETER_LEN field should be filled at the last part. */
+    index = offset++;
 
        unsigned char *encode_data = &p_pkg_str[offset];
 
        encode_size = encodeTelesvcMsg(&(p_msg->telesvc_msg), encode_data);
-       p_pkg_str[index] = encode_size; // PARAMETER_LEN
+       /* PARAMETER_LEN */
+       p_pkg_str[index] = encode_size;
 
        offset += encode_size;
 
@@ -356,21 +354,23 @@ int SmsPluginMsgCodec::encodeCBMsg(const sms_trans_broadcast_msg_s *p_msg, unsig
        int offset = 0, encode_size = 0;
        int len_index = 0;
 
-       // 1. Service Category(Mandatory)
+       /* 1. Service Category(Mandatory) */
        p_pkg_str[offset++] = SMS_TRANS_PARAM_SERVICE_CATEGORY;
        p_pkg_str[offset++] = 0x02;
        _copy_short_to_char(&p_pkg_str[offset],&p_msg->svc_ctg);
 
 
-       // 2. Bearer Data(Optional)
-       // TODO: give condition
+       /* 2. Bearer Data(Optional) */
+       /* TODO: give condition */
     p_pkg_str[offset++] = SMS_TRANS_PARAM_BEARER_DATA;
-       len_index = offset++; // PARAMETER_LEN field should be filled at the last part.
+    /* PARAMETER_LEN field should be filled at the last part. */
+       len_index = offset++;
 
        unsigned char *encode_data = &p_pkg_str[offset];
 
        encode_size = encodeTelesvcMsg(&(p_msg->telesvc_msg), encode_data);
-       p_pkg_str[len_index] = encode_size; // PARAMETER_LEN
+       /* PARAMETER_LEN */
+       p_pkg_str[len_index] = encode_size;
 
        offset += encode_size;
 
@@ -388,17 +388,18 @@ int SmsPluginMsgCodec::encodeAckMsg(const sms_trans_ack_msg_s *p_msg, unsigned c
        int addr_len = 0, len_index = 0;
        int index = 0;
 
-       // 1. Address
+       /* 1. Address */
        p_pkg_str[offset++] = SMS_TRANS_PARAM_DEST_ADDRESS;
 
-       len_index = offset++; // Will be set to param length
+       /* Will be set to param length */
+       len_index = offset++;
 
        p_pkg_str[offset] = p_msg->address.digit_mode ? 0x80 : 0x00;
        p_pkg_str[offset] |= (p_msg->address.number_mode ? 0x40 : 0x00);
 
        index = offset++;
 
-       if(p_msg->address.digit_mode == false) {
+       if (p_msg->address.digit_mode == false) {
                p_pkg_str[offset++] = p_msg->address.addr_len;
 
                addr_len = SmsPluginParamCodec::instance()->convertDigitToDTMF(p_msg->address.szData, p_msg->address.addr_len, 0, p_pkg_str+offset);
@@ -410,11 +411,10 @@ int SmsPluginMsgCodec::encodeAckMsg(const sms_trans_ack_msg_s *p_msg, unsigned c
                offset += addr_len;
 
                _shiftNBit(&p_pkg_str[index], offset-index+1, 6);
-       }
-       else if(p_msg->address.digit_mode == true) {
+       } else if (p_msg->address.digit_mode == true) {
                p_pkg_str[offset] |= p_msg->address.number_type << 3;
 
-               if(p_msg->address.number_mode == false) {
+               if (p_msg->address.number_mode == false) {
                        p_pkg_str[offset++] |= p_msg->address.number_plan >> 1;
                        p_pkg_str[offset++] |= p_msg->address.number_plan << 7;
                        index++;
@@ -425,8 +425,7 @@ int SmsPluginMsgCodec::encodeAckMsg(const sms_trans_ack_msg_s *p_msg, unsigned c
                        offset += p_msg->address.addr_len;
 
                        _shiftNBit(&p_pkg_str[index], offset-index+1, 7);
-               }
-               else if(p_msg->address.number_mode == true) {
+               } else if (p_msg->address.number_mode == true) {
                        p_pkg_str[++offset] = p_msg->address.addr_len;
                        offset++;
                        memcpy(p_pkg_str+offset, p_msg->address.szData, p_msg->address.addr_len);
@@ -440,8 +439,8 @@ int SmsPluginMsgCodec::encodeAckMsg(const sms_trans_ack_msg_s *p_msg, unsigned c
        p_pkg_str[len_index] = offset - len_index - 1 ;
        MSG_DEBUG("Address subparam length field = [%d]", p_pkg_str[len_index]);
 
-       // 2. Sub address
-       if(p_msg->sub_address.addr_len > 0) {
+       /* 2. Sub address */
+       if (p_msg->sub_address.addr_len > 0) {
                p_pkg_str[offset++] = SMS_TRANS_PARAM_ORG_SUB_ADDRESS;
                p_pkg_str[offset] = p_msg->sub_address.addr_len + 2;
                index = offset++;
@@ -450,12 +449,12 @@ int SmsPluginMsgCodec::encodeAckMsg(const sms_trans_ack_msg_s *p_msg, unsigned c
                p_pkg_str[offset++] = p_msg->sub_address.addr_len;
                memcpy(p_pkg_str+offset, p_msg->sub_address.szData, p_msg->sub_address.addr_len);
 
-               offset+=p_msg->sub_address.addr_len;
+               offset += p_msg->sub_address.addr_len;
 
                _shiftNBit(&p_pkg_str[index], offset-index+1, 4);
        }
 
-       // 3. Cause code
+       /* 3. Cause code */
        p_pkg_str[offset++] = SMS_TRANS_PARAM_CAUSE_CODES;
        index = offset++;
        p_pkg_str[offset] |= p_msg->cause_code.reply_seq << 2;
@@ -471,6 +470,7 @@ int SmsPluginMsgCodec::encodeAckMsg(const sms_trans_ack_msg_s *p_msg, unsigned c
 
 }
 
+
 int SmsPluginMsgCodec::encodeTelesvcMsg(const sms_telesvc_msg_s *p_msg, unsigned char *p_pkg_str)
 {
        MSG_BEGIN();
@@ -478,38 +478,42 @@ int SmsPluginMsgCodec::encodeTelesvcMsg(const sms_telesvc_msg_s *p_msg, unsigned
 
        MSG_DEBUG("Teleservice msg type = [%d]", p_msg->type);
 
-       switch(p_msg->type) {
-//             case SMS_TYPE_DELIVER :
-//                     encode_size = encodeTelesvcDeliverMsg(&(p_msg->data.delever), p_pkg_str);
-//                     break;
-               case SMS_TYPE_SUBMIT :
-                       encode_size = encodeTelesvcSubmitMsg(&(p_msg->data.submit), p_pkg_str);
-                       break;
-               case SMS_TYPE_CANCEL :
-                       encode_size = encodeTelesvcCancelMsg(&(p_msg->data.cancel), p_pkg_str);
-                       break;
-               case SMS_TYPE_USER_ACK :
-                       encode_size = encodeTelesvcUserAckMsg(&(p_msg->data.user_ack), p_pkg_str);
-                       break;
-               case SMS_TYPE_READ_ACK :
-                       encode_size = encodeTelesvcReadAckMsg(&(p_msg->data.read_ack), p_pkg_str);
-                       break;
-               case SMS_TYPE_DELIVER_REPORT :
-                       encode_size = encodeTelesvcDeliverReportMsg(&(p_msg->data.report), p_pkg_str);
-                       break;
-               default :
-                       MSG_DEBUG("No matching type for [%d]", p_msg->type);
-                       break;
+       switch (p_msg->type) {
+       /* case SMS_TYPE_DELIVER:
+               encode_size = encodeTelesvcDeliverMsg(&(p_msg->data.delever), p_pkg_str);
+               break;  */
+       case SMS_TYPE_SUBMIT:
+               encode_size = encodeTelesvcSubmitMsg(&(p_msg->data.submit), p_pkg_str);
+               break;
+       case SMS_TYPE_CANCEL:
+               encode_size = encodeTelesvcCancelMsg(&(p_msg->data.cancel), p_pkg_str);
+               break;
+       case SMS_TYPE_USER_ACK:
+               encode_size = encodeTelesvcUserAckMsg(&(p_msg->data.user_ack), p_pkg_str);
+               break;
+       case SMS_TYPE_READ_ACK:
+               encode_size = encodeTelesvcReadAckMsg(&(p_msg->data.read_ack), p_pkg_str);
+               break;
+       case SMS_TYPE_DELIVER_REPORT:
+               encode_size = encodeTelesvcDeliverReportMsg(&(p_msg->data.report), p_pkg_str);
+               break;
+       default:
+               MSG_DEBUG("No matching type for [%d]", p_msg->type);
+               break;
        }
 
        MSG_END();
        return encode_size;
 }
 
-//int SmsPluginMsgCodec::encodeTelesvcDeliverMsg(const sms_telesvc_deliver_s *p_msg, char *p_pkg_str)
-//{
-//
-//}
+
+/*
+int SmsPluginMsgCodec::encodeTelesvcDeliverMsg(const sms_telesvc_deliver_s *p_msg, char *p_pkg_str)
+{
+
+}
+*/
+
 
 int SmsPluginMsgCodec::encodeTelesvcReadAckMsg(const sms_telesvc_read_ack_s *p_msg, unsigned char *p_pkg_str)
 {
@@ -517,7 +521,6 @@ int SmsPluginMsgCodec::encodeTelesvcReadAckMsg(const sms_telesvc_read_ack_s *p_m
 
        int offset = 0;
 
-
        MSG_END();
 
        return offset;
@@ -543,29 +546,29 @@ int SmsPluginMsgCodec::encodeTelesvcDeliverReportMsg(const sms_telesvc_report_s
        int offset = 0, len_index = 0, encode_size = 0;
        bool delReservedBit = false;
 
-       // 1. Message Identifier (Mandatory)
+       /* 1. Message Identifier (Mandatory) */
        p_pkg_str[offset++] = SMS_BEARER_MESSAGE_IDENTIFIER;
        p_pkg_str[offset++] = 3;
        _copy_short_to_char(p_pkg_str+offset+1, &(p_msg->msg_id.msg_id));
        _shiftNBit(&p_pkg_str[offset], 3, 4);
        p_pkg_str[offset] |= SMS_TYPE_SUBMIT << 4;
-       offset+=2;
+       offset += 2;
        p_pkg_str[offset++] |= (p_msg->msg_id.header_ind ? 0x08 : 0x00);
 
 
-       // 2. TP-Failure Cause (Conditional)
-       if(p_msg->tp_fail_cause >= 0x8000) {
+       /* 2. TP-Failure Cause (Conditional) */
+       if (p_msg->tp_fail_cause >= 0x8000) {
                p_pkg_str[offset++] = SMS_BEARER_TP_FAILURE_CAUSE;
                p_pkg_str[offset++] = 1;
                p_pkg_str[offset++] = p_msg->tp_fail_cause;
        }
 
-       // 3. User Data (Optional)
-       if(p_msg->user_data.data_len > 0) {
+       /* 3. User Data (Optional) */
+       if (p_msg->user_data.data_len > 0) {
                p_pkg_str[offset++] = SMS_BEARER_USER_DATA;
                len_index = offset;
                offset++;
-               if(p_msg->user_data.encode_type == 0x01 || p_msg->user_data.encode_type == 0x0a)
+               if (p_msg->user_data.encode_type == 0x01 || p_msg->user_data.encode_type == 0x0a)
                        p_pkg_str[offset++] = p_msg->user_data.msg_type;
 
                p_pkg_str[offset++] = p_msg->user_data.encode_type << 3;
@@ -574,7 +577,7 @@ int SmsPluginMsgCodec::encodeTelesvcDeliverReportMsg(const sms_telesvc_report_s
                if (p_msg->user_data.encode_type == SMS_ENCODE_7BIT_ASCII || p_msg->user_data.encode_type == SMS_ENCODE_GSM7BIT) {
                        encode_size = encodeUserData(p_msg->user_data.user_data, &p_pkg_str[offset], p_msg->user_data.data_len);
                        offset += encode_size;
-                       if(p_msg->user_data.data_len % 8 > 4)
+                       if (p_msg->user_data.data_len % 8 > 4)
                                delReservedBit = true;
                } else {
                        memcpy(p_pkg_str+offset, p_msg->user_data.user_data, p_msg->user_data.data_len);
@@ -589,15 +592,16 @@ int SmsPluginMsgCodec::encodeTelesvcDeliverReportMsg(const sms_telesvc_report_s
 
        }
 
-       // 4. Language Indicator (Optional)
-       // TODO : give condition
-//     p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
-//     p_pkg_str[offset++] = 1;
-//     p_pkg_str[offset++] = p_msg->language;
-
+       /* 4. Language Indicator (Optional) */
+       /* TODO : give condition */
+       /*
+       p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
+       p_pkg_str[offset++] = 1;
+       p_pkg_str[offset++] = p_msg->language;
+       */
 
-       // 5. Multiple Encoding User Data (Optional)
-       // Omitted
+       /* 5. Multiple Encoding User Data (Optional) */
+       /* Omitted */
 
        MSG_END();
 
@@ -611,13 +615,13 @@ int SmsPluginMsgCodec::encodeTelesvcCancelMsg(const sms_telesvc_cancel_s *p_msg,
 
        int offset = 0;
 
-       // 1. Message Identifier
+       /* 1. Message Identifier */
        p_pkg_str[offset++] = SMS_BEARER_MESSAGE_IDENTIFIER;
        p_pkg_str[offset++] = 3;
        _copy_short_to_char(p_pkg_str+offset+1, &(p_msg->msg_id.msg_id));
        _shiftNBit(&p_pkg_str[offset], 3, 4);
        p_pkg_str[offset] |= SMS_TYPE_SUBMIT << 4;
-       offset+=2;
+       offset += 2;
        p_pkg_str[offset++] |= (p_msg->msg_id.header_ind ? 0x08 : 0x00);
 
        MSG_END();
@@ -634,21 +638,21 @@ int SmsPluginMsgCodec::encodeTelesvcSubmitMsg(const sms_telesvc_submit_s *p_msg,
        int encode_size = 0;
        bool delReservedBit = false;
 
-       // 1. Message Identifier
+       /* 1. Message Identifier */
        p_pkg_str[offset++] = SMS_BEARER_MESSAGE_IDENTIFIER;
        p_pkg_str[offset++] = 3;
        _copy_short_to_char(p_pkg_str+offset+1, &(p_msg->msg_id.msg_id));
        _shiftNBit(&p_pkg_str[offset], 3, 4);
        p_pkg_str[offset] |= SMS_TYPE_SUBMIT << 4;
-       offset+=2;
+       offset += 2;
        p_pkg_str[offset++] |= (p_msg->msg_id.header_ind ? 0x08 : 0x00);
 
-       // 2. User Data
-       if(p_msg->user_data.data_len > 0) {
+       /* 2. User Data */
+       if (p_msg->user_data.data_len > 0) {
                p_pkg_str[offset++] = SMS_BEARER_USER_DATA;
                len_index = offset;
                offset++;
-               if(p_msg->user_data.encode_type == 0x01 || p_msg->user_data.encode_type == 0x0a)
+               if (p_msg->user_data.encode_type == 0x01 || p_msg->user_data.encode_type == 0x0a)
                        p_pkg_str[offset++] = p_msg->user_data.msg_type;
 
                p_pkg_str[offset++] = p_msg->user_data.encode_type << 3;
@@ -657,12 +661,12 @@ int SmsPluginMsgCodec::encodeTelesvcSubmitMsg(const sms_telesvc_submit_s *p_msg,
                if (p_msg->user_data.encode_type == SMS_ENCODE_7BIT_ASCII) {
                        encode_size = encodeUserData(p_msg->user_data.user_data, &p_pkg_str[offset], p_msg->user_data.data_len);
                        offset += encode_size;
-                       if(p_msg->user_data.data_len % 8 > 4)
+                       if (p_msg->user_data.data_len % 8 > 4)
                                delReservedBit = true;
                } else if (p_msg->user_data.encode_type == SMS_ENCODE_GSM7BIT) {
                        encode_size = PackGSM7bitData(p_msg->user_data.user_data, &p_pkg_str[offset], p_msg->user_data.data_len);
                        offset += encode_size;
-                       if(p_msg->user_data.data_len % 8 > 4)
+                       if (p_msg->user_data.data_len % 8 > 4)
                                delReservedBit = true;
                } else if (p_msg->user_data.encode_type == SMS_ENCODE_UNICODE) {
                        MsgTextConvert *textCvt = MsgTextConvert::instance();
@@ -681,8 +685,9 @@ int SmsPluginMsgCodec::encodeTelesvcSubmitMsg(const sms_telesvc_submit_s *p_msg,
                p_pkg_str[len_index] = offset - len_index - 1;
 
        }
-/* Sprint and Verizon issue
-       // 3. Validity Period
+       /* Sprint and Verizon issue */
+       /* 3. Validity Period */
+       /*
        if (p_msg->val_period.format == SMS_TIME_RELATIVE) {
                p_pkg_str[offset++] = SMS_BEARER_VALIDITY_PERIOD_RELATIVE;
                p_pkg_str[offset++] = 1;
@@ -698,8 +703,9 @@ int SmsPluginMsgCodec::encodeTelesvcSubmitMsg(const sms_telesvc_submit_s *p_msg,
                p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.minutes);
                p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.seconds);
        }
-*/
-       // 4. Deferred Delivery Time
+       */
+
+       /* 4. Deferred Delivery Time */
        if (p_msg->defer_val_period.format == SMS_TIME_RELATIVE) {
                p_pkg_str[offset++] = SMS_BEARER_DEFERRED_DELIVERY_TIME_RELATIVE;
                p_pkg_str[offset++] = 1;
@@ -716,22 +722,24 @@ int SmsPluginMsgCodec::encodeTelesvcSubmitMsg(const sms_telesvc_submit_s *p_msg,
                p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.seconds);
        }
 
-       // 5. Priority Indicator
+       /* 5. Priority Indicator */
        if (p_msg->priority >= SMS_PRIORITY_NORMAL && p_msg->priority <=        SMS_PRIORITY_EMERGENCY) {
                p_pkg_str[offset++] = SMS_BEARER_PRIORITY_INDICATOR;
                p_pkg_str[offset++] = 1;
                p_pkg_str[offset++] = p_msg->priority << 6;
        }
 
-/* Sprint and Verizon issue
-       // 6. Privacy Indicator
+       /* Sprint and Verizon issue */
+       /* 6. Privacy Indicator */
+       /*
        if (p_msg->privacy >= SMS_PRIVACY_NOT_RESTRICTED && p_msg->privacy <= SMS_PRIVACY_SECRET) {
                p_pkg_str[offset++] = SMS_BEARER_PRIVACY_INDICATOR;
                p_pkg_str[offset++] = 1;
                p_pkg_str[offset++] = p_msg->privacy << 6;
        }
-*/
-       // 7. Reply Option
+       */
+
+       /* 7. Reply Option */
        if (p_msg->reply_opt.user_ack_req | p_msg->reply_opt.deliver_ack_req | p_msg->reply_opt.read_ack_req | p_msg->reply_opt.report_req) {
                p_pkg_str[offset++] = SMS_BEARER_REPLY_OPTION;
                p_pkg_str[offset++] = 1;
@@ -741,19 +749,23 @@ int SmsPluginMsgCodec::encodeTelesvcSubmitMsg(const sms_telesvc_submit_s *p_msg,
                p_pkg_str[offset++] |= p_msg->reply_opt.report_req << 4;
        }
 
-       // 8. Alert on Message Delivery
-       // TODO : give condition
-//     p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
-//     p_pkg_str[offset++] = 1;
-//     p_pkg_str[offset++] = p_msg->alert_priority << 6;
-
-       // 9. Language Indicator
-       // TODO : give condition
-//     p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
-//     p_pkg_str[offset++] = 1;
-//     p_pkg_str[offset++] = p_msg->language;
-
-       // 10. Call-back Number
+       /* 8. Alert on Message Delivery */
+       /* TODO : give condition */
+       /*
+       p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
+       p_pkg_str[offset++] = 1;
+       p_pkg_str[offset++] = p_msg->alert_priority << 6;
+       */
+
+       /* 9. Language Indicator */
+       /* TODO : give condition */
+       /*
+       p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
+       p_pkg_str[offset++] = 1;
+       p_pkg_str[offset++] = p_msg->language;
+       */
+
+       /* 10. Call-back Number */
        if (p_msg->callback_number.addr_len > 0) {
                p_pkg_str[offset++] = SMS_BEARER_CALLBACK_NUMBER;
 
@@ -761,13 +773,12 @@ int SmsPluginMsgCodec::encodeTelesvcSubmitMsg(const sms_telesvc_submit_s *p_msg,
 
                p_pkg_str[offset] |= p_msg->callback_number.digit_mode << 7;
 
-               if(p_msg->callback_number.digit_mode == false) {
+               if (p_msg->callback_number.digit_mode == false) {
                        p_pkg_str[offset++] |= (p_msg->callback_number.addr_len & 0xfe) >> 1;
                        p_pkg_str[offset] |= (p_msg->callback_number.addr_len & 0x01) << 7;
                        int addr_len = SmsPluginParamCodec::instance()->convertDigitToDTMF(p_msg->callback_number.szData, p_msg->callback_number.addr_len, 1, p_pkg_str+offset);
                        offset += addr_len;
-               }
-               else if(p_msg->callback_number.digit_mode == true) {
+               } else if (p_msg->callback_number.digit_mode == true) {
                        p_pkg_str[offset] |= p_msg->callback_number.number_type << 6;
                        p_pkg_str[offset++] |= p_msg->callback_number.number_plan;
                        p_pkg_str[offset++] = p_msg->callback_number.addr_len;
@@ -778,14 +789,14 @@ int SmsPluginMsgCodec::encodeTelesvcSubmitMsg(const sms_telesvc_submit_s *p_msg,
                p_pkg_str[len_index] = offset- len_index - 1;
        }
 
-       // 11. Multiple Encoding User Data
-       // Omitted
+       /* 11. Multiple Encoding User Data */
+       /* Omitted */
 
-       // 12. Message Deposit Index
-       // Omitted
+       /* 12. Message Deposit Index */
+       /* Omitted */
 
-       // 13. Service Category Program Results
-       // Omitted
+       /* 13. Service Category Program Results */
+       /* Omitted */
 
        MSG_END();
        return offset;
@@ -800,22 +811,22 @@ int SmsPluginMsgCodec::decodeMsg(const unsigned char *p_pkg_str, int pkg_len, sm
 
        char mti = p_pkg_str[0] & 0xff;
 
-       switch(mti) {
-               case SMS_TRANS_P2P_MSG:
-                       p_msg->type = SMS_TRANS_P2P_MSG;
-                       decodelen = decodeP2PMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.p2p_msg));
-                       break;
-               case SMS_TRANS_BROADCAST_MSG:
-                       p_msg->type = SMS_TRANS_BROADCAST_MSG;
-                       decodelen = decodeCBMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.cb_msg));
-                       break;
-               case SMS_TRANS_ACK_MSG:
-                       p_msg->type = SMS_TRANS_ACK_MSG;
-                       decodelen = decodeAckMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.ack_msg));
-                       break;
-               default:
-                       p_msg->type = SMS_TRANS_TYPE_RESERVED;
-                       break;
+       switch (mti) {
+       case SMS_TRANS_P2P_MSG:
+               p_msg->type = SMS_TRANS_P2P_MSG;
+               decodelen = decodeP2PMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.p2p_msg));
+               break;
+       case SMS_TRANS_BROADCAST_MSG:
+               p_msg->type = SMS_TRANS_BROADCAST_MSG;
+               decodelen = decodeCBMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.cb_msg));
+               break;
+       case SMS_TRANS_ACK_MSG:
+               p_msg->type = SMS_TRANS_ACK_MSG;
+               decodelen = decodeAckMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.ack_msg));
+               break;
+       default:
+               p_msg->type = SMS_TRANS_TYPE_RESERVED;
+               break;
        }
 
        MSG_END();
@@ -832,36 +843,36 @@ int SmsPluginMsgCodec::decodeP2PMsg(const unsigned char *p_pkg_str, int pkg_len,
 
        while (offset < pkg_len) {
                switch (p_pkg_str[offset]) {
-               case 0x00:                              // Teleservice Identifier
+               case 0x00:
+                       /* Teleservice Identifier */
                        offset += decodeTeleId(p_pkg_str+offset, pkg_len, &(p_p2p->telesvc_id));
                        break;
-
-               case 0x01:                              // Service Category
+                       case 0x01:
+                       /* Service Category */
                        offset += decodeSvcCtg(p_pkg_str+offset, pkg_len, &(p_p2p->svc_ctg));
                        break;
-
                case 0x02:
-               case 0x04:                              // Address
+               case 0x04:
+                       /* Address */
                        offset += decodeAddress(p_pkg_str+offset, pkg_len, &(p_p2p->address));
                        break;
-
                case 0x03:
-               case 0x05:                              // Subaddress
+               case 0x05:
+                       /* Subaddress */
                        offset += decodeSubAddress(p_pkg_str+offset, pkg_len, &(p_p2p->sub_address));
                        break;
-
-               case 0x06:                              // Bearer Reply Option
-                       offset+=2;
+               case 0x06:
+                       /* Bearer Reply Option*/
+                       offset += 2;
                        p_p2p->reply_seq = (sms_trans_reply_seq_t)(p_pkg_str[offset] >> 2);
                        offset++;
                        break;
-
-               case 0x08:                              // Bearer Data
+               case 0x08:
+                       /* Bearer Data */
                        tmp_len = p_pkg_str[++offset];
                        decodeP2PTelesvcMsg(p_pkg_str+offset+1, tmp_len, &p_p2p->telesvc_msg);
-                       offset+=(tmp_len+1);
+                       offset += (tmp_len+1);
                        break;
-
                default:
                        break;
                }
@@ -879,20 +890,20 @@ int SmsPluginMsgCodec::decodeCBMsg(const unsigned char *p_pkg_str, int pkg_len,
 
        int offset = 0, tmp_len = 0;
 
-       while(offset < pkg_len) {
-               if(p_pkg_str[offset] == 0x01) {                 // Service Category
+       while (offset < pkg_len) {
+               if (p_pkg_str[offset] == 0x01) {
+                       /* Service Category */
                        offset += decodeTeleId(p_pkg_str+offset, pkg_len, &(p_cb->svc_ctg));
-               }
-               else if(p_pkg_str[offset] == 0x08) {                                                    // Bearer Data
+               } else if (p_pkg_str[offset] == 0x08) {
+                       /* Bearer Data */
                        tmp_len = p_pkg_str[++offset];
-                       if(p_cb->svc_ctg >= SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL && p_cb->svc_ctg <= SMS_TRANS_SVC_CTG_CMAS_TEST) {
+                       if (p_cb->svc_ctg >= SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL && p_cb->svc_ctg <= SMS_TRANS_SVC_CTG_CMAS_TEST) {
                                decodeCBBearerData(p_pkg_str+offset+1, tmp_len, &(p_cb->telesvc_msg), true);
-                       }
-                       else {
+                       } else {
                                decodeCBBearerData(p_pkg_str+offset+1, tmp_len, &(p_cb->telesvc_msg), false);
                        }
 
-                       offset+=(tmp_len+1);
+                       offset += (tmp_len+1);
                }
        }
 
@@ -909,16 +920,17 @@ int SmsPluginMsgCodec::decodeAckMsg(const unsigned char *p_pkg_str, int pkg_len,
        int offset = 0;
 
        while (offset < pkg_len) {
-               if(p_pkg_str[offset] == 0x04) {                                 // Destination Address
+               if (p_pkg_str[offset] == 0x04) {
+                       /* Destination Address */
                        offset += decodeAddress(p_pkg_str+offset, pkg_len, &(p_ack->address));
-               }
-               else if(p_pkg_str[offset] == 0x05) {                                    // Destination Subaddress
+               } else if (p_pkg_str[offset] == 0x05) {
+                       /* Destination Subaddress */
                        offset += decodeSubAddress(p_pkg_str+offset, pkg_len, &(p_ack->sub_address));
-               }
-               else if(p_pkg_str[offset] == 0x07) {                                    // Cause Codes
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x07) {
+                       /* Cause Codes */
+                       offset += 2;
                        p_ack->cause_code.reply_seq = (sms_trans_reply_seq_t)p_pkg_str[offset] >> 2;
-                       switch(p_pkg_str[offset++] & 0x03) {
+                       switch (p_pkg_str[offset++] & 0x03) {
                        case 0x00:
                                p_ack->cause_code.error_class = SMS_TRANS_ERR_CLASS_NONE;
                                break;
@@ -932,7 +944,7 @@ int SmsPluginMsgCodec::decodeAckMsg(const unsigned char *p_pkg_str, int pkg_len,
                                break;
                        }
 
-                       if(p_ack->cause_code.error_class != SMS_TRANS_ERR_CLASS_NONE) {
+                       if (p_ack->cause_code.error_class != SMS_TRANS_ERR_CLASS_NONE) {
                                p_ack->cause_code.cause_code = (sms_trans_cause_code_t)p_pkg_str[offset++];
                        }
                }
@@ -969,7 +981,7 @@ void SmsPluginMsgCodec::decodeP2PTelesvcMsg(const unsigned char *p_pkg_str, int
                decodeP2PReadAckMsg(p_pkg_str, pkg_len, &p_telesvc->data.read_ack);
                break;
        case SMS_TYPE_SUBMIT_REPORT:
-//             decodeP2PSubmitReportMsg(p_pkg_str, pkg_len, &p_telesvc->data.report);
+               /* decodeP2PSubmitReportMsg(p_pkg_str, pkg_len, &p_telesvc->data.report); */
                break;
        default:
                break;
@@ -990,280 +1002,271 @@ void SmsPluginMsgCodec::decodeP2PDeliverMsg(const unsigned char *p_pkg_str, int
        while (offset < pkg_len) {
                MSG_DEBUG("current offset = [%d] [%x]", offset, p_pkg_str[offset]);
 
-               switch (p_pkg_str[offset])
-               {
-                       case 0x00:                              // Message Identifier
-                               offset += decodeMsgId(p_pkg_str+offset, 5, &(p_del->msg_id));
-                               break;
-
-                       case 0x01:                              // User Data
-                               offset += 2;
-                               tmp_len = p_pkg_str[offset-1];
-                               memset(tmp_str, 0x00, sizeof(tmp_str));
-                               memcpy(tmp_str, p_pkg_str+offset, tmp_len);
-                               decodeUserData(tmp_str, tmp_len, &(p_del->user_data));
-                               offset += tmp_len;
-                               break;
-
-                       case 0x03:                              // Message Center Time Stamp
-                               offset+=2;
-                               offset += decodeAbsTime(p_pkg_str+offset, &(p_del->time_stamp));
-                               break;
-
-                       case 0x04:                              // Validity Period - Absolute
-                               offset+=2;
-                               p_del->val_period.format = SMS_TIME_ABSOLUTE;
-                               offset += decodeAbsTime(p_pkg_str+offset, &(p_del->val_period.time.abs_time));
-                               break;
-
-                       case 0x05:                              // Validity Period - Relative
-                               offset+=2;
-                               p_del->val_period.format = SMS_TIME_RELATIVE;
-                               p_del->val_period.time.rel_time.rel_time = (sms_relative_time_t)p_pkg_str[offset++];
-                               break;
-
-                       case 0x08:                              // Priority Indicator
-                               offset+=2;
-                               p_del->priority = (sms_priority_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
-                               break;
-
-                       case 0x09:                              // Privacy Indicator
-                               offset+=2;
-                               p_del->privacy = (sms_privacy_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
-                               break;
-
-                       case 0x0a:                              // Reply Option
-                               offset+=2;
-
-                               if(p_pkg_str[offset] & 0x80)
-                                       p_del->reply_opt.user_ack_req = true;
-                               else
-                                       p_del->reply_opt.user_ack_req = false;
-
-                               if(p_pkg_str[offset] & 0x40)
-                                       p_del->reply_opt.deliver_ack_req = true;
-                               else
-                                       p_del->reply_opt.deliver_ack_req = false;
-
-                               if(p_pkg_str[offset] & 0x20)
-                                       p_del->reply_opt.read_ack_req = true;
-                               else
-                                       p_del->reply_opt.read_ack_req = false;
-
-                               if(p_pkg_str[offset] & 0x10)
-                                       p_del->reply_opt.report_req = true;
-                               else
-                                       p_del->reply_opt.report_req = false;
-
-                               offset++;
-                               break;
-
-                       case 0x0b:                              // Number of Message
-                               offset+=2;
-                               p_del->num_msg = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
-                               offset++;
-                               break;
-
-                       case 0x0c:                              // Alert on Message Delivery
-                               offset+=2;
-                               tmp_len = p_pkg_str[offset-1];
-                               if (tmp_len > 0)
-                                       p_del->alert_priority = (sms_alert_priority_t)((p_pkg_str[offset] & 0xc0) >> 6);
-                               offset+=tmp_len;
-                               break;
-
-                       case 0x0d:                              // Language Indicator
-                               offset+=2;
-                               p_del->language = (sms_language_type_t)p_pkg_str[offset++];
-                               break;
-
-                       case 0x0e:                              // Call-Back Number
-                               offset+=2;
-                               tmp_len = p_pkg_str[offset-1];
-
-                               decodeCallBackNum(&p_pkg_str[offset], tmp_len, &(p_del->callback_number));
-
-                               offset+=tmp_len;
-                               break;
+               switch (p_pkg_str[offset]) {
+               case 0x00:
+                       /* Message Identifier */
+                       offset += decodeMsgId(p_pkg_str+offset, 5, &(p_del->msg_id));
+                       break;
+               case 0x01:
+                       /* User Data */
+                       offset += 2;
+                       tmp_len = p_pkg_str[offset-1];
+                       memset(tmp_str, 0x00, sizeof(tmp_str));
+                       memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+                       decodeUserData(tmp_str, tmp_len, &(p_del->user_data));
+                       offset += tmp_len;
+                       break;
+               case 0x03:
+                       /* Message Center Time Stamp */
+                       offset += 2;
+                       offset += decodeAbsTime(p_pkg_str+offset, &(p_del->time_stamp));
+                       break;
+               case 0x04:
+                       /* Validity Period - Absolute */
+                       offset += 2;
+                       p_del->val_period.format = SMS_TIME_ABSOLUTE;
+                       offset += decodeAbsTime(p_pkg_str+offset, &(p_del->val_period.time.abs_time));
+                       break;
+               case 0x05:
+                       /* Validity Period - Relative */
+                       offset += 2;
+                       p_del->val_period.format = SMS_TIME_RELATIVE;
+                       p_del->val_period.time.rel_time.rel_time = (sms_relative_time_t)p_pkg_str[offset++];
+                       break;
+               case 0x08:
+                       /* Priority Indicator */
+                       offset += 2;
+                       p_del->priority = (sms_priority_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+                       break;
+               case 0x09:
+                       /* Privacy Indicator */
+                       offset += 2;
+                       p_del->privacy = (sms_privacy_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+                       break;
+               case 0x0a:
+                       /* Reply Option */
+                       offset += 2;
 
-                       case 0x0f:                              // Message Display Mode
-                               offset+=2;
+                       if (p_pkg_str[offset] & 0x80)
+                               p_del->reply_opt.user_ack_req = true;
+                       else
+                               p_del->reply_opt.user_ack_req = false;
 
-                               p_del->display_mode = (sms_display_mode_t)((p_pkg_str[offset++] & 0xc0) >> 6);
-                               break;
+                       if (p_pkg_str[offset] & 0x40)
+                               p_del->reply_opt.deliver_ack_req = true;
+                       else
+                               p_del->reply_opt.deliver_ack_req = false;
 
-                       case 0x10:                              // Multiple Encoding User Data
-                               offset+=2;
-                               tmp_len = p_pkg_str[offset-1];
+                       if (p_pkg_str[offset] & 0x20)
+                               p_del->reply_opt.read_ack_req = true;
+                       else
+                               p_del->reply_opt.read_ack_req = false;
 
+                       if (p_pkg_str[offset] & 0x10)
+                               p_del->reply_opt.report_req = true;
+                       else
+                               p_del->reply_opt.report_req = false;
 
-                               // TODO
+                       offset++;
+                       break;
+               case 0x0b:
+                       /* Number of Message */
+                       offset += 2;
+                       p_del->num_msg = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
+                       offset++;
+                       break;
+               case 0x0c:
+                       /* Alert on Message Delivery */
+                       offset += 2;
+                       tmp_len = p_pkg_str[offset-1];
+                       if (tmp_len > 0)
+                               p_del->alert_priority = (sms_alert_priority_t)((p_pkg_str[offset] & 0xc0) >> 6);
+                       offset += tmp_len;
+                       break;
+               case 0x0d:
+                       /* Language Indicator */
+                       offset += 2;
+                       p_del->language = (sms_language_type_t)p_pkg_str[offset++];
+                       break;
+               case 0x0e:
+                       /* Call-Back Number */
+                       offset += 2;
+                       tmp_len = p_pkg_str[offset-1];
 
+                       decodeCallBackNum(&p_pkg_str[offset], tmp_len, &(p_del->callback_number));
 
+                       offset += tmp_len;
+                       break;
+               case 0x0f:
+                       /* Message Display Mode */
+                       offset += 2;
 
-                               offset+=tmp_len;
-                               break;
+                       p_del->display_mode = (sms_display_mode_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+                       break;
+               case 0x10:
+                       /* Multiple Encoding User Data */
+                       offset += 2;
+                       tmp_len = p_pkg_str[offset-1];
 
-                       case 0x11:                              // Message Deposit Index
-                               offset+=2;
+                       /* TODO */
 
-                               memset(&tmp_param_s, 0x00, sizeof(unsigned short));
-                               _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
-                               p_del->deposit_id = tmp_param_s;
+                       offset += tmp_len;
+                       break;
+               case 0x11:
+                       /* Message Deposit Index */
+                       offset += 2;
 
-                               offset+=2;
-                               break;
+                       memset(&tmp_param_s, 0x00, sizeof(unsigned short));
+                       _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
+                       p_del->deposit_id = tmp_param_s;
 
-                       case 0x16:                              // Enhanced VMN
-                               offset++;
-                               tmp_len = p_pkg_str[offset++];
-                               memset(tmp_str, 0x00, sizeof(tmp_str));
-                               memcpy(tmp_str, p_pkg_str+offset, tmp_len);
-                               tmp_off = 0;
+                       offset += 2;
+                       break;
+               case 0x16:
+                       /* Enhanced VMN */
+                       offset++;
+                       tmp_len = p_pkg_str[offset++];
+                       memset(tmp_str, 0x00, sizeof(tmp_str));
+                       memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+                       tmp_off = 0;
 
-                               p_del->enhanced_vmn.priority = (sms_priority_indicator_t)(p_pkg_str[offset] >> 6);
-                               p_del->enhanced_vmn.password_req = p_pkg_str[offset] & 0x20 ? true : false;
-                               p_del->enhanced_vmn.setup_req = p_pkg_str[offset] & 0x10 ? true : false;
-                               p_del->enhanced_vmn.pw_change_req = p_pkg_str[offset] & 0x08 ? true : false;
-                               _shiftNBit_for_decode(tmp_str, tmp_len, 5);
+                       p_del->enhanced_vmn.priority = (sms_priority_indicator_t)(p_pkg_str[offset] >> 6);
+                       p_del->enhanced_vmn.password_req = p_pkg_str[offset] & 0x20 ? true : false;
+                       p_del->enhanced_vmn.setup_req = p_pkg_str[offset] & 0x10 ? true : false;
+                       p_del->enhanced_vmn.pw_change_req = p_pkg_str[offset] & 0x08 ? true : false;
+                       _shiftNBit_for_decode(tmp_str, tmp_len, 5);
 
-                               if(p_del->enhanced_vmn.setup_req || p_del->enhanced_vmn.pw_change_req) {
-                                       p_del->enhanced_vmn.min_pw_len = tmp_str[tmp_off] >> 4;
-                                       p_del->enhanced_vmn.max_pw_len = tmp_str[tmp_off++] & 0x0f;
-                               }
+                       if (p_del->enhanced_vmn.setup_req || p_del->enhanced_vmn.pw_change_req) {
+                               p_del->enhanced_vmn.min_pw_len = tmp_str[tmp_off] >> 4;
+                               p_del->enhanced_vmn.max_pw_len = tmp_str[tmp_off++] & 0x0f;
+                       }
 
-                               p_del->enhanced_vmn.vm_num_unheard_msg = tmp_str[tmp_off++];
-                               p_del->enhanced_vmn.vm_mailbox_alm_full = tmp_str[tmp_off] & 0x80 ? true : false;
-                               p_del->enhanced_vmn.vm_mailbox_full = tmp_str[tmp_off] & 0x40 ? true : false;
-                               p_del->enhanced_vmn.reply_allowed = tmp_str[tmp_off] & 0x20 ? true : false;
-                               p_del->enhanced_vmn.fax_included = tmp_str[tmp_off] & 0x10 ? true : false;
-                               p_del->enhanced_vmn.vm_len = ((tmp_str[tmp_off] >> 0x0f) << 8) | tmp_str[tmp_off+1];
-                               tmp_off+=2;
-                               p_del->enhanced_vmn.vm_ret_day = tmp_str[tmp_off] >> 1;
-                               _shiftNBit_for_decode(tmp_str, tmp_len, 7);
-                               p_del->enhanced_vmn.vm_msg_id = (tmp_str[tmp_off] << 8) | tmp_str[tmp_off+1];
-                               tmp_off+=2;
-                               p_del->enhanced_vmn.vm_mailbox_id = (tmp_str[tmp_off] << 8) | tmp_str[tmp_off+1];
-                               tmp_off+=2;
-
-                               p_del->enhanced_vmn.an_digit_mode = (sms_digit_mode_t)(tmp_str[tmp_off] & 0x80 ? true : false);
-                               p_del->enhanced_vmn.an_number_type = (sms_number_type_t)((tmp_str[tmp_off] & 0x70) >> 4);
-                               if (p_del->enhanced_vmn.an_digit_mode) {
-                                       p_del->enhanced_vmn.an_number_plan = (sms_number_plan_t)(tmp_str[tmp_off++] & 0x0f);
-                                       p_del->enhanced_vmn.an_num_field = tmp_str[tmp_off++];
-                                       for(int i=0; i<p_del->enhanced_vmn.an_num_field; i++) {
-                                               switch(tmp_str[tmp_off] & 0xf0)
-                                               {
-                                                       case 0x10:
-                                                       case 0x20:
-                                                       case 0x30:
-                                                       case 0x40:
-                                                       case 0x50:
-                                                       case 0x60:
-                                                       case 0x70:
-                                                       case 0x80:
-                                                       case 0x90:
-                                                               p_del->enhanced_vmn.an_char[i] = ((tmp_str[tmp_off] & 0xf0) >> 4) + '0';
-                                                               break;
-                                                       case 0xa0:
-                                                               p_del->enhanced_vmn.an_char[i] = '0';
-                                                               break;
-                                                       case 0xb0:
-                                                               p_del->enhanced_vmn.an_char[i] = '*';
-                                                               break;
-                                                       case 0xc0:
-                                                               p_del->enhanced_vmn.an_char[i] = '#';
-                                                               break;
-                                                       default:
-                                                               break;
-                                               }
-
-                                               _shiftNBit_for_decode(tmp_str, tmp_len, 4);
+                       p_del->enhanced_vmn.vm_num_unheard_msg = tmp_str[tmp_off++];
+                       p_del->enhanced_vmn.vm_mailbox_alm_full = tmp_str[tmp_off] & 0x80 ? true : false;
+                       p_del->enhanced_vmn.vm_mailbox_full = tmp_str[tmp_off] & 0x40 ? true : false;
+                       p_del->enhanced_vmn.reply_allowed = tmp_str[tmp_off] & 0x20 ? true : false;
+                       p_del->enhanced_vmn.fax_included = tmp_str[tmp_off] & 0x10 ? true : false;
+                       p_del->enhanced_vmn.vm_len = ((tmp_str[tmp_off] >> 0x0f) << 8) | tmp_str[tmp_off+1];
+                       tmp_off += 2;
+                       p_del->enhanced_vmn.vm_ret_day = tmp_str[tmp_off] >> 1;
+                       _shiftNBit_for_decode(tmp_str, tmp_len, 7);
+                       p_del->enhanced_vmn.vm_msg_id = (tmp_str[tmp_off] << 8) | tmp_str[tmp_off+1];
+                       tmp_off += 2;
+                       p_del->enhanced_vmn.vm_mailbox_id = (tmp_str[tmp_off] << 8) | tmp_str[tmp_off+1];
+                       tmp_off += 2;
+
+                       p_del->enhanced_vmn.an_digit_mode = (sms_digit_mode_t)(tmp_str[tmp_off] & 0x80 ? true : false);
+                       p_del->enhanced_vmn.an_number_type = (sms_number_type_t)((tmp_str[tmp_off] & 0x70) >> 4);
+                       if (p_del->enhanced_vmn.an_digit_mode) {
+                               p_del->enhanced_vmn.an_number_plan = (sms_number_plan_t)(tmp_str[tmp_off++] & 0x0f);
+                               p_del->enhanced_vmn.an_num_field = tmp_str[tmp_off++];
+                               for (int i=0; i<p_del->enhanced_vmn.an_num_field; i++) {
+                                       switch (tmp_str[tmp_off] & 0xf0) {
+                                       case 0x10:
+                                       case 0x20:
+                                       case 0x30:
+                                       case 0x40:
+                                       case 0x50:
+                                       case 0x60:
+                                       case 0x70:
+                                       case 0x80:
+                                       case 0x90:
+                                               p_del->enhanced_vmn.an_char[i] = ((tmp_str[tmp_off] & 0xf0) >> 4) + '0';
+                                               break;
+                                       case 0xa0:
+                                               p_del->enhanced_vmn.an_char[i] = '0';
+                                               break;
+                                       case 0xb0:
+                                               p_del->enhanced_vmn.an_char[i] = '*';
+                                               break;
+                                       case 0xc0:
+                                               p_del->enhanced_vmn.an_char[i] = '#';
+                                               break;
+                                       default:
+                                               break;
                                        }
-                               }
-                               else {
-                                       _shiftNBit_for_decode(tmp_str, tmp_len, 4);
-                                       p_del->enhanced_vmn.an_num_field = tmp_str[tmp_off++];
-                                       memset(p_del->enhanced_vmn.an_char, 0x00, sizeof(p_del->enhanced_vmn.an_char));
-                                       memcpy(p_del->enhanced_vmn.an_char, tmp_str+tmp_off, p_del->enhanced_vmn.an_num_field);
-                                       tmp_off+=p_del->enhanced_vmn.an_num_field;
-                               }
 
-                               p_del->enhanced_vmn.cli_digit_mode = (sms_digit_mode_t)(tmp_str[offset] & 0x80 ? true : false);
-                               p_del->enhanced_vmn.cli_number_type = (sms_number_type_t)(tmp_str[offset] & 0x70 >> 4);
-                               if (p_del->enhanced_vmn.cli_digit_mode) {
-                                       p_del->enhanced_vmn.cli_number_plan = (sms_number_plan_t)(tmp_str[tmp_off++] & 0x0f);
-                                       p_del->enhanced_vmn.cli_num_field = tmp_str[tmp_off++];
-                                       for(int i=0; i<p_del->enhanced_vmn.cli_num_field; i++) {
-                                               switch(tmp_str[tmp_off] & 0xf0)
-                                               {
-                                                       case 0x10:
-                                                       case 0x20:
-                                                       case 0x30:
-                                                       case 0x40:
-                                                       case 0x50:
-                                                       case 0x60:
-                                                       case 0x70:
-                                                       case 0x80:
-                                                       case 0x90:
-                                                               p_del->enhanced_vmn.cli_char[i] = ((tmp_str[tmp_off] & 0xf0) >> 4) + '0';
-                                                               break;
-                                                       case 0xa0:
-                                                               p_del->enhanced_vmn.cli_char[i] = '0';
-                                                               break;
-                                                       case 0xb0:
-                                                               p_del->enhanced_vmn.cli_char[i] = '*';
-                                                               break;
-                                                       case 0xc0:
-                                                               p_del->enhanced_vmn.cli_char[i] = '#';
-                                                               break;
-                                                       default:
-                                                               break;
-                                               }
-
-                                               _shiftNBit_for_decode(tmp_str, tmp_len, 4);
-                                       }
-                               }
-                               else {
                                        _shiftNBit_for_decode(tmp_str, tmp_len, 4);
-                                       p_del->enhanced_vmn.cli_num_field = tmp_str[tmp_off++];
-                                       memset(p_del->enhanced_vmn.cli_char, 0x00, sizeof(p_del->enhanced_vmn.cli_char));
-                                       memcpy(p_del->enhanced_vmn.cli_char, tmp_str+tmp_off, p_del->enhanced_vmn.cli_num_field);
-                                       tmp_off+=p_del->enhanced_vmn.cli_num_field;
                                }
+                       } else {
+                               _shiftNBit_for_decode(tmp_str, tmp_len, 4);
+                               p_del->enhanced_vmn.an_num_field = tmp_str[tmp_off++];
+                               memset(p_del->enhanced_vmn.an_char, 0x00, sizeof(p_del->enhanced_vmn.an_char));
+                               memcpy(p_del->enhanced_vmn.an_char, tmp_str+tmp_off, p_del->enhanced_vmn.an_num_field);
+                               tmp_off += p_del->enhanced_vmn.an_num_field;
+                       }
 
-                               offset+=tmp_len;
-                               break;
+                       p_del->enhanced_vmn.cli_digit_mode = (sms_digit_mode_t)(tmp_str[offset] & 0x80 ? true : false);
+                       p_del->enhanced_vmn.cli_number_type = (sms_number_type_t)(tmp_str[offset] & 0x70 >> 4);
+                       if (p_del->enhanced_vmn.cli_digit_mode) {
+                               p_del->enhanced_vmn.cli_number_plan = (sms_number_plan_t)(tmp_str[tmp_off++] & 0x0f);
+                               p_del->enhanced_vmn.cli_num_field = tmp_str[tmp_off++];
+                               for (int i=0; i<p_del->enhanced_vmn.cli_num_field; i++) {
+                                       switch (tmp_str[tmp_off] & 0xf0) {
+                                       case 0x10:
+                                       case 0x20:
+                                       case 0x30:
+                                       case 0x40:
+                                       case 0x50:
+                                       case 0x60:
+                                       case 0x70:
+                                       case 0x80:
+                                       case 0x90:
+                                               p_del->enhanced_vmn.cli_char[i] = ((tmp_str[tmp_off] & 0xf0) >> 4) + '0';
+                                               break;
+                                       case 0xa0:
+                                               p_del->enhanced_vmn.cli_char[i] = '0';
+                                               break;
+                                       case 0xb0:
+                                               p_del->enhanced_vmn.cli_char[i] = '*';
+                                               break;
+                                       case 0xc0:
+                                               p_del->enhanced_vmn.cli_char[i] = '#';
+                                               break;
+                                       default:
+                                               break;
+                                       }
 
-                       case 0x17:                              // Enhanced VMN Ack
-                               offset++;
-                               tmp_len = p_pkg_str[offset++];
-                               memset(tmp_str, 0x00, sizeof(tmp_str));
-                               memcpy(tmp_str, p_pkg_str+offset, tmp_len);
-                               p_del->enhanced_vmn_ack.vm_mailbox_id = tmp_str[offset] << 8 | tmp_str[offset+1];
-                               offset+=2;
-                               p_del->enhanced_vmn_ack.vm_num_unheard_msg = tmp_str[offset++];
-                               p_del->enhanced_vmn_ack.num_delete_ack = tmp_str[offset] >> 5;
-                               p_del->enhanced_vmn_ack.num_play_ack = (tmp_str[offset] & 0x1c) >> 2;
-                               _shiftNBit_for_decode(tmp_str, tmp_len, 6);
-                               for(int i=0; i<p_del->enhanced_vmn_ack.num_delete_ack; i++) {
-                                       p_del->enhanced_vmn_ack.da_vm_msg_id[i] = tmp_str[offset] << 8 | tmp_str[offset+1];
-                                       offset+=2;
-                               }
-                               for(int i=0; i<p_del->enhanced_vmn_ack.num_play_ack; i++) {
-                                       p_del->enhanced_vmn_ack.pa_vm_msg_id[i] = tmp_str[offset] << 8 | tmp_str[offset+1];
-                                       offset+=2;
+                                       _shiftNBit_for_decode(tmp_str, tmp_len, 4);
                                }
-                               break;
+                       } else {
+                               _shiftNBit_for_decode(tmp_str, tmp_len, 4);
+                               p_del->enhanced_vmn.cli_num_field = tmp_str[tmp_off++];
+                               memset(p_del->enhanced_vmn.cli_char, 0x00, sizeof(p_del->enhanced_vmn.cli_char));
+                               memcpy(p_del->enhanced_vmn.cli_char, tmp_str+tmp_off, p_del->enhanced_vmn.cli_num_field);
+                               tmp_off += p_del->enhanced_vmn.cli_num_field;
+                       }
 
-                       default:
-                               /* skip unrecognized sub parameters */
-                               offset++;
-                               tmp_len = p_pkg_str[offset++];
-                               offset += tmp_len;
-                               break;
+                       offset += tmp_len;
+                       break;
+               case 0x17:
+                       /* Enhanced VMN Ack */
+                       offset++;
+                       tmp_len = p_pkg_str[offset++];
+                       memset(tmp_str, 0x00, sizeof(tmp_str));
+                       memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+                       p_del->enhanced_vmn_ack.vm_mailbox_id = tmp_str[offset] << 8 | tmp_str[offset+1];
+                       offset += 2;
+                       p_del->enhanced_vmn_ack.vm_num_unheard_msg = tmp_str[offset++];
+                       p_del->enhanced_vmn_ack.num_delete_ack = tmp_str[offset] >> 5;
+                       p_del->enhanced_vmn_ack.num_play_ack = (tmp_str[offset] & 0x1c) >> 2;
+                       _shiftNBit_for_decode(tmp_str, tmp_len, 6);
+                       for (int i=0; i<p_del->enhanced_vmn_ack.num_delete_ack; i++) {
+                               p_del->enhanced_vmn_ack.da_vm_msg_id[i] = tmp_str[offset] << 8 | tmp_str[offset+1];
+                               offset += 2;
+                       }
+                       for (int i=0; i<p_del->enhanced_vmn_ack.num_play_ack; i++) {
+                               p_del->enhanced_vmn_ack.pa_vm_msg_id[i] = tmp_str[offset] << 8 | tmp_str[offset+1];
+                               offset += 2;
+                       }
+                       break;
+               default:
+                       /* skip unrecognized sub parameters */
+                       offset++;
+                       tmp_len = p_pkg_str[offset++];
+                       offset += tmp_len;
+                       break;
                }
-
        }
 
        MSG_END();
@@ -1277,11 +1280,11 @@ void SmsPluginMsgCodec::decodeP2PSubmitMsg(const unsigned char *p_pkg_str, int p
        unsigned char tmp_str[pkg_len+1];
 
        while (offset < pkg_len) {
-               if(p_pkg_str[offset] == 0x00) {                                 // Message Identifier
+               if (p_pkg_str[offset] == 0x00) {
+                       /* Message Identifier */
                        offset += decodeMsgId(p_pkg_str+offset, 5, &(p_sub->msg_id));
-               }
-
-               else if(p_pkg_str[offset] == 0x01) {                                    // User Data
+               } else if (p_pkg_str[offset] == 0x01) {
+                       /* User Data */
                        offset += 2;
                        tmp_len = p_pkg_str[offset-1];
                        memset(tmp_str, 0x00, sizeof(tmp_str));
@@ -1290,112 +1293,96 @@ void SmsPluginMsgCodec::decodeP2PSubmitMsg(const unsigned char *p_pkg_str, int p
                        decodeUserData(tmp_str, tmp_len, &(p_sub->user_data));
 
                        offset += tmp_len;
-               }
-
-               else if(p_pkg_str[offset] == 0x04) {                            // Validity Period - Absolute
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x04) {
+                       /* Validity Period - Absolute */
+                       offset += 2;
                        p_sub->val_period.format = SMS_TIME_ABSOLUTE;
                        offset += decodeAbsTime(p_pkg_str+offset, &(p_sub->val_period.time.abs_time));
-               }
-
-               else if(p_pkg_str[offset] == 0x05) {                            // Validity Period - Relative
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x05) {
+                       /* Validity Period - Relative */
+                       offset += 2;
                        p_sub->val_period.format = SMS_TIME_RELATIVE;
                        p_sub->val_period.time.rel_time.rel_time = (sms_relative_time_t)p_pkg_str[offset++];
-               }
-
-               else if(p_pkg_str[offset] == 0x06) {                            // Deferred Delivery Time - Absolute
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x06) {
+                       /* Deferred Delivery Time - Absolute */
+                       offset += 2;
                        p_sub->defer_val_period.format = SMS_TIME_ABSOLUTE;
                        offset += decodeAbsTime(p_pkg_str+offset, &(p_sub->defer_val_period.time.abs_time));
-               }
-
-               else if(p_pkg_str[offset] == 0x07) {                            // Deferred Delivery Time - Relative
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x07) {
+                       /* Deferred Delivery Time - Relative */
+                       offset += 2;
                        p_sub->defer_val_period.format = SMS_TIME_RELATIVE;
                        p_sub->defer_val_period.time.rel_time.rel_time = (sms_relative_time_t)p_pkg_str[offset++];
-               }
-
-               else if(p_pkg_str[offset] == 0x08) {                            // Priority indicator
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x08) {
+                       /* Priority indicator */
+                       offset += 2;
                        p_sub->priority = (sms_priority_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
-               }
-
-               else if(p_pkg_str[offset] == 0x09) {                            // Privacy indicator
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x09) {
+                       /* Privacy indicator */
+                       offset += 2;
                        p_sub->privacy = (sms_privacy_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
-               }
-
-               else if(p_pkg_str[offset] == 0x0a) {                            // Reply Option
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x0a) {
+                       /* Reply Option */
+                       offset += 2;
 
-                       if(p_pkg_str[offset] & 0x80)
+                       if (p_pkg_str[offset] & 0x80)
                                p_sub->reply_opt.user_ack_req = true;
                        else
                                p_sub->reply_opt.user_ack_req = false;
 
-                       if(p_pkg_str[offset] & 0x40)
+                       if (p_pkg_str[offset] & 0x40)
                                p_sub->reply_opt.deliver_ack_req = true;
                        else
                                p_sub->reply_opt.deliver_ack_req = false;
 
-                       if(p_pkg_str[offset] & 0x20)
+                       if (p_pkg_str[offset] & 0x20)
                                p_sub->reply_opt.read_ack_req = true;
                        else
                                p_sub->reply_opt.read_ack_req = false;
 
-                       if(p_pkg_str[offset] & 0x10)
+                       if (p_pkg_str[offset] & 0x10)
                                p_sub->reply_opt.report_req = true;
                        else
                                p_sub->reply_opt.report_req = false;
 
                        offset++;
-               }
-
-               else if(p_pkg_str[offset] == 0x0c) {                            // Alert on Message Delivery
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x0c) {
+                       /* Alert on Message Delivery */
+                       offset += 2;
 
                        p_sub->alert_priority = (sms_alert_priority_t)((p_pkg_str[offset++] & 0xc0) >> 6);
-               }
-
-               else if(p_pkg_str[offset] == 0x0d) {                            // Language Indicator
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x0d) {
+                       /* Language Indicator */
+                       offset += 2;
 
                        p_sub->language = (sms_language_type_t)p_pkg_str[offset++];
-               }
-
-               else if(p_pkg_str[offset] == 0x0e) {                            // Call-Back Number
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x0e) {
+                       /* Call-Back Number */
+                       offset += 2;
                        tmp_len = p_pkg_str[offset-1];
 
                        decodeCallBackNum(&p_pkg_str[offset], tmp_len, &(p_sub->callback_number));
 
-                       offset+=tmp_len;
-               }
-
-               else if(p_pkg_str[offset] == 0x10) {                            // Multiple Encoding User Data
-                       offset+=2;
+                       offset += tmp_len;
+               } else if (p_pkg_str[offset] == 0x10) {
+                       /* Multiple Encoding User Data */
+                       offset += 2;
                        tmp_len = p_pkg_str[offset-1];
 
+                       /* TODO */
 
-                       // TODO
-
-
-
-                       offset+=tmp_len;
-               }
-
-               else if(p_pkg_str[offset] == 0x11) {                            // Message Deposit Index
-                       offset+=2;
+                       offset += tmp_len;
+               } else if (p_pkg_str[offset] == 0x11) {
+                       /* Message Deposit Index */
+                       offset += 2;
 
                        memset(&tmp_param_s, 0x00, sizeof(unsigned short));
                        _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
                        p_sub->deposit_id = tmp_param_s;
 
-                       offset+=2;
+                       offset += 2;
                }
        }
-
 }
 
 
@@ -1408,11 +1395,11 @@ void SmsPluginMsgCodec::decodeP2PUserAckMsg(const unsigned char *p_pkg_str, int
        unsigned char tmp_str[pkg_len+1];
 
        while (offset < pkg_len) {
-               if(p_pkg_str[offset] == 0x00) {                                 // Message Identifier
+               if (p_pkg_str[offset] == 0x00) {
+                       /* Message Identifier */
                        offset += decodeMsgId(p_pkg_str+offset, 5, &(p_user_ack->msg_id));
-               }
-
-               else if(p_pkg_str[offset] == 0x01) {                                    // User Data
+               } else if (p_pkg_str[offset] == 0x01) {
+                       /* User Data */
                        offset += 2;
                        tmp_len = p_pkg_str[offset-1];
                        memset(tmp_str, 0x00, sizeof(tmp_str));
@@ -1421,38 +1408,31 @@ void SmsPluginMsgCodec::decodeP2PUserAckMsg(const unsigned char *p_pkg_str, int
                        decodeUserData(tmp_str, tmp_len, &(p_user_ack->user_data));
 
                        offset += tmp_len;
-               }
-
-               else if(p_pkg_str[offset] == 0x02) {                            // User Response Code
+               } else if (p_pkg_str[offset] == 0x02) {
+                       /* User Response Code */
                        offset += 2;
                        p_user_ack->resp_code = p_pkg_str[offset++];
-               }
-
-               else if(p_pkg_str[offset] == 0x03) {                            // Message Center Time Stamp
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x03) {
+                       /* Message Center Time Stamp */
+                       offset += 2;
                        offset += decodeAbsTime(p_pkg_str+offset, &(p_user_ack->time_stamp));
-               }
-
-               else if(p_pkg_str[offset] == 0x10) {                            // Multiple Encoding User Data
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x10) {
+                       /* Multiple Encoding User Data */
+                       offset += 2;
                        tmp_len = p_pkg_str[offset-1];
 
+                       /* TODO */
 
-                       // TODO
-
-
-
-                       offset+=tmp_len;
-               }
-
-               else if(p_pkg_str[offset] == 0x11) {                            // Message Deposit Index
-                       offset+=2;
+                       offset += tmp_len;
+               } else if (p_pkg_str[offset] == 0x11) {
+                       /* Message Deposit Index */
+                       offset += 2;
 
                        memset(&tmp_param_s, 0x00, sizeof(unsigned short));
                        _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
                        p_user_ack->deposit_id = tmp_param_s;
 
-                       offset+=2;
+                       offset += 2;
                }
        }
 
@@ -1469,11 +1449,11 @@ void SmsPluginMsgCodec::decodeP2PReadAckMsg(const unsigned char *p_pkg_str, int
        unsigned char tmp_str[pkg_len+1];
 
        while (offset < pkg_len) {
-               if(p_pkg_str[offset] == 0x00) {                                 // Message Identifier
+               if (p_pkg_str[offset] == 0x00) {
+                       /* Message Identifier */
                        offset += decodeMsgId(p_pkg_str+offset, 5, &(p_read_ack->msg_id));
-               }
-
-               else if(p_pkg_str[offset] == 0x01) {                                    // User Data
+               } else if (p_pkg_str[offset] == 0x01) {
+                       /* User Data */
                        offset += 2;
                        tmp_len = p_pkg_str[offset-1];
                        memset(tmp_str, 0x00, sizeof(tmp_str));
@@ -1482,33 +1462,27 @@ void SmsPluginMsgCodec::decodeP2PReadAckMsg(const unsigned char *p_pkg_str, int
                        decodeUserData(tmp_str, tmp_len, &(p_read_ack->user_data));
 
                        offset += tmp_len;
-               }
-
-               else if(p_pkg_str[offset] == 0x03) {                            // Message Center Time Stamp
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x03) {
+                       /* Message Center Time Stamp */
+                       offset += 2;
                        offset += decodeAbsTime(p_pkg_str+offset, &(p_read_ack->time_stamp));
-               }
-
-               else if(p_pkg_str[offset] == 0x10) {                            // Multiple Encoding User Data
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x10) {
+                       /* Multiple Encoding User Data */
+                       offset += 2;
                        tmp_len = p_pkg_str[offset-1];
 
+                       /* TODO */
 
-                       // TODO
-
-
-
-                       offset+=tmp_len;
-               }
-
-               else if(p_pkg_str[offset] == 0x11) {                            // Message Deposit Index
-                       offset+=2;
+                       offset += tmp_len;
+               } else if (p_pkg_str[offset] == 0x11) {
+                       /* Message Deposit Index */
+                       offset += 2;
 
                        memset(&tmp_param_s, 0x00, sizeof(unsigned short));
                        _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
                        p_read_ack->deposit_id = tmp_param_s;
 
-                       offset+=2;
+                       offset += 2;
                }
        }
 
@@ -1525,11 +1499,12 @@ void SmsPluginMsgCodec::decodeP2PSubmitReportMsg(const unsigned char *p_pkg_str,
 
        while (offset < pkg_len) {
                switch (p_pkg_str[offset]) {
-               case 0x00:                                      // Message Identifier
+               case 0x00:
+                       /* Message Identifier */
                        offset += decodeMsgId(p_pkg_str+offset, 5, &(p_sub_report->msg_id));
                        break;
-
-               case 0x01:                                      // User Data
+               case 0x01:
+                       /* User Data */
                        offset += 2;
                        tmp_len = p_pkg_str[offset-1];
                        memset(tmp_str, 0x00, sizeof(tmp_str));
@@ -1537,29 +1512,25 @@ void SmsPluginMsgCodec::decodeP2PSubmitReportMsg(const unsigned char *p_pkg_str,
                        decodeUserData(tmp_str, tmp_len, &(p_sub_report->user_data));
                        offset += tmp_len;
                        break;
-
-               case 0x0d:                                      // Language Indicator
-                       offset+=2;
+               case 0x0d:
+                       /* Language Indicator */
+                       offset += 2;
                        p_sub_report->language = (sms_language_type_t)p_pkg_str[offset++];
                        break;
-
-               case 0x10:                                      // Multiple Encoding User Data
-                       offset+=2;
+               case 0x10:
+                       /* Multiple Encoding User Data */
+                       offset += 2;
                        tmp_len = p_pkg_str[offset-1];
 
+                       /* TODO */
 
-                       // TODO
-
-
-
-                       offset+=tmp_len;
+                       offset += tmp_len;
                        break;
-
-               case 0x15:                                      // TP-Failure Cause
+               case 0x15:
+                       /* TP-Failure Cause */
                        offset += 2;
                        p_sub_report->tp_fail_cause = p_pkg_str[offset++];
                        break;
-
                default:
                        break;
                }
@@ -1576,13 +1547,14 @@ void SmsPluginMsgCodec::decodeP2PDeliveryAckMsg(const unsigned char *p_pkg_str,
        int offset = 0, tmp_len;
        unsigned char tmp_str[pkg_len+1];
 
-       while(offset < pkg_len) {
+       while (offset < pkg_len) {
                switch (p_pkg_str[offset]) {
-               case 0x00:                                      // Message Identifier
+               case 0x00:
+                       /* Message Identifier */
                        offset += decodeMsgId(p_pkg_str+offset, 5, &(p_del_ack->msg_id));
                        break;
-
-               case 0x01:                                      // User Data
+               case 0x01:
+                       /* User Data */
                        offset += 2;
                        tmp_len = p_pkg_str[offset-1];
                        memset(tmp_str, 0x00, sizeof(tmp_str));
@@ -1592,29 +1564,25 @@ void SmsPluginMsgCodec::decodeP2PDeliveryAckMsg(const unsigned char *p_pkg_str,
 
                        offset += tmp_len;
                        break;
-
-               case 0x03:                                      // Message Center Time Stamp
-                       offset+=2;
+               case 0x03:
+                       /* Message Center Time Stamp */
+                       offset += 2;
                        offset += decodeAbsTime(p_pkg_str+offset, &(p_del_ack->time_stamp));
                        break;
-
-               case 0x10:                                      // Multiple Encoding User Data
-                       offset+=2;
+               case 0x10:
+                       /* Multiple Encoding User Data */
+                       offset += 2;
                        tmp_len = p_pkg_str[offset-1];
 
+                       /* TODO */
 
-                       // TODO
-
-
-
-                       offset+=tmp_len;
+                       offset += tmp_len;
                        break;
-
-               case 0x14:                                      // Message Status
-                       offset+=2;
+               case 0x14:
+                       /* Message Status */
+                       offset += 2;
                        p_del_ack->msg_status = (sms_status_code_t)p_pkg_str[offset++];
                        break;
-
                default:
                        break;
                }
@@ -1632,84 +1600,72 @@ void SmsPluginMsgCodec::decodeCBBearerData(const unsigned char *p_pkg_str, int p
        unsigned char tmp_str[pkg_len+1];
 
        while (offset < pkg_len) {
-               if(p_pkg_str[offset] == 0x00) {                                 // Message Identifier
+               if (p_pkg_str[offset] == 0x00) {
+                       /* Message Identifier */
                        p_telesvc->type = SMS_TYPE_DELIVER;
                        offset += decodeMsgId(p_pkg_str+offset, 5, &(p_telesvc->data.deliver.msg_id));
-               }
-
-               else if(p_pkg_str[offset] == 0x01) {                                    // User Data
+               } else if (p_pkg_str[offset] == 0x01) {
+                       /* User Data */
                        offset += 2;
                        tmp_len = p_pkg_str[offset-1];
                        memset(tmp_str, 0x00, sizeof(tmp_str));
                        memcpy(tmp_str, p_pkg_str+offset, tmp_len);
 
-                       if(isCMAS)
+                       if (isCMAS)
                                decodeCMASData(tmp_str, tmp_len, &(p_telesvc->data.deliver.cmas_data));
                        else
                                decodeUserData(tmp_str, tmp_len, &(p_telesvc->data.deliver.user_data));
 
                        offset += tmp_len;
-               }
-
-               else if(p_pkg_str[offset] == 0x03) {                            // Message Center Time Stamp
+               } else if (p_pkg_str[offset] == 0x03) {
+                       /* Message Center Time Stamp */
                        offset += 2;
                        offset += decodeAbsTime(p_pkg_str+offset, &(p_telesvc->data.deliver.time_stamp));
-               }
-
-               else if(p_pkg_str[offset] == 0x04) {                            // Validity Period - Absolute
+               } else if (p_pkg_str[offset] == 0x04) {
+                       /* Validity Period - Absolute */
                        offset += 2;
                        p_telesvc->data.deliver.val_period.format = SMS_TIME_ABSOLUTE;
                        offset += decodeAbsTime(p_pkg_str+offset, &(p_telesvc->data.deliver.val_period.time.abs_time));
-               }
-
-               else if(p_pkg_str[offset] == 0x05) {                            // Validity Period - Relative
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x05) {
+                       /* Validity Period - Relative */
+                       offset += 2;
                        p_telesvc->data.deliver.val_period.format = SMS_TIME_RELATIVE;
                        p_telesvc->data.deliver.val_period.time.rel_time.rel_time = (sms_relative_time_t)p_pkg_str[offset++];
-               }
-
-               else if(p_pkg_str[offset] == 0x08) {                            // Priority indicator
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x08) {
+                       /* Priority indicator */
+                       offset += 2;
                        p_telesvc->data.deliver.priority = (sms_priority_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
-               }
-
-               else if(p_pkg_str[offset] == 0x0c) {                            // Alert on Message Delivery
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x0c) {
+                       /* Alert on Message Delivery */
+                       offset += 2;
 
                        p_telesvc->data.deliver.alert_priority = (sms_alert_priority_t)((p_pkg_str[offset++] & 0xc0) >> 6);
-               }
-
-               else if(p_pkg_str[offset] == 0x0d) {                            // Language Indicator
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x0d) {
+                       /* Language Indicator */
+                       offset += 2;
 
                        p_telesvc->data.deliver.language = (sms_language_type_t)p_pkg_str[offset++];
-               }
-
-               else if(p_pkg_str[offset] == 0x0e) {                            // Call-Back Number
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x0e) {
+                       /* Call-Back Number */
+                       offset += 2;
                        tmp_len = p_pkg_str[offset-1];
 
                        decodeCallBackNum(&p_pkg_str[offset], tmp_len, &(p_telesvc->data.deliver.callback_number));
 
-                       offset+=tmp_len;
-               }
-
-               else if(p_pkg_str[offset] == 0x0f) {                            // Message Display Mode
-                       offset+=2;
+                       offset += tmp_len;
+               } else if (p_pkg_str[offset] == 0x0f) {
+                       /* Message Display Mode */
+                       offset += 2;
 
                        p_telesvc->data.deliver.display_mode = (sms_display_mode_t)((p_pkg_str[offset++] & 0xc0) >> 6);
-               }
-
-               else if(p_pkg_str[offset] == 0x10) {                            // Multiple Encoding User Data
-                       offset+=2;
+               } else if (p_pkg_str[offset] == 0x10) {
+                       /* Multiple Encoding User Data */
+                       offset += 2;
                        tmp_len = p_pkg_str[offset-1];
 
+                       /* TODO */
 
-                       // TODO
-
-
-
-                       offset+=tmp_len;
+                       offset += tmp_len;
                }
        }
 
@@ -1722,38 +1678,38 @@ int SmsPluginMsgCodec::decodeTeleId(const unsigned char *p_pkg_str, int pkg_len,
        int offset = 0;
        unsigned short tmp_param_s;
 
-       offset+=2;
+       offset += 2;
 
     _copy_char_to_short(&tmp_param_s, &p_pkg_str[offset]);
 
-       switch(tmp_param_s) {
-               case SMS_TRANS_TELESVC_CMT_91:
-                       *tele_id = SMS_TRANS_TELESVC_CMT_91;
-                       break;
-               case SMS_TRANS_TELESVC_CPT_95:
-                       *tele_id = SMS_TRANS_TELESVC_CPT_95;
-                       break;
-               case SMS_TRANS_TELESVC_CMT_95:
-                       *tele_id = SMS_TRANS_TELESVC_CMT_95;
-                       break;
-               case SMS_TRANS_TELESVC_VMN_95:
-                       *tele_id = SMS_TRANS_TELESVC_VMN_95;
-                       break;
-               case SMS_TRANS_TELESVC_WAP:
-                       *tele_id = SMS_TRANS_TELESVC_WAP;
-                       break;
-               case SMS_TRANS_TELESVC_WEMT:
-                       *tele_id = SMS_TRANS_TELESVC_WEMT;
-                       break;
-               case SMS_TRANS_TELESVC_SCPT:
-                       *tele_id = SMS_TRANS_TELESVC_SCPT;
-                       break;
-               case SMS_TRANS_TELESVC_CATPT:
-                       *tele_id = SMS_TRANS_TELESVC_CATPT;
-                       break;
-               default:
-                       *tele_id = SMS_TRANS_TELESVC_RESERVED;
-                       break;
+       switch (tmp_param_s) {
+       case SMS_TRANS_TELESVC_CMT_91:
+               *tele_id = SMS_TRANS_TELESVC_CMT_91;
+               break;
+       case SMS_TRANS_TELESVC_CPT_95:
+               *tele_id = SMS_TRANS_TELESVC_CPT_95;
+               break;
+       case SMS_TRANS_TELESVC_CMT_95:
+               *tele_id = SMS_TRANS_TELESVC_CMT_95;
+               break;
+       case SMS_TRANS_TELESVC_VMN_95:
+               *tele_id = SMS_TRANS_TELESVC_VMN_95;
+               break;
+       case SMS_TRANS_TELESVC_WAP:
+               *tele_id = SMS_TRANS_TELESVC_WAP;
+               break;
+       case SMS_TRANS_TELESVC_WEMT:
+               *tele_id = SMS_TRANS_TELESVC_WEMT;
+               break;
+       case SMS_TRANS_TELESVC_SCPT:
+               *tele_id = SMS_TRANS_TELESVC_SCPT;
+               break;
+       case SMS_TRANS_TELESVC_CATPT:
+               *tele_id = SMS_TRANS_TELESVC_CATPT;
+               break;
+       default:
+               *tele_id = SMS_TRANS_TELESVC_RESERVED;
+               break;
        }
 
        return offset+2;
@@ -1765,15 +1721,14 @@ int SmsPluginMsgCodec::decodeSvcCtg(const unsigned char *p_pkg_str, int pkg_len,
        int offset = 0;
        unsigned short tmp_param_s;
 
-       offset+=2;
+       offset += 2;
 
        _copy_char_to_short(&tmp_param_s, &p_pkg_str[offset]);
-       if((tmp_param_s >= SMS_TRANS_SVC_CTG_UNKNOWN && tmp_param_s <= SMS_TRANS_SVC_CTG_KDDI_CORP_MAX1)
+       if ((tmp_param_s >= SMS_TRANS_SVC_CTG_UNKNOWN && tmp_param_s <= SMS_TRANS_SVC_CTG_KDDI_CORP_MAX1)
                || (tmp_param_s >= SMS_TRANS_SVC_CTG_KDDI_CORP_MIN2 && tmp_param_s <= SMS_TRANS_SVC_CTG_KDDI_CORP_MAX2)
                || (tmp_param_s >= SMS_TRANS_SVC_CTG_KDDI_CORP_MIN3 && tmp_param_s <= SMS_TRANS_SVC_CTG_KDDI_CORP_MAX3)) {
                *svc_ctg = (sms_trans_svc_ctg_t)tmp_param_s;
-       }
-       else {
+       } else {
                *svc_ctg = SMS_TRANS_SVC_CTG_RESERVED;
        }
 
@@ -1793,121 +1748,122 @@ int SmsPluginMsgCodec::decodeAddress(const unsigned char *p_pkg_str, int pkg_len
 
        offset += (tmp_len+1);
 
-       if(tmp_str[0] & 0x80)
+       if (tmp_str[0] & 0x80)
                addr->digit_mode = true;
        else
                addr->digit_mode = false;
 
-       if(tmp_str[0] & 0x40)
+       if (tmp_str[0] & 0x40)
                addr->number_mode = true;
        else
                addr->number_mode = false;
 
        _shiftNBit_for_decode(tmp_str, tmp_len, 2);
 
-       if(addr->digit_mode == false) {
+       if (addr->digit_mode == false) {
                addr->addr_len = tmp_str[0];
 
                memset(addr->szData, 0x00, sizeof(addr->szData));
 
-               for(unsigned int i = 0; i < addr->addr_len; i++) {
-                       switch(tmp_str[1] & 0xf0) {
-                               case 0x10:
-                               case 0x20:
-                               case 0x30:
-                               case 0x40:
-                               case 0x50:
-                               case 0x60:
-                               case 0x70:
-                               case 0x80:
-                               case 0x90:
-                                       addr->szData[i] = ((tmp_str[1] & 0xf0) >> 4) + '0';
-                                       break;
-                               case 0x00://sprint issue
-                               case 0xa0:
-                                       addr->szData[i] = '0';
-                                       break;
-                               case 0xb0:
-                                       addr->szData[i] = '*';
-                                       break;
-                               case 0xc0:
-                                       addr->szData[i] = '#';
-                                       break;
-                               default:
-                                       break;
+               for (unsigned int i = 0; i < addr->addr_len; i++) {
+                       switch (tmp_str[1] & 0xf0) {
+                       case 0x10:
+                       case 0x20:
+                       case 0x30:
+                       case 0x40:
+                       case 0x50:
+                       case 0x60:
+                       case 0x70:
+                       case 0x80:
+                       case 0x90:
+                               addr->szData[i] = ((tmp_str[1] & 0xf0) >> 4) + '0';
+                               break;
+                       case 0x00:
+                               /* sprint issue */
+                       case 0xa0:
+                               addr->szData[i] = '0';
+                               break;
+                       case 0xb0:
+                               addr->szData[i] = '*';
+                               break;
+                       case 0xc0:
+                               addr->szData[i] = '#';
+                               break;
+                       default:
+                               break;
                        }
 
                        _shiftNBit_for_decode(tmp_str, tmp_len, 4);
                }
-       }
-       else if(addr->digit_mode == true) {
-               if(addr->number_mode == false) {                                                // digit mode = 1, number mode = 0
-                       switch(tmp_str[0] & 0xe0) {
-                               case 0x00:
-                                       addr->number_type = SMS_NUMBER_TYPE_UNKNOWN;
-                                       break;
-                               case 0x20:
-                                       addr->number_type = SMS_NUMBER_TYPE_INTERNATIONAL;
-                                       break;
-                               case 0x40:
-                                       addr->number_type = SMS_NUMBER_TYPE_NATIONAL;
-                                       break;
-                               case 0x60:
-                                       addr->number_type = SMS_NUMBER_TYPE_NETWORK_SPECIFIC;
-                                       break;
-                               case 0x80:
-                                       addr->number_type = SMS_NUMBER_TYPE_SUBSCRIBER;
-                                       break;
-                               case 0xa0:
-                                       addr->number_type = SMS_NUMBER_TYPE_RESERVED_5;
-                                       break;
-                               case 0xc0:
-                                       addr->number_type = SMS_NUMBER_TYPE_ABBREVIATED;
-                                       break;
-                               case 0xe0:
-                                       addr->number_type = SMS_NUMBER_TYPE_RESERVED_7;
-                                       break;
+       } else if (addr->digit_mode == true) {
+               if (addr->number_mode == false) {
+                       /* digit mode = 1, number mode = 0 */
+                       switch (tmp_str[0] & 0xe0) {
+                       case 0x00:
+                               addr->number_type = SMS_NUMBER_TYPE_UNKNOWN;
+                               break;
+                       case 0x20:
+                               addr->number_type = SMS_NUMBER_TYPE_INTERNATIONAL;
+                               break;
+                       case 0x40:
+                               addr->number_type = SMS_NUMBER_TYPE_NATIONAL;
+                               break;
+                       case 0x60:
+                               addr->number_type = SMS_NUMBER_TYPE_NETWORK_SPECIFIC;
+                               break;
+                       case 0x80:
+                               addr->number_type = SMS_NUMBER_TYPE_SUBSCRIBER;
+                               break;
+                       case 0xa0:
+                               addr->number_type = SMS_NUMBER_TYPE_RESERVED_5;
+                               break;
+                       case 0xc0:
+                               addr->number_type = SMS_NUMBER_TYPE_ABBREVIATED;
+                               break;
+                       case 0xe0:
+                               addr->number_type = SMS_NUMBER_TYPE_RESERVED_7;
+                               break;
                        }
 
                        _shiftNBit_for_decode(tmp_str, tmp_len, 3);
 
-                       switch(tmp_str[0] & 0xf0) {
-                               case 0x00:
-                                       addr->number_plan = SMS_NPI_UNKNOWN;
-                                       break;
-                               case 0x10:
-                                       addr->number_plan = SMS_NPI_ISDN;
-                                       break;
-                               case 0x30:
-                                       addr->number_plan = SMS_NPI_DATA;
-                                       break;
-                               case 0x40:
-                                       addr->number_plan = SMS_NPI_TELEX;
-                                       break;
-                               case 0x90:
-                                       addr->number_plan = SMS_NPI_PRIVATE;
-                                       break;
-                               default:
-                                       addr->number_plan = SMS_NPI_RESERVED;
-                                       break;
+                       switch (tmp_str[0] & 0xf0) {
+                       case 0x00:
+                               addr->number_plan = SMS_NPI_UNKNOWN;
+                               break;
+                       case 0x10:
+                               addr->number_plan = SMS_NPI_ISDN;
+                               break;
+                       case 0x30:
+                               addr->number_plan = SMS_NPI_DATA;
+                               break;
+                       case 0x40:
+                               addr->number_plan = SMS_NPI_TELEX;
+                               break;
+                       case 0x90:
+                               addr->number_plan = SMS_NPI_PRIVATE;
+                               break;
+                       default:
+                               addr->number_plan = SMS_NPI_RESERVED;
+                               break;
                        }
 
                        _shiftNBit_for_decode(tmp_str, tmp_len, 4);
-               }
-               else if(addr->number_mode == true) {                                            // digit mode = 1, number mode = 1
-                       switch(tmp_str[0] & 0xe0) {
-                               case 0x00:
-                                       addr->number_type = SMS_TRANS_DNET_UNKNOWN;
-                                       break;
-                               case 0x20:
-                                       addr->number_type = SMS_TRANS_DNET_INTERNET_PROTOCOL;
-                                       break;
-                               case 0x40:
-                                       addr->number_type = SMS_TRANS_DNET_INTERNET_MAIL_ADDR;
-                                       break;
-                               default:
-                                       addr->number_type = SMS_TRANS_DNET_RESERVED;
-                                       break;
+               } else if (addr->number_mode == true) {
+                       /* digit mode = 1, number mode = 1 */
+                       switch (tmp_str[0] & 0xe0) {
+                       case 0x00:
+                               addr->number_type = SMS_TRANS_DNET_UNKNOWN;
+                               break;
+                       case 0x20:
+                               addr->number_type = SMS_TRANS_DNET_INTERNET_PROTOCOL;
+                               break;
+                       case 0x40:
+                               addr->number_type = SMS_TRANS_DNET_INTERNET_MAIL_ADDR;
+                               break;
+                       default:
+                               addr->number_type = SMS_TRANS_DNET_RESERVED;
+                               break;
                        }
 
                        _shiftNBit_for_decode(tmp_str, tmp_len, 3);
@@ -1934,19 +1890,19 @@ int SmsPluginMsgCodec::decodeSubAddress(const unsigned char *p_pkg_str, int pkg_
 
        offset += (tmp_len+1);
 
-       switch(tmp_str[0] & 0xe0) {
-               case 0x00:
-                       sub_addr->type = SMS_TRANS_SUB_ADDR_NSAP;
-                       break;
-               case 0x20:
-                       sub_addr->type = SMS_TRANS_SUB_ADDR_USER;
-                       break;
-               default:
-                       sub_addr->type = SMS_TRANS_SUB_ADDR_RESERVED;
-                       break;
+       switch (tmp_str[0] & 0xe0) {
+       case 0x00:
+               sub_addr->type = SMS_TRANS_SUB_ADDR_NSAP;
+               break;
+       case 0x20:
+               sub_addr->type = SMS_TRANS_SUB_ADDR_USER;
+               break;
+       default:
+               sub_addr->type = SMS_TRANS_SUB_ADDR_RESERVED;
+               break;
        }
 
-       if(tmp_str[0] & 0x10)
+       if (tmp_str[0] & 0x10)
                sub_addr->odd = true;
        else
                sub_addr->odd = false;
@@ -1974,12 +1930,12 @@ int SmsPluginMsgCodec::decodeMsgId(const unsigned char *p_pkg_str, int pkg_len,
        _copy_char_to_short(&tmp_param_s, tmp_str);
 
        p_msg_id->msg_id = tmp_param_s;
-       if(tmp_str[2] & 0x80)
+       if (tmp_str[2] & 0x80)
                p_msg_id->header_ind = true;
        else
                p_msg_id->header_ind = false;
 
-       offset+=5;
+       offset += 5;
 
        return offset;
 }
@@ -1990,39 +1946,39 @@ void SmsPluginMsgCodec::decodeCallBackNum(const unsigned char *p_pkg_str, int pk
        int offset = 0;
        unsigned char tmp_str[pkg_len+1];
 
-       if(p_pkg_str[offset] & 0x80) {
+       if (p_pkg_str[offset] & 0x80) {
                p_callback->digit_mode = true;
 
-               switch(p_pkg_str[offset] & 0x70) {
-                       case 0x00:
-                               p_callback->number_type = SMS_NUMBER_TYPE_UNKNOWN;
-                               break;
-                       case 0x10:
-                               p_callback->number_type = SMS_NUMBER_TYPE_INTERNATIONAL;
-                               break;
-                       case 0x20:
-                               p_callback->number_type = SMS_NUMBER_TYPE_NATIONAL;
-                               break;
-                       case 0x30:
-                               p_callback->number_type = SMS_NUMBER_TYPE_NETWORK_SPECIFIC;
-                               break;
-                       case 0x40:
-                               p_callback->number_type = SMS_NUMBER_TYPE_SUBSCRIBER;
-                               break;
-                       case 0x50:
-                               p_callback->number_type = SMS_NUMBER_TYPE_RESERVED_5;
-                               break;
-                       case 0x60:
-                               p_callback->number_type = SMS_NUMBER_TYPE_ABBREVIATED;
-                               break;
-                       case 0x70:
-                               p_callback->number_type = SMS_NUMBER_TYPE_RESERVED_7;
-                               break;
-                       default:
-                               break;
+               switch (p_pkg_str[offset] & 0x70) {
+               case 0x00:
+                       p_callback->number_type = SMS_NUMBER_TYPE_UNKNOWN;
+                       break;
+               case 0x10:
+                       p_callback->number_type = SMS_NUMBER_TYPE_INTERNATIONAL;
+                       break;
+               case 0x20:
+                       p_callback->number_type = SMS_NUMBER_TYPE_NATIONAL;
+                       break;
+               case 0x30:
+                       p_callback->number_type = SMS_NUMBER_TYPE_NETWORK_SPECIFIC;
+                       break;
+               case 0x40:
+                       p_callback->number_type = SMS_NUMBER_TYPE_SUBSCRIBER;
+                       break;
+               case 0x50:
+                       p_callback->number_type = SMS_NUMBER_TYPE_RESERVED_5;
+                       break;
+               case 0x60:
+                       p_callback->number_type = SMS_NUMBER_TYPE_ABBREVIATED;
+                       break;
+               case 0x70:
+                       p_callback->number_type = SMS_NUMBER_TYPE_RESERVED_7;
+                       break;
+               default:
+                       break;
                }
 
-               switch(p_pkg_str[offset++] & 0x0f) {
+               switch (p_pkg_str[offset++] & 0x0f) {
                case 0x00:
                        p_callback->number_plan = SMS_NPI_UNKNOWN;
                        break;
@@ -2049,15 +2005,13 @@ void SmsPluginMsgCodec::decodeCallBackNum(const unsigned char *p_pkg_str, int pk
 
                if (p_callback->number_type == SMS_NUMBER_TYPE_INTERNATIONAL) {
                        memcpy(&(p_callback->szData[1]), p_pkg_str+offset, p_callback->addr_len);
-                       if(p_callback->szData[1] != '\0') {
+                       if (p_callback->szData[1] != '\0') {
                                p_callback->szData[0] = '+';
                        }
-               }
-               else {
+               } else {
                        memcpy(p_callback->szData, p_pkg_str+offset, p_callback->addr_len);
                }
-       }
-       else {
+       } else {
                p_callback->digit_mode = false;
 
                memset(tmp_str, 0x00, sizeof(tmp_str));
@@ -2069,30 +2023,30 @@ void SmsPluginMsgCodec::decodeCallBackNum(const unsigned char *p_pkg_str, int pk
 
                memset(p_callback->szData, 0x00, sizeof(p_callback->szData));
 
-               for(unsigned int i = 0; i < p_callback->addr_len; i++) {
-                       switch(tmp_str[1] & 0xf0) {
-                               case 0x10:
-                               case 0x20:
-                               case 0x30:
-                               case 0x40:
-                               case 0x50:
-                               case 0x60:
-                               case 0x70:
-                               case 0x80:
-                               case 0x90:
-                                       p_callback->szData[i] = ((tmp_str[1] & 0xf0) >> 4) + '0';
-                                       break;
-                               case 0xa0:
-                                       p_callback->szData[i] = '0';
-                                       break;
-                               case 0xb0:
-                                       p_callback->szData[i] = '*';
-                                       break;
-                               case 0xc0:
-                                       p_callback->szData[i] = '#';
-                                       break;
-                               default :
-                                       break;
+               for (unsigned int i = 0; i < p_callback->addr_len; i++) {
+                       switch (tmp_str[1] & 0xf0) {
+                       case 0x10:
+                       case 0x20:
+                       case 0x30:
+                       case 0x40:
+                       case 0x50:
+                       case 0x60:
+                       case 0x70:
+                       case 0x80:
+                       case 0x90:
+                               p_callback->szData[i] = ((tmp_str[1] & 0xf0) >> 4) + '0';
+                               break;
+                       case 0xa0:
+                               p_callback->szData[i] = '0';
+                               break;
+                       case 0xb0:
+                               p_callback->szData[i] = '*';
+                               break;
+                       case 0xc0:
+                               p_callback->szData[i] = '#';
+                               break;
+                       default :
+                               break;
                        }
 
                        _shiftNBit_for_decode(tmp_str, pkg_len, 4);
@@ -2138,7 +2092,7 @@ int SmsPluginMsgCodec::encodeUserData(const unsigned char* src, unsigned char *d
        for (i = 0; i < src_size; i++) {
                shift = j % 7;
                dest[j++] = (tmp[i] << shift) + (tmp[i+1] >> (7-shift));
-               if(shift == 6) {
+               if (shift == 6) {
                        i++;
                }
        }
@@ -2162,8 +2116,7 @@ void SmsPluginMsgCodec::decodeCMASData(unsigned char *p_pkg_str, int pkg_len, sm
        if ((p_pkg_str[offset] & 0xf8) != 0x00) {
                MSG_ERR("Wrong Encode Type = [%d]!! The type must be 0", (p_pkg_str[offset]&0xf8)>>3);
                return;
-       }
-       else {
+       } else {
                _shiftNBit_for_decode(p_pkg_str, pkg_len, 5);
 
                offset++;
@@ -2183,77 +2136,76 @@ void SmsPluginMsgCodec::decodeCMASData(unsigned char *p_pkg_str, int pkg_len, sm
                                memset(tmp_str, 0x00, sizeof(tmp_str));
                                memcpy(tmp_str, p_pkg_str+offset, tmp_len);
 
-                               switch(tmp_str[0] & 0xf8) {
-                                       case 0x00:
-                                               p_cmas->encode_type = SMS_ENCODE_OCTET;
-                                               break;
-                                       case 0x08:
-                                               p_cmas->encode_type = SMS_ENCODE_EPM;
-                                               break;
-                                       case 0x10:
-                                               p_cmas->encode_type = SMS_ENCODE_7BIT_ASCII;
-                                               break;
-                                       case 0x18:
-                                               p_cmas->encode_type = SMS_ENCODE_IA5;
-                                               break;
-                                       case 0x20:
-                                               p_cmas->encode_type = SMS_ENCODE_UNICODE;
-                                               break;
-                                       case 0x28:
-                                               p_cmas->encode_type = SMS_ENCODE_SHIFT_JIS;
-                                               break;
-                                       case 0x30:
-                                               p_cmas->encode_type = SMS_ENCODE_KOREAN;
-                                               break;
-                                       case 0x38:
-                                               p_cmas->encode_type = SMS_ENCODE_LATIN_HEBREW;
-                                               break;
-                                       case 0x40:
-                                               p_cmas->encode_type = SMS_ENCODE_LATIN;
-                                               break;
-                                       case 0x48:
-                                               p_cmas->encode_type = SMS_ENCODE_GSM7BIT;
-                                               break;
-                                       case 0x50:
-                                               p_cmas->encode_type = SMS_ENCODE_GSMDCS;
-                                               break;
-                                       case 0x80:              // reserved value, but SKT use this value for KSC5601
-                                               p_cmas->encode_type = SMS_ENCODE_EUCKR;
-                                               break;
-                                       default :
-                                               p_cmas->encode_type = SMS_ENCODE_RESERVED;
-                                               break;
+                               switch (tmp_str[0] & 0xf8) {
+                               case 0x00:
+                                       p_cmas->encode_type = SMS_ENCODE_OCTET;
+                                       break;
+                               case 0x08:
+                                       p_cmas->encode_type = SMS_ENCODE_EPM;
+                                       break;
+                               case 0x10:
+                                       p_cmas->encode_type = SMS_ENCODE_7BIT_ASCII;
+                                       break;
+                               case 0x18:
+                                       p_cmas->encode_type = SMS_ENCODE_IA5;
+                                       break;
+                               case 0x20:
+                                       p_cmas->encode_type = SMS_ENCODE_UNICODE;
+                                       break;
+                               case 0x28:
+                                       p_cmas->encode_type = SMS_ENCODE_SHIFT_JIS;
+                                       break;
+                               case 0x30:
+                                       p_cmas->encode_type = SMS_ENCODE_KOREAN;
+                                       break;
+                               case 0x38:
+                                       p_cmas->encode_type = SMS_ENCODE_LATIN_HEBREW;
+                                       break;
+                               case 0x40:
+                                       p_cmas->encode_type = SMS_ENCODE_LATIN;
+                                       break;
+                               case 0x48:
+                                       p_cmas->encode_type = SMS_ENCODE_GSM7BIT;
+                                       break;
+                               case 0x50:
+                                       p_cmas->encode_type = SMS_ENCODE_GSMDCS;
+                                       break;
+                               case 0x80:
+                                       /* reserved value, but SKT use this value for KSC5601 */
+                                       p_cmas->encode_type = SMS_ENCODE_EUCKR;
+                                       break;
+                               default :
+                                       p_cmas->encode_type = SMS_ENCODE_RESERVED;
+                                       break;
                                }
                                _shiftNBit_for_decode(tmp_str, tmp_len, 5);
 
-                               switch(p_cmas->encode_type) {
-                                       case SMS_ENCODE_7BIT_ASCII:
-                                       case SMS_ENCODE_IA5:
-                                       case SMS_ENCODE_GSM7BIT:
-                                               memset(p_cmas->alert_text, 0x00, sizeof(p_cmas->alert_text));
-                                               p_cmas->data_len = (tmp_len*8-5) / 7;
-                                               for(unsigned int i = 0; i < p_cmas->data_len; i++) {
-                                                       p_cmas->alert_text[i] = tmp_str[0] >> 1;
-                                                       _shiftNBit_for_decode(tmp_str, tmp_len, 7);
-                                               }
-                                               break;
-                                       case SMS_ENCODE_EPM:
-                                               break;
-                                       case SMS_ENCODE_GSMDCS:
-                                               break;
-                                       default:
-                                               p_cmas->data_len = tmp_len - 1;
-                                               memset(p_cmas->alert_text, 0x00, sizeof(p_cmas->alert_text));
-                                               memcpy(p_cmas->alert_text, tmp_str+offset, tmp_len-1);
-                                               break;
+                               switch (p_cmas->encode_type) {
+                               case SMS_ENCODE_7BIT_ASCII:
+                               case SMS_ENCODE_IA5:
+                               case SMS_ENCODE_GSM7BIT:
+                                       memset(p_cmas->alert_text, 0x00, sizeof(p_cmas->alert_text));
+                                       p_cmas->data_len = (tmp_len*8-5) / 7;
+                                       for (unsigned int i = 0; i < p_cmas->data_len; i++) {
+                                               p_cmas->alert_text[i] = tmp_str[0] >> 1;
+                                               _shiftNBit_for_decode(tmp_str, tmp_len, 7);
+                                       }
+                                       break;
+                               case SMS_ENCODE_EPM:
+                                       break;
+                               case SMS_ENCODE_GSMDCS:
+                                       break;
+                               default:
+                                       p_cmas->data_len = tmp_len - 1;
+                                       memset(p_cmas->alert_text, 0x00, sizeof(p_cmas->alert_text));
+                                       memcpy(p_cmas->alert_text, tmp_str+offset, tmp_len-1);
+                                       break;
                                }
 
-                               offset+=tmp_len;
-                       }
-
-                       else if (p_pkg_str[offset] == 0x01) {
+                               offset += tmp_len;
+                       } else if (p_pkg_str[offset] == 0x01) {
                                MSG_DEBUG("Type 1 Decode!");
-                               offset+=2;
+                               offset += 2;
                                tmp_len = p_pkg_str[offset-1];
                                MSG_DEBUG("Type 1 length = [%d]", tmp_len);
                                p_cmas->category = (sms_cmae_category_t)p_pkg_str[offset++];
@@ -2261,15 +2213,13 @@ void SmsPluginMsgCodec::decodeCMASData(unsigned char *p_pkg_str, int pkg_len, sm
                                p_cmas->severity = (sms_cmae_severity_t)(p_pkg_str[offset] >> 4);
                                p_cmas->urgency = (sms_cmae_urgency_t)(p_pkg_str[offset++] & 0x0f);
                                p_cmas->certainty = (sms_cmae_certainty_t)(p_pkg_str[offset++] >> 4);
-                       }
-
-                       else if (p_pkg_str[offset] == 0x02) {
+                       } else if (p_pkg_str[offset] == 0x02) {
                                MSG_DEBUG("Type 2 Decode!");
-                               offset+=2;
+                               offset += 2;
                                tmp_len = p_pkg_str[offset-1];
                                MSG_DEBUG("Type 2 length = [%d]", tmp_len);
                                _copy_char_to_short(&(p_cmas->id), p_pkg_str+offset);
-                               offset+=2;
+                               offset += 2;
                                p_cmas->alert_handle = (sms_cmae_alert_handle_t)p_pkg_str[offset++];
                                offset += decodeAbsTime(p_pkg_str+offset, &(p_cmas->expires));
                                p_cmas->language = (sms_language_type_t)p_pkg_str[offset++];
@@ -2285,95 +2235,95 @@ void SmsPluginMsgCodec::decodeCMASData(unsigned char *p_pkg_str, int pkg_len, sm
 
 void SmsPluginMsgCodec::decodeUserData(unsigned char *p_pkg_str, int pkg_len, sms_telesvc_userdata_s *p_user)
 {
-       switch(p_pkg_str[0] & 0xf8) {
-               case 0x00:
-                       p_user->encode_type = SMS_ENCODE_OCTET;
-                       break;
-               case 0x08:
-                       p_user->encode_type = SMS_ENCODE_EPM;
-                       break;
-               case 0x10:
-                       p_user->encode_type = SMS_ENCODE_7BIT_ASCII;
-                       break;
-               case 0x18:
-                       p_user->encode_type = SMS_ENCODE_IA5;
-                       break;
-               case 0x20:
-                       p_user->encode_type = SMS_ENCODE_UNICODE;
-                       break;
-               case 0x28:
-                       p_user->encode_type = SMS_ENCODE_SHIFT_JIS;
-                       break;
-               case 0x30:
-                       p_user->encode_type = SMS_ENCODE_KOREAN;
-                       break;
-               case 0x38:
-                       p_user->encode_type = SMS_ENCODE_LATIN_HEBREW;
-                       break;
-               case 0x40:
-                       p_user->encode_type = SMS_ENCODE_LATIN;
-                       break;
-               case 0x48:
-                       p_user->encode_type = SMS_ENCODE_GSM7BIT;
-                       break;
-               case 0x50:
-                       p_user->encode_type = SMS_ENCODE_GSMDCS;
-                       break;
-               case 0x80:              // reserved value, but SKT use this value for KSC5601
-                       p_user->encode_type = SMS_ENCODE_EUCKR;
-                       break;
-               default :
-                       p_user->encode_type = SMS_ENCODE_RESERVED;
-                       break;
+       switch (p_pkg_str[0] & 0xf8) {
+       case 0x00:
+               p_user->encode_type = SMS_ENCODE_OCTET;
+               break;
+       case 0x08:
+               p_user->encode_type = SMS_ENCODE_EPM;
+               break;
+       case 0x10:
+               p_user->encode_type = SMS_ENCODE_7BIT_ASCII;
+               break;
+       case 0x18:
+               p_user->encode_type = SMS_ENCODE_IA5;
+               break;
+       case 0x20:
+               p_user->encode_type = SMS_ENCODE_UNICODE;
+               break;
+       case 0x28:
+               p_user->encode_type = SMS_ENCODE_SHIFT_JIS;
+               break;
+       case 0x30:
+               p_user->encode_type = SMS_ENCODE_KOREAN;
+               break;
+       case 0x38:
+               p_user->encode_type = SMS_ENCODE_LATIN_HEBREW;
+               break;
+       case 0x40:
+               p_user->encode_type = SMS_ENCODE_LATIN;
+               break;
+       case 0x48:
+               p_user->encode_type = SMS_ENCODE_GSM7BIT;
+               break;
+       case 0x50:
+               p_user->encode_type = SMS_ENCODE_GSMDCS;
+               break;
+       case 0x80:
+               /* reserved value, but SKT use this value for KSC5601 */
+               p_user->encode_type = SMS_ENCODE_EUCKR;
+               break;
+       default :
+               p_user->encode_type = SMS_ENCODE_RESERVED;
+               break;
        }
 
        _shiftNBit_for_decode(p_pkg_str, pkg_len, 5);
 
-       if(p_user->encode_type == SMS_ENCODE_EPM || p_user->encode_type == SMS_ENCODE_GSMDCS) {
+       if (p_user->encode_type == SMS_ENCODE_EPM || p_user->encode_type == SMS_ENCODE_GSMDCS) {
                p_user->msg_type = p_pkg_str[0];
                _shiftNBit_for_decode(p_pkg_str, pkg_len, 8);
        }
 
        p_user->data_len = p_pkg_str[0];
-       switch(p_user->encode_type) {
-               case SMS_ENCODE_7BIT_ASCII:
-                       memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
-                       for(unsigned int i = 0; i < p_user->data_len; i++) {
-                               p_user->user_data[i] = p_pkg_str[1] >> 1;
-                               _shiftNBit_for_decode(p_pkg_str, pkg_len, 7);
-                       }
-                       break;
-               case SMS_ENCODE_IA5:
-               case SMS_ENCODE_GSM7BIT:
-                       memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
-                       UnpackGSM7bitData(&(p_pkg_str[1]), p_user->user_data, p_user->data_len);
-                       break;
-               case SMS_ENCODE_EPM:
-                       break;
-               case SMS_ENCODE_GSMDCS:
-                       break;
-               case SMS_ENCODE_UNICODE:
-                       p_user->data_len*=2;
-                       memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
-                       memcpy(p_user->user_data, p_pkg_str+1, p_user->data_len);
-                       break;
-               default:
-                       memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
-                       memcpy(p_user->user_data, p_pkg_str+1, p_user->data_len);
-                       break;
+       switch (p_user->encode_type) {
+       case SMS_ENCODE_7BIT_ASCII:
+       case SMS_ENCODE_IA5:
+               memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
+               for (unsigned int i = 0; i < p_user->data_len; i++) {
+                       p_user->user_data[i] = p_pkg_str[1] >> 1;
+                       _shiftNBit_for_decode(p_pkg_str, pkg_len, 7);
+               }
+               break;
+       case SMS_ENCODE_GSM7BIT:
+               memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
+               UnpackGSM7bitData(&(p_pkg_str[1]), p_user->user_data, p_user->data_len);
+               break;
+       case SMS_ENCODE_EPM:
+               break;
+       case SMS_ENCODE_GSMDCS:
+               break;
+       case SMS_ENCODE_UNICODE:
+               p_user->data_len*=2;
+               memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
+               memcpy(p_user->user_data, p_pkg_str+1, p_user->data_len);
+               break;
+       default:
+               memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
+               memcpy(p_user->user_data, p_pkg_str+1, p_user->data_len);
+               break;
        }
-
 }
 
 
 sms_message_type_t SmsPluginMsgCodec::findMsgType(const unsigned char *p_pkg_str, int pkg_len)
 {
        int offset = 0;
-       while(offset < pkg_len) {
-               if(p_pkg_str[offset] == 0x00) {
+       while (offset < pkg_len) {
+               if (p_pkg_str[offset] == 0x00) {
                        return (sms_message_type_t)((p_pkg_str[offset+2]&0xf0)>>4);
                }
-               offset+=(p_pkg_str[offset+1]+2);
+               offset += (p_pkg_str[offset+1]+2);
        }
 
        return SMS_TYPE_MAX_VALUE;
index b8736e4..37112bd 100755 (executable)
@@ -41,7 +41,7 @@ SmsPluginEventHandler* SmsPluginEventHandler::pInstance = NULL;
 
 SmsPluginEventHandler::SmsPluginEventHandler()
 {
-       /**  Initialize global parameters */
+       /*  Initialize global parameters */
        memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S));
        memset(&sentInfo, 0x00, sizeof(sms_sent_info_s));
        devStatus = false;
@@ -62,6 +62,7 @@ SmsPluginEventHandler* SmsPluginEventHandler::instance()
        return pInstance;
 }
 
+
 void SmsPluginEventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
 {
        listener = *pListener;
@@ -72,7 +73,7 @@ void SmsPluginEventHandler::convertTpduToMsginfo(sms_trans_p2p_msg_s *p_p2p_msg,
 {
        MSG_BEGIN();
 
-       // Address
+       /* Address */
        if (p_p2p_msg->telesvc_msg.data.deliver.callback_number.szData[0] != '\0')
                p_msg_info->nAddressCnt = 2;
        else
@@ -82,14 +83,14 @@ void SmsPluginEventHandler::convertTpduToMsginfo(sms_trans_p2p_msg_s *p_p2p_msg,
 
        if (p_msg_info->addressList) {
                switch (p_msg_info->nAddressCnt) {
-                       case 2 :
-                               memset(p_msg_info->addressList[1].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
-                       case 1 :
-                               memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
-                               break;
-                       default :
-                               MSG_ERR("Invalid case");
-                               memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
+               case 2:
+                       memset(p_msg_info->addressList[1].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
+               case 1:
+                       memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
+                       break;
+               default:
+                       MSG_ERR("Invalid case");
+                       memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
                }
        }
 
@@ -100,24 +101,23 @@ void SmsPluginEventHandler::convertTpduToMsginfo(sms_trans_p2p_msg_s *p_p2p_msg,
        }
 
 
-       // Teleservice message
-       switch(p_p2p_msg->telesvc_msg.type)
-       {
-               case SMS_TYPE_DELIVER :
-                       p_msg_info->msgType.subType = MSG_NORMAL_SMS;
-                       p_msg_info->folderId = MSG_INBOX_ID;
-
-                       convertDeliverMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.deliver), p_msg_info);
-                       break;
-               case SMS_TYPE_DELIVERY_ACK :
-                       convertAckMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.delivery_ack), p_msg_info);
-                       break;
-               case SMS_TYPE_SUBMIT_REPORT :
-                       convertReportMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.report), p_msg_info);
-                       break;
-               default :
-                       MSG_DEBUG("No matching type = [%d]", p_p2p_msg->telesvc_msg.type);
-                       break;
+       /* Teleservice message */
+       switch (p_p2p_msg->telesvc_msg.type) {
+       case SMS_TYPE_DELIVER:
+       p_msg_info->msgType.subType = MSG_NORMAL_SMS;
+       p_msg_info->folderId = MSG_INBOX_ID;
+
+       convertDeliverMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.deliver), p_msg_info);
+       break;
+       case SMS_TYPE_DELIVERY_ACK:
+               convertAckMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.delivery_ack), p_msg_info);
+               break;
+       case SMS_TYPE_SUBMIT_REPORT:
+               convertReportMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.report), p_msg_info);
+               break;
+       default:
+               MSG_DEBUG("No matching type = [%d]", p_p2p_msg->telesvc_msg.type);
+               break;
        }
 
        MSG_END();
@@ -128,7 +128,7 @@ void SmsPluginEventHandler::convertTpduToMsginfo(sms_trans_broadcast_msg_s *p_cb
 {
        MSG_BEGIN();
 
-       // Address
+       /* Address */
        p_msg_info->nAddressCnt = 0;
        p_msg_info->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
 
@@ -136,8 +136,8 @@ void SmsPluginEventHandler::convertTpduToMsginfo(sms_trans_broadcast_msg_s *p_cb
                memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
        }
 
-       // Bearer Data
-       if(p_cb_msg->telesvc_msg.type == SMS_TYPE_DELIVER) {
+       /* Bearer Data */
+       if (p_cb_msg->telesvc_msg.type == SMS_TYPE_DELIVER) {
                p_msg_info->msgType.subType = MSG_CB_SMS;
                p_msg_info->folderId = MSG_CBMSGBOX_ID;
 
@@ -145,8 +145,7 @@ void SmsPluginEventHandler::convertTpduToMsginfo(sms_trans_broadcast_msg_s *p_cb
                        convertCMASMsgToMsgInfo(&(p_cb_msg->telesvc_msg.data.deliver), p_msg_info);
                else
                        convertDeliverMsgToMsgInfo(&(p_cb_msg->telesvc_msg.data.deliver), p_msg_info);
-       }
-       else {
+       } else {
                MSG_DEBUG("No matching type = [%d]", p_cb_msg->telesvc_msg.type);
        }
 
@@ -186,7 +185,8 @@ void SmsPluginEventHandler::convertCMASMsgToMsgInfo(sms_telesvc_deliver_s *p_del
        p_msg_info->direction = MSG_DIRECTION_TYPE_MT;
        p_msg_info->bTextSms = true;
 
-       if (p_deliver->callback_number.szData[0] != '\0') {                     // If callback number is in received pdu, replace the address value.
+       if (p_deliver->callback_number.szData[0] != '\0') {
+               /* If callback number is in received pdu, replace the address value. */
                memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
                p_msg_info->nAddressCnt = 1;
                p_msg_info->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
@@ -197,7 +197,7 @@ void SmsPluginEventHandler::convertCMASMsgToMsgInfo(sms_telesvc_deliver_s *p_del
        time_t rawtime = 0;
        p_msg_info->storageId = MSG_STORAGE_PHONE;
 
-#if 0 // Save Timestamp of message center.
+#if 0 /* Save Timestamp of message center. */
                char displayTime[32];
                struct tm * timeTM;
 
@@ -270,28 +270,24 @@ void SmsPluginEventHandler::convertCMASMsgToMsgInfo(sms_telesvc_deliver_s *p_del
                p_msg_info->dataSize = strlen(p_msg_info->msgData);
                return;
        } else {
-               if(p_msg_info->encodeType == MSG_ENCODE_UCS2) {
+               if (p_msg_info->encodeType == MSG_ENCODE_UCS2) {
                        MSG_DEBUG("Encode Type = UCS2");
                        MsgTextConvert *textCvt = MsgTextConvert::instance();
                        p_msg_info->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len);
-               }
-               else if(p_msg_info->encodeType == MSG_ENCODE_EUCKR) {
+               } else if (p_msg_info->encodeType == MSG_ENCODE_EUCKR) {
                        MSG_DEBUG("Encode Type = EUCKR");
                        MsgTextConvert *textCvt = MsgTextConvert::instance();
                        p_msg_info->dataSize = textCvt->convertEUCKRToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len);
-               }
-               else if(p_msg_info->encodeType == MSG_ENCODE_SHIFT_JIS) {
+               } else if (p_msg_info->encodeType == MSG_ENCODE_SHIFT_JIS) {
                        MSG_DEBUG("Encode Type = Shift-JIS");
                        MsgTextConvert *textCvt = MsgTextConvert::instance();
                        p_msg_info->dataSize = textCvt->convertSHIFTJISToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len);
-               }
-               else if(p_msg_info->encodeType == MSG_ENCODE_GSM7BIT) {
+               } else if (p_msg_info->encodeType == MSG_ENCODE_GSM7BIT) {
                        MSG_DEBUG("Encode Type = GSM7BIT");
                        MSG_LANG_INFO_S langinfo = {0,};
                        MsgTextConvert *textCvt = MsgTextConvert::instance();
                        p_msg_info->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len, &langinfo);
-               }
-               else {
+               } else {
                        snprintf(p_msg_info->msgText, sizeof(p_msg_info->msgText), "%s", p_deliver->cmas_data.alert_text);
                        p_msg_info->dataSize = p_deliver->cmas_data.data_len;
                }
@@ -306,10 +302,10 @@ void SmsPluginEventHandler::convertDeliverMsgToMsgInfo(sms_telesvc_deliver_s *p_
        MSG_BEGIN();
 
        p_msg_info->msgType.mainType = MSG_SMS_TYPE;
-//     p_msg_info->msgType.subType = MSG_NORMAL_SMS;
-
-//     p_msg_info->folderId = MSG_INBOX_ID;
-
+       /*
+       p_msg_info->msgType.subType = MSG_NORMAL_SMS;
+       p_msg_info->folderId = MSG_INBOX_ID;
+       */
        p_msg_info->msgType.classType = MSG_CLASS_NONE;
        p_msg_info->networkStatus = MSG_NETWORK_RECEIVED;
        p_msg_info->bRead = false;
@@ -317,7 +313,8 @@ void SmsPluginEventHandler::convertDeliverMsgToMsgInfo(sms_telesvc_deliver_s *p_
        p_msg_info->direction = MSG_DIRECTION_TYPE_MT;
        p_msg_info->bTextSms = true;
 
-       if (p_deliver->callback_number.szData[0] != '\0') {                     // If callback number is in received pdu, replace the address value.
+       if (p_deliver->callback_number.szData[0] != '\0') {
+               /* If callback number is in received pdu, replace the address value. */
                memset(p_msg_info->addressList[1].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
                p_msg_info->addressList[1].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
                memcpy(p_msg_info->addressList[1].addressVal, p_deliver->callback_number.szData, MAX_ADDRESS_VAL_LEN);
@@ -327,7 +324,7 @@ void SmsPluginEventHandler::convertDeliverMsgToMsgInfo(sms_telesvc_deliver_s *p_
        time_t rawtime = 0;
        p_msg_info->storageId = MSG_STORAGE_PHONE;
 
-#if 0 // Save Timestamp of message center.
+#if 0 /* Save Timestamp of message center. */
                char displayTime[32];
                struct tm * timeTM;
 
@@ -400,28 +397,24 @@ void SmsPluginEventHandler::convertDeliverMsgToMsgInfo(sms_telesvc_deliver_s *p_
                p_msg_info->dataSize = strlen(p_msg_info->msgData);
                return;
        } else {
-               if(p_msg_info->encodeType == MSG_ENCODE_UCS2) {
+               if (p_msg_info->encodeType == MSG_ENCODE_UCS2) {
                        MSG_DEBUG("Encode Type = UCS2");
                        MsgTextConvert *textCvt = MsgTextConvert::instance();
                        p_msg_info->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len);
-               }
-               else if(p_msg_info->encodeType == MSG_ENCODE_EUCKR) {
+               } else if (p_msg_info->encodeType == MSG_ENCODE_EUCKR) {
                        MSG_DEBUG("Encode Type = EUCKR");
                        MsgTextConvert *textCvt = MsgTextConvert::instance();
                        p_msg_info->dataSize = textCvt->convertEUCKRToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len);
-               }
-               else if(p_msg_info->encodeType == MSG_ENCODE_SHIFT_JIS) {
+               } else if (p_msg_info->encodeType == MSG_ENCODE_SHIFT_JIS) {
                        MSG_DEBUG("Encode Type = Shift-JIS");
                        MsgTextConvert *textCvt = MsgTextConvert::instance();
                        p_msg_info->dataSize = textCvt->convertSHIFTJISToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len);
-               }
-               else if(p_msg_info->encodeType == MSG_ENCODE_GSM7BIT) {
+               } else if (p_msg_info->encodeType == MSG_ENCODE_GSM7BIT) {
                        MSG_DEBUG("Encode Type = GSM7BIT");
                        MSG_LANG_INFO_S langinfo = {0,};
                        MsgTextConvert *textCvt = MsgTextConvert::instance();
                        p_msg_info->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len, &langinfo);
-               }
-               else {
+               } else {
                        snprintf(p_msg_info->msgText, sizeof(p_msg_info->msgText), "%s", p_deliver->user_data.user_data);
                        p_msg_info->dataSize = p_deliver->user_data.data_len;
                }
@@ -459,7 +452,7 @@ void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus)
        MSG_DEBUG("NetStatus[%d]", NetStatus);
 
        if (sentInfo.bLast == true || NetStatus != MSG_NETWORK_SEND_SUCCESS) {
-               /** Update Msg Status */
+               /* Update Msg Status */
                if (sentInfo.reqInfo.msgInfo.msgPort.valid == false) {
 
                        sentInfo.reqInfo.msgInfo.networkStatus = NetStatus;
@@ -477,12 +470,12 @@ void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus)
 
                MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bSetting [%d]", sentInfo.reqInfo.sendOptInfo.bSetting);
                MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bKeepCopy [%d]", sentInfo.reqInfo.sendOptInfo.bKeepCopy);
-               /** Check sending options */
+               /* Check sending options */
                if (sentInfo.reqInfo.sendOptInfo.bSetting && !sentInfo.reqInfo.sendOptInfo.bKeepCopy && NetStatus == MSG_NETWORK_SEND_SUCCESS) {
                        callbackStorageChange(MSG_STORAGE_CHANGE_DELETE, &(sentInfo.reqInfo.msgInfo));
                }
 
-               /** Callback to MSG FW */
+               /* Callback to MSG FW */
                MSG_SENT_STATUS_S msgStatus;
 
                msgStatus.reqId = sentInfo.reqInfo.reqId;
@@ -499,16 +492,16 @@ void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus)
 void SmsPluginEventHandler::handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
 {
 
-       /** Make MSG_MESSAGE_INFO_S */
+       /* Make MSG_MESSAGE_INFO_S */
        MSG_MESSAGE_INFO_S msgInfo;
 
-       /** initialize msgInfo */
+       /* initialize msgInfo */
        memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
 
        msgInfo.addressList = NULL;
        unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
 
-       /** convert to msgInfo */
+       /* convert to msgInfo */
        convertTpduToMsginfo(p_p2p_msg, &msgInfo);
 
        if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_RESERVED) {
@@ -517,7 +510,7 @@ void SmsPluginEventHandler::handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
                return;
        }
 
-       /** Check for Voice Mail Notification */
+       /* Check for Voice Mail Notification */
        if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_VMN_95) {
                if (p_p2p_msg->telesvc_msg.data.deliver.enhanced_vmn.fax_included)
                        msgInfo.msgType.subType = MSG_MWI_FAX_SMS;
@@ -529,7 +522,7 @@ void SmsPluginEventHandler::handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
 
                int voice_cnt = MsgSettingGetInt(VOICEMAIL_COUNT);
 
-               // repeated msg check for voicemail
+               /* repeated msg check for voicemail */
                if (voice_cnt == p_p2p_msg->telesvc_msg.data.deliver.num_msg) {
                        SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS, p_p2p_msg);
                        return;
@@ -541,9 +534,8 @@ void SmsPluginEventHandler::handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
 
                snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d", p_p2p_msg->telesvc_msg.data.deliver.num_msg);
                msgInfo.dataSize = strlen(msgInfo.msgText);
-       }
-       /** Check for EMS(Unsupported) */
-       else if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_WEMT) {
+       } else if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_WEMT) {
+               /* Check for EMS(Unsupported) */
                char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSGF_POP_ERROR_UNSUPPORTED_MSG");
                memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
                snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%s", msg_text);
@@ -555,7 +547,7 @@ void SmsPluginEventHandler::handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
                }
        }
 
-       /** Print MSG_MESSAGE_INFO_S */
+       /* Print MSG_MESSAGE_INFO_S */
        MSG_DEBUG("############# Convert  tpdu values to Message Info values ####################");
        MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
        MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
@@ -589,19 +581,21 @@ void SmsPluginEventHandler::handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
        memset(&unq_ind, 0x00, sizeof(MSG_UNIQUE_INDEX_S));
 
        if (msgInfo.msgType.subType == MSG_STATUS_REPORT_SMS) {
-//             /** Status Report Message */
-//             err = SmsPluginStorage::instance()->updateMsgDeliverStatus(&msgInfo, pTpdu->data.statusRep.msgRef);
-//
-//             if (err == MSG_SUCCESS)
-//                     err = listener.pfMsgIncomingCb(&msgInfo);
-//             else
-//                     MSG_DEBUG("updateMsgDeliverStatus is failed [%d]", err);
-//
-//             /** Handling of Fail Case ?? */
-//             SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS);
-       } else { /** SMS Deliver */
-
-               /** Add message to DB */
+               /* Status Report Message */
+               /*
+               err = SmsPluginStorage::instance()->updateMsgDeliverStatus(&msgInfo, pTpdu->data.statusRep.msgRef);
+
+               if (err == MSG_SUCCESS)
+                       err = listener.pfMsgIncomingCb(&msgInfo);
+               else
+                       MSG_DEBUG("updateMsgDeliverStatus is failed [%d]", err);
+               */
+
+               /* Handling of Fail Case ?? */
+               /* SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS); */
+       } else { /* SMS Deliver */
+
+               /* Add message to DB */
                if (msgInfo.msgPort.valid == false) {
                        if (p_p2p_msg->telesvc_id != SMS_TRANS_TELESVC_VMN_95) {
                                memcpy(unq_ind.address, p_p2p_msg->address.szData, sizeof(p_p2p_msg->address.szData));
@@ -618,13 +612,12 @@ void SmsPluginEventHandler::handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
 
                if (isUnique) {
                        err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
-               }
-               else {
+               } else {
                        SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS, p_p2p_msg);
                        return;
                }
 
-               /** Callback to MSG FW */
+               /* Callback to MSG FW */
                if (err == MSG_SUCCESS) {
                        MSG_DEBUG("callback to msg fw");
                        err = listener.pfMsgIncomingCb(&msgInfo);
@@ -639,14 +632,14 @@ void SmsPluginEventHandler::handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
                if (err == MSG_SUCCESS && p_p2p_msg->telesvc_id != SMS_TRANS_TELESVC_VMN_95)
                        listener.pfCheckUniquenessCb(&unq_ind, msgInfo.msgId, true);
 
-               /** Send Deliver Report */
+               /* Send Deliver Report */
                if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_WEMT) {
                        SmsPluginTransport::instance()->sendDeliverReport(MSG_ERR_INVALID_MSG_TYPE, p_p2p_msg);
                } else {
                        SmsPluginTransport::instance()->sendDeliverReport(err, p_p2p_msg);
                }
 
-               // Tizen Validation System
+               /* Tizen Validation System */
                char *msisdn = NULL;
                char keyName[MAX_VCONFKEY_NAME_LEN];
                int simIndex = 1;
@@ -681,20 +674,20 @@ void SmsPluginEventHandler::handleCbMsgIncoming(sms_trans_broadcast_msg_s *p_cb_
                return;
        }
 
-       /** Make MSG_MESSAGE_INFO_S */
+       /* Make MSG_MESSAGE_INFO_S */
        MSG_MESSAGE_INFO_S msgInfo;
 
-       /** initialize msgInfo */
+       /* initialize msgInfo */
        memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
 
        msgInfo.addressList = NULL;
        unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
 
-       /** convert to msgInfo */
+       /* convert to msgInfo */
        convertTpduToMsginfo(p_cb_msg, &msgInfo);
        msgInfo.msgId = p_cb_msg->telesvc_msg.data.deliver.msg_id.msg_id;
 
-       /** Print MSG_MESSAGE_INFO_S */
+       /* Print MSG_MESSAGE_INFO_S */
        MSG_DEBUG("############# Convert  tpdu values to Message Info values ####################");
        MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
        MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
@@ -721,18 +714,17 @@ void SmsPluginEventHandler::handleCbMsgIncoming(sms_trans_broadcast_msg_s *p_cb_
 
        msg_error_t err = MSG_SUCCESS;
 
-       /** Add message to DB */
+       /* Add message to DB */
        if (msgInfo.msgPort.valid == false) {
                err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
        }
 
-       if (!checkCbOpt(p_cb_msg->svc_ctg))
-       {
+       if (!checkCbOpt(p_cb_msg->svc_ctg)) {
                MSG_DEBUG("The CB Msg is not supported by option.");
                return;
        }
 
-       /** Callback to MSG FW */
+       /* Callback to MSG FW */
        if (err == MSG_SUCCESS) {
 
 #if 1
@@ -740,49 +732,46 @@ void SmsPluginEventHandler::handleCbMsgIncoming(sms_trans_broadcast_msg_s *p_cb_
                bool is_duplicate = false;
 
                switch (p_cb_msg->svc_ctg) {
-                       case SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL :
-                               msgInfo.msgType.subType = MSG_CMAS_PRESIDENTIAL;
-                               break;
-                       case SMS_TRANS_SVC_CTG_CMAS_EXTREME :
-                               msgInfo.msgType.subType = MSG_CMAS_EXTREME;
-                               break;
-                       case SMS_TRANS_SVC_CTG_CMAS_SEVERE :
-                               msgInfo.msgType.subType = MSG_CMAS_SEVERE;
-                               break;
-                       case SMS_TRANS_SVC_CTG_CMAS_AMBER :
-                               msgInfo.msgType.subType = MSG_CMAS_AMBER;
-                               break;
-                       case SMS_TRANS_SVC_CTG_CMAS_TEST :
-                               msgInfo.msgType.subType = MSG_CMAS_TEST;
-                               break;
-                       default :
-                               msgInfo.msgType.subType = MSG_CB_SMS;
-                               break;
+               case SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL :
+                       msgInfo.msgType.subType = MSG_CMAS_PRESIDENTIAL;
+                       break;
+               case SMS_TRANS_SVC_CTG_CMAS_EXTREME :
+                       msgInfo.msgType.subType = MSG_CMAS_EXTREME;
+                       break;
+               case SMS_TRANS_SVC_CTG_CMAS_SEVERE :
+                       msgInfo.msgType.subType = MSG_CMAS_SEVERE;
+                       break;
+               case SMS_TRANS_SVC_CTG_CMAS_AMBER :
+                       msgInfo.msgType.subType = MSG_CMAS_AMBER;
+                       break;
+               case SMS_TRANS_SVC_CTG_CMAS_TEST :
+                       msgInfo.msgType.subType = MSG_CMAS_TEST;
+                       break;
+               default :
+                       msgInfo.msgType.subType = MSG_CB_SMS;
+                       break;
                }
 
                cbOutMsg.type = msgInfo.msgType.subType;
                cbOutMsg.receivedTime = msgInfo.displayTime;
-               cbOutMsg.serialNum = 0;//encodeCbSerialNum (CbMsgPage.pageHeader.serialNum);
+               /* encodeCbSerialNum (CbMsgPage.pageHeader.serialNum); */
+               cbOutMsg.serialNum = 0;
                cbOutMsg.messageId = msgInfo.msgId;
-//             cbOutMsg.dcs = CbMsgPage.pageHeader.dcs.rawData;
+               /* cbOutMsg.dcs = CbMsgPage.pageHeader.dcs.rawData; */
                memset (cbOutMsg.cbText, 0x00, sizeof(cbOutMsg.cbText));
 
                cbOutMsg.cbTextLen= msgInfo.dataSize;
                memset(cbOutMsg.language_type, 0x00, sizeof(cbOutMsg.language_type));
-//             memcpy(cbOutMsg.language_type, CbMsgPage.pageHeader.dcs.iso639Lang, 3);
+               /* memcpy(cbOutMsg.language_type, CbMsgPage.pageHeader.dcs.iso639Lang, 3); */
 
-               if (!is_duplicate)
-               {
+               if (!is_duplicate) {
                        MSG_DEBUG("callback to msg fw");
                        err = listener.pfCBMsgIncomingCb(&cbOutMsg, &msgInfo);
 
-                       if (err != MSG_SUCCESS)
-                       {
+                       if (err != MSG_SUCCESS) {
                                MSG_WARN("callbackMsgIncoming() Error !! [%d]", err);
                        }
-               }
-               else
-               {
+               } else {
                        MSG_WARN("duplicate cb serialNum[%d] messageId[%d]", cbOutMsg.serialNum, cbOutMsg.messageId);
                }
 
@@ -791,10 +780,10 @@ void SmsPluginEventHandler::handleCbMsgIncoming(sms_trans_broadcast_msg_s *p_cb_
 #endif
        }
 
-       /** Send Deliver Report */
-//     SmsPluginTransport::instance()->sendDeliverReport(err, p_cb_msg);
+       /* Send Deliver Report */
+       /* SmsPluginTransport::instance()->sendDeliverReport(err, p_cb_msg); */
 
-       // Tizen Validation System
+       /* Tizen Validation System */
        char *msisdn = NULL;
        char keyName[MAX_VCONFKEY_NAME_LEN];
        int simIndex = 1;
@@ -879,8 +868,7 @@ void SmsPluginEventHandler::handleWapMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
                        ((pTmpUserData[6] << 8 | pTmpUserData[7]) == 0x0b84)) {
                        dataSize -= 8;
                        memcpy(pUserData, &pTmpUserData[8], dataSize);
-               }
-               else {
+               } else {
                        dataSize -= 4;
                        memcpy(pUserData, &pTmpUserData[4], dataSize);
                }
@@ -895,13 +883,12 @@ void SmsPluginEventHandler::handleWapMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
                                msgInfo.msgType.mainType = MSG_SMS_TYPE;
                                SmsPluginWapPushHandler::instance()->copyDeliverData(&(p_p2p_msg->address));
                                SmsPluginWapPushHandler::instance()->handleWapPushMsg(pUserData, dataSize);
-                       }
-                       else {
+                       } else {
                                MSG_DEBUG("not supported wap push port [%x]", dstPort);
                        }
                }
 
-               // remove from waplist
+               /* remove from waplist */
                for (int index = wapList.size()-1; index >= 0 ; index--) {
                        if (wapList[index].msgId == msg.msgId) {
                                MSG_DEBUG("remove waplist of the index [%d]", index);
@@ -911,7 +898,7 @@ void SmsPluginEventHandler::handleWapMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
                }
        }
 
-       /** Send Deliver Report */
+       /* Send Deliver Report */
        SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS, p_p2p_msg);
 
        MSG_END();
@@ -930,7 +917,7 @@ msg_error_t SmsPluginEventHandler::callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgI
 
        msg_error_t err = MSG_SUCCESS;
 
-       /** Callback to MSG FW */
+       /* Callback to MSG FW */
        err = listener.pfMsgIncomingCb(pMsgInfo);
 
        MSG_END();
@@ -941,7 +928,7 @@ msg_error_t SmsPluginEventHandler::callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgI
 
 msg_error_t SmsPluginEventHandler::callbackStorageChange(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
 {
-       /** Callback to MSG FW */
+       /* Callback to MSG FW */
        listener.pfStorageChangeCb(storageChangeType, pMsgInfo);
 
        return MSG_SUCCESS;
@@ -974,37 +961,42 @@ bool SmsPluginEventHandler::getDeviceStatus()
        return devStatus;
 }
 
+
 void SmsPluginEventHandler::setNeedInitConfig(bool bNeeded)
 {
        bNeedInitConfig = bNeeded;
 }
 
+
 bool SmsPluginEventHandler::getNeedInitConfig()
 {
        return bNeedInitConfig;
 }
 
+
 msg_encode_type_t SmsPluginEventHandler::getEncodeType(sms_encoding_type_t encode_type)
 {
-       switch(encode_type) {
-               case SMS_ENCODE_IA5 :
-               case SMS_ENCODE_GSM7BIT :
-                       return MSG_ENCODE_GSM7BIT;
-               case SMS_ENCODE_KOREAN :
-               case SMS_ENCODE_EUCKR :
-                       return MSG_ENCODE_EUCKR;
-               case SMS_ENCODE_7BIT_ASCII :
-               case SMS_ENCODE_LATIN_HEBREW :
-               case SMS_ENCODE_LATIN :
-               case SMS_ENCODE_OCTET :
-                       return MSG_ENCODE_8BIT;
-               case SMS_ENCODE_SHIFT_JIS :
-                       return MSG_ENCODE_SHIFT_JIS;
-//             case SMS_ENCODE_EPM :
-//             case SMS_ENCODE_UNICODE :
-//             case SMS_ENCODE_GSMDCS :
-               default :
-                       return MSG_ENCODE_UCS2;
+       switch (encode_type) {
+       case SMS_ENCODE_GSM7BIT:
+               return MSG_ENCODE_GSM7BIT;
+       case SMS_ENCODE_KOREAN:
+       case SMS_ENCODE_EUCKR:
+               return MSG_ENCODE_EUCKR;
+       case SMS_ENCODE_IA5:
+       case SMS_ENCODE_7BIT_ASCII:
+       case SMS_ENCODE_LATIN_HEBREW:
+       case SMS_ENCODE_LATIN:
+       case SMS_ENCODE_OCTET:
+               return MSG_ENCODE_8BIT;
+       case SMS_ENCODE_SHIFT_JIS:
+               return MSG_ENCODE_SHIFT_JIS;
+       /*
+       case SMS_ENCODE_EPM :
+       case SMS_ENCODE_UNICODE :
+       case SMS_ENCODE_GSMDCS :
+       */
+       default:
+               return MSG_ENCODE_UCS2;
        }
 
        return MSG_ENCODE_UCS2;
@@ -1045,7 +1037,7 @@ unsigned short SmsPluginEventHandler::checkWapMsg(sms_wap_msg_s *pMsg, sms_teles
                }
        }
 
-       /** New Wap Push Msg */
+       /* New Wap Push Msg */
        if (bFind == false) {
                sms_wap_info_s tmpInfo;
                tmpInfo.msgId = pMsg->msgId;
@@ -1113,7 +1105,7 @@ void SmsPluginEventHandler::handleSyncMLMsgIncoming(msg_syncml_message_type_t ms
 
        memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
 
-       /** set syncML data */
+       /* set syncML data */
        syncMLData.syncmlType = msgType;
 
        syncMLData.pushBodyLen = PushBodyLen;
@@ -1122,7 +1114,7 @@ void SmsPluginEventHandler::handleSyncMLMsgIncoming(msg_syncml_message_type_t ms
        syncMLData.wspHeaderLen= WspHeaderLen;
        memcpy(syncMLData.wspHeader, pWspHeader, WspHeaderLen);
 
-       /** Callback to MSG FW */
+       /* Callback to MSG FW */
        listener.pfSyncMLMsgIncomingCb(&syncMLData);
 }
 
@@ -1133,13 +1125,13 @@ void SmsPluginEventHandler::handleLBSMsgIncoming(char* pPushHeader, char* pPushB
 
        memset(&lBSData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
 
-       /** set LBA data */
+       /* set LBA data */
        memcpy(lBSData.pushHeader, pPushHeader, strlen(pPushHeader));
 
        lBSData.pushBodyLen = pushBodyLen;
        memcpy(lBSData.pushBody, pPushBody, pushBodyLen);
 
-       /** Callback to MSG FW */
+       /* Callback to MSG FW */
        listener.pfLBSMsgIncomingCb(&lBSData);
 }
 
@@ -1150,7 +1142,7 @@ void SmsPluginEventHandler::handlePushMsgIncoming(char* pPushHeader, char* pPush
 
        memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S));
 
-       /** set PUSH data */
+       /* set PUSH data */
        memcpy(pushData.pushHeader, pPushHeader, strlen(pPushHeader));
 
        pushData.pushBodyLen = pushBodyLen;
@@ -1159,7 +1151,7 @@ void SmsPluginEventHandler::handlePushMsgIncoming(char* pPushHeader, char* pPush
        memcpy(pushData.pushAppId, application_id, MAX_WAPPUSH_ID_LEN);
        memcpy(pushData.pushContentType, content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);
 
-       /** Callback to MSG FW */
+       /* Callback to MSG FW */
        listener.pfPushMsgIncomingCb(&pushData);
 }
 
@@ -1167,11 +1159,15 @@ void SmsPluginEventHandler::handlePushMsgIncoming(char* pPushHeader, char* pPush
 bool SmsPluginEventHandler::checkCbOpt(sms_trans_svc_ctg_t svc_ctg)
 {
        bool bReceive = false;
-       MsgSettingGetBool(CB_RECEIVE, &bReceive);
+       char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
+       int sim_idx = 1;
+
+       memset(keyName, 0x00, sizeof(keyName));
+       snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, sim_idx);
+       MsgSettingGetBool(keyName, &bReceive);
 
-       // Receive CB Msg = FALSE
-       if (!bReceive)
-       {
+       /* Receive CB Msg = FALSE */
+       if (!bReceive) {
                MSG_DEBUG("RECEIVE CB = FALSE");
                return false;
        }
@@ -1189,13 +1185,11 @@ bool SmsPluginEventHandler::checkCbOpt(sms_trans_svc_ctg_t svc_ctg)
                        return false;
                }
 
-               for (int i = 0; i < cbChannelInfo.channelCnt; i++)
-               {
+               for (int i = 0; i < cbChannelInfo.channelCnt; i++) {
                        bActivate = cbChannelInfo.channelInfo[i].bActivate;
                        Category = cbChannelInfo.channelInfo[i].ctg;
 
-                       if (bActivate == true && svc_ctg == Category)
-                       {
+                       if (bActivate == true && svc_ctg == Category) {
                                MSG_DEBUG("FIND CHANNEL = [%d]", svc_ctg);
                                return true;
                        }
index f597b7d..fb4d7e2 100755 (executable)
@@ -70,15 +70,13 @@ static void MsgTapiInitCB(keynode_t *key, void* data)
        mx.unlock();
 }
 
+
 msg_error_t MsgPlgCreateHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
 {
-       if (pPluginHandle == NULL)
-       {
+       if (pPluginHandle == NULL) {
                MSG_DEBUG("SMS plugin: create handler error ");
                return MSG_ERR_NULL_POINTER;
-       }
-       else
-       {
+       } else {
                pPluginHandle->pfInitialize = SmsPlgInitialize;
                pPluginHandle->pfFinalize = SmsPlgFinalize;
                pPluginHandle->pfRegisterListener = SmsPlgRegisterListener;
@@ -101,8 +99,7 @@ msg_error_t MsgPlgCreateHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
 
 msg_error_t MsgPlgDestroyHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
 {
-       if (pPluginHandle != NULL)
-       {
+       if (pPluginHandle != NULL) {
                free(pPluginHandle);
                pPluginHandle = NULL;
        }
@@ -123,7 +120,7 @@ msg_error_t SmsPlgInitialize()
                MsgSettingGetBool(VCONFKEY_TELEPHONY_READY, &bReady);
                MSG_DEBUG("Get VCONFKEY_TELEPHONY_READY [%d].", bReady ? 1 : 0);
 
-               if(bReady)
+               if (bReady)
                        break;
 
                sleep(1);
@@ -137,14 +134,14 @@ msg_error_t SmsPlgInitialize()
        pTapiHandle = tel_init(NULL);
 
        if (pTapiHandle) {
-               // register event.
+               /* register event. */
                SmsPluginCallback::instance()->registerEvent();
 
-               // set sim change status.
+               /* set sim change status. */
                MSG_DEBUG("Try to initialize SIM on init");
                SmsPluginSetting::instance()->setSimChangeStatus();
 
-               // set resource monitor
+               /* set resource monitor */
                MsgResourceMonitorInit();
        }
 
@@ -189,7 +186,7 @@ msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo)
 {
        msg_error_t err = MSG_SUCCESS;
 
-       // Add Submit SMS into DB
+       /* Add Submit SMS into DB */
        if (pReqInfo->msgInfo.msgId == 0) {
                if (pReqInfo->msgInfo.msgPort.valid == false) {
 
@@ -213,19 +210,19 @@ msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo)
                }
        }
 
-       // Check SIM is present or not
-//     MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(MSG_SIM_CHANGED);
-//
-//     if (simStatus == MSG_SIM_STATUS_NOT_FOUND)
-//     {
-//             MSG_DEBUG("SIM is not present..");
-//
-//             // Update Msg Status
-//             if (pReqInfo->msgInfo.msgPort.valid == false)
-//                     SmsPluginStorage::instance()->updateSentMsg(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
-//
-//             return MSG_ERR_NO_SIM;
-//     }
+       /* Check SIM is present or not */
+       /*
+       MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(MSG_SIM_CHANGED);
+
+       if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
+               MSG_DEBUG("SIM is not present..");
+
+               if (pReqInfo->msgInfo.msgPort.valid == false)
+                       SmsPluginStorage::instance()->updateSentMsg(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+
+               return MSG_ERR_NO_SIM;
+       }
+       */
 
        sms_request_info_s *request = NULL;
 
@@ -275,8 +272,7 @@ msg_error_t SmsPlgSetMemoryStatus(msg_error_t Error)
        int tapiRet = TAPI_API_SUCCESS;
        int status = TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE;
 
-       if (Error == MSG_ERR_SIM_STORAGE_FULL || Error == MSG_ERR_MESSAGE_COUNT_FULL)
-       {
+       if (Error == MSG_ERR_SIM_STORAGE_FULL || Error == MSG_ERR_MESSAGE_COUNT_FULL) {
                status = TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL;
        }
 
@@ -284,12 +280,9 @@ msg_error_t SmsPlgSetMemoryStatus(msg_error_t Error)
 
        tapiRet = tel_set_sms_memory_status(pTapiHandle, status, TapiEventMemoryStatus, NULL);
 
-       if (tapiRet == TAPI_API_SUCCESS)
-       {
+       if (tapiRet == TAPI_API_SUCCESS) {
                MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! return : [%d] #######", tapiRet);
        }
 
@@ -299,17 +292,12 @@ msg_error_t SmsPlgSetMemoryStatus(msg_error_t Error)
 
 msg_error_t SmsPlgSetConfigData(const MSG_SETTING_S *pSetting)
 {
-       try
-       {
+       try {
                SmsPluginSetting::instance()->setConfigData(pSetting);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
-       }
-       catch (exception& e)
-       {
+       } catch (exception& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
        }
@@ -320,17 +308,12 @@ msg_error_t SmsPlgSetConfigData(const MSG_SETTING_S *pSetting)
 
 msg_error_t SmsPlgGetConfigData(MSG_SETTING_S *pSetting)
 {
-       try
-       {
+       try {
                SmsPluginSetting::instance()->getConfigData(pSetting);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
-       }
-       catch (exception& e)
-       {
+       } catch (exception& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
        }
@@ -345,6 +328,7 @@ msg_error_t SmsPlgAddMessage(MSG_MESSAGE_INFO_S *pMsgInfo,  MSG_SENDINGOPT_INFO_
        return MSG_SUCCESS;
 }
 
+
 static void on_change_received(GDBusConnection *connection, const gchar *sender_name,
                const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                GVariant *parameters, gpointer user_data)
@@ -355,12 +339,13 @@ static void on_change_received(GDBusConnection *connection, const gchar *sender_
                gint memStatus;
                g_variant_get(parameters, "(i)", &memStatus);
                MSG_DEBUG("memStatus = [%d]", memStatus);
-               if(memStatus == 0) {
+               if (memStatus == 0) {
                        SmsPlgSetMemoryStatus(MSG_SUCCESS);
                }
        }
 }
 
+
 void MsgResourceMonitorInit(void)
 {
     MSG_BEGIN();
@@ -415,7 +400,6 @@ _DBUS_ERROR:
 
        MSG_END();
        return;
-
 }
 
 
index 274cf6d..9f9cb0f 100755 (executable)
@@ -39,6 +39,7 @@ SmsPluginParamCodec::~SmsPluginParamCodec()
 
 }
 
+
 SmsPluginParamCodec* SmsPluginParamCodec::instance()
 {
        if (!pInstance)
@@ -80,6 +81,7 @@ int SmsPluginParamCodec::convertDigitToBcd(char *pDigit, int DigitLen, unsigned
        return offset;
 }
 
+
 int SmsPluginParamCodec::convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit)
 {
        int offset = 0;
@@ -119,6 +121,7 @@ int SmsPluginParamCodec::convertBcdToDigit(const unsigned char *pBcd, int BcdLen
        return offset;
 }
 
+
 int SmsPluginParamCodec::convertDigitToDTMF(const char *pDigit, int DigitLen, int startBit, unsigned char *pDtmf)
 {
        int shift = startBit;
@@ -171,6 +174,7 @@ int SmsPluginParamCodec::convertDigitToDTMF(const char *pDigit, int DigitLen, in
        return offset;
 }
 
+
 int SmsPluginParamCodec::convertDTMFToDigit(const unsigned char *pDtmf, int DtmfLen, int startBit, char *pDigit)
 {
        int shift = startBit;
@@ -220,6 +224,7 @@ int SmsPluginParamCodec::convertDTMFToDigit(const unsigned char *pDtmf, int Dtmf
        return offset;
 }
 
+
 bool SmsPluginParamCodec::isDtmfNumber(const char *pDigit, int DigitLen)
 {
        bool isDtmf = true;
@@ -235,6 +240,3 @@ bool SmsPluginParamCodec::isDtmfNumber(const char *pDigit, int DigitLen)
 
        return isDtmf;
 }
-
-
-
index c4f4b08..ef594c5 100755 (executable)
@@ -55,7 +55,7 @@ SmsPluginSetting* SmsPluginSetting::pInstance = NULL;
 
 SmsPluginSetting::SmsPluginSetting()
 {
-       // Initialize member variables
+       /* Initialize member variables */
        memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
        memset(&meImei, 0x00, sizeof(meImei));
 
@@ -86,11 +86,11 @@ void* SmsPluginSetting::initSimInfo(void *data)
 
        int tapiRet = TAPI_API_SUCCESS;
 
-       // Get IMSI
+       /* Get IMSI */
        char imsi[17];
        memset(imsi, 0x00, sizeof(imsi));
 
-       // Get IMSI
+       /* Get IMSI */
        TelSimImsiInfo_t imsiInfo;
        memset(&imsiInfo, 0x00, sizeof(TelSimImsiInfo_t));
 
@@ -112,6 +112,7 @@ void* SmsPluginSetting::initSimInfo(void *data)
        return NULL;
 }
 
+
 void SmsPluginSetting::updateSimStatus()
 {
        MSG_BEGIN();
@@ -145,7 +146,7 @@ void SmsPluginSetting::updateSimStatus()
                }
        }
 
-       // init config data.
+       /* init config data. */
        initConfigData();
 
        MSG_END();
@@ -160,7 +161,7 @@ void SmsPluginSetting::setSimChangeStatus()
 
        pthread_t thd;
 
-       if(pthread_create(&thd, NULL, &initSimInfo, NULL) < 0) {
+       if (pthread_create(&thd, NULL, &initSimInfo, NULL) < 0) {
                MSG_DEBUG("pthread_create() error");
        }
 
@@ -170,19 +171,19 @@ void SmsPluginSetting::setSimChangeStatus()
 }
 
 
-
 void SmsPluginSetting::initConfigData()
 {
        MSG_BEGIN();
 
        msg_error_t     err = MSG_SUCCESS;
+       char keyName[MAX_VCONFKEY_NAME_LEN];
+       int sim_idx = 1;
 
-#if 1
        /*==================== CB configuration ====================*/
-//     if (simStatus != MSG_SIM_STATUS_NOT_FOUND)
-//     {
-//             MSG_DEBUG("simStatus == [%d]", simStatus);
-
+       /*
+       if (simStatus != MSG_SIM_STATUS_NOT_FOUND) {
+               MSG_DEBUG("simStatus == [%d]", simStatus);
+       */
                MSG_CBMSG_OPT_S cbMsgOpt = {0,};
 
                if (getCbConfig(&cbMsgOpt) == true) {
@@ -199,22 +200,6 @@ void SmsPluginSetting::initConfigData()
                        }
                } else {
                        MSG_DEBUG("########  getCbConfig Fail !!! #######");
-#endif
-
-#if 0
-                       // CSC doesn't support CB Info any longer
-                       if (MsgCscGetCBInfo(&cbMsgOpt) == true) {
-                               err = addCbOpt(&cbMsgOpt);
-
-                               if (err == MSG_SUCCESS) {
-                                       MSG_DEBUG("########  Add CB Option From CSC Success !!! #######");
-                               } else {
-                                       MSG_DEBUG("########  Add CB Option from CSC Fail !!! return : %d #######", err);
-                               }
-                       } else {
-                               MSG_DEBUG("########  MsgCscGetCBInfo Fail !!! #######");
-                       }
-#endif
                }
 
                /*==================== MSISDN update ====================*/
@@ -223,37 +208,21 @@ void SmsPluginSetting::initConfigData()
                } else {
                        MSG_DEBUG("########  getMsisdnInfo Fail !!! #######");
                }
-#if 1
-               /*==================== Default Voice mail Setting ====================*/
-               char *num = MsgSettingGetString(VOICEMAIL_DEFAULT_NUMBER);
-
-               if (num) {
-                       MSG_DEBUG("Voicemail Default Number [%s]", num);
-                       if (MsgSettingSetString(VOICEMAIL_NUMBER, num) != MSG_SUCCESS)
-                               MSG_DEBUG("MsgSettingSetInt is failed!!");
-                       free(num);
-                       num = NULL;
-               }
-               else {
-                       MSG_DEBUG("Voicemail Default Number is NULL");
-                       if (MsgSettingSetString(VOICEMAIL_NUMBER, "") != MSG_SUCCESS)
-                               MSG_DEBUG("MsgSettingSetInt is failed!!");
-               }
-
-               char *voiceNumber = MsgSettingGetString(VOICEMAIL_NUMBER);
 
-               if (!voiceNumber || (voiceNumber && voiceNumber[0] == '\0')) {
-                       MSG_DEBUG("Voice Number is Empty");
-               }
+               /*==================== Default Voice mail Setting ====================*/
+               MSG_DEBUG("Voicemail Default Number is NULL");
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
+               if (MsgSettingSetString(keyName, VOICEMAIL_DEFAULT_NUMBER) != MSG_SUCCESS)
+                       MSG_DEBUG("Error to set config data [%s]", keyName);
 
-               if (voiceNumber) {
-                       free(voiceNumber);
-                       voiceNumber = NULL;
-               }
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
 
-               if (MsgSettingSetString(VOICEMAIL_ALPHA_ID, VOICEMAIL_DEFAULT_ALPHA_ID) != MSG_SUCCESS)
-                       MSG_DEBUG("MsgSettingSetString is failed!!");
-#endif
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, sim_idx);
+               if (MsgSettingSetString(keyName, VOICEMAIL_DEFAULT_ALPHA_ID) != MSG_SUCCESS)
+                       MSG_DEBUG("Error to set config data [%s]", keyName);
 
        MSG_END();
 }
@@ -263,7 +232,7 @@ void SmsPluginSetting::SimRefreshCb()
 {
        pthread_t thd;
 
-       if(pthread_create(&thd, NULL, &init_config_data, NULL) < 0) {
+       if (pthread_create(&thd, NULL, &init_config_data, NULL) < 0) {
                MSG_DEBUG("pthread_create() error");
        }
 
@@ -283,26 +252,25 @@ void SmsPluginSetting::setConfigData(const MSG_SETTING_S *pSetting)
 {
        MSG_DEBUG("Setting Type : [%d]", pSetting->type);
 
-       switch (pSetting->type)
-       {
+       switch (pSetting->type) {
 #if 0
-               case MSG_SMS_SENDOPT :
-                       setNetworkMode(&pSetting->option.smsSendOpt);
-                       break;
-               case MSG_SMSC_LIST :
-                       setParamList(&pSetting->option.smscList);
-                       break;
+       case MSG_SMS_SENDOPT :
+               setNetworkMode(&pSetting->option.smsSendOpt);
+               break;
+       case MSG_SMSC_LIST :
+               setParamList(&pSetting->option.smscList);
+               break;
 #endif
-               case MSG_VOICEMAIL_OPT:
-                       setVoiceMailInfo(&pSetting->option.voiceMailOpt);
-                       break;
-
-               case MSG_CBMSG_OPT :
-                       setCbConfig(&pSetting->option.cbMsgOpt);
-                       break;
-               default :
-                       THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
-                       break;
+       case MSG_VOICEMAIL_OPT:
+               setVoiceMailInfo(&pSetting->option.voiceMailOpt);
+               break;
+
+       case MSG_CBMSG_OPT :
+               setCbConfig(&pSetting->option.cbMsgOpt);
+               break;
+       default :
+               THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+               break;
        }
 }
 
@@ -311,20 +279,19 @@ void SmsPluginSetting::getConfigData(MSG_SETTING_S *pSetting)
 {
        MSG_DEBUG("Setting Type : [%d]", pSetting->type);
 
-       switch (pSetting->type)
-       {
+       switch (pSetting->type) {
 #if 0
-               case MSG_SMSC_LIST :
-                       getParamList(&pSetting->option.smscList);
-               break;
+       case MSG_SMSC_LIST :
+               getParamList(&pSetting->option.smscList);
+       break;
 #endif
-               case MSG_CBMSG_OPT :
-                       getCbConfig(&pSetting->option.cbMsgOpt);
-               break;
+       case MSG_CBMSG_OPT :
+               getCbConfig(&pSetting->option.cbMsgOpt);
+       break;
 
-               default :
-                       THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
-               break;
+       default :
+               THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+       break;
        }
 }
 
@@ -333,17 +300,16 @@ msg_error_t SmsPluginSetting::addCbOpt(MSG_CBMSG_OPT_S *pCbOpt)
 {
        msg_error_t err = MSG_SUCCESS;
 
-//     MSG_DEBUG("Receive [%d], Max SIM Count [%d]", pCbOpt->bReceive, pCbOpt->maxSimCnt);
+       /* MSG_DEBUG("Receive [%d], Max SIM Count [%d]", pCbOpt->bReceive, pCbOpt->maxSimCnt); */
 
        MSG_DEBUG("Receive [%d], Channel Count [%d]", pCbOpt->bReceive, pCbOpt->channelData.channelCnt);
 
-       for (int i = 0; i < pCbOpt->channelData.channelCnt; i++)
-       {
+       for (int i = 0; i < pCbOpt->channelData.channelCnt; i++) {
                MSG_DEBUG("Channel Category [%d], Channel Language [%d]", pCbOpt->channelData.channelInfo[i].ctg, pCbOpt->channelData.channelInfo[i].lang);
        }
 
 #if 0
-       // Set Setting Data into Vconf
+       /* Set Setting Data into Vconf */
        if (MsgSettingSetBool(CB_RECEIVE, pCbOpt->bReceive) != MSG_SUCCESS) {
                MSG_DEBUG("Error to set config data [%s]", CB_RECEIVE);
                return MSG_ERR_SET_SETTING;
@@ -379,7 +345,7 @@ void SmsPluginSetting::getCbOpt(MSG_SETTING_S *pSetting)
 
        MsgSettingGetBool(CB_RECEIVE, &pSetting->option.cbMsgOpt.bReceive);
 
-//     pSetting->option.cbMsgOpt.maxSimCnt = MsgSettingGetInt(CB_MAX_SIM_COUNT);
+       /* pSetting->option.cbMsgOpt.maxSimCnt = MsgSettingGetInt(CB_MAX_SIM_COUNT); */
 
        err = MsgStoGetCBChannelInfo(&dbHandle, &pSetting->option.cbMsgOpt.channelData);
        MSG_DEBUG("MsgStoAddCBChannelInfo : err=[%d]", err);
@@ -394,9 +360,9 @@ void SmsPluginSetting::getCbOpt(MSG_SETTING_S *pSetting)
                MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]);
        }
 #endif
-
 }
 
+
 void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
 {
        bUpdateVoicemailByMdn = false;
@@ -404,6 +370,7 @@ void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
        return;
 }
 
+
 bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
 {
        int ret = TAPI_API_SUCCESS;
@@ -413,7 +380,7 @@ bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
 
        cbConfig.CBEnabled = (int)pCbOpt->bReceive;
        cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP2;
-//     cbConfig.MsgIdMaxCount = pCbOpt->maxSimCnt;
+       /* cbConfig.MsgIdMaxCount = pCbOpt->maxSimCnt; */
        cbConfig.MsgIdRangeCount = pCbOpt->channelData.channelCnt;
 
        for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
@@ -602,23 +569,23 @@ void SmsPluginSetting::setMwiInfo(MSG_SUB_TYPE_T type, int count)
 
        if (MsgSettingSetInt(VOICEMAIL_COUNT, count) != MSG_SUCCESS)
                MSG_DEBUG("MsgSettingSetInt is failed!!");
+       /*
+       if (count == 0) {
+               MsgStoClearUniquenessTable();
+       }
 
-//     if (count == 0) {
-//             MsgStoClearUniquenessTable();
-//     }
-
-//     if(count <= 0) {
-//             if (type == MSG_MWI_VOICE_SMS)
-//                     MsgCleanAndResetNotification(MSG_NOTI_TYPE_VOICE_1);
-//             else if (type == MSG_MWI_VOICE2_SMS)
-//                     MsgCleanAndResetNotification(MSG_NOTI_TYPE_VOICE_2);
-//     }
-
-//     if (bMbdnEnable == false) {
-//             MSG_DEBUG("MBDN service is disable.");
-//             return;
-//     }
+       if (count <= 0) {
+               if (type == MSG_MWI_VOICE_SMS)
+                       MsgCleanAndResetNotification(MSG_NOTI_TYPE_VOICE_1);
+               else if (type == MSG_MWI_VOICE2_SMS)
+                       MsgCleanAndResetNotification(MSG_NOTI_TYPE_VOICE_2);
+       }
 
+       if (bMbdnEnable == false) {
+               MSG_DEBUG("MBDN service is disable.");
+               return;
+       }
+       */
        return;
 }
 
index dc0064c..582650c 100755 (executable)
@@ -119,7 +119,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf
 
        pMsgInfo->msgId = msgId;
 
-       /** Update Status - MSG_MESSAGE_TABLE */
+       /* Update Status - MSG_MESSAGE_TABLE */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE MSG_ID = %d AND MSG_REF > 0;",
                        MSGFW_SMS_REPORT_TABLE_NAME, msgId);
@@ -141,7 +141,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf
                }
        }
 
-       /** Update Status - MSG_REPORT_TABLE */
+       /* Update Status - MSG_REPORT_TABLE */
        if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_SUCCESS) {
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
@@ -152,7 +152,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf
                        MSG_DEBUG("Query Failed : [%s]", sqlQuery);
                        return MSG_ERR_DB_EXEC;
                }
-       } else if(pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_EXPIRED) {
+       } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_EXPIRED) {
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
                                MSGFW_SMS_REPORT_TABLE_NAME, 0, (int)pMsgInfo->displayTime, msgId, normalNum);
@@ -162,7 +162,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf
                        MSG_DEBUG("Query Failed : [%s]", sqlQuery);
                        return MSG_ERR_DB_EXEC;
                }
-       } else if(pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_PENDING) {
+       } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_PENDING) {
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
                                MSGFW_SMS_REPORT_TABLE_NAME, 3, (int)pMsgInfo->displayTime, msgId, normalNum);
@@ -172,7 +172,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf
                        MSG_DEBUG("Query Failed : [%s]", sqlQuery);
                        return MSG_ERR_DB_EXEC;
                }
-       } else if(pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_FAIL) {
+       } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_FAIL) {
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
                                MSGFW_SMS_REPORT_TABLE_NAME, 8, (int)pMsgInfo->displayTime, msgId, normalNum);
@@ -206,7 +206,7 @@ msg_error_t SmsPluginStorage::updateSentMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_ne
 
        MSG_DEBUG("Update Msg ID : [%d], Network Status : [%d] ", pMsgInfo->msgId, status);
 
-       /** Move Msg to SENTBOX */
+       /* Move Msg to SENTBOX */
        if (status == MSG_NETWORK_SEND_SUCCESS) {
                snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d, FOLDER_ID = %d WHERE MSG_ID = %d;",
                                        MSGFW_MESSAGE_TABLE_NAME, status, MSG_SENTBOX_ID, pMsgInfo->msgId);
@@ -237,7 +237,7 @@ msg_error_t SmsPluginStorage::checkMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
 
        msg_error_t err = MSG_SUCCESS;
 
-       /**  Check whether storage is full or not */
+       /*  Check whether storage is full or not */
        err = checkStorageStatus(pMsgInfo);
 
        if (err != MSG_SUCCESS) {
@@ -245,24 +245,26 @@ msg_error_t SmsPluginStorage::checkMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
                        pMsgInfo->folderId = 0;
                        err = MSG_SUCCESS;
                }
-//             else if(pMsgInfo->msgType.classType == MSG_CLASS_2 &&
-//                             (pMsgInfo->msgType.subType == MSG_NORMAL_SMS || pMsgInfo->msgType.subType == MSG_REJECT_SMS)) {
-//                     err = addClass2Message(pMsgInfo);
-//             }
+               /*
+               else if (pMsgInfo->msgType.classType == MSG_CLASS_2 &&
+                               (pMsgInfo->msgType.subType == MSG_NORMAL_SMS || pMsgInfo->msgType.subType == MSG_REJECT_SMS)) {
+                       err = addClass2Message(pMsgInfo);
+               }
+               */
                else if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS){
                        err = MSG_SUCCESS;
                }
                return err;
        }
 
-       /**  Amend message information for type **/
+       /*  Amend message information for type */
        if (pMsgInfo->msgType.subType == MSG_NORMAL_SMS || pMsgInfo->msgType.subType == MSG_REJECT_SMS) {
                MSG_DEBUG("Normal SMS");
 
                if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
-//                     err = addClass2Message(pMsgInfo);
+                       /* err = addClass2Message(pMsgInfo); */
                } else if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
-                       /** Class 0 Msg should be saved in hidden folder */
+                       /* Class 0 Msg should be saved in hidden folder */
                        pMsgInfo->folderId = 0;
                }
 
@@ -270,9 +272,9 @@ msg_error_t SmsPluginStorage::checkMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
                MSG_DEBUG("Replace SM Type [%d]", pMsgInfo->msgType.subType-3);
 
                if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
-//                     err = addClass2Message(pMsgInfo);
+                       /* err = addClass2Message(pMsgInfo); */
                } else if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
-                       /** Class 0 Msg should be saved in hidden folder */
+                       /* Class 0 Msg should be saved in hidden folder */
                        pMsgInfo->folderId = 0;
                        pMsgInfo->msgType.subType = MSG_NORMAL_SMS;
                }
@@ -280,10 +282,11 @@ msg_error_t SmsPluginStorage::checkMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
        } else if ((pMsgInfo->msgType.subType >= MSG_MWI_VOICE_SMS) && (pMsgInfo->msgType.subType <= MSG_MWI_OTHER_SMS)) {
                if (pMsgInfo->bStore == true) {
                        MSG_DEBUG("MWI Message");
-
-//                     if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
-//                             err = addClass2Message(pMsgInfo);
-//                     }
+                       /*
+                       if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
+                               err = addClass2Message(pMsgInfo);
+                       }
+                       */
                }
        } else {
                MSG_DEBUG("No matching type [%d]", pMsgInfo->msgType.subType);
@@ -321,7 +324,7 @@ msg_error_t SmsPluginStorage::addSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
                pMsgInfo->threadId = convId;
        }
 
-       /**  Add Message Table */
+       /*  Add Message Table */
        rowId = MsgStoAddMessageTable(dbHandle, pMsgInfo);
 
        if (rowId <= 0) {
@@ -329,7 +332,7 @@ msg_error_t SmsPluginStorage::addSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
                return MSG_ERR_DB_ROW;
        }
 
-       /** Update conversation table */
+       /* Update conversation table */
        err = MsgStoUpdateConversation(dbHandle, convId);
 
        if (err != MSG_SUCCESS) {
@@ -357,7 +360,7 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
        MsgDbHandler *dbHandle = getDbHandle();
        char sqlQuery[MAX_QUERY_LEN+1];
 
-        /**  Get SUB_TYPE, STORAGE_ID */
+        /*  Get SUB_TYPE, STORAGE_ID */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MAIN_TYPE, SUB_TYPE, FOLDER_ID, CONV_ID, SIM_INDEX \
                        FROM %s WHERE MSG_ID = %d;",
@@ -393,7 +396,7 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SMS_SENDOPT_TABLE_NAME, msgId);
 
-       /**  Delete SMS Send Option */
+       /*  Delete SMS Send Option */
        if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
                dbHandle->endTrans(false);
                return MSG_ERR_DB_EXEC;
@@ -403,7 +406,7 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_CB_MSG_TABLE_NAME, msgId);
 
-               /** Delete Push Message from push table */
+               /* Delete Push Message from push table */
                if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
                        dbHandle->endTrans(false);
                        return MSG_ERR_DB_EXEC;
@@ -412,7 +415,7 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_PUSH_MSG_TABLE_NAME, msgId);
 
-               /**  Delete Push Message from push table */
+               /*  Delete Push Message from push table */
                if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
                        dbHandle->endTrans(false);
                        return MSG_ERR_DB_EXEC;
@@ -421,14 +424,14 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SYNCML_MSG_TABLE_NAME, msgId);
 
-               /**  Delete SyncML Message from syncML table */
+               /*  Delete SyncML Message from syncML table */
                if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
                        dbHandle->endTrans(false);
                        return MSG_ERR_DB_EXEC;
                }
        }
 
-       /** Delete Message from msg table */
+       /* Delete Message from msg table */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId);
        if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
@@ -436,7 +439,7 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
                return MSG_ERR_DB_EXEC;
        }
 
-       /** Delete Message from msg_report table */
+       /* Delete Message from msg_report table */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SMS_REPORT_TABLE_NAME, msgId);
        if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
@@ -444,7 +447,7 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
                return MSG_ERR_DB_EXEC;
        }
 
-       /** Delete Message from msg_sim table */
+       /* Delete Message from msg_sim table */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SIM_MSG_TABLE_NAME, msgId);
        if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
@@ -452,13 +455,13 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
                return MSG_ERR_DB_EXEC;
        }
 
-       /**  Clear Conversation table */
+       /*  Clear Conversation table */
        if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) {
                dbHandle->endTrans(false);
                return MSG_ERR_DB_EXEC;
        }
 
-       /**  Update conversation table.*/
+       /*  Update conversation table.*/
        if (MsgStoUpdateConversation(dbHandle, convId) != MSG_SUCCESS) {
                dbHandle->endTrans(false);
                return MSG_ERR_STORAGE_ERROR;
@@ -469,14 +472,14 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
        if (folderId == MSG_INBOX_ID) {
                msgType.classType = MSG_CLASS_NONE;
 
-               /**  Set memory status in SIM */
+               /*  Set memory status in SIM */
                if (MsgStoCheckMsgCntFull(dbHandle, &msgType, folderId) == MSG_SUCCESS) {
                        MSG_DEBUG("Set Memory Status");
                        SmsPlgSetMemoryStatus(MSG_SUCCESS);
                }
        }
 
-//     MsgRefreshAllNotification(true, false, false);
+       /* MsgRefreshAllNotification(true, false, false); */
 
        return MSG_SUCCESS;
 }
@@ -492,14 +495,15 @@ msg_error_t SmsPluginStorage::addSmsSendOption(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN
        if (pSendOptInfo->bSetting == false) {
                MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSendOptInfo->bDeliverReq);
                MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSendOptInfo->option.smsSendOptInfo.bReplyPath);
-
-//             if (pSendOptInfo->bDeliverReq || pSendOptInfo->option.smsSendOptInfo.bReplyPath) {
-//                     pSendOptInfo->bSetting = true;
+               /*
+               if (pSendOptInfo->bDeliverReq || pSendOptInfo->option.smsSendOptInfo.bReplyPath) {
+                       pSendOptInfo->bSetting = true;
+               */
                        MsgSettingGetBool(MSG_KEEP_COPY, &pSendOptInfo->bKeepCopy);
-//             }
+               /* } */
        }
 
-//     if (pSendOptInfo->bSetting == true) {
+       /* if (pSendOptInfo->bSetting == true) { */
                char sqlQuery[MAX_QUERY_LEN+1];
 
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
@@ -512,7 +516,7 @@ msg_error_t SmsPluginStorage::addSmsSendOption(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN
                if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
                        err = MSG_ERR_DB_EXEC;
                }
-//     }
+       /* } */
 
        MSG_END();
 
@@ -539,13 +543,13 @@ msg_error_t SmsPluginStorage::checkStorageStatus(MSG_MESSAGE_INFO_S *pMsgInfo)
                        if (bAutoErase == true) {
                                msg_message_id_t msgId;
 
-                               /** Find the oldest message's msgId */
+                               /* Find the oldest message's msgId */
                                err = MsgStoGetOldestMessage(dbHandle, pMsgInfo, &msgId);
 
                                if (err != MSG_SUCCESS)
                                        return err;
 
-                               /** Delete the corresponding message. */
+                               /* Delete the corresponding message. */
                                err = deleteSmsMessage(msgId);
                        }
                }
@@ -577,8 +581,7 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou
        if (err == MSG_ERR_DB_NORECORD) {
                dbHandle->freeTable();
                return MSG_SUCCESS;
-       }
-       else if ( err != MSG_SUCCESS) {
+       } else if ( err != MSG_SUCCESS) {
                dbHandle->freeTable();
                return err;
        }
@@ -599,14 +602,14 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou
                dbHandle->getColumnToString(index++, MAX_WAPPUSH_ID_LEN + 1, appId);
                appcode = dbHandle->getColumnToInt(index++);
 
-               //MSG_DEBUG("content_type: %s, app_id: %s", content_type, app_id);
+               /* MSG_DEBUG("content_type: %s, app_id: %s", content_type, app_id); */
                _content_type = strcasestr(pPushHeader, contentType);
-               if(_content_type) {
+               if (_content_type) {
                        _app_id = strcasestr(pPushHeader, appId);
-                       if(appcode)
+                       if (appcode)
                                default_appcode = appcode;
 
-                       if(_app_id) {
+                       if (_app_id) {
                                PUSH_APPLICATION_INFO_S pInfo = {0, };
                                pInfo.appcode = appcode;
                                MSG_SEC_DEBUG("appcode: %d, app_id: %s", pInfo.appcode, appId);
@@ -619,9 +622,8 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou
                }
        }
 
-       if(!found && default_appcode != SMS_WAP_APPLICATION_LBS)
-       {
-               // perform default action.
+       if (!found && default_appcode != SMS_WAP_APPLICATION_LBS) {
+               /* perform default action. */
                PUSH_APPLICATION_INFO_S pInfo = {0, };
                pInfo.appcode = default_appcode;
                memset(appId, 0, MAX_WAPPUSH_ID_LEN + 1);
@@ -639,14 +641,13 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou
 msg_error_t SmsPluginStorage::getnthPushEvent(int index, int *appcode)
 {
        msg_error_t err = MSG_SUCCESS;
-       if((unsigned int)index > pushAppInfoList.size() - 1)
+       if ((unsigned int)index > pushAppInfoList.size() - 1)
                return MSG_ERR_INVALID_PARAMETER;
 
        std::list<PUSH_APPLICATION_INFO_S>::iterator it = pushAppInfoList.begin();
        int count = 0;
-       for (; it != pushAppInfoList.end(); it++)
-       {
-               if(index == count){
+       for (; it != pushAppInfoList.end(); it++) {
+               if (index == count){
                        *appcode = it->appcode;
                        break;
                }
index 43020d4..25b8b27 100755 (executable)
@@ -98,17 +98,17 @@ unsigned char SmsPluginTransport::getSubmitMsgId()
 void SmsPluginTransport::convertMsgInfoToTelesvcMsg(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_trans_msg_s *pTransMsg)
 {
        switch (pTransMsg->type) {
-               case SMS_TRANS_P2P_MSG:
-               {
-                       MSG_DEBUG("Convert  MSG_MESSAGE_INFO_S data to SMS_TRANS_MSG_S data.");
-                       sms_trans_p2p_msg_s *pPtpMsg = (sms_trans_p2p_msg_s *)&(pTransMsg->data.p2p_msg);
+       case SMS_TRANS_P2P_MSG:
+       {
+               MSG_DEBUG("Convert  MSG_MESSAGE_INFO_S data to SMS_TRANS_MSG_S data.");
+               sms_trans_p2p_msg_s *pPtpMsg = (sms_trans_p2p_msg_s *)&(pTransMsg->data.p2p_msg);
 
-                       convertMsgInfoToPtp(pMsgInfo, pPtpMsg);
-               }
-                       break;
-               default:
-                       MSG_DEBUG("Error Unsupported Transport Type");
-                       break;
+               convertMsgInfoToPtp(pMsgInfo, pPtpMsg);
+       }
+               break;
+       default:
+               MSG_DEBUG("Error Unsupported Transport Type");
+               break;
        }
 }
 
@@ -133,24 +133,23 @@ void SmsPluginTransport::convertMsgInfoToPtp(const MSG_MESSAGE_INFO_S *pMsgInfo,
        if (pMsgInfo->addressList[0].addressVal[0] == '+') {
                pPtpMsg->address.digit_mode = SMS_DIGIT_8BIT;
                pPtpMsg->address.number_type = SMS_NUMBER_TYPE_INTERNATIONAL;
-       }
-       else {
+       } else {
                pPtpMsg->address.number_type = SMS_NUMBER_TYPE_NATIONAL;
        }
 
        /* 4. Convert Sub-address values */
-       // TODO
+       /* TODO */
 
        /* 5. Set Reply sequence number. */
        pPtpMsg->reply_seq = getSeqNum();
 
        /* convert msgInfo to Teleservice Message */
        switch (pPtpMsg->telesvc_msg.type) {
-               case SMS_TYPE_SUBMIT:
-                       convertMsgInfoToSubmit(pMsgInfo, &(pPtpMsg->telesvc_msg.data.submit));
-                       break;
-               default:
-                       break;
+       case SMS_TYPE_SUBMIT:
+               convertMsgInfoToSubmit(pMsgInfo, &(pPtpMsg->telesvc_msg.data.submit));
+               break;
+       default:
+               break;
        }
 
 }
@@ -175,28 +174,19 @@ void SmsPluginTransport::convertMsgInfoToSubmit(const MSG_MESSAGE_INFO_S *pMsgIn
 
 
        if (pMsgInfo->bTextSms == true) {
-               if (pMsgInfo->encodeType == MSG_ENCODE_GSM7BIT)
-               {
+               if (pMsgInfo->encodeType == MSG_ENCODE_GSM7BIT) {
                        pSubmit->user_data.encode_type = SMS_ENCODE_GSM7BIT;
-               }
-               else if (pMsgInfo->encodeType == MSG_ENCODE_8BIT)
-               {
+               } else if (pMsgInfo->encodeType == MSG_ENCODE_8BIT) {
                        pSubmit->user_data.encode_type = SMS_ENCODE_OCTET;
-               }
-               else if (pMsgInfo->encodeType == MSG_ENCODE_UCS2)
-               {
+               } else if (pMsgInfo->encodeType == MSG_ENCODE_UCS2) {
                        pSubmit->user_data.encode_type = SMS_ENCODE_UNICODE;
-               }
-               else if (pMsgInfo->encodeType == MSG_ENCODE_AUTO)
-               {
+               } else if (pMsgInfo->encodeType == MSG_ENCODE_AUTO) {
                        textCvt->convertUTF8ToAuto(decodeData, SMS_MAX_USER_DATA_LEN + 1, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, &encodeType);
                        if (encodeType == MSG_ENCODE_ASCII7BIT) {
                                pSubmit->user_data.encode_type = SMS_ENCODE_7BIT_ASCII;
-                       }
-                       else if (encodeType == MSG_ENCODE_8BIT) {
+                       } else if (encodeType == MSG_ENCODE_8BIT) {
                                pSubmit->user_data.encode_type = SMS_ENCODE_OCTET;
-                       }
-                       else if (encodeType == MSG_ENCODE_UCS2) {
+                       } else if (encodeType == MSG_ENCODE_UCS2) {
                                pSubmit->user_data.encode_type = SMS_ENCODE_UNICODE;
                        }
                }
@@ -223,16 +213,16 @@ void SmsPluginTransport::convertMsgInfoToSubmit(const MSG_MESSAGE_INFO_S *pMsgIn
 #endif
 
        /* 4. Set Defer valid period */
-       // TODO
+       /* TODO */
 
        /* 5. Set Priority */
        switch (pMsgInfo->priority) {
-               case MSG_MESSAGE_PRIORITY_HIGH:
-                       pSubmit->priority = SMS_PRIORITY_URGENT;
-                       break;
-               default:
-                       pSubmit->priority = SMS_PRIORITY_NORMAL;
-                       break;
+       case MSG_MESSAGE_PRIORITY_HIGH:
+               pSubmit->priority = SMS_PRIORITY_URGENT;
+               break;
+       default:
+               pSubmit->priority = SMS_PRIORITY_NORMAL;
+               break;
        }
 
        /* 6. Set Privacy */
@@ -248,21 +238,20 @@ void SmsPluginTransport::convertMsgInfoToSubmit(const MSG_MESSAGE_INFO_S *pMsgIn
        pSubmit->language = SMS_LAN_UNKNOWN;
 
        /* 10. Set Callback number */
-       // TODO :: Set callback number to MSISDN
+       /* TODO :: Set callback number to MSISDN */
 
        /* 11. Set Multi encode data */
-       // TODO
+       /* TODO */
 
        /* 12. Set Deposit id */
-       // TODO
+       /* TODO */
 
        /* 13. Set Service category program data */
-       // TODO
+       /* TODO */
 
 }
 
 
-
 void SmsPluginTransport::submitRequest(sms_request_info_s *pReqInfo)
 {
        int tapiRet = TAPI_API_SUCCESS;
@@ -271,19 +260,19 @@ void SmsPluginTransport::submitRequest(sms_request_info_s *pReqInfo)
                THROW(MsgException::SMS_PLG_ERROR, "pReqInfo is NULL");
        }
 
-       // Get address informations.
+       /* Get address informations. */
        MsgDbHandler *dbHandle = getDbHandle();
-       //contacts-service is not used for gear
+       /* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
        MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, 0, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList);
 #else
-       //contactNameOrder is never used
+       /*contactNameOrder is never used */
        MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList);
-#endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
 
        MSG_DEBUG("pReqInfo->msgInfo.nAddressCnt [%d]", pReqInfo->msgInfo.nAddressCnt);
 
-       // Get MSISDN
+       /* Get MSISDN */
        char *msisdn = NULL;
        char keyName[MAX_VCONFKEY_NAME_LEN];
        int simIndex = 1;
@@ -293,7 +282,7 @@ void SmsPluginTransport::submitRequest(sms_request_info_s *pReqInfo)
 
        msisdn = MsgSettingGetString(keyName);
 
-       // Tapi Data Structure
+       /* Tapi Data Structure */
        TelSmsDatapackageInfo_t tapi_data_pkg;
        memset(&tapi_data_pkg, 0x00, sizeof(TelSmsDatapackageInfo_t));
 
@@ -326,71 +315,72 @@ void SmsPluginTransport::submitRequest(sms_request_info_s *pReqInfo)
        }
        MSG_DEBUG("Encode PDU= [%s]", pduDbg);
 
-       /* send request */
        sms_network_status_t retStatus;
-       sms_sent_info_s sent_info;
-       memset(&sent_info, 0x00, sizeof(sms_sent_info_s));
-       memcpy(&sent_info.reqInfo, pReqInfo, sizeof(sent_info.reqInfo));
 
-       sent_info.bLast = true;
+       for (int cnt = 0; cnt < MAX_SMS_SEND_RETRY; ++cnt) {
+               /* send request */
+               sms_sent_info_s sent_info;
+               memset(&sent_info, 0x00, sizeof(sms_sent_info_s));
+               memcpy(&sent_info.reqInfo, pReqInfo, sizeof(sent_info.reqInfo));
 
-       SmsPluginEventHandler::instance()->SetSentInfo(&sent_info);
+               sent_info.bLast = true;
 
-       int svc_type;
-       tel_get_property_int(pTapiHandle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
+               SmsPluginEventHandler::instance()->SetSentInfo(&sent_info);
 
-       if(svc_type < TAPI_NETWORK_SERVICE_TYPE_2G){
-               MSG_DEBUG("Network service is not available : [%d]", svc_type);
-               SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_PENDING);
-               goto _RETURN_FUNC;
-       }
+               int svc_type;
+               tel_get_property_int(pTapiHandle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
 
-       curStatus = SMS_NETWORK_SENDING;
+               if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G) {
+                       MSG_DEBUG("Network service is not available : [%d]", svc_type);
+                       SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_PENDING);
+                       goto _RETURN_FUNC;
+               }
 
-       // Send SMS
-       tapiRet = tel_send_sms(pTapiHandle, &tapi_data_pkg, bMoreMsgToSend, TapiEventSentStatus, NULL);
+               curStatus = SMS_NETWORK_SENDING;
 
-       if (tapiRet == TAPI_API_SUCCESS)
-       {
-               MSG_DEBUG("########  tel_send_sms Success !!! return : [%d] #######", tapiRet);
-       }
-       else
-       {
-               SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
-               THROW(MsgException::SMS_PLG_ERROR, "########  tel_send_sms Fail !!! return : [%d] #######", tapiRet);
-       }
+               /* Send SMS */
+               tapiRet = tel_send_sms(pTapiHandle, &tapi_data_pkg, bMoreMsgToSend, TapiEventSentStatus, NULL);
+
+               if (tapiRet == TAPI_API_SUCCESS) {
+                       MSG_DEBUG("########  tel_send_sms Success !!! return : [%d] #######", tapiRet);
+               } else {
+                       SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
+                       THROW(MsgException::SMS_PLG_ERROR, "########  tel_send_sms Fail !!! return : [%d] #######", tapiRet);
+               }
 
-       // Tizen Validation System
-       MSG_SMS_VLD_INFO("%d, SMS Send Start, %s->%s, %s",  pReqInfo->msgInfo.msgId, \
-                                                                                                                               (msisdn == NULL)?"ME":msisdn, \
-                                                                                                                               pReqInfo->msgInfo.addressList[0].addressVal, \
-                                                                                                                               (tapiRet == TAPI_API_SUCCESS)?"Success":"Fail");
+               /* Tizen Validation System */
+               MSG_SMS_VLD_INFO("%d, SMS Send Start, %s->%s, %s",  pReqInfo->msgInfo.msgId, \
+                                                                                                                                       (msisdn == NULL)?"ME":msisdn, \
+                                                                                                                                       pReqInfo->msgInfo.addressList[0].addressVal, \
+                                                                                                                                       (tapiRet == TAPI_API_SUCCESS)?"Success":"Fail");
 
-       MSG_SMS_VLD_TXT("%d, [%s]", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.msgText);
+               MSG_SMS_VLD_TXT("%d, [%s]", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.msgText);
 
-       retStatus = getNetStatus();
+               retStatus = getNetStatus();
+
+               if (retStatus != SMS_NETWORK_SEND_FAIL_TEMPORARY)
+                       break;
+       }
 
        MSG_SMS_VLD_INFO("%d, SMS Send End, %s->%s, %s",  pReqInfo->msgInfo.msgId, \
                                                                                                                        (msisdn == NULL)?"ME":msisdn, \
                                                                                                                        pReqInfo->msgInfo.addressList[0].addressVal, \
                                                                                                                        (retStatus == SMS_NETWORK_SEND_SUCCESS)?"Success":"Fail");
 
-       if (retStatus == SMS_NETWORK_SEND_SUCCESS)
-       {
+       if (retStatus == SMS_NETWORK_SEND_SUCCESS) {
                MSG_DEBUG("########  Msg Sent was Successful !!! #######");
-       }
-       else
-       {
-               if (retStatus == SMS_NETWORK_SEND_FAIL_TIMEOUT)
+       } else {
+               if (retStatus == SMS_NETWORK_SEND_FAIL_TIMEOUT || retStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY
+                       || retStatus == SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING || retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED)
                        SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
 
-               if (retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED) {
+               if (retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED)
                        MsgInsertTicker("Unable to send the message while Fixed dialling mode is enabled", SMS_FDN_RESTRICTED, true, 0);
-               } else if(retStatus == SMS_NETWORK_SEND_PENDING) {
+               else if (retStatus == SMS_NETWORK_SEND_PENDING)
                        MsgInsertTicker("Unable to send message. It will be sent when service available.", SMS_MESSAGE_SENDING_PENDING, true, 0);
-               }else {
+               else
                        MsgInsertTicker("Sending SMS is failed", SMS_MESSAGE_SENDING_FAIL, true, pReqInfo->msgInfo.msgId);
-               }
+
        }
 
 _RETURN_FUNC :
@@ -404,6 +394,7 @@ _RETURN_FUNC :
        return;
 }
 
+
 void SmsPluginTransport::sendDeliverReport(msg_error_t err, sms_trans_p2p_msg_s *p_p2p_msg)
 {
        MSG_BEGIN();
@@ -426,24 +417,19 @@ void SmsPluginTransport::sendDeliverReport(msg_error_t err, sms_trans_p2p_msg_s
                cause_code.reply_seq = p_p2p_msg->reply_seq;
 
 
-       if (err == MSG_SUCCESS)
-       {
+       if (err == MSG_SUCCESS) {
                cause_code.error_class = SMS_TRANS_ERR_CLASS_NONE;
 
                response = TAPI_NETTEXT_SENDSMS_SUCCESS;
 
-               if(isMemAvailable == false)
-               {
+               if (isMemAvailable == false) {
                        tapiRet = tel_set_sms_memory_status(pTapiHandle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, TapiEventMemoryStatus, NULL);
 
                        if (tapiRet == TAPI_API_SUCCESS)
-                       {
                                MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
-                       }
                        else
-                       {
                                MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
-                       }
+
                }
 
        } else if (err == MSG_ERR_MESSAGE_COUNT_FULL) {
@@ -451,18 +437,15 @@ void SmsPluginTransport::sendDeliverReport(msg_error_t err, sms_trans_p2p_msg_s
                cause_code.error_class = SMS_TRANS_ERR_CLASS_TEMPORARY;
 
                response = TAPI_NETTEXT_ME_FULL;
-//             MsgInsertTicker("Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL, true, 0);
+               /* MsgInsertTicker("Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL, true, 0); */
 
                tapiRet = tel_set_sms_memory_status(pTapiHandle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, TapiEventMemoryStatus, NULL);
 
                if (tapiRet == TAPI_API_SUCCESS)
-               {
                        MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
-               }
                else
-               {
                        MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
-               }
+
        } else if (err == MSG_ERR_UNKNOWN) {
                cause_code.error_class = SMS_TRANS_ERR_CLASS_TEMPORARY;
                cause_code.cause_code = SMS_CAUSE_CODE_SERVICE_TERMINATION_DENIED;
@@ -474,9 +457,7 @@ void SmsPluginTransport::sendDeliverReport(msg_error_t err, sms_trans_p2p_msg_s
                cause_code.cause_code = SMS_CAUSE_CODE_INVAILD_TELESERVICE_ID;
 
                response = TAPI_NETTEXT_INVALID_MSG;
-       }
-       else
-       {
+       } else {
                cause_code.error_class = SMS_TRANS_ERR_CLASS_TEMPORARY;
                response = TAPI_NETTEXT_SIM_FULL;
 
@@ -494,18 +475,17 @@ void SmsPluginTransport::sendDeliverReport(msg_error_t err, sms_trans_p2p_msg_s
 
 
        MSG_DEBUG("######## DeliverReport tpdu #########");
-       for(int i=0; i < bufLen; i++)
-       {
+       for (int i=0; i < bufLen; i++) {
                printf("[%02x] ", buf[i]);
        }
        MSG_DEBUG("#################################");
 
-       // Make Telephony Structure
+       /* Make Telephony Structure */
        TelSmsDatapackageInfo_t pkgInfo;
 
        pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP2;
 
-       // Set TPDU data
+       /* Set TPDU data */
        memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
        memcpy((void*)pkgInfo.szData, buf, bufLen);
 
@@ -513,17 +493,13 @@ void SmsPluginTransport::sendDeliverReport(msg_error_t err, sms_trans_p2p_msg_s
        pkgInfo.MsgLength = bufLen;
 
 
-       // Send Deliver Report
+       /* Send Deliver Report */
        tapiRet = tel_send_sms_deliver_report(pTapiHandle, &pkgInfo, response, TapiEventDeliveryReportCNF, NULL);
 
        if (tapiRet == TAPI_API_SUCCESS)
-       {
                MSG_DEBUG("########  tel_send_sms_deliver_report() Success !!! #######");
-       }
        else
-       {
                MSG_DEBUG("########  tel_send_sms_deliver_report() Fail !!! return : [%d] #######", tapiRet);
-       }
 
        MSG_END();
 }
@@ -549,8 +525,7 @@ sms_network_status_t SmsPluginTransport::getNetStatus()
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
+       if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: SENT STATUS TIME-OUT");
                curStatus = SMS_NETWORK_SEND_FAIL_TIMEOUT;
        }
index 4fc98b4..1b4f52f 100755 (executable)
@@ -48,8 +48,7 @@ SmsPluginUAManager* SmsPluginUAManager::instance()
 
 void SmsPluginUAManager::run()
 {
-       while (1)
-       {
+       while (1) {
                lock();
                while (smsTranQ.empty()) {
                        wait();
@@ -61,21 +60,16 @@ void SmsPluginUAManager::run()
                request.msgInfo.addressList = NULL;
                unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&request.msgInfo.addressList, unique_ptr_deleter);
 
-               try
-               {
+               try {
                        SmsPluginTransport::instance()->submitRequest(&request);
-               }
-               catch (MsgException& e)
-               {
+               } catch (MsgException& e) {
                        MSG_FATAL("%s", e.what());
 
                        lock();
                        smsTranQ.pop_front();
                        unlock();
                        continue;
-               }
-               catch (exception& e)
-               {
+               } catch (exception& e) {
                        MSG_FATAL("%s", e.what());
                        lock();
                        smsTranQ.pop_front();
@@ -101,4 +95,3 @@ void SmsPluginUAManager::addReqEntity(sms_request_info_s *request)
        cv.signal();
        unlock();
 }
-
index 63126eb..aa1fb9f 100755 (executable)
@@ -43,8 +43,7 @@ const unsigned long wspLanguageCount    = 0x11a;
 const unsigned char wspSecurityTypeCount = 0x04;
 
 
-static const SMS_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] =
-{
+static const SMS_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] = {
        { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
        { (char*)"application/vnd.wap.connectivity-wbxml", 0x36 },
        { (char*)"application/pkcs7-mime",  0x37 },
@@ -77,81 +76,79 @@ static const SMS_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] =
 };
 
 
-const char* wspHeaderFieldName[] =
-{
-       (char*)"Accept",  //0x00
+const char* wspHeaderFieldName[] = {
+       (char*)"Accept", /* 0x00 */
        (char*)"Accept-Charset",
        (char*)"Accept-Encoding",
        (char*)"Accept-Language",
        (char*)"Accept-Ranges",
-       (char*)"Age", //0x05
+       (char*)"Age", /* 0x05 */
        (char*)"Allow",
        (char*)"Authorization",
        (char*)"Cache-Control",
        (char*)"Connection",
-       (char*)"Content-Base", //0x0a
+       (char*)"Content-Base", /* 0x0a */
        (char*)"Content-Encoding",
        (char*)"Content-Language",
        (char*)"Content-Length",
        (char*)"Content-Location",
        (char*)"Content-MD5",
-       (char*)"Content-Range", //0x10
+       (char*)"Content-Range", /* 0x10 */
        (char*)"Content-Type",
        (char*)"Date",
        (char*)"ETag",
        (char*)"Expires",
-       (char*)"From", //0x15
+       (char*)"From", /* 0x15 */
        (char*)"Host",
        (char*)"If-Modified-Since",
        (char*)"If-Match",
        (char*)"If-None-Match",
-       (char*)"If-Range", //0x1a
+       (char*)"If-Range", /* 0x1a */
        (char*)"If-Unmodified-Since",
        (char*)"Location",
        (char*)"Last-Modified",
        (char*)"Max-Forwards",
        (char*)"Pragma",
-       (char*)"Proxy-Authenticate", //0x20
+       (char*)"Proxy-Authenticate", /* 0x20 */
        (char*)"Proxy-Authorization",
        (char*)"Public",
        (char*)"Range",
        (char*)"Referer",
-       (char*)"Retry-After", //0x25
+       (char*)"Retry-After", /* 0x25 */
        (char*)"Server",
        (char*)"Transfer-Encodig",
        (char*)"Upgrade",
        (char*)"User-Agent",
-       (char*)"Vary", //0x2a
+       (char*)"Vary", /* 0x2a */
        (char*)"Via",
        (char*)"Warning",
        (char*)"Www-Authenticate",
        (char*)"Content-Disposition",
        (char*)"X-Wap-Application-Id",
-       (char*)"X-Wap-Content-URI", //0x30
+       (char*)"X-Wap-Content-URI", /* 0x30 */
        (char*)"X-Wap-Iinitiator-URI",
-       (char*)"Accept-Application", // Back
+       (char*)"Accept-Application", /* Back */
        (char*)"Bearer-Indication",
        (char*)"Push-Flag",
-       (char*)"Profile", //0x35
+       (char*)"Profile", /* 0x35 */
        (char*)"Profile-Diff",
-       (char*)"Profile-Warning", // end of WAP 1.2
+       (char*)"Profile-Warning", /* end of WAP 1.2 */
        (char*)"Expect",
        (char*)"Te",
-       (char*)"Trailer", //0x3a
-       (char*)"Accept-Charset", //Back
-       (char*)"Accept-Encoding", // Back
-       (char*)"Cache-Control", // back
+       (char*)"Trailer", /* 0x3a */
+       (char*)"Accept-Charset", /* Back */
+       (char*)"Accept-Encoding", /* Back */
+       (char*)"Cache-Control", /* back */
        (char*)"Content-Range",
        (char*)"X-Wap-Tod",
-       (char*)"Content-ID", //x40
+       (char*)"Content-ID", /*x40 */
        (char*)"Set-Cookie",
        (char*)"Cookie",
        (char*)"Encoding-Version"
 };
 
 
-const SMS_WSP_CHARSET_S wspCharset[] =
-{
+const SMS_WSP_CHARSET_S wspCharset[] = {
        { (char*)"big5", 0x07ea },
        { (char*)"iso-10646-ucs-2", 0x03e8 },
        { (char*)"iso-8859-1", 0x04 },
@@ -171,17 +168,14 @@ const SMS_WSP_CHARSET_S wspCharset[] =
 };
 
 
-
-const char* wspEncodeMethod[] =
-{
+const char* wspEncodeMethod[] = {
        (char*)"Gzip",
        (char*)"Compress",
        (char*)"Deflate"
 };
 
 
-const SMS_WSP_CONTENTS_TYPE_S wspContentsType[] =
-{
+const SMS_WSP_CONTENTS_TYPE_S wspContentsType[] = {
        { (char*)"*/*", 0x00 },
        { (char*)"text/*", 0x01 },
        { (char*)"text/html", 0x02 },
@@ -258,17 +252,18 @@ const SMS_WSP_CONTENTS_TYPE_S wspContentsType[] =
        { (char*)"application/vnd.wv.csp.cir", 0x46 }
 };
 
-static const SMS_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]=
-{
+
+static const SMS_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]= {
        { (char*)"application/vnd.wap.emn+wbxml", 0x30A},
        { (char*)"application/vnd.omaloc-supl-init", 0x312},
        { (char*)"application/vnd.oma.drm.roap-trigger+wbxml", 0x316}
 };
 
+
 const unsigned long wspUnregisteredContentsTypeCount = sizeof(wspUnregisterContentsType)/sizeof(SMS_WAP_UNREGISTER_CONTENTS_TYPE_S);
 
-const SMS_WSP_LANGUAGE_S wspLanguage[] =
-{
+
+const SMS_WSP_LANGUAGE_S wspLanguage[] = {
        { (char*)"English", 0x19 },
        { (char*)"en", 0x19 },
        { (char*)"Korean", 0x3d },
@@ -555,8 +550,7 @@ const SMS_WSP_LANGUAGE_S wspLanguage[] =
 };
 
 
-const SMS_WSP_HEADER_PARAMETER_S wspHeaderApplId[] =
-{
+const SMS_WSP_HEADER_PARAMETER_S wspHeaderApplId[] = {
        { (char*)"x-wap-application:*",  0x00 },
        { (char*)"x-wap-application:push.sia",  0x01},
        { (char*)"x-wap-application:wml.ua",  0x02 },
@@ -585,8 +579,7 @@ const SMS_WSP_HEADER_PARAMETER_S wspHeaderApplId[] =
 };
 
 
-const char* wspCacheControl[] =
-{
+const char* wspCacheControl[] = {
        (char*)"No-cache",
        (char*)"No-store",
        (char*)"Max-age",
@@ -600,8 +593,7 @@ const char* wspCacheControl[] =
        (char*)"Proxy-revalidate"
 };
 
-const SMS_WSP_METHOD_TYPE_S wspMethodType[] =
-{
+const SMS_WSP_METHOD_TYPE_S wspMethodType[] = {
        { (char*)"GET", 0x40 },
        { (char*)"OPTIONS", 0x41 },
        { (char*)"HEAD", 0x42 },
@@ -612,8 +604,7 @@ const SMS_WSP_METHOD_TYPE_S wspMethodType[] =
 };
 
 
-const SMS_WSP_SECURITY_TYPE_S wspSecurityType[] =
-{
+const SMS_WSP_SECURITY_TYPE_S wspSecurityType[] = {
        {(char*)"NETWPIN",0x00},
        {(char*)"USERPIN",0x01},
        {(char*)"USERNETWPIN",0x02},
@@ -622,8 +613,7 @@ const SMS_WSP_SECURITY_TYPE_S wspSecurityType[] =
 
 
 
-const char* wspWeek[] =
-{
+const char* wspWeek[] = {
        (char*)"Sun",
        (char*)"Mon",
        (char*)"Tue",
@@ -634,8 +624,7 @@ const char* wspWeek[] =
 };
 
 
-const char* wspWeekDay[] =
-{
+const char* wspWeekDay[] = {
        (char*)"Sunday",
        (char*)"Monday",
        (char*)"Tuesday",
@@ -645,8 +634,7 @@ const char* wspWeekDay[] =
        (char*)"Saturday"
 };
 
-const char* wspMonth[] =
-{
+const char* wspMonth[] = {
        (char*)"Jan",
        (char*)"Feb",
        (char*)"Mar",
@@ -689,6 +677,7 @@ SmsPluginWapPushHandler* SmsPluginWapPushHandler::instance()
        return pInstance;
 }
 
+
 bool SmsPluginWapPushHandler::IsWapPushMsg(unsigned short dstport)
 {
        MSG_BEGIN();
@@ -770,8 +759,7 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi
        MSG_DEBUG("DataSize [%d]", DataSize);
 
        MSG_DEBUG("[pUserData]");
-       for (int i = 0; i < DataSize; i++)
-       {
+       for (int i = 0; i < DataSize; i++) {
                printf("[%02x]", pUserData[i]);
        }
        printf("\n\n");
@@ -798,7 +786,7 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi
        unique_ptr<char*, void(*)(char**)> WspBodyBuf(&pWspBody, unique_ptr_deleter);
        unsigned long wspBodyLen = 0;
 
-       /** pass PDU type */
+       /* pass PDU type */
        iPDU++;
 
        pushHeaderLen = wspRetriveUintvarDecode( pPDUTypeData, &iPDU );
@@ -827,20 +815,19 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi
        MSG_DEBUG("wspHeaderLen [%d]", wspHeaderLen);
 
        MSG_DEBUG("[pWspHeader]");
-       for (int i = 0; i < wspHeaderLen; i++)
-       {
+       for (int i = 0; i < wspHeaderLen; i++) {
                printf("[%02x]", pWspHeader[i]);
        }
        printf("\n\n");
 #endif
 
-       /** return if it is below case error */
+       /* return if it is below case error */
        if (PDUTypeDataLen < wspHeaderLen) {
                MSG_DEBUG("PDUTypeDataLen < wspHeaderLen !!!");
                return;
        }
 
-       /** Finding wspBody Information */
+       /* Finding wspBody Information */
        wspBodyLen = PDUTypeDataLen - wspHeaderLen;
 
        if (wspBodyLen > 0) {
@@ -866,7 +853,7 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi
        if (pushBodyLen > 0) {
                pPushBody = new char[pushBodyLen];
 
-               if (pPushBody == NULL)  {
+               if (pPushBody == NULL) {
                        MSG_DEBUG("pPushBody Memory Allocation Failed");
                        return;
                } else {
@@ -894,7 +881,7 @@ void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPu
 
        SMS_WAP_APP_CODE_T      appCode = getAppCode(pPushHeader);
 
-       /**  check Push message receive setting */
+       /*  check Push message receive setting */
        bool bPushRecv = false;
 
        MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv);
@@ -909,118 +896,95 @@ void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPu
                MSG_DEBUG("Received MMS Notification");
                handleMMSNotification(pPushBody, PushBodyLen);
                break;
-
        case SMS_WAP_APPLICATION_PUSH_SI:
                MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
                handleSIMessage(pPushBody, PushBodyLen, true);
                break;
-
        case SMS_WAP_APPLICATION_PUSH_SIC:
                MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
                handleSIMessage(pPushBody, PushBodyLen, false);
-               break;
-
+       break;
        case SMS_WAP_APPLICATION_PUSH_SL:
                MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
                handleSLMessage(pPushBody, PushBodyLen, true);
                break;
-
        case SMS_WAP_APPLICATION_PUSH_SLC:
                MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
                handleSLMessage(pPushBody, PushBodyLen, false);
-               break;
-
+       break;
        case SMS_WAP_APPLICATION_PUSH_CO:
                MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
                handleCOMessage(pPushBody, PushBodyLen, true);
                break;
-
        case SMS_WAP_APPLICATION_PUSH_COC:
                MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
                handleCOMessage(pPushBody, PushBodyLen, false);
                break;
-
        case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
                MSG_DEBUG("Received DM BOOTSTRAP");
                SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                break;
-
        case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
                MSG_DEBUG("Received DM BOOTSTRAP");
                SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                break;
-
        case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
                MSG_DEBUG("Received Provisioning");
                SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                break;
-
        case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
                MSG_DEBUG("Received Provisioning");
                SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                break;
-
        case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
        case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
                MSG_DEBUG("Received Provisioning");
                SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                break;
-
        case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
                MSG_DEBUG("Received DM Notification");
                SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                break;
-
        case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
                MSG_DEBUG("Received DS Notification");
                SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                break;
-
        case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
                MSG_DEBUG("Received DS Notification");
                SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                break;
-
        case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
        case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
                MSG_DEBUG("Received DRM UA");
-
                if (pPushBody != NULL)
                        handleDrmVer1(pPushBody, PushBodyLen);
-
                break;
-
        case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
        case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
        case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
        case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
                MSG_DEBUG("Received DRM V2");
-               // TODO: DRM V2
+               /* TODO: DRM V2 */
                break;
-
        case SMS_WAP_APPLICATION_PUSH_EMAIL:
        case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
        case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
                MSG_DEBUG("Received Email");
-               // TODO: Email
+               /* TODO: Email */
                break;
-
        case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
                MSG_DEBUG("Received IMPS CIR");
-               // TODO: IMPS CIR
+               /* TODO: IMPS CIR */
                break;
-
-       case SMS_WAP_APPLICATION_LBS :
+       case SMS_WAP_APPLICATION_LBS:
                MSG_DEBUG("Received LBS related message");
                SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
-               // TODO: LBS
+               /* TODO: LBS */
                break;
-
-       case SMS_WAP_APPLICATION_PUSH_SIA :
+       case SMS_WAP_APPLICATION_PUSH_SIA:
                MSG_DEBUG("Received SIA");
-               // TODO: SIA
+               /* TODO: SIA */
                break;
-
        default:
                MSG_DEBUG("Unknown Application [%d]", appCode);
                break;
@@ -1041,91 +1005,83 @@ static void launchProcessByAppcode(int appcode)
        GVariant *result_agent = NULL;
        GVariant *result_service = NULL;
 
-       switch(appcode){
-               case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
-               case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
-               case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
-               case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
-               case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
-               case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
-               case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
-                       {
-                               connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
-
+       switch (appcode) {
+       case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
+       case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
+       case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
+       case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
+       case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
+       case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
+       case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
+               {
+                       connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
                                dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_NONE,
-                                                                                       NULL, "org.tizen.omadmagent", "/org/tizen/omadmagent",
-                                                                                       "org.tizen.omadmagent", NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
-
+                                                                               NULL, "org.tizen.omadmagent", "/org/tizen/omadmagent",
+                                                                               "org.tizen.omadmagent", NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
                                result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("invoking agent proxy call failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
-
+                       if (error) {
+                               MSG_DEBUG("invoking agent proxy call failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
                                connection_service = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
-
+                       if (error) {
+                               MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
                                dbus_proxy_service =g_dbus_proxy_new_sync(connection_service, G_DBUS_PROXY_FLAGS_NONE, NULL,
-                                                                                       "org.tizen.omadmservice", "/org/tizen/omadmservice",
-                                                                                       "org.tizen.omadmservice", NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to service proxy failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
-
+                                                                               "org.tizen.omadmservice", "/org/tizen/omadmservice",
+                                                                               "org.tizen.omadmservice", NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("Connecting to service proxy failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
                                result_service = g_dbus_proxy_call_sync(dbus_proxy_service, "wakeup", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("invoking service proxy call failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
-
-                               Mutex mx;
-                               CndVar cv;
-                               mx.lock();
-                               cv.timedwait(mx.pMutex(), 2);
-                               mx.unlock();
-
-                               MSG_END();
+                       if (error) {
+                               MSG_DEBUG("invoking service proxy call failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
+                       Mutex mx;
+                       CndVar cv;
+                       mx.lock();
+                       cv.timedwait(mx.pMutex(), 2);
+                       mx.unlock();
+                       MSG_END();
+               }
+       break;
+       case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+       case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
+               {
+                       connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
                        }
-                       break;
-               case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
-               case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
-                       {
-                               connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
-
-                               dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_NONE, NULL,
-                                                                                       "org.tizen.omadsagent", "/org/tizen/omadsagent",
-                                                                                       "org.tizen.omadsagent", NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
 
-                               result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL,
+                       dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                                                                               "org.tizen.omadsagent", "/org/tizen/omadsagent",
+                                                                               "org.tizen.omadsagent", NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
+                       result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL,
                                                                                G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("invoking service error: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
+                       if (error) {
+                               MSG_DEBUG("invoking service error: %s\n", error->message);
+                               goto _DBUS_ERROR;
                        }
-                       break;
-               default:
-                       break;
+               }
+               break;
+       default:
+               break;
        }
 
 _DBUS_ERROR:
@@ -1190,9 +1146,9 @@ void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPu
                return;
        }
 
-       for(int i = 0; i < pushEvt_cnt; ++i)    {
+       for (int i = 0; i < pushEvt_cnt; ++i) {
 
-               /**  check Push message receive setting */
+               /*  check Push message receive setting */
                bool bPushRecv = false;
                int appcode = 0;
                MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv);
@@ -1205,7 +1161,7 @@ void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPu
                }
 
 #ifdef FEATURE_MMS_DISABLE
-               if (appcode == SMS_WAP_APPLICATION_MMS_UA){
+               if (appcode == SMS_WAP_APPLICATION_MMS_UA) {
                        MSG_DEBUG("Drop MMS Notification for DOCOMO");
                        return;
                }
@@ -1218,119 +1174,95 @@ void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPu
                        MSG_DEBUG("Received MMS Notification");
                        handleMMSNotification(pPushBody, PushBodyLen);
                        break;
-
                case SMS_WAP_APPLICATION_PUSH_SI:
                        MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
-//                     handleSIMessage(pPushBody, PushBodyLen, true);
+                       /* handleSIMessage(pPushBody, PushBodyLen, true); */
                        break;
-
                case SMS_WAP_APPLICATION_PUSH_SIC:
                        MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
-//                     handleSIMessage(pPushBody, PushBodyLen, false);
+                       /* handleSIMessage(pPushBody, PushBodyLen, false); */
                        break;
-
                case SMS_WAP_APPLICATION_PUSH_SL:
                        MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
-//                     handleSLMessage(pPushBody, PushBodyLen, true);
+                       /* handleSLMessage(pPushBody, PushBodyLen, true); */
                        break;
-
                case SMS_WAP_APPLICATION_PUSH_SLC:
                        MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
-//                     handleSLMessage(pPushBody, PushBodyLen, false);
+                       /* handleSLMessage(pPushBody, PushBodyLen, false); */
                        break;
-
                case SMS_WAP_APPLICATION_PUSH_CO:
                        MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
-//                     handleCOMessage(pPushBody, PushBodyLen, true);
+                       /* handleCOMessage(pPushBody, PushBodyLen, true); */
                        break;
-
                case SMS_WAP_APPLICATION_PUSH_COC:
                        MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
-//                     handleCOMessage(pPushBody, PushBodyLen, false);
+                       /* handleCOMessage(pPushBody, PushBodyLen, false); */
                        break;
-
                case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
                        MSG_DEBUG("Received DM BOOTSTRAP");
                        SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                        break;
-
                case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
                        MSG_DEBUG("Received DM BOOTSTRAP");
                        SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                        break;
-
                case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
                        MSG_DEBUG("Received Provisioning");
                        SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                        break;
-
                case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
                        MSG_DEBUG("Received Provisioning");
                        SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                        break;
-
                case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
                case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
                        MSG_DEBUG("Received Provisioning");
                        SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                        break;
-
                case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
                        MSG_DEBUG("Received DM Notification");
                        SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                        break;
-
                case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
                        MSG_DEBUG("Received DS Notification");
                        SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                        break;
-
                case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
                        MSG_DEBUG("Received DS Notification");
                        SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
                        break;
-
                case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
                case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
                        MSG_DEBUG("Received DRM UA");
-
                        if (pPushBody != NULL)
                                handleDrmVer1(pPushBody, PushBodyLen);
-
                        break;
-
                case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
                case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
                case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
                case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
                        MSG_DEBUG("Received DRM V2");
-                       // TODO: DRM V2
+                       /* TODO: DRM V2 */
                        break;
-
                case SMS_WAP_APPLICATION_PUSH_EMAIL:
                case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
                case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
                        MSG_DEBUG("Received Email");
-                       // TODO: Email
+                       /* TODO: Email */
                        break;
-
-
                case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
                        MSG_DEBUG("Received IMPS CIR");
-                       // TODO: IMPS CIR
+                       /* TODO: IMPS CIR */
                        break;
-
-               case SMS_WAP_APPLICATION_LBS :
+               case SMS_WAP_APPLICATION_LBS:
                        MSG_DEBUG("Received LBS related message");
                        SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
-                       // TODO: LBS
+                       /* TODO: LBS */
                        break;
-
-               case SMS_WAP_APPLICATION_PUSH_SIA :
+               case SMS_WAP_APPLICATION_PUSH_SIA:
                        MSG_DEBUG("Received SIA");
-                       // TODO: SIA
+                       /* TODO: SIA */
                        break;
-
                default:
                        SmsPluginEventHandler::instance()->handlePushMsgIncoming(pPushHeader, pPushBody, PushBodyLen, app_id, content_type);
                        break;
@@ -1349,14 +1281,13 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P
 #ifdef MSG_FW_FOR_DEBUG
        printf("\n\n[handleMMSNotification] Push Body.\n");
 
-       for (int i = 0; i < PushBodyLen; i++)
-       {
+       for (int i = 0; i < PushBodyLen; i++) {
                printf(" [%02x]", pPushBody[i]);
        }
        printf("\n\n");
 #endif
 
-       /** Make MSG_MESSAGE_INFO_S */
+       /* Make MSG_MESSAGE_INFO_S */
        MSG_MESSAGE_INFO_S msgInfo;
        memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
 
@@ -1365,7 +1296,7 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P
 
        createMsgInfo(&msgInfo);
 
-       /** Convert Type values */
+       /* Convert Type values */
        msgInfo.msgType.mainType = MSG_MMS_TYPE;
        msgInfo.msgType.subType = MSG_NOTIFICATIONIND_MMS;
        msgInfo.msgType.classType = MSG_CLASS_NONE;
@@ -1375,7 +1306,7 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P
        if (msgInfo.dataSize > MAX_MSG_TEXT_LEN) {
                msgInfo.bTextSms = false;
 
-               /** Save Message Data into File */
+               /* Save Message Data into File */
                char fileName[MSG_FILENAME_LEN_MAX+1];
                memset(fileName, 0x00, sizeof(fileName));
 
@@ -1397,16 +1328,16 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P
 
        msg_error_t err = MSG_SUCCESS;
 
-       /** Add MMS Noti Msg into DB */
+       /* Add MMS Noti Msg into DB */
        err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
 
        if (err == MSG_SUCCESS) {
-               /**  Callback */
+               /*  Callback */
                err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
 
-               if (err != MSG_SUCCESS) {
+               if (err != MSG_SUCCESS)
                        MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
-               }
+
        } else {
                MSG_DEBUG("checkMessage() Error !! [%d]", err);
        }
@@ -1414,6 +1345,7 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P
        MSG_END();
 }
 
+
 void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, bool isText)
 {
        MSG_BEGIN();
@@ -1462,10 +1394,10 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen,
                return;
        }
 
-       /**  temporary set to max. */
+       /*  temporary set to max. */
        pushMsg.expires = 0xFFFFFFFF;
 
-       /** setting received time */
+       /* setting received time */
        time_t  t               =       time(NULL);
        time_t  utfTime =       time(&t);
 
@@ -1512,7 +1444,7 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen,
 
        strncpy(pushMsg.contents, (char*)tmpXmlChar, MAX_WAPPUSH_CONTENTS_LEN-1);
 
-       /** Write push Msg to file */
+       /* Write push Msg to file */
        char fileName[MSG_FILENAME_LEN_MAX+1];
        memset(fileName, 0x00, sizeof(fileName));
 
@@ -1528,7 +1460,7 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen,
                THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
        }
 
-       /**  Pack Message Info Structure */
+       /*  Pack Message Info Structure */
        MSG_MESSAGE_INFO_S msgInfo;
        memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
 
@@ -1539,7 +1471,7 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen,
 
        strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
 
-       /**  Convert Type values */
+       /*  Convert Type values */
        msgInfo.msgType.mainType = MSG_SMS_TYPE;
        msgInfo.msgType.subType = MSG_WAP_SI_SMS;
 
@@ -1550,14 +1482,14 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen,
 
        msg_error_t err = MSG_SUCCESS;
 
-       /** Add WAP Push Msg into DB */
+       /* Add WAP Push Msg into DB */
        err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
 
        if (err == MSG_SUCCESS) {
-               /** Callback */
+               /* Callback */
                err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
 
-               if (err != MSG_SUCCESS){
+               if (err != MSG_SUCCESS) {
                        MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
                }
        } else {
@@ -1617,7 +1549,7 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen,
                indNode = indNode->next;
        }
 
-       /**  setting received time setting */
+       /*  setting received time setting */
        time_t  t               =       time(NULL);
        time_t  utfTime =       time(&t);
 
@@ -1635,9 +1567,9 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen,
        tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
        pushMsg.action = convertSLActionStrToEnum((char*)tmpXmlChar);
 
-       /** Setting other parameters in default values */
+       /* Setting other parameters in default values */
        pushMsg.created = pushMsg.received;
-       /** temporary set to MAX value. */
+       /* temporary set to MAX value. */
        pushMsg.expires = 0xFFFFFFFF;
 
        MSG_DEBUG("check pushMsg data");
@@ -1649,7 +1581,7 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen,
        MSG_DEBUG("pushMsg.href : [%s]", pushMsg.href);
        MSG_DEBUG("pushMsg.contents : [%s]", pushMsg.contents);
 
-       /** Write push Msg to file */
+       /* Write push Msg to file */
        char fileName[MSG_FILENAME_LEN_MAX+1];
        memset(fileName, 0x00, sizeof(fileName));
 
@@ -1659,7 +1591,7 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen,
        if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false)
                THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
 
-       /** Pack Message Info Structure */
+       /* Pack Message Info Structure */
        MSG_MESSAGE_INFO_S msgInfo;
        memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
 
@@ -1670,22 +1602,22 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen,
 
        strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
 
-       /** Convert Type values */
+       /* Convert Type values */
        msgInfo.msgType.mainType = MSG_SMS_TYPE;
        msgInfo.msgType.subType = MSG_WAP_SL_SMS;
 
-       /* Update Msg Text */
+       /* Update Msg Text */
        strncpy(msgInfo.msgText, pushMsg.href, MAX_MSG_TEXT_LEN);
 
        msgInfo.dataSize = sizeof(pushMsg);
 
        MSG_DEBUG("dataSize : %d", msgInfo.dataSize);
 
-       /** Add WAP Push Msg into DB */
+       /* Add WAP Push Msg into DB */
        err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
 
        if (err == MSG_SUCCESS) {
-               /** Callback to MSG FW */
+               /* Callback to MSG FW */
                err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
 
                if (err != MSG_SUCCESS)
@@ -1702,6 +1634,7 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen,
        return;
 }
 
+
 void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, bool isText)
 {
        MSG_PUSH_CACHEOP_S cacheOp;
@@ -1735,8 +1668,7 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen,
 
        indNode = topNode->xmlChildrenNode;
 
-
-       while(indNode != NULL) {
+       while (indNode != NULL) {
 
                xmlChar* tmpUrl = NULL;
                if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_OBJ)) {
@@ -1769,7 +1701,7 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen,
                indNode = indNode->next;
        }
 
-       /**  Write push Msg to file */
+       /*  Write push Msg to file */
        char fileName[MSG_FILENAME_LEN_MAX+1];
        memset(fileName, 0x00, sizeof(fileName));
 
@@ -1783,7 +1715,7 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen,
                THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
        }
 
-       /**  Pack Message Info Structure */
+       /*  Pack Message Info Structure */
        MSG_MESSAGE_INFO_S msgInfo;
        memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
 
@@ -1794,7 +1726,7 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen,
 
        strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
 
-       /**  Convert Type values */
+       /*  Convert Type values */
        msgInfo.msgType.mainType = MSG_SMS_TYPE;
        msgInfo.msgType.subType = MSG_WAP_CO_SMS;
 
@@ -1802,11 +1734,11 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen,
 
        msg_error_t err = MSG_SUCCESS;
 
-       /** Add WAP Push Msg into DB */
+       /* Add WAP Push Msg into DB */
        err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
 
        if (err == MSG_SUCCESS) {
-               /** Callback */
+               /* Callback */
                err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
 
                if (err != MSG_SUCCESS) {
@@ -1857,10 +1789,10 @@ void SmsPluginWapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen)
 
 void SmsPluginWapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
 {
-       /** Convert class Type values */
+       /* Convert class Type values */
        pMsgInfo->msgType.classType = MSG_CLASS_NONE;
 
-       /**  set folder id (temporary) */
+       /*  set folder id (temporary) */
        pMsgInfo->folderId = MSG_INBOX_ID;
 
        pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
@@ -1870,9 +1802,8 @@ void SmsPluginWapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
        pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
 
        time_t rawtime = time(NULL);
-
-/*** Comment below lines to save local UTC time..... (it could be used later.)
-
+       /* Comment below lines to save local UTC time..... (it could be used later.) */
+       /*
        if (tmpTimeStamp.format == SMS_TIME_ABSOLUTE) {
 
                MSG_DEBUG("year : %d", tmpTimeStamp.time.absolute.year);
@@ -1922,12 +1853,11 @@ void SmsPluginWapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
                strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
                MSG_DEBUG("displayTime [%s]", displayTime);
        }
-
-***/
+       */
 
        pMsgInfo->displayTime = rawtime;
 
-       /**  Convert Address values */
+       /*  Convert Address values */
        pMsgInfo->nAddressCnt = 1;
 
        pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
@@ -1942,6 +1872,7 @@ void SmsPluginWapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
 
 }
 
+
 void SmsPluginWapPushHandler::getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText)
 {
        if (pPushBody == NULL) {
@@ -1949,7 +1880,6 @@ void SmsPluginWapPushHandler::getXmlDoc(const char* pPushBody, const int PushBod
                return;
        }
 
-
        if (isText) {
                *pXmlDoc = xmlParseMemory(pPushBody, AcStrlen(pPushBody));
        } else {
@@ -1977,6 +1907,7 @@ void SmsPluginWapPushHandler::getXmlDoc(const char* pPushBody, const int PushBod
 
 }
 
+
 unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
 {
        struct tm       timeStruct;
@@ -1987,13 +1918,13 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        memset(tmpBuf, 0x00, sizeof(tmpBuf));
        memset(&timeStruct, 0x00, sizeof(struct tm));
 
-       /** check pDate */
+       /* check pDate */
        if (AcStrlen(pDate)<20)
                return 0;
 
        MSG_DEBUG("pDate [%s]", pDate);
 
-       /** Year */
+       /* Year */
        for (i = 0; i < 4; i++) {
                tmpBuf[i] = pDate[index++];
        }
@@ -2001,7 +1932,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        index++;
        timeStruct.tm_year = (atoi( tmpBuf)-1900);
 
-       /**  Month */
+       /*  Month */
        for (i = 0; i < 2; i++) {
                tmpBuf[i] = pDate[index++];
        }
@@ -2009,7 +1940,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        index++;
        timeStruct.tm_mon = (atoi( tmpBuf) - 1);
 
-       /** Date */
+       /* Date */
        for (i = 0; i < 2; i++) {
                tmpBuf[i] = pDate[index++];
        }
@@ -2017,7 +1948,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        index++;
        timeStruct.tm_mday = atoi( tmpBuf);
 
-       /** Hours */
+       /* Hours */
        for (i = 0; i < 2; i++) {
                tmpBuf[i] = pDate[index++];
        }
@@ -2025,7 +1956,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        index++;
        timeStruct.tm_hour = atoi( tmpBuf);
 
-       /** Minites */
+       /* Minites */
        for (i = 0; i < 2; i++) {
                tmpBuf[i] = pDate[index++];
        }
@@ -2033,7 +1964,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        index++;
        timeStruct.tm_min = atoi( tmpBuf);
 
-       /** Seconds */
+       /* Seconds */
        for (i = 0; i < 2; i++) {
                tmpBuf[i] = pDate[index++];
        }
@@ -2046,6 +1977,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        return nTimeInSec;
 }
 
+
 msg_push_action_t SmsPluginWapPushHandler::convertSIActionStrToEnum(char* pAction)
 {
        int comp = 0;
@@ -2055,36 +1987,37 @@ msg_push_action_t SmsPluginWapPushHandler::convertSIActionStrToEnum(char* pActio
                return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
        }
 
-       /** compare  with signal-none. */
+       /* compare  with signal-none. */
        comp = g_strcmp0( "signal-none", pAction );
        if (comp == 0)
                return MSG_PUSH_SI_ACTION_SIGNAL_NONE;
 
-       /** compare  with signal-low. */
+       /* compare  with signal-low. */
        comp = g_strcmp0( "signal-low", pAction );
        if (comp == 0)
                return MSG_PUSH_SI_ACTION_SIGNAL_LOW;
 
-       /**  compare  with signal-medium. */
+       /*  compare  with signal-medium. */
        comp = g_strcmp0( "signal-medium", pAction );
        if (comp == 0)
                return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
 
-       /**  compare  with signal-high. */
+       /*  compare  with signal-high. */
        comp = g_strcmp0( "signal-high", pAction );
        if (comp == 0)
                return MSG_PUSH_SI_ACTION_SIGNAL_HIGH;
 
-       /**  compare  with delete. */
+       /*  compare  with delete. */
        comp = g_strcmp0( "delete", pAction );
        if (comp == 0)
                return MSG_PUSH_SI_ACTION_DELETE;
 
-       /**  signal-medium is default action value. */
+       /*  signal-medium is default action value. */
        return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
 
 }
 
+
 msg_push_action_t SmsPluginWapPushHandler::convertSLActionStrToEnum(char* pAction)
 {
        int comp = 0;
@@ -2094,22 +2027,22 @@ msg_push_action_t SmsPluginWapPushHandler::convertSLActionStrToEnum(char* pActio
                return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
        }
 
-       /**  compare pSrcStr with execute-low. */
+       /*  compare pSrcStr with execute-low. */
        comp = g_strcmp0( "execute-low", pAction );
        if (comp == 0)
                return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
 
-       /**  compare pSrcStr with execute-high. */
+       /*  compare pSrcStr with execute-high. */
        comp = g_strcmp0( "execute-high", pAction );
        if (comp == 0)
                return MSG_PUSH_SL_ACTION_EXECUTE_HIGH;
 
-       /** compare pSrcStr with cache. */
+       /* compare pSrcStr with cache. */
        comp = g_strcmp0( "cache", pAction );
        if (comp == 0)
                return MSG_PUSH_SL_ACTION_CACHE;
 
-       /** default SL action value is execute-low. */
+       /* default SL action value is execute-low. */
        return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
 
 }
@@ -2201,7 +2134,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un
 
        if (fContentType) {
                encodedHeader = new char[ encodedHeaderLen + 1 ];
-               if (encodedHeader == NULL)      {
+               if (encodedHeader == NULL) {
                        MSG_DEBUG("encodedHeader Memory allocation is failed.\n" );
                        return;
                }
@@ -2209,7 +2142,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un
                memcpy( encodedHeader + 1, sEncodedHeader, (size_t)encodedHeaderLen );
        } else {
                encodedHeader = new char[ encodedHeaderLen ];
-               if (encodedHeader == NULL)      {
+               if (encodedHeader == NULL) {
                        MSG_DEBUG("encodedHeader Memory allocation is failed.\n" );
                        return;
                }
@@ -2273,8 +2206,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un
                                unsigned char fieldValue[1275];
                                fieldCode = track & 0x7f;
                                /*
-                               if (( fieldValueLen == 0 ) || ( fieldValueLen == 0x80 ))
-                               {
+                               if (( fieldValueLen == 0 ) || ( fieldValueLen == 0x80 )) {
                                        dprint( DNET_WAP,DNET_DBG_HIGH, "%X %X %X %X %X %X\n" , fieldCode, encodedHeader[iEncodedHeader + 1], encodedHeader[iEncodedHeader + 2],encodedHeader[iEncodedHeader + 3],encodedHeader[iEncodedHeader + 4], encodedHeader[iEncodedHeader + 5] );
                                }
                                */
@@ -2328,7 +2260,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un
 
                                                        if (fieldValueLen == 1) {
                                                                /* field value is one byte integer over 0x80 */
-                                                               /** make it two byte integer */
+                                                               /* make it two byte integer */
                                                                fieldValue[0] = 0x00;
                                                                memcpy( fieldValue + 1, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
                                                                fieldValueLen = 2;
@@ -2361,560 +2293,554 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un
                                        }
 
 
-                                       switch ( fieldCode )
-                                       {
-                                               /* accept charset */
-                                               /* It's normal way of field process. */
-                                               case 0x01 :
-                                                       {
-                                                               unsigned long  i = 0;
-                                                               unsigned long  code;
-
-                                                               /* Case of length of charset greater than 1 are two thigins.
-                                                               1. code length of charset is greater than 1.
-                                                               2. It include parameter.
-                                                               3. Or both of two
-                                                               */
-                                                               if (1 != fieldValueLen) {
-                                                                       code = wspHeaderDecodeInteger( fieldValue );
-                                                                       /* Calculate iField. */
-                                                                       if (fieldValue[0] < 0x80 )
-                                                                               iField = fieldValue[0];
-                                                                       else
-                                                                               iField = 1;
-
-                                                                       while ( wspCharset[i].charsetCode != code )
-                                                                               i++;
-                                                                       strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       /* If parameter exist */
-                                                                       if (iField < fieldValueLen) {
-                                                                               char* param = NULL;
-                                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                               wspHeaderDecodeQValue( fieldValueLen - iField, fieldValue + iField, &param);
-                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       }
-                                                               } else {
-                                                                       code = fieldValue[0] & 0x7f;
+                                       switch (fieldCode) {
+                                       /* accept charset */
+                                       /* It's normal way of field process. */
+                                       case 0x01:
+                                               {
+                                                       unsigned long  i = 0;
+                                                       unsigned long  code;
+
+                                                       /* Case of length of charset greater than 1 are two thigins.
+                                                       1. code length of charset is greater than 1.
+                                                       2. It include parameter.
+                                                       3. Or both of two
+                                                       */
+                                                       if (1 != fieldValueLen) {
+                                                               code = wspHeaderDecodeInteger( fieldValue );
+                                                               /* Calculate iField. */
+                                                               if (fieldValue[0] < 0x80 )
+                                                                       iField = fieldValue[0];
+                                                               else
+                                                                       iField = 1;
 
-                                                                       while (( wspCharset[i].charsetCode != code ) && ( wspCharset[i].charsetCode != 0xffff  )) i++;
-                                                                       strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               while ( wspCharset[i].charsetCode != code )
+                                                                       i++;
+                                                               strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               /* If parameter exist */
+                                                               if (iField < fieldValueLen) {
+                                                                       char* param = NULL;
+                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                                       wspHeaderDecodeQValue( fieldValueLen - iField, fieldValue + iField, &param);
+                                                                       strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
                                                                }
+                                                       } else {
+                                                               code = fieldValue[0] & 0x7f;
 
+                                                               while (( wspCharset[i].charsetCode != code ) && ( wspCharset[i].charsetCode != 0xffff  )) i++;
+                                                               strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
                                                        }
-                                                       break;
 
-                                               /* type encoding */
-                                               /* Like below routine, Same decoding routine process together. */
-                                               /* Accept-encoding */
-                                               case 0x02 :
-                                               /* content-encoding */
-                                               case 0x0b :
-                                                       {
-                                                               int integerValue;
-
-                                                               integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen );
-                                                               if (integerValue > 2) {
-                                                                       MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(2).\n");
-                                                                       break;
-                                                               }
-                                                               strncat( (char*)temper, (char*)wspEncodeMethod[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                       break;
+
+                                       /* type encoding */
+                                       /* Like below routine, Same decoding routine process together. */
+                                       /* Accept-encoding */
+                                       case 0x02:
+                                       /* content-encoding */
+                                       case 0x0b:
+                                               {
+                                                       int integerValue;
+
+                                                       integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen );
+                                                       if (integerValue > 2) {
+                                                               MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(2).\n");
+                                                               break;
+                                                       }
+                                                       strncat( (char*)temper, (char*)wspEncodeMethod[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                               break;
+                                       /* contents type decoder */
+                                       /* accept */
+                                       case 0x00:
+                                       /* content-type */
+                                       case 0x11:
+                                               {
+                                                       unsigned long  contentsTypeCode;
+                                                       unsigned long  i = 0;
+                                                       /* encoded content type length body */
+                                                       unsigned long  tempLen;
+                                                       MSG_DEBUG("fieldValueLen: %d", fieldValueLen);
+
+                                                       /* Like HTTP result state 304, it's for processing without Content type. This part doesn't defined. */
+                                                       if (0 == fieldValueLen) {
+                                                               strncat( (char*)temper, (char*)"None" , (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                               break;
+                                                       }
+                                                       /* 01 AE --> 00 AE --> AE*/
+                                                       if (fieldValueLen == 2  &&  fieldValue[0] == 0) {
+                                                               memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
+                                                               MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
                                                        }
-                                                       break;
-                                               /* contents type decoder */
-                                               /* accept */
-                                               case 0x00 :
-                                               /* content-type */
-                                               case 0x11 :
-                                                       {
-                                                               unsigned long  contentsTypeCode;
-                                                               unsigned long  i = 0;
-                                                               /* encoded content type length body */
-                                                               unsigned long  tempLen;
-                                                               MSG_DEBUG("fieldValueLen: %d", fieldValueLen);
-
-                                                               /* Like HTTP result state 304, it's for processing without Content type. This part doesn't defined. */
-                                                               if (0 == fieldValueLen) {
-                                                                       strncat( (char*)temper, (char*)"None" , (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-                                                                       break;
-                                                               }
-                                                               /* 01 AE --> 00 AE --> AE*/
-                                                               if (fieldValueLen == 2  &&  fieldValue[0] == 0) {
-                                                                       memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
-                                                                       MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
-                                                               }
-
-                                                               if ((fieldValue[0] < 0x20 ) || (fieldValue[0] >= 0x80 )) {
-                                                                       if (fieldValue[0] >= 0x80) {
-                                                                               tempLen = 1;
-                                                                       } else if (fieldValueLen == 2 && fieldValue[0] == 0x03 && fieldValue[1] == 0x0A) { /** 06 05 02 03 0A AF 89 */
-                                                                               fieldValue[3] = fieldValue[2];
-                                                                               fieldValue[2] = fieldValue[1];
-                                                                               fieldValue[1] = fieldValue[0];
-                                                                               fieldValue[0] = 0x02;
-                                                                               tempLen = 2;
-                                                                               fieldValueLen = 3;
-                                                                               MSG_DEBUG("WspLDecodeHeader:For CPE problem\r\n" );
-                                                                       } else {
-                                                                               tempLen = fieldValue[0]; /** 06 06 03 02 03 16 AF 88 */
-                                                                       }
-
-                                                                       if (tempLen == 1) {
-
-                                                                               char* szExtendedContent;
-
-                                                                               contentsTypeCode = fieldValue[0] & 0x7f;
-                                                                               while (( wspContentsType[i].contentsTypeCode != contentsTypeCode ) && ( i < wspContentsTypeCount )) i++;
 
-                                                                               /* If specified content type doesn't exist */
-                                                                               if (i < wspContentsTypeCount)
-                                                                                       strncat( (char*)temper, (char*)wspContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       if ((fieldValue[0] < 0x20 ) || (fieldValue[0] >= 0x80 )) {
+                                                               if (fieldValue[0] >= 0x80) {
+                                                                       tempLen = 1;
+                                                               } else if (fieldValueLen == 2 && fieldValue[0] == 0x03 && fieldValue[1] == 0x0A) { /* 06 05 02 03 0A AF 89 */
+                                                                       fieldValue[3] = fieldValue[2];
+                                                                       fieldValue[2] = fieldValue[1];
+                                                                       fieldValue[1] = fieldValue[0];
+                                                                       fieldValue[0] = 0x02;
+                                                                       tempLen = 2;
+                                                                       fieldValueLen = 3;
+                                                                       MSG_DEBUG("WspLDecodeHeader:For CPE problem\r\n" );
+                                                               } else {
+                                                                       tempLen = fieldValue[0]; /* 06 06 03 02 03 16 AF 88 */
+                                                               }
 
-                                                                               szExtendedContent =  wspExtendedDecodeType( (char)contentsTypeCode );
+                                                               if (tempLen == 1) {
+                                                                       char* szExtendedContent;
 
-                                                                               if (szExtendedContent != NULL) {
-                                                                                       MSG_DEBUG("WspLDecodeHeader: Tele2 server problem \n " );
-                                                                                       strncat( (char*)temper, (char*)szExtendedContent, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                               }
-                                                                       } else {
-                                                                               contentsTypeCode = wspHeaderDecodeInteger(fieldValue);
+                                                                       contentsTypeCode = fieldValue[0] & 0x7f;
+                                                                       while (( wspContentsType[i].contentsTypeCode != contentsTypeCode ) && ( i < wspContentsTypeCount )) i++;
 
-                                                                               while ((i < wspUnregisteredContentsTypeCount) && (wspUnregisterContentsType[i].contentsTypeCode != contentsTypeCode)) i++;
+                                                                       /* If specified content type doesn't exist */
+                                                                       if (i < wspContentsTypeCount)
+                                                                               strncat( (char*)temper, (char*)wspContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
 
-                                                                               /** If there is a Content-Type assigned, */
-                                                                               if (i < wspUnregisteredContentsTypeCount)
-                                                                                       strncat ((char*)temper, (char*)wspUnregisterContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                                       szExtendedContent =  wspExtendedDecodeType( (char)contentsTypeCode );
 
-                                                                               tempLen +=1;
+                                                                       if (szExtendedContent != NULL) {
+                                                                               MSG_DEBUG("WspLDecodeHeader: Tele2 server problem \n " );
+                                                                               strncat( (char*)temper, (char*)szExtendedContent, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
                                                                        }
                                                                } else {
-                                                                       tempLen = AcStrlen( (char*)fieldValue ) + 1;
+                                                                       contentsTypeCode = wspHeaderDecodeInteger(fieldValue);
 
-                                                                       strncat ((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-                                                                       MSG_DEBUG("WspLDecodeHeader: Attention, Decoding Check of Content-Type\n ", tempLen);
-                                                               }
+                                                                       while ((i < wspUnregisteredContentsTypeCount) && (wspUnregisterContentsType[i].contentsTypeCode != contentsTypeCode))
+                                                                               i++;
 
-                                                               /* If there is a parameter */
-                                                               if (tempLen < fieldValueLen) {
-                                                                       char* param = NULL;
-                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                       wspHeaderDecodeParameter( fieldValue + tempLen, fieldValueLen - tempLen, &param);
-                                                                       if (param != NULL) {
-                                                                               strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       }
-                                                               }
-                                                       }
-                                                       break;
+                                                                       /* If there is a Content-Type assigned, */
+                                                                       if (i < wspUnregisteredContentsTypeCount)
+                                                                               strncat ((char*)temper, (char*)wspUnregisterContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
 
-                                               /* language */
-                                               /* content-language */
-                                               case 0x0c :
-                                               /* accept-language */
-                                               case 0x03 :
-                                                       {
-                                                               unsigned long i = 0;
-                                                               unsigned long code;
-                                                               unsigned long tempLen;
-                                                               if ((fieldValue[0] < 0x20 ) || (fieldValue[0] > 0x80 )) {
-                                                                       if (fieldValue[0] > 0x80 )
-                                                                               tempLen = 1;
-                                                                       else
-                                                                               tempLen = fieldValue[0];
-                                                               } else {
-                                                                       tempLen = AcStrlen( (char*)fieldValue ) + 1;
+                                                                               tempLen +=1;
                                                                }
+                                                       } else {
+                                                               tempLen = AcStrlen( (char*)fieldValue ) + 1;
 
-                                                               if (tempLen == 1) {
-
-                                                                       code = wspHeaderDecodeInteger( fieldValue );
-                                                                       while ( wspLanguage[i].languageCode != code) {
-                                                                               i++;
-                                                                               if (i == wspLanguageCount)
-                                                                                       break;
-                                                                       }
-
-                                                                       if (i < wspLanguageCount) {
-                                                                               strncat( (char*)temper, (char*)wspLanguage[i].languageName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       }
-                                                               } else {
-                                                                       strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-                                                               }
+                                                               strncat ((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                               MSG_DEBUG("WspLDecodeHeader: Attention, Decoding Check of Content-Type\n ", tempLen);
+                                                       }
 
-                                                               if (tempLen < fieldValueLen) {
-                                                                       char* param = NULL;
-                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                       wspHeaderDecodeQValue(  fieldValueLen - tempLen, fieldValue + tempLen, &param );
+                                                       /* If there is a parameter */
+                                                       if (tempLen < fieldValueLen) {
+                                                               char* param = NULL;
+                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                               wspHeaderDecodeParameter( fieldValue + tempLen, fieldValueLen - tempLen, &param);
+                                                               if (param != NULL) {
+                                                                       strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                                        strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
                                                                }
                                                        }
-                                                       break;
-
-                                               /* integer */
-                                               /* Max-forwards */
-                                               case 0x1e :
-                                               /* content-length */
-                                               case 0x0d :
-                                               /* age */
-                                               case 0x05 :
-                                               /* Bearer-indication */
-                                               case 0x33 :
-                                               /* Push-Flag */
-                                               case 0x34 :
-                                                       {
-
-                                                               unsigned char temp[16];
-                                                               /*
-                                                               if (( fieldValueLen == 2 ) && ( fieldValue[0] > 0x7f ))
-                                                                       AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[1]);
+                                               }
+                                               break;
+
+                                       /* language */
+                                       /* content-language */
+                                       case 0x0c:
+                                       /* accept-language */
+                                       case 0x03:
+                                               {
+                                                       unsigned long i = 0;
+                                                       unsigned long code;
+                                                       unsigned long tempLen;
+                                                       if ((fieldValue[0] < 0x20 ) || (fieldValue[0] > 0x80 )) {
+                                                               if (fieldValue[0] > 0x80 )
+                                                                       tempLen = 1;
                                                                else
-                                                               */
-                                                               snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                       tempLen = fieldValue[0];
+                                                       } else {
+                                                               tempLen = AcStrlen( (char*)fieldValue ) + 1;
                                                        }
-                                                       break;
-                                               /* X-Wap-Application-Id */
-                                               case 0x2f :
-                                                       {
-                                                               unsigned char temp[64];
-                                                               int         integerValue;
-
-                                                               if (fieldValueLen == 2 &&  fieldValue[0] == 0) {
-                                                                       memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
-                                                                       MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
-                                                                       fieldValueLen = 1;
-                                                               }
 
-                                                               integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
+                                                       if (tempLen == 1) {
 
-                                                               int count = sizeof(wspHeaderApplId)/sizeof(SMS_WSP_HEADER_PARAMETER_S);
-                                                               for(int i = 0; i < count ; ++i)
-                                                               {
-                                                                       if ((unsigned int)integerValue == wspHeaderApplId[i].parameterCode)
-                                                                       {
-                                                                               snprintf((char*)temp, 64, "%s", wspHeaderApplId[i].parameterToken);
-                                                                               strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+                                                               code = wspHeaderDecodeInteger( fieldValue );
+                                                               while ( wspLanguage[i].languageCode != code) {
+                                                                       i++;
+                                                                       if (i == wspLanguageCount)
                                                                                break;
-                                                                       }
                                                                }
-                                                       }
-                                                       break;
-                                               /* Accept-Application */
-                                               case 0x32 :
-                                                       if (0x80 == fieldValue[0]) {
-                                                               strncat( (char*)temper, "*", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
-                                                       } else {
-
-                                                               unsigned char temp[16];
-                                                               /*
-                                if (( fieldValueLen == 2 ) && ( fieldValue[0] == 1 ))
-                                       AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[0]);
-                                else
-                                                               */
-                                                               snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
-                                                       }
-                                                       break;
-
-
-                                               /* date */
-                                               /* last-modified */
-                                               case 0x1d :
-                                               /* if-unmodified-since */
-                                               case 0x1b :
-                                               /* if-range */
-                                               case 0x1a :
-                                               /* if-modified-since */
-                                               case 0x17 :
-                                               /* expires */
-                                               case 0x14 :
-                                               /* date */
-                                               case 0x12 :
-                                                       {
-                                                               char* decodedString = NULL;
-                                                               unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
-                                                               wspHeaderDecodeDateValue( fieldValueLen, fieldValue, &decodedString);
-                                                               strncat( (char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
-                                                       }
-                                                       break;
-
-                                               /* connection */
-                                               case 0x09 :
-                                                       if (fieldValue[0] == 0x80 )
-                                                               strncat( (char*)temper, "Close", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
-                                                       break;
-                                               /* accept-ranges */
-                                               case 0x04 :
-                                                       if (fieldValue[0] == 0x80 )
-                                                               strncat( (char*)temper, "None", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
-                                                       if (fieldValue[0] == 0x81 )
-                                                               strncat( (char*)temper, "Bytes", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
-                                                       break;
-                                               /* content-md5 */
-                                               case 0x0f :
-                                                       {
-                                                               unsigned char temp[1275];
-                                                               memcpy( temp, fieldValue, (size_t)fieldValueLen );
-                                                               temp[fieldValueLen] = 0;
-                                                               wspHeaderCopyDecodedString( temp, &currentLength, &temper );
-                                                       }
-                                                       break;
-                                               /* Credential */
-                                               /* authorization */
-                                               case 0x07 :
-                                               /* proxy - authorization */
-                                               case 0x21 :
-                                                       if (fieldValue[0] == 0x80) {
-                                                               char* addString = NULL;
-                                                               unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
-                                                               wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString );
-                                                               strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       } else {
-                                                               iField = AcStrlen( (char*)fieldValue) + 1;
 
-                                                               strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                               if (iField < fieldValueLen) {
-                                                                       char* param = NULL;
-                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                       wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, &param );
-                                                                       if (param != NULL) {
-                                                                               strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       }
+                                                               if (i < wspLanguageCount) {
+                                                                       strncat( (char*)temper, (char*)wspLanguage[i].languageName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
                                                                }
-                                                       }
-                                                       break;
-
-
-                                               /* Challenge */
-                                               /* www - auth */
-                                               case 0x2d :
-                                               /* Proxy-authenticate */
-                                               case 0x20 :
-                                                       if (0 == fieldValueLen )
-                                                               break;
-                                                       if (fieldValue[0] == 0x80) {
-                                                               char* addString = NULL;
-                                                               unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
-                                                               wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString );
-                                                               strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
                                                        } else {
-                                                               unsigned char  authScheme[WSP_STANDARD_STR_LEN_MAX + 1];
-                                                               unsigned char  realmValue[WSP_STANDARD_STR_LEN_MAX];
-                                                               unsigned char  addedString[WSP_STANDARD_STR_LEN_MAX];
-
-                                                               strncpy( (char*)authScheme, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX -1);
-                                                               iField = AcStrlen( (char*)authScheme ) + 1;
-                                                               strncpy( (char*)realmValue, (char*)(fieldValue + iField ), WSP_STANDARD_STR_LEN_MAX-1);
-                                                               iField = iField + AcStrlen( (char*)realmValue ) + 1;
-                                                               snprintf( (char*)addedString, sizeof(addedString), "%s %s", authScheme, realmValue );
-                                                               wspHeaderCopyDecodedString( addedString, &currentLength, &temper );
-
-                                                               if (iField < fieldValueLen) {
-                                                                       char* param = NULL;
-                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                       wspHeaderDecodeParameter( fieldValue + iField, fieldValueLen - iField, &param );
-                                                                       if (param != NULL) {
-                                                                               strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                               wspHeaderCopyDecodedString( (unsigned char*)param, &currentLength, &temper );
-                                                                       }
-                                                               }
+                                                               strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                        }
-                                                       break;
-
-                                               /* content -range */
-                                               case 0x10 :
-                                                       {
-                                                               unsigned long  first, len, last;
-
-                                                               unsigned char  temp[16];
-                                                               iField = 0;
-
-                                                               strncat( (char*)temper," bytes ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
 
-                                                               first = wspRetriveUintvarDecode( fieldValue, &iField );
-                                                               len = wspRetriveUintvarDecode( fieldValue, &iField );
-                                                               /* Originally range of HTTP include entity length. But WSP omit it. Finally to calculate this, it should be get content length from export. If this field is included without content length, then it can get wrong result. This content length can be get by calculating PDU length.
-                                                               */
-                                                               last = first + contentsLength - 1;
-
-                                                               snprintf( (char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len );
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       if (tempLen < fieldValueLen) {
+                                                               char* param = NULL;
+                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                               wspHeaderDecodeQValue(  fieldValueLen - tempLen, fieldValue + tempLen, &param );
+                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
                                                        }
-                                                       break;
-
-                                               /* cache-control */
-                                               case 0x08 :
-                                                       {
-                                                               char* cacheString = NULL;
-                                                               unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter);
-
-                                                               wspHeaderDecodeCacheControl( fieldValue, fieldValueLen, &cacheString );
-                                                               strncat( (char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               }
+                                               break;
+
+                                       /* integer */
+                                       /* Max-forwards */
+                                       case 0x1e:
+                                       /* content-length */
+                                       case 0x0d:
+                                       /* age */
+                                       case 0x05:
+                                       /* Bearer-indication */
+                                       case 0x33:
+                                       /* Push-Flag */
+                                       case 0x34:
+                                               {
+
+                                                       unsigned char temp[16];
+                                                       /*
+                                                       if (( fieldValueLen == 2 ) && ( fieldValue[0] > 0x7f ))
+                                                               AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[1]);
+                                                       else
+                                                       */
+                                                       snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
+                                                       strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               }
+                                               break;
+                                       /* X-Wap-Application-Id */
+                                       case 0x2f:
+                                               {
+                                                       unsigned char temp[64];
+                                                       int         integerValue;
+
+                                                       if (fieldValueLen == 2 &&  fieldValue[0] == 0) {
+                                                               memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
+                                                               MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
+                                                               fieldValueLen = 1;
                                                        }
-                                                       break;
 
-                                               /* pragma */
-                                               case 0x1f :
-                                                       if (fieldValue[0] == 0x80) {
-                                                               strncat( (char*)temper, (char*)wspCacheControl[0], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       } else {
-                                                               if (1 < fieldValueLen) {
-                                                                       char* param = NULL;
-                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                       wspHeaderDecodeParameter( fieldValue, fieldValueLen, &param );
+                                                       integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
 
-                                                                       if (param != NULL) {
-                                                                               strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       }
+                                                       int count = sizeof(wspHeaderApplId)/sizeof(SMS_WSP_HEADER_PARAMETER_S);
+                                                       for (int i = 0; i < count ; ++i) {
+                                                               if ((unsigned int)integerValue == wspHeaderApplId[i].parameterCode) {
+                                                                       snprintf((char*)temp, 64, "%s", wspHeaderApplId[i].parameterToken);
+                                                                       strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+                                                                       break;
                                                                }
                                                        }
+                                               }
+                                               break;
+                                       /* Accept-Application */
+                                       case 0x32:
+                                               if (0x80 == fieldValue[0]) {
+                                                       strncat( (char*)temper, "*", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
+                                               } else {
 
-                                                       break;
-                                               /* public */
-                                               case 0x22 :
-                                               /* allow */
-                                               case 0x06 :
-                                                       {
-                                                               unsigned long  i = 0;
-                                                               while ( wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ) != wspMethodType[i].methodCode ) i++;
-                                                               strncat( (char*)temper, (char*)wspMethodType[i].methodName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       }
-                                                       break;
-                                               /* range */
-                                               case 0x23 :
-                                                       strncat( (char*)temper, "bytes=", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       if (fieldValue[0] == 0x80) {
-                                                               unsigned char temp[16];
-                                                               unsigned long  first, last;
-                                                               iField = 0;
-
-                                                               first = wspRetriveUintvarDecode( fieldValue, &iField );
-                                                               last = wspRetriveUintvarDecode( fieldValue, &iField );
-
-                                                               snprintf( (char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last );
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       }
-                                                       if (fieldValue[0] == 0x81) {
-                                                               unsigned char temp[16];
-                                                               unsigned long  suffix;
-
-                                                               suffix = wspRetriveUintvarDecode( fieldValue, &iField );
-
-                                                               snprintf( (char*)temp, sizeof(temp), "-%u", (unsigned int)suffix );
+                                                       unsigned char temp[16];
+                                                       /*
+                               if (( fieldValueLen == 2 ) && ( fieldValue[0] == 1 ))
+                                      AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[0]);
+                               else
+                                                       */
+                                                       snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
+                                                       strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+                                               }
+                                               break;
+
+
+                                       /* date */
+                                       /* last-modified */
+                                       case 0x1d:
+                                       /* if-unmodified-since */
+                                       case 0x1b:
+                                       /* if-range */
+                                       case 0x1a:
+                                       /* if-modified-since */
+                                       case 0x17:
+                                       /* expires */
+                                       case 0x14:
+                                       /* date */
+                                       case 0x12:
+                                               {
+                                                       char* decodedString = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
+                                                       wspHeaderDecodeDateValue( fieldValueLen, fieldValue, &decodedString);
+                                                       strncat( (char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
+                                               }
+                                               break;
+
+                                       /* connection */
+                                       case 0x09:
+                                               if (fieldValue[0] == 0x80 )
+                                                       strncat( (char*)temper, "Close", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
+                                               break;
+                                       /* accept-ranges */
+                                       case 0x04:
+                                               if (fieldValue[0] == 0x80 )
+                                                       strncat( (char*)temper, "None", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
+                                               if (fieldValue[0] == 0x81 )
+                                                       strncat( (char*)temper, "Bytes", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
+                                               break;
+                                       /* content-md5 */
+                                       case 0x0f:
+                                               {
+                                                       unsigned char temp[1275];
+                                                       memcpy( temp, fieldValue, (size_t)fieldValueLen );
+                                                       temp[fieldValueLen] = 0;
+                                                       wspHeaderCopyDecodedString( temp, &currentLength, &temper );
+                                               }
+                                               break;
+                                       /* Credential */
+                                       /* authorization */
+                                       case 0x07:
+                                       /* proxy - authorization */
+                                       case 0x21:
+                                               if (fieldValue[0] == 0x80) {
+                                                       char* addString = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
+                                                       wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString );
+                                                       strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               } else {
+                                                       iField = AcStrlen( (char*)fieldValue) + 1;
 
+                                                       strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       if (iField < fieldValueLen) {
+                                                               char* param = NULL;
+                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                               wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, &param );
+                                                               if (param != NULL) {
+                                                                       strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                       strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               }
                                                        }
+                                               }
+                                               break;
+
+                                       /* Challenge */
+                                       /* www - auth */
+                                       case 0x2d:
+                                       /* Proxy-authenticate */
+                                       case 0x20:
+                                               if (0 == fieldValueLen )
                                                        break;
-                                               /* retry-after */
-                                               case 0x25 :
-                                                       if (fieldValue[0] == 0x80) {
-                                                               char* temp = NULL;
-                                                               unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter);
-
-                                                               wspHeaderDecodeDateValue( fieldValueLen - 1, fieldValue + 1, &temp );
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               if (fieldValue[0] == 0x80) {
+                                                       char* addString = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
+                                                       wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString );
+                                                       strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               } else {
+                                                       unsigned char  authScheme[WSP_STANDARD_STR_LEN_MAX + 1];
+                                                       unsigned char  realmValue[WSP_STANDARD_STR_LEN_MAX];
+                                                       unsigned char  addedString[WSP_STANDARD_STR_LEN_MAX];
+
+                                                       strncpy( (char*)authScheme, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX -1);
+                                                       iField = AcStrlen( (char*)authScheme ) + 1;
+                                                       strncpy( (char*)realmValue, (char*)(fieldValue + iField ), WSP_STANDARD_STR_LEN_MAX-1);
+                                                       iField = iField + AcStrlen( (char*)realmValue ) + 1;
+                                                       snprintf( (char*)addedString, sizeof(addedString), "%s %s", authScheme, realmValue );
+                                                       wspHeaderCopyDecodedString( addedString, &currentLength, &temper );
+
+                                                       if (iField < fieldValueLen) {
+                                                               char* param = NULL;
+                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                               wspHeaderDecodeParameter( fieldValue + iField, fieldValueLen - iField, &param );
+                                                               if (param != NULL) {
+                                                                       strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                                       wspHeaderCopyDecodedString( (unsigned char*)param, &currentLength, &temper );
+                                                               }
                                                        }
+                                               }
+                                               break;
 
-                                                       if (fieldValue[0] == 0x81) {
-                                                               unsigned char temp[16];
+                                       /* content -range */
+                                       case 0x10:
+                                               {
+                                                       unsigned long  first, len, last;
 
-                                                               snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen ));
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       }
-                                                       break;
-                                               /* transfer-encoding */
-                                               case 0x27 :
-                                                       /* No other cases allowed */
-                                                       if (fieldValue[0] == 0x80 )
-                                                               strncat( (char*)temper, "chunked", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       unsigned char  temp[16];
+                                                       iField = 0;
 
-                                                       break;
-                                               /* vary */
-                                               case 0x2a :
-                                                       {
-                                                               int integerValue = wspHeaderDecodeIntegerByLength(fieldValue,fieldValueLen );
-                                                               if (integerValue > wspHeaderFieldCount) {
-                                                                       MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x%x).\n",wspHeaderFieldCount);
-                                                                       break;
-                                                               }
-                                                               strncat( (char*)temper, (char*)wspHeaderFieldName[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       }
-                                                       break;
-                                               /* warning */
-                                               case 0x2c :
-                                                       {
-                                                               unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
+                                                       strncat( (char*)temper," bytes ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
 
-                                                               if (fieldValue[0] < 0x20 )
-                                                                       iField = fieldValue[0];
-                                                               else
-                                                                       iField = 1;
+                                                       first = wspRetriveUintvarDecode( fieldValue, &iField );
+                                                       len = wspRetriveUintvarDecode( fieldValue, &iField );
+                                                       /* Originally range of HTTP include entity length. But WSP omit it. Finally to calculate this, it should be get content length from export. If this field is included without content length, then it can get wrong result. This content length can be get by calculating PDU length. */
+                                                       last = first + contentsLength - 1;
 
-                                                               snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, iField ));
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                               if (iField < fieldValueLen) {
-                                                                       unsigned char agent[WSP_STANDARD_STR_LEN_MAX];
-                                                                       unsigned char text[WSP_STANDARD_STR_LEN_MAX];
-                                                                       strncpy( (char*)agent, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
-                                                                       iField = iField + AcStrlen((char*)agent ) + 1;
-                                                                       strncpy((char*)text, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
-                                                                       snprintf( (char*)temp, sizeof(temp), " %s %s", agent, text );
-                                                                       wspHeaderCopyDecodedString( temp, &currentLength, &temper );
-                                                               }
-                                                       }
-                                                       break;
-                                               /* content-disposition */
-                                               case 0x2e :
-                                                       if (fieldValue[0] == 0x80 )
-                                                               strncat( (char*)temper, "form-data", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       snprintf( (char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len );
+                                                       strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               }
+                                               break;
 
-                                                       if (fieldValue[0] == 0x81 )
-                                                               strncat( (char*)temper, "attachment", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                       /* cache-control */
+                                       case 0x08:
+                                               {
+                                                       char* cacheString = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter);
+
+                                                       wspHeaderDecodeCacheControl( fieldValue, fieldValueLen, &cacheString );
+                                                       strncat( (char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               }
+                                               break;
 
+                                       /* pragma */
+                                       case 0x1f:
+                                               if (fieldValue[0] == 0x80) {
+                                                       strncat( (char*)temper, (char*)wspCacheControl[0], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               } else {
                                                        if (1 < fieldValueLen) {
                                                                char* param = NULL;
                                                                unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                               wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, &param );
+                                                               wspHeaderDecodeParameter( fieldValue, fieldValueLen, &param );
 
                                                                if (param != NULL) {
                                                                        strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
                                                                        strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
                                                                }
                                                        }
-                                                       break;
-                                               /* Profile-diff */
-                                               case 0x36 :
-                                                       temper[AcStrlen((char*)temper) + fieldValueLen] = '\0';
-                                                       memcpy( temper, fieldValue, (size_t)fieldValueLen );
-                                                       break;
-                                               /* Profile-Warning */
-                                               case 0x37 :
-                                                       {
-                                                               unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
-
-                                                               snprintf( (char*)temp, sizeof(temp), "%lX", wspHeaderDecodeInteger(fieldValue ));
-                                                               temp[2] = temp[1];
-                                                               temp[1] = (unsigned char)0x30;
-                                                               temp[3] = '\0';
-                                                               if (fieldValueLen > 1) {
-                                                                       /* copy warn-target - URI */
-                                                                       strncat( (char*)temp, (char*)(fieldValue + 1), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
-                                                                       if (fieldValueLen > ( AcStrlen( (char*)(fieldValue + 1)) + 1 )) {
-                                                                               /* copy warn-date */
-                                                                               char* decodedString = NULL;
-                                                                               unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
-                                                                               wspHeaderDecodeDateValue( fieldValueLen - ( AcStrlen( (char*)(fieldValue + 1)) + 2 ), fieldValue + AcStrlen( (char*)(fieldValue + 1)) + 1, &decodedString );
-                                                                               strncat( (char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
-                                                                       }
+                                               }
+                                               break;
+
+                                       /* public */
+                                       case 0x22:
+                                       /* allow */
+                                       case 0x06:
+                                               {
+                                                       unsigned long  i = 0;
+                                                       while ( wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ) != wspMethodType[i].methodCode ) i++;
+                                                       strncat( (char*)temper, (char*)wspMethodType[i].methodName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               }
+                                               break;
+                                       /* range */
+                                       case 0x23:
+                                               strncat( (char*)temper, "bytes=", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               if (fieldValue[0] == 0x80) {
+                                                       unsigned char temp[16];
+                                                       unsigned long  first, last;
+                                                       iField = 0;
+
+                                                       first = wspRetriveUintvarDecode( fieldValue, &iField );
+                                                       last = wspRetriveUintvarDecode( fieldValue, &iField );
+
+                                                       snprintf( (char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last );
+                                                       strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               }
+                                               if (fieldValue[0] == 0x81) {
+                                                       unsigned char temp[16];
+                                                       unsigned long  suffix;
+
+                                                       suffix = wspRetriveUintvarDecode( fieldValue, &iField );
+
+                                                       snprintf( (char*)temp, sizeof(temp), "-%u", (unsigned int)suffix );
+
+                                               }
+                                               break;
+                                       /* retry-after */
+                                       case 0x25:
+                                               if (fieldValue[0] == 0x80) {
+                                                       char* temp = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter);
+
+                                                       wspHeaderDecodeDateValue( fieldValueLen - 1, fieldValue + 1, &temp );
+                                                       strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               }
+
+                                               if (fieldValue[0] == 0x81) {
+                                                       unsigned char temp[16];
+
+                                                       snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen ));
+                                                       strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               }
+                                               break;
+                                       /* transfer-encoding */
+                                       case 0x27:
+                                               /* No other cases allowed */
+                                               if (fieldValue[0] == 0x80 )
+                                                       strncat( (char*)temper, "chunked", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+
+                                               break;
+                                       /* vary */
+                                       case 0x2a:
+                                               {
+                                                       int integerValue = wspHeaderDecodeIntegerByLength(fieldValue,fieldValueLen );
+                                                       if (integerValue > wspHeaderFieldCount) {
+                                                               MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x%x).\n",wspHeaderFieldCount);
+                                                               break;
+                                                       }
+                                                       strncat( (char*)temper, (char*)wspHeaderFieldName[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               }
+                                               break;
+                                       /* warning */
+                                       case 0x2c:
+                                               {
+                                                       unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
+
+                                                       if (fieldValue[0] < 0x20 )
+                                                               iField = fieldValue[0];
+                                                       else
+                                                               iField = 1;
+
+                                                       snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, iField ));
+                                                       strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       if (iField < fieldValueLen) {
+                                                               unsigned char agent[WSP_STANDARD_STR_LEN_MAX];
+                                                               unsigned char text[WSP_STANDARD_STR_LEN_MAX];
+                                                               strncpy( (char*)agent, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
+                                                               iField = iField + AcStrlen((char*)agent ) + 1;
+                                                               strncpy((char*)text, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
+                                                               snprintf( (char*)temp, sizeof(temp), " %s %s", agent, text );
+                                                               wspHeaderCopyDecodedString( temp, &currentLength, &temper );
+                                                       }
+                                               }
+                                               break;
+                                       /* content-disposition */
+                                       case 0x2e:
+                                               if (fieldValue[0] == 0x80 )
+                                                       strncat( (char*)temper, "form-data", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+
+                                               if (fieldValue[0] == 0x81 )
+                                                       strncat( (char*)temper, "attachment", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+
+                                               if (1 < fieldValueLen) {
+                                                       char* param = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                       wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, &param );
+
+                                                       if (param != NULL) {
+                                                               strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       }
+                                               }
+                                               break;
+                                       /* Profile-diff */
+                                       case 0x36:
+                                               temper[AcStrlen((char*)temper) + fieldValueLen] = '\0';
+                                               memcpy( temper, fieldValue, (size_t)fieldValueLen );
+                                               break;
+                                       /* Profile-Warning */
+                                       case 0x37:
+                                               {
+                                                       unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
+
+                                                       snprintf( (char*)temp, sizeof(temp), "%lX", wspHeaderDecodeInteger(fieldValue ));
+                                                       temp[2] = temp[1];
+                                                       temp[1] = (unsigned char)0x30;
+                                                       temp[3] = '\0';
+                                                       if (fieldValueLen > 1) {
+                                                               /* copy warn-target - URI */
+                                                               strncat( (char*)temp, (char*)(fieldValue + 1), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
+                                                               if (fieldValueLen > ( AcStrlen( (char*)(fieldValue + 1)) + 1 )) {
+                                                                       /* copy warn-date */
+                                                                       char* decodedString = NULL;
+                                                                       unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
+                                                                       wspHeaderDecodeDateValue( fieldValueLen - ( AcStrlen( (char*)(fieldValue + 1)) + 2 ), fieldValue + AcStrlen( (char*)(fieldValue + 1)) + 1, &decodedString );
+                                                                       strncat( (char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
                                                                }
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
                                                        }
-                                                       break;
+                                                       strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                               }
+                                               break;
 
-                                               default :
-                                                       break;
+                                       default:
+                                               break;
                                        }
-
                                }
                        }
                }
@@ -3081,92 +3007,92 @@ void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, uns
                return;
        }
 
-       switch ( data[0] & 0x7f )
-       {
-               case 0x00 :
-                       wspHeaderDecodeQValue(  length - 1, data + 1, &param);
-                       break;
-               case 0x01 :
-                       wspHeaderDecodeCharset( length - 1 , data + 1, &param);
-                       break;
-               case 0x02 :
-                       wspHeaderDecodeVersion( length - 1, data + 1, &param);
-                       break;
-                       /* integer */
-               case 0x03 :
-                       //param = (unsigned char *)malloc( (size_t)WSP_STANDARD_STR_LEN_MAX );
-                       param = new char[WSP_STANDARD_STR_LEN_MAX];
-                       if (param == NULL) {
-                               MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n");
-                               return;
-                       } else {
-                               sprintf( (char*)param, "Type=%i", (int)wspHeaderDecodeInteger( data + 1 ));
-                       }
-                       break;
-               case 0x08 :
-                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+       switch (data[0] & 0x7f) {
+       case 0x00:
+               wspHeaderDecodeQValue(  length - 1, data + 1, &param);
+               break;
+       case 0x01:
+               wspHeaderDecodeCharset( length - 1 , data + 1, &param);
+               break;
+       case 0x02:
+               wspHeaderDecodeVersion( length - 1, data + 1, &param);
+               break;
+               /* integer */
+       case 0x03:
+               /* param = (unsigned char *)malloc( (size_t)WSP_STANDARD_STR_LEN_MAX ); */
+               param = new char[WSP_STANDARD_STR_LEN_MAX];
+               if (param == NULL) {
+                       MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n");
+                       return;
+               } else {
+                       sprintf( (char*)param, "Type=%i", (int)wspHeaderDecodeInteger( data + 1 ));
+               }
+               break;
+       case 0x08:
+               param = new char[WSP_STANDARD_STR_LEN_MAX];
 
-                       if (param == NULL) {
-                               MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n");
-                               return;
-                       } else {
-                               sprintf( (char*)param, "Padding=%i", (int)wspHeaderDecodeInteger( data + 1 ));
-                       }
-                       break;
-               case 0x05 :
-                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+               if (param == NULL) {
+                       MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n");
+                       return;
+               } else {
+                       sprintf( (char*)param, "Padding=%i", (int)wspHeaderDecodeInteger( data + 1 ));
+               }
+               break;
+       case 0x05:
+               param = new char[WSP_STANDARD_STR_LEN_MAX];
 
-                       if (param == NULL) {
-                               MSG_DEBUG("WspLHeaderDecodeParameter:0x05 MemAlloc failed\n");
-                               return;
-                       } else {
-                               strncpy( (char*)param, "Name=", WSP_STANDARD_STR_LEN_MAX-1);
-                               memcpy( param + 5, data + 1, length - 1 );
-                               param[5 + length - 1] = '\0';
-                       }
-                       break;
-               case 0x06 :
-                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+               if (param == NULL) {
+                       MSG_DEBUG("WspLHeaderDecodeParameter:0x05 MemAlloc failed\n");
+                       return;
+               } else {
+                       strncpy( (char*)param, "Name=", WSP_STANDARD_STR_LEN_MAX-1);
+                       memcpy( param + 5, data + 1, length - 1 );
+                       param[5 + length - 1] = '\0';
+               }
+               break;
+       case 0x06:
+               param = new char[WSP_STANDARD_STR_LEN_MAX];
 
-                       if (param == NULL) {
-                               MSG_DEBUG("WspLHeaderDecodeParameter:0x06 MemAlloc failed\n");
-                               return;
-                       } else {
-                               strncpy( (char*)param, "Filename=", WSP_STANDARD_STR_LEN_MAX-1);
-                               memcpy( param + 9, (char*)(data + 1), (size_t)(length - 1) );
-                               param[9 + length - 1] = '\0';
-                       }
-                       break;
-               case 0x07 :
-                       param = NULL;
-                       /* TBI */
-                       break;
-                       /*OMA Provisioning*/
-               case 0x11 :
-                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+               if (param == NULL) {
+                       MSG_DEBUG("WspLHeaderDecodeParameter:0x06 MemAlloc failed\n");
+                       return;
+               } else {
+                       strncpy( (char*)param, "Filename=", WSP_STANDARD_STR_LEN_MAX-1);
+                       memcpy( param + 9, (char*)(data + 1), (size_t)(length - 1) );
+                       param[9 + length - 1] = '\0';
+               }
+               break;
+       case 0x07:
+               param = NULL;
+               /* TBI */
+               break;
+               /*OMA Provisioning*/
+       case 0x11:
+               param = new char[WSP_STANDARD_STR_LEN_MAX];
 
-                       if (param == NULL) {
-                               MSG_DEBUG("WspLHeaderDecodeParameter:0x11 MemAlloc failed\n");
-                               return;
-                       } else {
-                               strncpy((char*)param, "SEC=", WSP_STANDARD_STR_LEN_MAX-1);
-                               SecurityTypeCode = data[1] & 0x7f;
-                               while (( i < wspSecurityTypeCount ) && ( wspSecurityType[i].SecurityTypeCode != SecurityTypeCode )) i++;
+               if (param == NULL) {
+                       MSG_DEBUG("WspLHeaderDecodeParameter:0x11 MemAlloc failed\n");
+                       return;
+               } else {
+                       strncpy((char*)param, "SEC=", WSP_STANDARD_STR_LEN_MAX-1);
+                       SecurityTypeCode = data[1] & 0x7f;
+                       while (( i < wspSecurityTypeCount ) && ( wspSecurityType[i].SecurityTypeCode != SecurityTypeCode ))
+                               i++;
 
-                               if (i < wspSecurityTypeCount) {
-                                       strncat( (char*)param, (char*)wspSecurityType[i].SecurityTypeName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
-                               }
+                       if (i < wspSecurityTypeCount) {
+                               strncat( (char*)param, (char*)wspSecurityType[i].SecurityTypeName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+                       }
 
-                               if (0x12 == (data[2] & 0x7f)) {
-                                       strncat( (char*)param, "; MAC=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 );
-                                       memcpy(param+AcStrlen( (char*)param),(char*)(data+3),(size_t)length-3 );
-                               }
+                       if (0x12 == (data[2] & 0x7f)) {
+                               strncat( (char*)param, "; MAC=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 );
+                               memcpy(param+AcStrlen( (char*)param),(char*)(data+3),(size_t)length-3 );
                        }
-                       break;
+               }
+               break;
 
-               default :
-                       param = NULL;
-                       break;
+       default:
+               param = NULL;
+               break;
        }
 
        *pParam = param;
@@ -3206,7 +3132,6 @@ void SmsPluginWapPushHandler::wspHeaderDecodeCharset( unsigned long length, unsi
 }
 
 
-
 void SmsPluginWapPushHandler::wspHeaderDecodeVersion( unsigned long length, unsigned char* data, char** pDecodedString )
 {
        *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
@@ -3256,8 +3181,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, un
 
        /* check date value validity */
        {
-               if (( pTMData->tm_wday > 6 ) || (pTMData->tm_mon > 11 ) || (pTMData->tm_mday >  31 ))
-               {
+               if (( pTMData->tm_wday > 6 ) || (pTMData->tm_mon > 11 ) || (pTMData->tm_mday >  31 )) {
                        MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData->tm_wday, pTMData->tm_mon, pTMData->tm_mday );
                        strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
                        return;
@@ -3265,28 +3189,26 @@ void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, un
        }
 
 #ifdef MSG_FW_FOR_DEBUG
-       /** Date type selection */
-       switch ( wspMachineStatus.dateType )
-       {
-                       /* UNIX asciitime function */
-               case UNIX_DATE_TYPE :
-                       snprintf( (char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
-                                          pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 );
-                       break;
-               case RFC1123_DATE_TYPE :
-                       snprintf( (char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData->tm_wday], pTMData->tm_mday,
-                                          wspMonth[pTMData->tm_mon], pTMData->tm_year + 1900, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec );
-                       break;
-               case RFC850_DATE_TYPE :
-                       /* Have some Y2K Problems */
-                       /* In RFC 850, date is represented like 11-May-99. So Y2K problem always can be occured. So remainer (year divided by 100) is used.                     */
-                       snprintf( (char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData->tm_wday], pTMData->tm_mday,
-                                          wspMonth[pTMData->tm_mon], pTMData->tm_year % CENTURY, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec );
-
-                       break;
+       /* Date type selection */
+       switch (wspMachineStatus.dateType) {
+               /* UNIX asciitime function */
+       case UNIX_DATE_TYPE:
+               snprintf( (char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
+                                  pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 );
+               break;
+       case RFC1123_DATE_TYPE:
+               snprintf( (char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData->tm_wday], pTMData->tm_mday,
+                                  wspMonth[pTMData->tm_mon], pTMData->tm_year + 1900, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec );
+               break;
+       case RFC850_DATE_TYPE:
+               /* Have some Y2K Problems */
+               /* In RFC 850, date is represented like 11-May-99. So Y2K problem always can be occured. So remainer (year divided by 100) is used.                     */
+               snprintf( (char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData->tm_wday], pTMData->tm_mday,
+                                  wspMonth[pTMData->tm_mon], pTMData->tm_year % CENTURY, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec );
+               break;
        }
 #endif
-       /**UNIX_DATE_TYPE : */
+       /*UNIX_DATE_TYPE : */
        snprintf( (char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
                                                                                        pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 );
 
@@ -3294,12 +3216,13 @@ void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, un
 
 }
 
+
 void SmsPluginWapPushHandler::wspHeaderCopyDecodedString( unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper )
 {
        unsigned long elementLen = AcStrlen( (char*)szDecodedString );
        char* temper2 = NULL;
 
-       /**  // CR+LF */
+       /* CR+LF */
        *currentLen = *currentLen + elementLen + 2;
 
        if ( *currentLen > AcStrlen( (char*)* pTemper ) + 2) {
@@ -3399,35 +3322,32 @@ void SmsPluginWapPushHandler::wspHeaderDecodeCacheControl(unsigned char* fieldVa
        if (fieldValue[0] > 0x7f) {
                /* directive that has parameter */
                cacheCode = fieldValue[0] & 0x7f;
-               switch ( cacheCode )
-               {
-                               /* field name */
-                               /* no-cache */
-                       case 0x00 :
-                               /* private */
-                       case 0x07 :
-                               if (fieldValue[1] > 0x7f) {
-                                       /* well known field name */
-                                       strncpy( (char*)paramString, (char*)wspHeaderFieldName[fieldValue[1] & 0x7f],WSP_STANDARD_STR_LEN_MAX-1 );
-                                       paramString[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
-                               } else {
-                                       /* unknown field name */
-                                       strncpy( (char*)paramString, (char*)fieldValue + 1 , WSP_STANDARD_STR_LEN_MAX-1);
-                               }
-                               break;
-                               /* secound */
-                               /* max-age */
-                       case 0x02 :
-                               /* max- stale */
-                       case 0x03 :
-                               /* min-fresh */
-                       case 0x04 :
-                               snprintf( (char*)paramString, sizeof(paramString), "%u", (unsigned int)wspHeaderDecodeInteger( fieldValue + 1));
-                               break;
-
-                       default :
-                               break;
-
+               switch (cacheCode) {
+               /* field name */
+               /* no-cache */
+               case 0x00:
+               /* private */
+               case 0x07:
+                       if (fieldValue[1] > 0x7f) {
+                               /* well known field name */
+                               strncpy( (char*)paramString, (char*)wspHeaderFieldName[fieldValue[1] & 0x7f],WSP_STANDARD_STR_LEN_MAX-1 );
+                               paramString[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
+                       } else {
+                               /* unknown field name */
+                               strncpy( (char*)paramString, (char*)fieldValue + 1 , WSP_STANDARD_STR_LEN_MAX-1);
+                       }
+                       break;
+               /* secound */
+               /* max-age */
+               case 0x02:
+               /* max- stale */
+               case 0x03:
+               /* min-fresh */
+               case 0x04:
+                       snprintf( (char*)paramString, sizeof(paramString), "%u", (unsigned int)wspHeaderDecodeInteger( fieldValue + 1));
+                       break;
+               default:
+                       break;
                }
                snprintf((char*)*pCacheString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s=%s", (char*)wspCacheControl[cacheCode], (char*)paramString );
        } else {
index 79e2c30..0e3e1f5 100755 (executable)
@@ -76,5 +76,4 @@ private:
        static SmsPluginCallback* pInstance;
 };
 
-#endif //SMS_CDMA_PLUGIN_CALLBACK_H
-
+#endif /* SMS_CDMA_PLUGIN_CALLBACK_H */
index 3396bff..a71a311 100755 (executable)
@@ -84,4 +84,4 @@ private:
        static sms_message_type_t findMsgType(const unsigned char *p_pkg_str, int pkg_len);
 };
 
-#endif //SMS_CDMA_PLUGIN_CODEC_H
+#endif /* SMS_CDMA_PLUGIN_CODEC_H */
index 977a250..6772c77 100755 (executable)
@@ -37,23 +37,20 @@ using namespace std;
 /*==================================================================================================
                                      VARIABLES AND DEFINES
 ==================================================================================================*/
-struct wap_data_s
-{
+struct wap_data_s {
        int     length;
        char data[SMS_MAX_USER_DATA_LEN+1];
 };
 
 typedef map<unsigned char, wap_data_s> wapDataMap;
 
-typedef struct _sms_wap_msg_s
-{
+typedef struct _sms_wap_msg_s {
        unsigned short  msgId;
        unsigned char           totalSeg;
        unsigned char           segNum;
 } sms_wap_msg_s;
 
-typedef struct _sms_wap_info_s
-{
+typedef struct _sms_wap_info_s {
        unsigned short  msgId;
        unsigned char           totalSeg;
        unsigned char           segNum;
@@ -63,7 +60,6 @@ typedef struct _sms_wap_info_s
 } sms_wap_info_s;
 
 
-
 /*==================================================================================================
                                      CLASS DEFINITIONS
 ==================================================================================================*/
@@ -128,5 +124,4 @@ private:
 
 };
 
-#endif //SMS_CDMA_PLUGIN_EVENT_HANDLER_H
-
+#endif /* SMS_CDMA_PLUGIN_EVENT_HANDLER_H */
index f4f1253..4fe2916 100755 (executable)
@@ -62,5 +62,4 @@ msg_error_t SmsPlgAddMessage(MSG_MESSAGE_INFO_S *pMsgInfo,  MSG_SENDINGOPT_INFO_
 }
 #endif
 
-#endif //SMS_CDMA_PLUGIN_MAIN_H
-
+#endif /* SMS_CDMA_PLUGIN_MAIN_H */
index bdcc06c..466b588 100755 (executable)
@@ -89,5 +89,4 @@ private:
        CndVar cv;
 };
 
-#endif //SMS_CDMA_PLUGIN_SETTING_H
-
+#endif /* SMS_CDMA_PLUGIN_SETTING_H */
index 30f6222..c42631e 100755 (executable)
@@ -72,5 +72,4 @@ private:
        std::list<PUSH_APPLICATION_INFO_S> pushAppInfoList;
 };
 
-#endif //SMS_CDMA_PLUGIN_STORAGE_H
-
+#endif /* SMS_CDMA_PLUGIN_STORAGE_H */
index e486209..607f71f 100755 (executable)
@@ -72,4 +72,4 @@ private:
        CndVar cv;
 };
 
-#endif //SMS_PLUGIN_TRANSPORT_H
+#endif /* SMS_PLUGIN_TRANSPORT_H */
index 8d1bc57..ee83bc9 100755 (executable)
 #ifndef SMS_CDMA_PLUGIN_TYPES_H
 #define SMS_CDMA_PLUGIN_TYPES_H
 
-#define SMS_MAX_MESSAGE_ID                     65536
-#define SMS_SEQ_NUM_MAX                                64
-#define SMS_MAX_USER_DATA_LEN          160
-#define SMS_MAX_SUBMIT_MESSAGE_ID      256
+#define MAX_SMS_SEND_RETRY     4
+#define SMS_MAX_MESSAGE_ID 65536
+#define SMS_SEQ_NUM_MAX 64
+#define SMS_MAX_USER_DATA_LEN 160
+#define SMS_MAX_SUBMIT_MESSAGE_ID 256
 
-#define SMS_TRANS_ADDRESS_MAX_LEN      256
+#define SMS_TRANS_ADDRESS_MAX_LEN 256
 
-#define SMS_MAX_NUMBER_OF_ACK          8
+#define SMS_MAX_NUMBER_OF_ACK 8
 
-#define SMS_PUSH_XML_HREF_TAG          "href"
-#define SMS_PUSH_XML_SI_ID_TAG         "si-id"
-#define SMS_PUSH_XML_CREATED_TAG       "created"
-#define SMS_PUSH_XML_EXPIRES_TAG       "si-expires"
-#define SMS_PUSH_XML_ACTION_TAG                "action"
+#define SMS_PUSH_XML_HREF_TAG "href"
+#define SMS_PUSH_XML_SI_ID_TAG "si-id"
+#define SMS_PUSH_XML_CREATED_TAG "created"
+#define SMS_PUSH_XML_EXPIRES_TAG "si-expires"
+#define SMS_PUSH_XML_ACTION_TAG "action"
 
-#define SMS_PUSH_XML_INVAL_OBJ         "invalidate-object"
-#define SMS_PUSH_XML_INVAL_SVC         "invalidate-service"
-#define SMS_PUSH_XML_CO_URI                    "uri"
+#define SMS_PUSH_XML_INVAL_OBJ "invalidate-object"
+#define SMS_PUSH_XML_INVAL_SVC "invalidate-service"
+#define SMS_PUSH_XML_CO_URI "uri"
 
 
 typedef unsigned char sms_wap_app_code_t;      /* _sms_wap_app_code_e */
 
-typedef struct _SMS_WSP_CONTENTS_TYPE_S
-{
+typedef struct _SMS_WSP_CONTENTS_TYPE_S {
        char*         contentsTypeName;
        unsigned char contentsTypeCode;
 } SMS_WSP_CONTENTS_TYPE_S;
 
 
-typedef struct _SMS_WSP_CHARSET_S
-{
+typedef struct _SMS_WSP_CHARSET_S {
        char*  charsetName;
        unsigned short charsetCode;
 } SMS_WSP_CHARSET_S;
 
 
-typedef struct _SMS_WAP_UNREGISTER_CONTENTS_TYPE_S
-{
+typedef struct _SMS_WAP_UNREGISTER_CONTENTS_TYPE_S {
        char*         contentsTypeName;
        unsigned short contentsTypeCode;
 } SMS_WAP_UNREGISTER_CONTENTS_TYPE_S;
 
 
-typedef struct _SMS_WSP_LANGUAGE_S
-{
+typedef struct _SMS_WSP_LANGUAGE_S {
        char*         languageName;
        unsigned char languageCode;
 } SMS_WSP_LANGUAGE_S;
 
 
-typedef struct _SMS_WSP_HEADER_PARAMETER_S
-{
+typedef struct _SMS_WSP_HEADER_PARAMETER_S {
        char*         parameterToken;
        unsigned int parameterCode;
 } SMS_WSP_HEADER_PARAMETER_S;
 
 
-typedef struct _SMS_WSP_METHOD_TYPE_S
-{
+typedef struct _SMS_WSP_METHOD_TYPE_S {
        char*         methodName;
        unsigned char methodCode;
 } SMS_WSP_METHOD_TYPE_S;
 
 
-typedef struct _SMS_WSP_SECURITY_TYPE_S
-{
+typedef struct _SMS_WSP_SECURITY_TYPE_S {
        char*         SecurityTypeName;
        unsigned char SecurityTypeCode;
 }SMS_WSP_SECURITY_TYPE_S;
 
-typedef struct
-{
-       msg_request_id_t                        reqId;          /**< Indicates the request ID, which is unique. When applications submit a request to the framework, this value will be set by the framework. */
-       MSG_MESSAGE_INFO_S                      msgInfo;        /**< Indicates the message structure to be sent by applications. */
+
+typedef struct {
+       msg_request_id_t                        reqId;          /* < Indicates the request ID, which is unique. When applications submit a request to the framework, this value will be set by the framework. */
+       MSG_MESSAGE_INFO_S                      msgInfo;        /* < Indicates the message structure to be sent by applications. */
        MSG_SENDINGOPT_INFO_S           sendOptInfo;
 } sms_request_info_s;
 
 
-typedef struct _sms_sent_info_s
-{
-       sms_request_info_s              reqInfo;                /**< Indicates the corresponding request structure. */
+typedef struct _sms_sent_info_s {
+       sms_request_info_s              reqInfo;                /* < Indicates the corresponding request structure. */
        bool                                            bLast;
 } sms_sent_info_s;
 
@@ -122,8 +115,8 @@ enum _sms_network_status_e {
        SMS_NETWORK_SEND_FAIL_NETWORK_NOT_READY,
 };
 
-enum _sms_wap_app_code_e
-{
+
+enum _sms_wap_app_code_e {
        SMS_WAP_APPLICATION_DEFAULT = 0x00,
 
        SMS_WAP_APPLICATION_PUSH_SI,
@@ -205,23 +198,21 @@ typedef unsigned char             sms_number_type_t;                      /* _sms_number_type_e */
 typedef unsigned char          sms_number_plan_t;                      /* _sms_number_plan_e */
 
 
-typedef enum _sms_message_type_e
-{
-       SMS_TYPE_RESERVED               = 0x00,         // reserved
-       SMS_TYPE_DELIVER,                                       // mobile-terminated only
-       SMS_TYPE_SUBMIT,                                        // mobile-originated only
-       SMS_TYPE_CANCEL,                                        // mobile-originated only
-       SMS_TYPE_DELIVERY_ACK,                          // mobile-terminated only
-       SMS_TYPE_USER_ACK,                                      // either direction
-       SMS_TYPE_READ_ACK,                                      // either direction
-       SMS_TYPE_DELIVER_REPORT,                        // mobile-originated only
-       SMS_TYPE_SUBMIT_REPORT  = 0x08,         // mobile-terminated only
+typedef enum _sms_message_type_e {
+       SMS_TYPE_RESERVED               = 0x00,         /* reserved */
+       SMS_TYPE_DELIVER,                                       /* mobile-terminated only */
+       SMS_TYPE_SUBMIT,                                        /* mobile-originated only */
+       SMS_TYPE_CANCEL,                                        /* mobile-originated only */
+       SMS_TYPE_DELIVERY_ACK,                          /* mobile-terminated only*/
+       SMS_TYPE_USER_ACK,                                      /* either direction */
+       SMS_TYPE_READ_ACK,                                      /* either direction */
+       SMS_TYPE_DELIVER_REPORT,                        /* mobile-originated only */
+       SMS_TYPE_SUBMIT_REPORT  = 0x08,         /* mobile-terminated only */
        SMS_TYPE_MAX_VALUE
 }sms_message_type_t;
 
 
-typedef enum _sms_alert_option_e
-{
+typedef enum _sms_alert_option_e {
        SMS_ALERT_NO_ALERT                              = 0,
        SMS_ALERT_DEFAULT_ALERT,
        SMS_ALERT_VIBRATE_ONCE,
@@ -250,8 +241,7 @@ typedef enum _sms_language_type_e {
 }sms_language_type_t;
 
 
-typedef enum _sms_priority_indicator_e
-{
+typedef enum _sms_priority_indicator_e {
        SMS_PRIORITY_NORMAL                             = 0x00,
        SMS_PRIORITY_INTERACTIVE,
        SMS_PRIORITY_URGENT,
@@ -259,8 +249,7 @@ typedef enum _sms_priority_indicator_e
 }sms_priority_indicator_t;
 
 
-typedef enum _sms_privacy_indicator_e
-{
+typedef enum _sms_privacy_indicator_e {
        SMS_PRIVACY_NOT_RESTRICTED              = 0x00,
        SMS_PRIVACY_RESTRICTED,
        SMS_PRIVACY_CONFIDENTIAL,
@@ -268,8 +257,7 @@ typedef enum _sms_privacy_indicator_e
 }sms_privacy_indicator_t;
 
 
-typedef enum _sms_alert_priority_e
-{
+typedef enum _sms_alert_priority_e {
        SMS_ALERT_MOBILE_DEFAULT                = 0x00,
        SMS_ALERT_LOW_PRIORITY,
        SMS_ALERT_MEDIUM_PRIORITY,
@@ -277,8 +265,7 @@ typedef enum _sms_alert_priority_e
 }sms_alert_priority_t;
 
 
-typedef enum _sms_display_mode_e
-{
+typedef enum _sms_display_mode_e {
        SMS_DISPLAY_IMMEDIATE                   = 0x00,
        SMS_DISPLAY_DEFAULT_SETTING,
        SMS_DISPLAY_USER_INVOKE,
@@ -286,8 +273,7 @@ typedef enum _sms_display_mode_e
 }sms_display_mode_t;
 
 
-typedef enum _sms_encoding_type_e
-{
+typedef enum _sms_encoding_type_e {
        SMS_ENCODE_OCTET        = 0x0,
        SMS_ENCODE_EPM  = 0x1,  /*IS-91 Extended Protocol Message*/
        SMS_ENCODE_7BIT_ASCII   = 0x2,
@@ -304,8 +290,7 @@ typedef enum _sms_encoding_type_e
 }sms_encoding_type_t;
 
 
-typedef enum _sms_relative_time_e
-{
+typedef enum _sms_relative_time_e {
        SMS_REL_TIME_5_MINS                     = 0,
        SMS_REL_TIME_12_HOURS           = 143,
        SMS_REL_TIME_1_DAY                      = 167,
@@ -320,8 +305,7 @@ typedef enum _sms_relative_time_e
 }sms_relative_time_t;
 
 
-typedef enum _sms_status_code_e
-{
+typedef enum _sms_status_code_e {
        /* ERROR_CLASS = '00' (no error) */
        SMS_STATUS_ACCEPTED                             = 0x00,
        SMS_STATUS_DEPOSITED                    = 0x01,
@@ -407,8 +391,7 @@ typedef enum _sms_cmae_alert_handle_e {
 }sms_cmae_alert_handle_t;
 
 
-enum _sms_bearer_sub_param_e
-{
+enum _sms_bearer_sub_param_e {
        SMS_BEARER_MESSAGE_IDENTIFIER                           = 0x00,
        SMS_BEARER_USER_DATA                                            = 0x01,
        SMS_BEARER_USER_RESPONSE_CODE                           = 0x02,
@@ -437,8 +420,7 @@ enum _sms_bearer_sub_param_e
 };
 
 
-enum _sms_svc_ctg_result_e
-{
+enum _sms_svc_ctg_result_e {
        SMS_SVC_RESULT_SUCCESS                                  = 0x00,
        SMS_SVC_RESULT_MEMORY_LIMIT_EXCEEDED,
        SMS_SVC_RESULT_LIMIT_EXCEEDED,
@@ -451,6 +433,7 @@ enum _sms_svc_ctg_result_e
        SMS_SVC_RESULT_RESERVED
 };
 
+
 enum _SMS_TIME_FORMAT_E {
        SMS_TIME_EMPTY = 0,
        SMS_TIME_RELATIVE       ,
@@ -504,15 +487,13 @@ enum _sms_tp_failure_cause_e {
 };
 
 
-typedef struct _sms_trans_msg_id_s
-{
+typedef struct _sms_trans_msg_id_s {
        unsigned short          msg_id;
        bool                            header_ind;
 }sms_trans_msg_id_s;
 
 
-typedef struct _sms_telesvc_addr_s
-{
+typedef struct _sms_telesvc_addr_s {
        sms_digit_mode_t        digit_mode;
        sms_number_type_t       number_type;
        sms_number_plan_t       number_plan;
@@ -521,8 +502,7 @@ typedef struct _sms_telesvc_addr_s
 }sms_telesvc_addr_s;
 
 
-typedef struct _sms_reply_option_s
-{
+typedef struct _sms_reply_option_s {
        bool    user_ack_req;
        bool    deliver_ack_req;
        bool    read_ack_req;
@@ -530,24 +510,21 @@ typedef struct _sms_reply_option_s
 }sms_reply_option_s;
 
 
-typedef struct _sms_time_relative_s
-{
+typedef struct _sms_time_relative_s {
        sms_relative_time_t             rel_time;
 }sms_time_rel_s;
 
-typedef struct _sms_time_stamp_s
-{
-       unsigned char           year;           // range 00-99 (96~99 : 19xx, 00~95 : 20xx)
-       unsigned char           month;          // range 1-12
+typedef struct _sms_time_stamp_s {
+       unsigned char           year;           /* range 00-99 (96~99 : 19xx, 00~95 : 20xx) */
+       unsigned char           month;          /* range 1-12 */
        unsigned char           day;
-       unsigned char           hours;          // range 0-23
-       unsigned char           minutes;        // range 0-59
-       unsigned char           seconds;        // range 0-59
+       unsigned char           hours;          /* range 0-23 */
+       unsigned char           minutes;        /* range 0-59 */
+       unsigned char           seconds;        /* range 0-59 */
 }sms_time_abs_s;
 
 
-typedef struct _sms_val_period_s
-{
+typedef struct _sms_val_period_s {
        unsigned char           format;
        union {
                sms_time_rel_s  rel_time;
@@ -556,16 +533,14 @@ typedef struct _sms_val_period_s
 }sms_val_period_s;
 
 
-typedef struct _sms_encoding_specific_s
-{
+typedef struct _sms_encoding_specific_s {
        sms_encoding_type_t             encode_type;
        unsigned int                    data_len;
        char                                    user_data[SMS_MAX_USER_DATA_LEN +1];
 }sms_encoding_specific_s;
 
 
-typedef struct _sms_ctg_specific_s
-{
+typedef struct _sms_ctg_specific_s {
        unsigned char           operation_code;
        unsigned short          category;
        sms_language_type_t     language;
@@ -576,16 +551,14 @@ typedef struct _sms_ctg_specific_s
 }sms_ctg_specific_s;
 
 
-typedef struct _sms_svc_ctg_program_data_s
-{
+typedef struct _sms_svc_ctg_program_data_s {
        sms_encoding_type_t             encode_type;
        unsigned int                    num_data;
        sms_ctg_specific_s              *specific_data;
 }sms_svc_ctg_program_data_s;
 
 
-typedef struct _sms_telesvc_userdata_s
-{
+typedef struct _sms_telesvc_userdata_s {
        sms_encoding_type_t             encode_type;
        unsigned char                   msg_type;
        unsigned int                    data_len;
@@ -593,8 +566,7 @@ typedef struct _sms_telesvc_userdata_s
 }sms_telesvc_userdata_s;
 
 
-typedef struct _sms_telesvc_cmasdata_s
-{
+typedef struct _sms_telesvc_cmasdata_s {
        unsigned int                            data_len;
        sms_encoding_type_t             encode_type;
        unsigned char                           alert_text[SMS_MAX_USER_DATA_LEN +1];
@@ -611,8 +583,7 @@ typedef struct _sms_telesvc_cmasdata_s
 }sms_telesvc_cmasdata_s;
 
 
-typedef struct _sms_enhanced_vmn_s
-{
+typedef struct _sms_enhanced_vmn_s {
        sms_priority_indicator_t                priority;
        bool                                                    password_req;
        bool                                                    setup_req;
@@ -643,8 +614,7 @@ typedef struct _sms_enhanced_vmn_s
 }sms_enhanced_vmn_s;
 
 
-typedef struct _sms_enhanced_vmn_ack_s
-{
+typedef struct _sms_enhanced_vmn_ack_s {
        unsigned short                          vm_mailbox_id;
        unsigned char                                   vm_num_unheard_msg;
        unsigned char                                   num_delete_ack;
@@ -655,8 +625,7 @@ typedef struct _sms_enhanced_vmn_ack_s
 }sms_enhanced_vmn_ack_s;
 
 
-typedef struct _sms_telesvc_deliver_s
-{
+typedef struct _sms_telesvc_deliver_s {
        sms_trans_msg_id_s                      msg_id;
        sms_telesvc_userdata_s          user_data;
        sms_telesvc_cmasdata_s          cmas_data;
@@ -673,14 +642,13 @@ typedef struct _sms_telesvc_deliver_s
        sms_display_mode_t                      display_mode;
        sms_encoding_specific_s         multi_encode_data;
        unsigned short                          deposit_id;
-       //sms_svc_ctg_program_data_s    svc_ctg;
+       /* sms_svc_ctg_program_data_s   svc_ctg; */
        sms_enhanced_vmn_s                      enhanced_vmn;
        sms_enhanced_vmn_ack_s          enhanced_vmn_ack;
 }sms_telesvc_deliver_s;
 
 
-typedef struct _sms_telesvc_submit_s
-{
+typedef struct _sms_telesvc_submit_s {
        sms_trans_msg_id_s                      msg_id;
        sms_telesvc_userdata_s          user_data;
        sms_val_period_s                        val_period;
@@ -693,18 +661,16 @@ typedef struct _sms_telesvc_submit_s
        sms_telesvc_addr_s                      callback_number;
        sms_encoding_specific_s         multi_encode_data;
        unsigned char                           deposit_id;
-       //sms_svc_ctg_program_data_s    svc_ctg;
+       /* sms_svc_ctg_program_data_s   svc_ctg; */
 }sms_telesvc_submit_s;
 
 
-typedef struct _sms_telesvc_cancel_s
-{
+typedef struct _sms_telesvc_cancel_s {
        sms_trans_msg_id_s              msg_id;
 }sms_telesvc_cancel_s;
 
 
-typedef struct _sms_telesvc_user_ack_s
-{
+typedef struct _sms_telesvc_user_ack_s {
        sms_trans_msg_id_s                      msg_id;
        sms_telesvc_userdata_s          user_data;
        unsigned char                           resp_code;
@@ -714,8 +680,7 @@ typedef struct _sms_telesvc_user_ack_s
 }sms_telesvc_user_ack_s;
 
 
-typedef struct _sms_telesvc_deliver_ack_s
-{
+typedef struct _sms_telesvc_deliver_ack_s {
        sms_trans_msg_id_s                      msg_id;
        sms_telesvc_userdata_s          user_data;
        sms_time_abs_s                          time_stamp;
@@ -724,8 +689,7 @@ typedef struct _sms_telesvc_deliver_ack_s
 }sms_telesvc_deliver_ack_s;
 
 
-typedef struct _sms_telesvc_read_ack_s
-{
+typedef struct _sms_telesvc_read_ack_s {
        sms_trans_msg_id_s                      msg_id;
        sms_telesvc_userdata_s          user_data;
        sms_time_abs_s                          time_stamp;
@@ -733,8 +697,7 @@ typedef struct _sms_telesvc_read_ack_s
        unsigned char                           deposit_id;
 }sms_telesvc_read_ack_s;
 
-typedef struct _sms_telesvc_deliver_report_s
-{
+typedef struct _sms_telesvc_deliver_report_s {
        sms_trans_msg_id_s              msg_id;
        unsigned char                   tp_fail_cause;
        sms_telesvc_userdata_s  user_data;
@@ -743,8 +706,7 @@ typedef struct _sms_telesvc_deliver_report_s
 }sms_telesvc_report_s;
 
 
-typedef struct _sms_telesvc_msg_s
-{
+typedef struct _sms_telesvc_msg_s {
        sms_message_type_t              type;
 
        union {
@@ -773,8 +735,7 @@ typedef unsigned short              sms_trans_svc_ctg_t;                    /* _sms_trans_svc_ctg_e */
 typedef unsigned char          sms_trans_reply_seq_t;
 
 
-typedef enum _sms_trans_msg_type_e
-{
+typedef enum _sms_trans_msg_type_e {
        SMS_TRANS_P2P_MSG                       = 0x00,
        SMS_TRANS_BROADCAST_MSG         = 0x01,
        SMS_TRANS_ACK_MSG                       = 0x02,
@@ -782,8 +743,7 @@ typedef enum _sms_trans_msg_type_e
 }sms_trans_msg_type_t;
 
 
-enum _sms_trans_param_id_e
-{
+enum _sms_trans_param_id_e {
        SMS_TRANS_PARAM_TELESVC_IDENTIFIER              = 0x00,
        SMS_TRANS_PARAM_SERVICE_CATEGORY                = 0x01,
        SMS_TRANS_PARAM_ORG_ADDRESS                             = 0x02,
@@ -797,8 +757,7 @@ enum _sms_trans_param_id_e
 };
 
 
-enum _sms_trans_telesvc_id_e
-{
+enum _sms_trans_telesvc_id_e {
        SMS_TRANS_TELESVC_CMT_91                = 0x1000,       /* IS-91 Extended Protocol Enhanced Services */
        SMS_TRANS_TELESVC_CPT_95                = 0x1001,       /* Wireless Paging Teleservice */
        SMS_TRANS_TELESVC_CMT_95                = 0x1002,       /* Wireless Messaging Teleservice */
@@ -811,8 +770,7 @@ enum _sms_trans_telesvc_id_e
 };
 
 
-enum _sms_trans_svc_ctg_e
-{
+enum _sms_trans_svc_ctg_e {
        SMS_TRANS_SVC_CTG_UNKNOWN                               = 0x0000,
        SMS_TRANS_SVC_CTG_EMERGENCY                             = 0x0001,
        SMS_TRANS_SVC_CTG_ADMINISTRATIVE                = 0x0002,
@@ -848,7 +806,7 @@ enum _sms_trans_svc_ctg_e
        SMS_TRANS_SVC_CTG_CATPT                                 = 0x0020,
        SMS_TRANS_SVC_CTG_KDDI_CORP_MIN1                = 0x0021,
        SMS_TRANS_SVC_CTG_KDDI_CORP_MAX1                = 0x003f,
-       SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL     = 0x1000,
+       SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL             = 0x1000,
        SMS_TRANS_SVC_CTG_CMAS_EXTREME                  = 0x1001,
        SMS_TRANS_SVC_CTG_CMAS_SEVERE                   = 0x1002,
        SMS_TRANS_SVC_CTG_CMAS_AMBER                    = 0x1003,
@@ -862,24 +820,21 @@ enum _sms_trans_svc_ctg_e
 };
 
 
-typedef enum _sms_trans_err_class_e
-{
+typedef enum _sms_trans_err_class_e {
        SMS_TRANS_ERR_CLASS_NONE                                = 0x00,
        SMS_TRANS_ERR_CLASS_TEMPORARY                   = 0x02,
        SMS_TRANS_ERR_CLASS_PERMANENT                   = 0x03
 }sms_trans_err_class_t;
 
 
-typedef enum _sms_trans_cause_code_e
-{
-       SMS_CAUSE_CODE_INVAILD_TELESERVICE_ID   = 0x04,
-       SMS_CAUSE_CODE_SERVICE_TERMINATION_DENIED               = 0x62,
+typedef enum _sms_trans_cause_code_e {
+       SMS_CAUSE_CODE_INVAILD_TELESERVICE_ID           = 0x04,
+       SMS_CAUSE_CODE_SERVICE_TERMINATION_DENIED       = 0x62,
        SMS_TODO_FILL_THIS_ENUMS
 }sms_trans_cause_code_t;
 
 
-typedef enum _sms_trans_sub_addr_type_e
-{
+typedef enum _sms_trans_sub_addr_type_e {
        SMS_TRANS_SUB_ADDR_NSAP                                 = 0x00,
        SMS_TRANS_SUB_ADDR_USER                                 = 0x01,
        SMS_TRANS_SUB_ADDR_RESERVED
@@ -887,8 +842,7 @@ typedef enum _sms_trans_sub_addr_type_e
 
 
 
-enum _sms_trans_dnet_addr_type_e
-{
+enum _sms_trans_dnet_addr_type_e {
        SMS_TRANS_DNET_UNKNOWN                                  = 0x00,
        SMS_TRANS_DNET_INTERNET_PROTOCOL                = 0x01,
        SMS_TRANS_DNET_INTERNET_MAIL_ADDR               = 0x02,
@@ -898,20 +852,20 @@ enum _sms_trans_dnet_addr_type_e
 
 enum _sms_digit_mode_e {
        SMS_DIGIT_4BIT_DTMF     = 0,
-       SMS_DIGIT_8BIT  = 1
+       SMS_DIGIT_8BIT          = 1
 };
 
 
 enum _sms_number_mode_e {
        SMS_NUMBER_MODE_NONE_DATANETWORK        = 0,
-       SMS_NUMBER_MODE_DATANETWORK     = 1,    /*using data network address format*/
+       SMS_NUMBER_MODE_DATANETWORK                     = 1,    /*using data network address format*/
 };
 
 
 enum _sms_dnet_number_type_e {
-       SMS_ADDRESS_TYPE_UNKNOWN        = 0x00,
+       SMS_ADDRESS_TYPE_UNKNOWN                        = 0x00,
        SMS_ADDRESS_TYPE_INTERNET_PROTOCOL      = 0x01,
-       SMS_ADDRESS_TYPE_EMAIL_ADDRESS  = 0x02,
+       SMS_ADDRESS_TYPE_EMAIL_ADDRESS          = 0x02,
 };
 
 
@@ -933,17 +887,16 @@ enum _sms_number_type_e {
 
 
 enum _sms_number_plan_e {
-       SMS_NPI_UNKNOWN = 0,
-       SMS_NPI_ISDN    = 1,
-       SMS_NPI_DATA    = 3,
-       SMS_NPI_TELEX   = 4,
-       SMS_NPI_PRIVATE = 9,
+       SMS_NPI_UNKNOWN         = 0,
+       SMS_NPI_ISDN            = 1,
+       SMS_NPI_DATA            = 3,
+       SMS_NPI_TELEX           = 4,
+       SMS_NPI_PRIVATE         = 9,
        SMS_NPI_RESERVED        = 15,
 };
 
 
-typedef struct _sms_trans_addr_s
-{
+typedef struct _sms_trans_addr_s {
        sms_digit_mode_t        digit_mode;
        sms_number_mode_t       number_mode;
        sms_number_type_t       number_type;
@@ -953,8 +906,7 @@ typedef struct _sms_trans_addr_s
 }sms_trans_addr_s;
 
 
-typedef struct _sms_trans_sub_addr_s
-{
+typedef struct _sms_trans_sub_addr_s {
        sms_trans_sub_addr_type_t       type;
        bool                                            odd;
        unsigned int                            addr_len;
@@ -962,16 +914,14 @@ typedef struct _sms_trans_sub_addr_s
 }sms_trans_sub_addr_s;
 
 
-typedef struct _sms_trans_cause_code_s
-{
+typedef struct _sms_trans_cause_code_s {
        sms_trans_reply_seq_t                   reply_seq;
        sms_trans_err_class_t                   error_class;
        sms_trans_cause_code_t                  cause_code;
 }sms_trans_cause_code_s;
 
 
-typedef struct _sms_trans_p2p_msg_s
-{
+typedef struct _sms_trans_p2p_msg_s {
        sms_trans_telesvc_id_t                  telesvc_id;
        sms_trans_svc_ctg_t                             svc_ctg;
        sms_trans_addr_s                                address;
@@ -981,23 +931,20 @@ typedef struct _sms_trans_p2p_msg_s
 }sms_trans_p2p_msg_s;
 
 
-typedef struct _sms_trans_broadcast_msg_s
-{
+typedef struct _sms_trans_broadcast_msg_s {
        sms_trans_svc_ctg_t                             svc_ctg;
        sms_telesvc_msg_s                               telesvc_msg;
 }sms_trans_broadcast_msg_s;
 
 
-typedef struct _sms_trans_ack_msg_s
-{
+typedef struct _sms_trans_ack_msg_s {
        sms_trans_addr_s                                address;
        sms_trans_sub_addr_s                    sub_address;
        sms_trans_cause_code_s                  cause_code;
 }sms_trans_ack_msg_s;
 
 
-typedef struct _sms_trans_msg_s
-{
+typedef struct _sms_trans_msg_s {
        sms_trans_msg_type_t            type;
        union {
                sms_trans_p2p_msg_s                     p2p_msg;
@@ -1007,5 +954,4 @@ typedef struct _sms_trans_msg_s
 }sms_trans_msg_s;
 
 
-#endif //SMS_CDMA_PLUGIN_TYPES_H
-
+#endif /* SMS_CDMA_PLUGIN_TYPES_H */
index c14d59a..04f92f6 100755 (executable)
@@ -35,7 +35,7 @@ class SmsPluginUAManager : public MsgThread
 public:
        static SmsPluginUAManager* instance();
 
-       //virtual void start();
+       /* virtual void start(); */
 
        void addReqEntity(sms_request_info_s *request);
 
@@ -59,5 +59,4 @@ private:
        CndVar cv;
 };
 
-#endif //SMS_CDMA_PLUGIN_UA_MANAGER_H
-
+#endif /* SMS_CDMA_PLUGIN_UA_MANAGER_H */
index f2aac5c..f2142fb 100755 (executable)
@@ -50,7 +50,7 @@ class SmsPluginWapPushHandler
 public:
        static SmsPluginWapPushHandler* instance();
 
-       //void registerPushCallback();
+       /* void registerPushCallback(); */
        bool IsWapPushMsg(unsigned short dstport);
 
        void copyDeliverData(sms_trans_addr_s *pAddr);
@@ -94,8 +94,7 @@ private:
 
 
        sms_trans_addr_s        tmpAddress;
-//     SMS_TIMESTAMP_S tmpTimeStamp;
+       /* SMS_TIMESTAMP_S      tmpTimeStamp; */
 };
 
-#endif //SmsPluginWapPushHandler
-
+#endif /* SmsPluginWapPushHandler */
index 32fc48c..5ecebab 100755 (executable)
@@ -42,7 +42,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 db-util capi-telephony)
+pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 capi-telephony)
 
 FOREACH(flag ${sms_plugin_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 038d40f..99bb053 100755 (executable)
@@ -31,6 +31,7 @@
 #include "SmsPluginSimMsg.h"
 #include "SmsPluginSetting.h"
 #include "MsgGconfWrapper.h"
+#include "MsgDevicedWrapper.h"
 #include "SmsPluginCallback.h"
 #include "SmsPluginDSHandler.h"
 
@@ -44,13 +45,10 @@ void TapiEventDeviceReady(TapiHandle *handle, const char *noti_id, void *data, v
 {
        MSG_DEBUG("TapiEventDeviceReady is called. : noti_id = [%d]", noti_id);
 
-       try
-       {
-               // Call Event Handler
+       try {
+               /* Call Event Handler */
                SmsPluginEventHandler::instance()->setDeviceStatus(handle);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
@@ -63,38 +61,39 @@ SMS_NETWORK_STATUS_T convertTapiRespToSmsPlugin(int result)
 
        /* Convert TAPI status -> SMS network status */
        switch ((TelSmsResponse_t)result) {
-               case TAPI_NETTEXT_SENDSMS_SUCCESS :
-                       sentStatus = SMS_NETWORK_SEND_SUCCESS;
-                       break;
+       case TAPI_NETTEXT_SENDSMS_SUCCESS :
+               sentStatus = SMS_NETWORK_SEND_SUCCESS;
+               break;
 
-               case TAPI_NETTEXT_INVALID_MANDATORY_INFO :
-                       sentStatus = SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING;
-                       break;
+       case TAPI_NETTEXT_INVALID_MANDATORY_INFO :
+               sentStatus = SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING;
+               break;
 
-               case TAPI_NETTEXT_DESTINAITION_OUTOFSERVICE :
-               case TAPI_NETTEXT_TEMPORARY_FAILURE :
-               case TAPI_NETTEXT_CONGESTION :
-               case TAPI_NETTEXT_RESOURCES_UNAVAILABLE :
-               case TAPI_NETTEXT_MESSAGE_NOT_COMPAT_PROTOCOL :
-               case TAPI_NETTEXT_NETWORK_OUTOFORDER:
-                       sentStatus = SMS_NETWORK_SEND_FAIL_TEMPORARY;
-                       break;
+       case TAPI_NETTEXT_DESTINAITION_OUTOFSERVICE :
+       case TAPI_NETTEXT_TEMPORARY_FAILURE :
+       case TAPI_NETTEXT_CONGESTION :
+       case TAPI_NETTEXT_RESOURCES_UNAVAILABLE :
+       case TAPI_NETTEXT_MESSAGE_NOT_COMPAT_PROTOCOL :
+       case TAPI_NETTEXT_NETWORK_OUTOFORDER:
+               sentStatus = SMS_NETWORK_SEND_FAIL_TEMPORARY;
+               break;
 
-               case TAPI_NETTEXT_MESSAGE_TRANSFER_REJECTED :
-                       sentStatus = SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED;
-                       break;
+       case TAPI_NETTEXT_MESSAGE_TRANSFER_REJECTED :
+               sentStatus = SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED;
+               break;
 
-               case TAPI_NETTEXT_DEST_ADDRESS_FDN_RESTRICTED :
-               case TAPI_NETTEXT_SCADDRESS_FDN_RESTRICTED :
-                       sentStatus = SMS_NETWORK_SEND_FAIL_FDN_RESTRICED;
-                       break;
-               case TAPI_NETTEXT_ROUTING_NOT_AVAILABLE :
-                       sentStatus = SMS_NETWORK_SEND_FAIL_NO_ROUTING;
-                       break;
-               default :
-                       sentStatus = SMS_NETWORK_SEND_FAIL;
-                       break;
+       case TAPI_NETTEXT_DEST_ADDRESS_FDN_RESTRICTED :
+       case TAPI_NETTEXT_SCADDRESS_FDN_RESTRICTED :
+               sentStatus = SMS_NETWORK_SEND_FAIL_FDN_RESTRICED;
+               break;
+       case TAPI_NETTEXT_ROUTING_NOT_AVAILABLE :
+               sentStatus = SMS_NETWORK_SEND_FAIL_NO_ROUTING;
+               break;
+       default :
+               sentStatus = SMS_NETWORK_SEND_FAIL;
+               break;
        }
+
        return sentStatus;
 }
 
@@ -120,7 +119,8 @@ void TapiEventSentStatus(TapiHandle *handle, int result, void *data, void *user_
 
        /* only temporary errors should be returned without calling handleSentStatus() in order to resend sms  */
        if (sentStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY ||
-                       sentStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD) {
+                       sentStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD ||
+                       sentStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED) {
                SmsPluginTransport::instance()->setNetStatus(sentStatus);
                return;
        }
@@ -128,9 +128,8 @@ void TapiEventSentStatus(TapiHandle *handle, int result, void *data, void *user_
        if (sentStatus == SMS_NETWORK_SEND_FAIL) {
                int svc_type;
                tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
-               if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G) {
+               if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G)
                        sentStatus = SMS_NETWORK_SEND_PENDING;
-               }
        }
 
        /* Convert SMS status -> Messaging network status */
@@ -146,14 +145,11 @@ void TapiEventSentStatus(TapiHandle *handle, int result, void *data, void *user_
                netStatus = MSG_NETWORK_SEND_FAIL;
        }
 
-       try
-       {
+       try {
                SmsPluginEventHandler::instance()->handleSentStatus(netStatus);
 
                SmsPluginTransport::instance()->setNetStatus(sentStatus);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
@@ -162,7 +158,7 @@ void TapiEventSentStatus(TapiHandle *handle, int result, void *data, void *user_
 
 void TapiEventSatSmsSentStatus(TapiHandle *handle, int result, void *data, void *user_data)
 {
-       MSG_DEBUG("TapiEventSatSmsSentStatus is called. : result = [%d]", result);
+       MSG_INFO("TapiEventSatSmsSentStatus is called. : result = [%d]", result);
 
        SMS_NETWORK_STATUS_T sentStatus;
 
@@ -170,21 +166,16 @@ void TapiEventSatSmsSentStatus(TapiHandle *handle, int result, void *data, void
 
        MSG_DEBUG("SMS Network Status = [%d]", sentStatus);
 
-       if (sentStatus == SMS_NETWORK_SEND_FAIL && result != TAPI_NETTEXT_DEVICE_FAILURE)
-       {
+       if (sentStatus == SMS_NETWORK_SEND_FAIL && result != TAPI_NETTEXT_DEVICE_FAILURE) {
                int svc_type;
                tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
-               if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G){
+               if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G)
                        sentStatus = SMS_NETWORK_SEND_PENDING;
-               }
        }
 
-       try
-       {
+       try {
                SmsPluginSatHandler::instance()->ctrlSms(handle, sentStatus);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
@@ -195,24 +186,26 @@ void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, v
        MSG_SEC_DEBUG("TapiEventMsgIncoming is called. noti_id [%s]", noti_id);
 
        if (data == NULL) {
-               MSG_DEBUG("Error. evt->pData is NULL.");
+               MSG_ERR("Error. data is NULL.");
                return;
        }
 #if 0
        SmsPluginCbMsgHandler::instance()->handleCbMsg(handle, NULL);
        return;
 #endif
+       /* make a margin timeout(500ms) till suspending status */
+       MsgDisplayLock();
+
        TelSmsDatapackageInfo_t* pDataPackage = (TelSmsDatapackageInfo_t*)data;
 
        SMS_TPDU_S tpdu;
        memset(&tpdu, 0x00, sizeof(SMS_TPDU_S));
 
-       // Decode Incoming Message
+       /* Decode Incoming Message */
        SmsPluginTpduCodec::decodeTpdu(pDataPackage->szData, pDataPackage->MsgLength, &tpdu);
 
-       /// Print tpdu
-       if (tpdu.tpduType == SMS_TPDU_DELIVER)
-       {
+       /* Print tpdu */
+       if (tpdu.tpduType == SMS_TPDU_DELIVER) {
                MSG_DEBUG("############# SMS_TPDU_DELIVER Incoming decoded tpdu values ####################");
                MSG_DEBUG("tpdu.data.deliver.bMoreMsg : %d", tpdu.data.deliver.bMoreMsg);
                MSG_DEBUG("tpdu.data.deliver.bStatusReport : %d", tpdu.data.deliver.bStatusReport);
@@ -231,9 +224,7 @@ void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, v
                MSG_DEBUG("tpdu.data.deliver.userData.length : %d", tpdu.data.deliver.userData.length);
                MSG_DEBUG("tpdu.data.deliver.userData.data : %s", tpdu.data.deliver.userData.data);
                MSG_DEBUG("#####################################################");
-       }
-       else if (tpdu.tpduType == SMS_TPDU_STATUS_REP)
-       {
+       } else if (tpdu.tpduType == SMS_TPDU_STATUS_REP) {
                MSG_DEBUG("############# SMS_TPDU_STATUS_REP Incoming decoded tpdu values ####################");
                MSG_DEBUG("tpdu.data.statusRep.msgRef : %d", tpdu.data.statusRep.msgRef);
                MSG_DEBUG("tpdu.data.statusRep.bMoreMsg : %d", tpdu.data.statusRep.bMoreMsg);
@@ -256,36 +247,31 @@ void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, v
                MSG_DEBUG("#####################################################");
        }
 
-       try
-       {
-               if (tpdu.tpduType == SMS_TPDU_DELIVER)
-               {
+       MsgDisplayUnlock();
+
+       try {
+               if (tpdu.tpduType == SMS_TPDU_DELIVER) {
                        if (tpdu.data.deliver.dcs.msgClass == SMS_MSG_CLASS_2) {
-                               // For GCF test, 34.2.5.3
+                               /* For GCF test, 34.2.5.3 */
                                SmsPluginSimMsg::instance()->setSmsData((const char*)pDataPackage->Sca, (const char *)pDataPackage->szData, pDataPackage->MsgLength);
                        }
 
                        if (SmsPluginConcatHandler::instance()->IsConcatMsg(&(tpdu.data.deliver.userData)) == true ||
-                               SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(tpdu.data.deliver.userData)) == true)
-                       {
-                               SmsPluginConcatHandler::instance()->handleConcatMsg(handle, &tpdu); // Call Concat Msg Handler
-                       }
-                       else
-                       {
-                               SmsPluginEventHandler::instance()->handleMsgIncoming(handle, &tpdu); // Call Event Handler
+                               SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(tpdu.data.deliver.userData)) == true) {
+                               /* Call Concat Msg Handler */
+                               SmsPluginConcatHandler::instance()->handleConcatMsg(handle, &tpdu);
+                       } else {
+                               /* Call Event Handler */
+                               SmsPluginEventHandler::instance()->handleMsgIncoming(handle, &tpdu);
                        }
+               } else if (tpdu.tpduType == SMS_TPDU_STATUS_REP) {
+                       /* Call Event Handler */
+                       SmsPluginEventHandler::instance()->handleMsgIncoming(handle, &tpdu);
                }
-               else if (tpdu.tpduType == SMS_TPDU_STATUS_REP)
-               {
-                       SmsPluginEventHandler::instance()->handleMsgIncoming(handle, &tpdu); // Call Event Handler
-               }
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
-
 }
 
 
@@ -294,22 +280,18 @@ void TapiEventCbMsgIncoming(TapiHandle *handle, const char *noti_id, void *data,
        MSG_SEC_DEBUG("TapiEventCbMsgIncoming is called. noti_id [%s]", noti_id);
 
        if (data == NULL) {
-               MSG_DEBUG("Error. evt->pData is NULL.");
+               MSG_ERR("Error. data is NULL.");
                return;
        }
 
        TelSmsCbMsg_t *pCbMsg = (TelSmsCbMsg_t*)data;
 
-       try
-       {
+       try {
                SmsPluginCbMsgHandler::instance()->handleCbMsg(handle, pCbMsg);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
-
 }
 
 
@@ -318,18 +300,15 @@ void TapiEventEtwsMsgIncoming(TapiHandle *handle, const char *noti_id, void *dat
        MSG_SEC_DEBUG("TapiEventEtwsMsgIncoming is called. noti_id [%s]", noti_id);
 
        if (data == NULL) {
-               MSG_DEBUG("Error. evt->pData is NULL.");
+               MSG_ERR("Error. data is NULL.");
                return;
        }
 
        TelSmsEtwsMsg_t *pEtwsMsg = (TelSmsEtwsMsg_t*)data;
 
-       try
-       {
+       try {
                SmsPluginCbMsgHandler::instance()->handleEtwsMsg(handle, pEtwsMsg);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
@@ -348,9 +327,8 @@ void TapiEventGetSimMsgCnt(TapiHandle *handle, int result, void *data, void *use
 {
        MSG_DEBUG("TapiEventGetSimMsgCnt is called.");
 
-       if (result != TAPI_API_SUCCESS || data == NULL)
-       {
-               MSG_DEBUG("Error. data is NULL.");
+       if (result != TAPI_API_SUCCESS || data == NULL) {
+               MSG_ERR("Error. data is NULL. result:[0x%x]", result);
                MSG_SIM_COUNT_S simCnt;
                memset(&simCnt, 0x00, sizeof(MSG_SIM_COUNT_S));
                SmsPluginSimMsg::instance()->setSimMsgCntEvent(handle, &simCnt);
@@ -366,9 +344,8 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d
 {
        MSG_DEBUG("TapiEventGetSimMsg is called.");
 
-       if (result != TAPI_API_SUCCESS || data == NULL)
-       {
-               MSG_DEBUG("Error!! pEvent->Status [%d]", result);
+       if (result != TAPI_API_SUCCESS || data == NULL) {
+               MSG_ERR("Error!! result [0x%x]", result);
 
                SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
 
@@ -377,17 +354,16 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d
 
 
        TelSmsData_t* pSmsTpdu = (TelSmsData_t*)data;
-       //SmsPluginSimMsg::instance()->deleteSimMessage((msg_sim_id_t)pSmsTpdu->SimIndex);
 
        int *simIdList = (int *)user_data;
 
-       // Reading TelSmsData_t
-       MSG_DEBUG ("sim index %d", pSmsTpdu->SimIndex);
-       MSG_DEBUG ("status %d", pSmsTpdu->MsgStatus);
+       /* Reading TelSmsData_t */
+       MSG_DEBUG("sim index %d", pSmsTpdu->SimIndex);
+       MSG_DEBUG("status %d", pSmsTpdu->MsgStatus);
+       MSG_DEBUG("sim msg [%s]", pSmsTpdu->SmsData.szData);
 
-       // Reading TelSmsDatapackageInfo_t
-       if (pSmsTpdu->SmsData.MsgLength > MAX_TPDU_DATA_LEN)
-       {
+       /* Reading TelSmsDatapackageInfo_t */
+       if (pSmsTpdu->SmsData.MsgLength > MAX_TPDU_DATA_LEN) {
                MSG_DEBUG ("WARNING: tpdu_len > MAX_SMS_TPDU_SIZE [%d] bytes. setting to 0.", pSmsTpdu->SmsData.MsgLength);
 
                SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
@@ -397,21 +373,20 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d
 
        SMS_TPDU_S tpdu;
 
-       // decode Tpdu
+       /* decode Tpdu */
        SmsPluginTpduCodec::decodeTpdu(pSmsTpdu->SmsData.szData, pSmsTpdu->SmsData.MsgLength, &tpdu);
 
        MSG_DEBUG("Sim Message Type [%d]", tpdu.tpduType);
 
        bool bRead = false;
 
-       // set read status
+       /* set read status */
        if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_READ)
                bRead = true;
        else if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_UNREAD)
                bRead = false;
 
-       if (tpdu.tpduType == SMS_TPDU_DELIVER)
-       {
+       if (tpdu.tpduType == SMS_TPDU_DELIVER) {
                if (tpdu.data.deliver.dcs.codingScheme == SMS_CHARSET_8BIT && tpdu.data.deliver.pid == 0x11) {
                        MSG_DEBUG("Unsupported message!!");
                        SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
@@ -419,13 +394,11 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d
                }
 
                MSG_DEBUG("headerCnt [%d]", tpdu.data.deliver.userData.headerCnt);
-               for (int i = 0; i < tpdu.data.deliver.userData.headerCnt; i++)
-               {
-                       // Handler Concatenated Message
+               for (int i = 0; i < tpdu.data.deliver.userData.headerCnt; i++) {
+                       /* Handler Concatenated Message */
                        if (tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
                                tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
                                SmsPluginConcatHandler::instance()->handleSimConcatMsg(handle, &tpdu, pSmsTpdu->SimIndex, bRead, simIdList);
-                               //SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
                                return;
                        }
 
@@ -435,9 +408,7 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d
                                return;
                        }
                }
-       }
-       else if (tpdu.tpduType == SMS_TPDU_SUBMIT)
-       {
+       } else if (tpdu.tpduType == SMS_TPDU_SUBMIT) {
                if (tpdu.data.submit.dcs.codingScheme == SMS_CHARSET_8BIT && tpdu.data.submit.pid == 0x11) {
                        MSG_DEBUG("Unsupported message!!");
                        SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
@@ -445,23 +416,21 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d
                }
                MSG_DEBUG("headerCnt [%d]", tpdu.data.submit.userData.headerCnt);
 
-               for (int i = 0; i < tpdu.data.submit.userData.headerCnt; i++)
-               {
-                       // Handler Concatenated Message
+               for (int i = 0; i < tpdu.data.submit.userData.headerCnt; i++) {
+                       /* Handler Concatenated Message */
                        if (tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
-                               tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT)
-                       {
+                               tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
                                SmsPluginConcatHandler::instance()->handleSimConcatMsg(handle, &tpdu, pSmsTpdu->SimIndex, bRead, simIdList);
                                return;
                        }
                }
        }
 
-       // Make MSG_MESSAGE_INFO_S
+       /* Make MSG_MESSAGE_INFO_S */
        MSG_MESSAGE_INFO_S msgInfo;
        memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
 
-       // set storage id
+       /* set storage id */
        msgInfo.storageId = MSG_STORAGE_SIM;
 
        msgInfo.addressList = NULL;
@@ -503,16 +472,15 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d
                        memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
                        snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "Voice message");
                }
-       }
-       else if (tpdu.tpduType == SMS_TPDU_SUBMIT) {
+       } else if (tpdu.tpduType == SMS_TPDU_SUBMIT) {
                msgInfo.displayTime =  time(NULL);
        }
 
-       // set read status
+       /* set read status */
        msgInfo.bRead = bRead;
 
        simIdList[0] = pSmsTpdu->SimIndex + 1;
-       /// Print MSG_MESSAGE_INFO_S
+       /* Print MSG_MESSAGE_INFO_S */
        MSG_DEBUG("############# Convert  tpdu values to Message Info values ####################");
        MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
        MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
@@ -536,7 +504,8 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d
        MSG_DEBUG("msgInfo.sim_idx : %d", msgInfo.sim_idx);
        MSG_DEBUG("###############################################################");
 
-       SmsPluginSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true); // Call Event Handler
+       /* Call Event Handler */
+       SmsPluginSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true);
 
 
 }
@@ -551,7 +520,7 @@ void TapiEventSaveSimMsg(TapiHandle *handle, int result, void *data, void *user_
        if (data != NULL)
                simId = *((int*)data);
        else
-               MSG_DEBUG("Data(SIM Msg ID) is NULL");
+               MSG_ERR("Data(SIM Msg ID) is NULL");
 
        SmsPluginSimMsg::instance()->setSaveSimMsgEvent(handle, simId, result);
 }
@@ -567,21 +536,17 @@ void TapiEventSaveClass2Msg(TapiHandle *handle, int result, void *data, void *us
                simId = *((int*)data);
                MSG_DEBUG("SIM Msg ID : %d", simId);
        } else {
-               MSG_DEBUG("Data(SIM Msg ID) is NULL");
+               MSG_ERR("Data(SIM Msg ID) is NULL");
        }
 
        MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)user_data;
 
        SmsPluginSimMsg::instance()->setSaveClass2MsgEvent(handle, simId, result, pMsgInfo);
 
-       if(result == TAPI_NETTEXT_SENDSMS_SUCCESS)
-       {
+       if (result == TAPI_NETTEXT_SENDSMS_SUCCESS)
                SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)simId, true);
-       }
        else
-       {
                SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)0, false);
-       }
 
        if (pMsgInfo) {
                if (pMsgInfo->addressList) {
@@ -598,9 +563,8 @@ void TapiEventDeleteSimMsg(TapiHandle *handle, int result, void *data, void *use
 {
        MSG_DEBUG("TapiEventDeleteSimMsg is called. result [%d]", result);
 
-       if (result != TAPI_API_SUCCESS || data == NULL)
-       {
-               MSG_DEBUG("Error. data is NULL.");
+       if (result != TAPI_API_SUCCESS || data == NULL) {
+               MSG_ERR("Error. data is NULL. result:0x%x", result);
                SmsPluginSimMsg::instance()->setDelSimEvent(-1, false);
                return;
        }
@@ -616,9 +580,8 @@ void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *us
 {
        MSG_DEBUG("TapiEventSetConfigData is called.");
 
-       if (data == NULL)
-       {
-               MSG_DEBUG("Error. data is NULL.");
+       if (data == NULL) {
+               MSG_ERR("Error. data is NULL. result:%d", result);
                return;
        }
 
@@ -626,30 +589,29 @@ void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *us
 
        MSG_DEBUG("responseType : [%d]", *responseType);
 
-       switch (*responseType)
-       {
-               case TAPI_NETTEXT_SETPREFERREDBEARER_RSP :
-                       MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
+       switch (*responseType) {
+       case TAPI_NETTEXT_SETPREFERREDBEARER_RSP :
+               MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
                break;
 
-               case TAPI_NETTEXT_SETPARAMETERS_RSP :
-                       MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
+       case TAPI_NETTEXT_SETPARAMETERS_RSP :
+               MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
                break;
 
-               case TAPI_NETTEXT_CBSETCONFIG_RSP :
-                       MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
+       case TAPI_NETTEXT_CBSETCONFIG_RSP :
+               MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
                break;
 
-               case TAPI_NETTEXT_SETMEMORYSTATUS_RSP :
-                       MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
+       case TAPI_NETTEXT_SETMEMORYSTATUS_RSP :
+               MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
                break;
 
-               case TAPI_NETTEXT_SETMESSAGESTATUS_RSP :
-                       MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
+       case TAPI_NETTEXT_SETMESSAGESTATUS_RSP :
+               MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
                break;
 
-               default :
-                       MSG_DEBUG("Unknown Response is called [%d]", *responseType);
+       default :
+               MSG_DEBUG("Unknown Response is called [%d]", *responseType);
                break;
        }
 
@@ -671,9 +633,8 @@ void TapiEventGetParamCnt(TapiHandle *handle, int result, void *data, void *user
 {
        MSG_DEBUG("TapiEventGetParamCnt is called.");
 
-       if (result != TAPI_API_SUCCESS || data == NULL)
-       {
-               MSG_DEBUG("Error. evt->pData is NULL.");
+       if (result != TAPI_API_SUCCESS || data == NULL) {
+               MSG_ERR("Error. data is NULL. result:0x%x", result);
                SmsPluginSetting::instance()->setParamCntEvent(0);
                return;
        }
@@ -690,9 +651,8 @@ void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_da
 {
        MSG_DEBUG("TapiEventGetConfigData is called.");
 
-       if (result != TAPI_API_SUCCESS || data == NULL)
-       {
-               MSG_DEBUG("Error. data is NULL.");
+       if (result != TAPI_API_SUCCESS || data == NULL) {
+               MSG_ERR("Error. data is NULL. result:0x%x", result);
                SmsPluginSetting::instance()->setParamEvent(handle, NULL, -1, false);
                return;
        }
@@ -707,8 +667,7 @@ void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_da
        alphaIdLen = smsParam->AlphaIdLen;
        MSG_DEBUG("alphaId_len[%d]", alphaIdLen);
 
-       if (alphaIdLen < 0 || alphaIdLen > SMSC_NAME_MAX)
-       {
+       if (alphaIdLen < 0 || alphaIdLen > SMSC_NAME_MAX) {
                MSG_DEBUG("Wrong Alpha ID Length[%d]", alphaIdLen);
 
                SmsPluginSetting::instance()->setParamEvent(handle, NULL, -1, false);
@@ -720,14 +679,11 @@ void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_da
        /*Check Address value*/
        addrLen = smsParam->TpSvcCntrAddr.DialNumLen;
 
-       if(addrLen > SMSC_ADDR_MAX)
-       {
+       if (addrLen > SMSC_ADDR_MAX) {
                MSG_DEBUG("addrLen is too long: %d", addrLen);
                SmsPluginSetting::instance()->setParamEvent(handle, NULL, -1, false);
                return;
-       }
-       else if(addrLen < 2)
-       {
+       } else if (addrLen < 2) {
                MSG_DEBUG("addrLen is too short: %d", addrLen);
                SmsPluginSetting::instance()->setParamEvent(handle, NULL, -1, false);
                return;
@@ -735,13 +691,11 @@ void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_da
 
        MSG_DEBUG("addrLen : %d", addrLen);
 
-
        /*SMSP Parameter Indicator value*/
        MSG_DEBUG("ParamIndicator[%02x]", smsParam->ParamIndicator);
 
        /*Get SMSC Address*/
-       if(0x00 == (0x02 & smsParam->ParamIndicator))
-       {
+       if (0x00 == (0x02 & smsParam->ParamIndicator)) {
                MSG_DEBUG("record index[%d]", (int)smsParam->RecordIndex);
 
                MSG_DEBUG("TON : %d", smsParam->TpSvcCntrAddr.Ton);
@@ -762,58 +716,46 @@ void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_da
                smscData.name[alphaIdLen] = '\0';
 
                MSG_SEC_DEBUG("SMSC Name : [%s]", smscData.name);
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("SMSC Address is not present");
 
-//             smscData.smscAddr.ton = MSG_TON_UNKNOWN;
-//             smscData.smscAddr.npi = MSG_NPI_UNKNOWN;
-//
-//             memset(smscData.smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
-//             memset(smscData.name, 0x00, SMSC_NAME_MAX+1);
-
                SmsPluginSetting::instance()->setParamEvent(handle, NULL, -1, false);
 
                return;
        }
 
        /*Get the PID value*/
-       if (0x00 == (0x04 & smsParam->ParamIndicator))
-       {
+       if (0x00 == (0x04 & smsParam->ParamIndicator)) {
                SMS_PID_T pid = (SMS_PID_T)smsParam->TpProtocolId;
 
                MSG_DEBUG("smsParam->TpProtocolId : %d", smsParam->TpProtocolId);
 
-               switch (pid)
-               {
-                       case SMS_PID_NORMAL:
-                               smscData.pid = MSG_PID_TEXT;
+               switch (pid) {
+               case SMS_PID_NORMAL:
+                       smscData.pid = MSG_PID_TEXT;
                        break;
-                       case SMS_PID_VOICE:
-                               smscData.pid = MSG_PID_VOICE;
+               case SMS_PID_VOICE:
+                       smscData.pid = MSG_PID_VOICE;
                        break;
-                       case SMS_PID_TELEX:
-                               smscData.pid = MSG_PID_FAX;
+               case SMS_PID_TELEX:
+                       smscData.pid = MSG_PID_FAX;
                        break;
-                       case SMS_PID_x400:
-                               smscData.pid = MSG_PID_X400;
+               case SMS_PID_x400:
+                       smscData.pid = MSG_PID_X400;
                        break;
-                       case SMS_PID_ERMES:
-                               smscData.pid = MSG_PID_ERMES;
+               case SMS_PID_ERMES:
+                       smscData.pid = MSG_PID_ERMES;
                        break;
-                       case SMS_PID_EMAIL:
-                               smscData.pid = MSG_PID_EMAIL;
+               case SMS_PID_EMAIL:
+                       smscData.pid = MSG_PID_EMAIL;
                        break;
-                       default:
-                               smscData.pid = MSG_PID_TEXT;
+               default:
+                       smscData.pid = MSG_PID_TEXT;
                        break;
                }
 
                MSG_DEBUG("smscData.pid : %d", smscData.pid);
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("PID is not present");
                smscData.pid = MSG_PID_TEXT;
                MSG_DEBUG("MSG_PID_TEXT is inserted to PID");
@@ -834,21 +776,16 @@ void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_da
 #endif
 
        /*Get the ValidityPeriod value*/
-       if (0x00 == (0x10 & smsParam->ParamIndicator))
-       {
+       if (0x00 == (0x10 & smsParam->ParamIndicator)) {
                smscData.valPeriod = smsParam->TpValidityPeriod;
                MSG_DEBUG("valPeriod : %d", smscData.valPeriod);
-       }
-       else
-       {
-
+       } else {
                smscData.valPeriod = 0;
 
                MSG_DEBUG("Validity Period is not present");
        }
 
        SmsPluginSetting::instance()->setParamEvent(handle, &smscData, (int)smsParam->RecordIndex, true);
-
 }
 
 
@@ -856,11 +793,10 @@ void TapiEventSetSmscInfo(TapiHandle *handle, int result, void *data, void *user
 {
        MSG_DEBUG("TapiEventSetSmscInfo is called. result=[%d]", result);
 
-       if (result != TAPI_API_SUCCESS) {
+       if (result != TAPI_API_SUCCESS)
                SmsPluginSetting::instance()->setResultFromSim(false);
-       } else {
+       else
                SmsPluginSetting::instance()->setResultFromSim(true);
-       }
 }
 
 
@@ -872,9 +808,8 @@ void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user
 
        int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
 
-       if (result != TAPI_API_SUCCESS || data == NULL || simIndex == 0)
-       {
-               MSG_DEBUG("Error. data is NULL.");
+       if (result != TAPI_API_SUCCESS || data == NULL || simIndex == 0) {
+               MSG_ERR("Error. data is NULL. result:0x%x, simIndex:%d", result, simIndex);
 
                SmsPluginSetting::instance()->setCbConfigEvent(handle, NULL, false);
 
@@ -893,16 +828,14 @@ void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user
 
        cbOpt.channelData.channelCnt = pCBConfig->MsgIdRangeCount;
 
-       if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX)
-       {
+       if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX) {
                MSG_DEBUG("Channel Count [%d] from TAPI is over MAX", cbOpt.channelData.channelCnt);
                cbOpt.channelData.channelCnt = CB_CHANNEL_MAX;
        }
 
        MSG_DEBUG("Channel Count [%d]", cbOpt.channelData.channelCnt);
 
-       for (int i = 0; i < cbOpt.channelData.channelCnt; i++)
-       {
+       for (int i = 0; i < cbOpt.channelData.channelCnt; i++) {
                cbOpt.channelData.channelInfo[i].bActivate = pCBConfig->MsgIDs[i].Net3gpp.Selected;
                cbOpt.channelData.channelInfo[i].from = pCBConfig->MsgIDs[i].Net3gpp.FromMsgId;
                cbOpt.channelData.channelInfo[i].to = pCBConfig->MsgIDs[i].Net3gpp.ToMsgId;
@@ -999,9 +932,8 @@ void TapiEventGetMwiInfo(TapiHandle *handle, int result, void *data, void *user_
 {
        MSG_DEBUG("TapiEventGetMwiInfo is called.");
 
-       if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL)
-       {
-               MSG_DEBUG("Error. data is NULL.");
+       if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL) {
+               MSG_ERR("Error. data is NULL. result:0x%x", result);
                SmsPluginSetting::instance()->setMwiInfoEvent(handle, NULL, false);
 
                return;
@@ -1022,7 +954,7 @@ void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *us
        bool bRet = false;
 
        if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL) {
-               MSG_DEBUG("Error. data is NULL.");
+               MSG_ERR("Error. data is NULL. result:0x%x", result);
                SmsPluginSetting::instance()->setResultFromSim(bRet);
                return;
        }
@@ -1038,7 +970,7 @@ void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *us
                        snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, simIndex);
 
                        if (MsgSettingSetString(keyName, list->list[i].num) == MSG_SUCCESS) {
-                               MSG_SEC_DEBUG("Get MSISDN from SIM : [%s]", list->list[i].num);
+                               MSG_SEC_INFO("Get MSISDN from SIM : [%s]", list->list[i].num);
                                bRet = true;
                        } else {
                                MSG_DEBUG("Getting MSISDN is failed!");
@@ -1059,8 +991,7 @@ void TapiEventGetSimServiceTable(TapiHandle *handle, int result, void *data, voi
 
        bool bRet = true;
 
-       if (access_rt != TAPI_SIM_ACCESS_SUCCESS || svct == NULL)
-       {
+       if (access_rt != TAPI_SIM_ACCESS_SUCCESS || svct == NULL) {
                MSG_ERR("Error. data is NULL and access_rt [%d] failed", access_rt);
                SmsPluginSetting::instance()->setResultFromSim(false);
                return;
@@ -1095,14 +1026,14 @@ void TapiEventGetSimServiceTable(TapiHandle *handle, int result, void *data, voi
                MSG_DEBUG("Setting result = [%d]", err);
 
        } else if (svct->sim_type == TAPI_SIM_CARD_TYPE_USIM) {
-               if (svct->table.sst.service[TAPI_SIM_UST_SMS] == 1) {
+               if (svct->table.ust.service[TAPI_SIM_UST_SMS] == 1) {
                        err = MsgSettingSetBool(sstKey, true);
                } else {
                        err = MsgSettingSetBool(sstKey, false);
                }
                MSG_DEBUG("Setting result = [%d]", err);
 
-               if (svct->table.sst.service[TAPI_SIM_UST_MO_SMS_CTRL] == 1){
+               if (svct->table.ust.service[TAPI_SIM_UST_MO_SMS_CTRL] == 1){
                        err = MsgSettingSetBool(moCtrlKey, true);
                } else {
                        err = MsgSettingSetBool(moCtrlKey, false);
@@ -1120,22 +1051,17 @@ void TapiEventSatSmsRefresh(TapiHandle *handle, int result, void *data, void *us
 {
        MSG_DEBUG("TapiEventSatSmsRefresh is called.");
 
-       if (result != TAPI_API_SUCCESS || data == NULL)
-       {
-               MSG_DEBUG("Error. data is NULL.");
+       if (result != TAPI_API_SUCCESS || data == NULL) {
+               MSG_ERR("Error. data is NULL. result:0x%x", result);
                return;
        }
 
-       try
-       {
+       try {
                SmsPluginSatHandler::instance()->refreshSms(handle, data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
-
 }
 
 
@@ -1143,22 +1069,17 @@ void TapiEventSatSendSms(TapiHandle *handle, const char *noti_id, void *data, vo
 {
        MSG_DEBUG("TapiEventSatSendSms is called.");
 
-       if (data == NULL)
-       {
-               MSG_DEBUG("Error. data is NULL.");
+       if (data == NULL) {
+               MSG_ERR("Error. data is NULL.");
                return;
        }
 
-       try
-       {
+       try {
                SmsPluginSatHandler::instance()->sendSms(handle, data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
-
 }
 
 
@@ -1166,40 +1087,32 @@ void TapiEventSatMoSmsCtrl(TapiHandle *handle, const char *noti_id, void *data,
 {
        MSG_DEBUG("TapiEventSatMoSmsCtrl is called.");
 
-       if (data == NULL)
-       {
-               MSG_DEBUG("Error. data is NULL.");
+       if (data == NULL) {
+               MSG_ERR("Error. data is NULL.");
                return;
        }
 
-       try
-       {
+       try {
                SmsPluginSatHandler::instance()->ctrlSms(handle, data);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
-
 }
 
 void TapiEventMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data)
 {
        MSG_DEBUG("Tapi result is [%d]", result);
-       if(result == TAPI_API_SUCCESS)
-       {
+       if (result == TAPI_API_SUCCESS)
                isMemAvailable = true;
-       }
 }
 
 void TapiEventSetMsgStatus(TapiHandle *handle, int result, void *data, void *user_data)
 {
        MSG_DEBUG("TapiEventSetMsgStatus is called. result [%d]", result);
 
-       if (result != TAPI_API_SUCCESS || data == NULL)
-       {
-               MSG_DEBUG("Error. data is NULL.");
+       if (result != TAPI_API_SUCCESS || data == NULL) {
+               MSG_ERR("Error. data is NULL. result:0x%x", result);
                SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)0, false);
                return;
        }
@@ -1214,9 +1127,8 @@ void TapiEventGetMeImei(TapiHandle *handle, int result, void *data, void *user_d
 {
        MSG_SEC_DEBUG("TapiEventGetMeImei is called. result [%d]", result);
 
-       if (result != TAPI_API_SUCCESS || data == NULL)
-       {
-               MSG_DEBUG("Error. data is NULL.");
+       if (result != TAPI_API_SUCCESS || data == NULL) {
+               MSG_ERR("Error. data is NULL. result:0x%x", result);
                SmsPluginSetting::instance()->setResultImei(false, NULL);
                return;
        }
@@ -1232,7 +1144,7 @@ void TapiEventSimStatusChange(TapiHandle *handle, const char *noti_id, void *dat
        MSG_DEBUG("TapiEventSimStatusChange is called.");
 
        if (data == NULL) {
-               MSG_DEBUG("Error. data is NULL.");
+               MSG_ERR("Error. data is NULL.");
                return;
        }
 
@@ -1251,7 +1163,7 @@ void TapiEventNetworkStatusChange(TapiHandle *handle, const char *noti_id, void
        MSG_DEBUG("TapiEventNetworkStatusChange is called.");
 
        if (data == NULL) {
-               MSG_DEBUG("Error. data is NULL.");
+               MSG_ERR("Error. data is NULL.");
                return;
        }
 
@@ -1260,7 +1172,8 @@ void TapiEventNetworkStatusChange(TapiHandle *handle, const char *noti_id, void
        MSG_INFO("network status type [%d]", *type);
 
        if (*type > TAPI_NETWORK_SERVICE_TYPE_SEARCH) {
-               SmsPluginEventHandler::instance()->handleResendMessage(); // Call Event Handler
+               /* Call Event Handler */
+               SmsPluginEventHandler::instance()->handleResendMessage();
        }
 }
 
@@ -1304,13 +1217,13 @@ SmsPluginCallback* SmsPluginCallback::instance()
 
 void SmsPluginCallback::registerEvent()
 {
-       struct tapi_handle *pTapiHandle;
+       TapiHandle *pTapiHandle;
 
        int count = SmsPluginDSHandler::instance()->getTelHandleCount();
 
        for (int i = 1; i <= count; ++i) {
                pTapiHandle = SmsPluginDSHandler::instance()->getTelHandle(i);
-               int simIndex = SmsPluginDSHandler::instance()->getSimIndex(pTapiHandle);
+//             int simIndex = SmsPluginDSHandler::instance()->getSimIndex(pTapiHandle);
 
                if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_DEVICE_READY, TapiEventDeviceReady, NULL) != TAPI_API_SUCCESS)
                        MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SMS_DEVICE_READY);
index ce9e959..4ab8907 100755 (executable)
@@ -29,7 +29,7 @@
 #include "SmsPluginDSHandler.h"
 
 /*==================================================================================================
-                                     IMPLEMENTATION OF SmsPluginCbMsgHandler - Member Functions
+                  IMPLEMENTATION OF SmsPluginCbMsgHandler - Member Functions
 ==================================================================================================*/
 SmsPluginCbMsgHandler* SmsPluginCbMsgHandler::pInstance = NULL;
 
@@ -69,56 +69,49 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs
        SMS_CB_NETWORK_TYPE_T type = pCbMsg->EtwsMsgType;
        SMS_CBMSG_PAGE_S CbMsgPage = {0};
 
-       switch (type)
-       {
-               case SMS_CB_NETWORK_TYPE_2G_GSM :
-                       Decode2gCbMsg((TelSmsCbMsg_t *)pCbMsg, &CbMsgPage);
+       switch (type) {
+       case SMS_CB_NETWORK_TYPE_2G_GSM :
+               Decode2gCbMsg((TelSmsCbMsg_t *)pCbMsg, &CbMsgPage);
                break;
 
-               case SMS_CB_NETWORK_TYPE_3G_UMTS :
-                       Decode3gCbMsg((TelSmsCbMsg_t *)pCbMsg, &CbMsgPage);
+       case SMS_CB_NETWORK_TYPE_3G_UMTS :
+               Decode3gCbMsg((TelSmsCbMsg_t *)pCbMsg, &CbMsgPage);
                break;
-
        }
 #else
        SMS_CB_NETWORK_TYPE_T type = pCbMsg->CbMsgType;
        SMS_CBMSG_PAGE_S CbMsgPage = {0};
 
-       switch (type)
-       {
-               case SMS_CB_NETWORK_TYPE_2G_GSM :
-                       Decode2gCbMsg(pCbMsg, &CbMsgPage);
+       switch (type) {
+       case SMS_CB_NETWORK_TYPE_2G_GSM :
+               Decode2gCbMsg(pCbMsg, &CbMsgPage);
                break;
 
-               case SMS_CB_NETWORK_TYPE_3G_UMTS :
-                       Decode3gCbMsg(pCbMsg, &CbMsgPage);
+       case SMS_CB_NETWORK_TYPE_3G_UMTS :
+               Decode3gCbMsg(pCbMsg, &CbMsgPage);
                break;
-
        }
 #endif
-       // Check CB Msg Options
+       /* Check CB Msg Options */
        bool bJavaMsg = false;
 
        int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
 
-       if (!checkCbOpt(&CbMsgPage, &bJavaMsg, simIndex))
-       {
+       if (!checkCbOpt(&CbMsgPage, &bJavaMsg, simIndex)) {
                MSG_DEBUG("The CB Msg is not supported by option.");
                return;
        }
 
-       if (bJavaMsg == true)
-       {
+       if (bJavaMsg == true) {
                MSG_DEBUG("JAVA CB Msg.");
                CbMsgPage.cbMsgType = SMS_CBMSG_TYPE_JAVACBS;
        }
 
 
-       // Check CB Pages
+       /* Check CB Pages */
        unsigned char pageCnt = checkCbPage(&CbMsgPage);
 
-       if (pageCnt == CbMsgPage.pageHeader.totalPages)
-       {
+       if (pageCnt == CbMsgPage.pageHeader.totalPages) {
                MSG_DEBUG("RECEIVED LAST MSG : %d", pageCnt);
 
                SMS_CBMSG_S *cbMsg = NULL;
@@ -134,22 +127,22 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs
                msgInfo.addressList = NULL;
                unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
 
-               // Make CB Msg Structure
+               /* Make CB Msg Structure */
                MakeCbMsg(&CbMsgPage, cbMsg);
 
-               // Convert to MSG_MESSAGE_INFO_S
+               /* Convert to MSG_MESSAGE_INFO_S */
                convertCbMsgToMsginfo(cbMsg, &msgInfo, simIndex);
 
-               // Add CB Msg into DB
+               /* Add CB Msg into DB */
                msg_error_t err = MSG_SUCCESS;
 
                err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
 
-               if (err == MSG_SUCCESS)
-               {
+               if (err == MSG_SUCCESS) {
                        MSG_CB_MSG_S cbOutMsg = {0, };
 
-                       cbOutMsg.type = MSG_CB_SMS;
+//                     cbOutMsg.type = MSG_CB_SMS;
+                       cbOutMsg.type = msgInfo.msgType.subType;
                        cbOutMsg.receivedTime = cbMsg->recvTime;
                        cbOutMsg.serialNum = encodeCbSerialNum (CbMsgPage.pageHeader.serialNum);
                        cbOutMsg.messageId = cbMsg->msgId;
@@ -161,13 +154,9 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs
                        memcpy(cbOutMsg.language_type, CbMsgPage.pageHeader.dcs.iso639Lang, 3);
                        err = SmsPluginEventHandler::instance()->callbackCBMsgIncoming(&cbOutMsg, &msgInfo);
                        if (err != MSG_SUCCESS)
-                       {
-                               MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
-                       }
-               }
-               else
-               {
-                       MSG_DEBUG("checkMessage() Error !! [%d]", err);
+                               MSG_WARN("callbackMsgIncoming() Error !! [%d]", err);
+               } else {
+                       MSG_WARN("checkMessage() Error !! [%d]", err);
                }
 
 #if 0
@@ -179,7 +168,7 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs
                        MSG_DEBUG("insertReceivedCBMessage() Error !! [%d]", err);
                }
 #endif
-               // Remove From List
+               /* Remove From List */
                removeFromPageList(&CbMsgPage);
        }
        MSG_END();
@@ -195,8 +184,7 @@ void SmsPluginCbMsgHandler::handleEtwsMsg(TapiHandle *handle, TelSmsEtwsMsg_t *p
        SMS_ETWS_PRIMARY_S              etwsPn = {0, };
        MSG_CB_MSG_S                    cbOutMsg = {0, };
 
-       if(type != TAPI_NETTEXT_ETWS_PRIMARY)
-       {
+       if (type != TAPI_NETTEXT_ETWS_PRIMARY) {
                MSG_DEBUG("The Etws secondary Message");
                handleCbMsg(handle, (TelSmsCbMsg_t *)pEtwsMsg);
                return;
@@ -213,9 +201,7 @@ void SmsPluginCbMsgHandler::handleEtwsMsg(TapiHandle *handle, TelSmsEtwsMsg_t *p
 
        err = SmsPluginEventHandler::instance()->callbackCBMsgIncoming(&cbOutMsg, NULL);
        if (err != MSG_SUCCESS)
-       {
                MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
-       }
 
        MSG_END();
 }
@@ -229,7 +215,7 @@ void SmsPluginCbMsgHandler::Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
        memcpy(cbData, pCbMsg->szMsgData, pCbMsg->Length);
        cbData[pCbMsg->Length] = '\0';
 
-       // print cb data
+       /* print cb data */
        MSG_INFO("Received CB length:%d", pCbMsg->Length);
        char cbDataTmp[(pCbMsg->Length*2)+1];
        memset(cbDataTmp, 0x00, sizeof(cbDataTmp));
@@ -241,7 +227,7 @@ void SmsPluginCbMsgHandler::Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
 
        pCbPage->cbMsgType = SMS_CBMSG_TYPE_CBS;
 
-       // Serial Number
+       /* Serial Number */
        pCbPage->pageHeader.serialNum.geoScope = (cbData[0] & 0xC0) >> 6;
 
        pCbPage->pageHeader.serialNum.msgCode = (cbData[0] & 0x3F) << 4;
@@ -255,10 +241,10 @@ void SmsPluginCbMsgHandler::Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
 
        MSG_DEBUG("MSG ID : [%d]", pCbPage->pageHeader.msgId);
 
-       // DCS
+       /* DCS */
        decodeCbMsgDCS(cbData[4], (unsigned char*)cbData + 6, &(pCbPage->pageHeader.dcs));
 
-       // Page Parameter
+       /* Page Parameter */
        pCbPage->pageHeader.totalPages = cbData[5] & 0x0F;
        pCbPage->pageHeader.page = (cbData[5] & 0xF0) >> 4;
 
@@ -267,64 +253,61 @@ void SmsPluginCbMsgHandler::Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
 
        MSG_DEBUG("Total Page : [%d], Page : [%d]", pCbPage->pageHeader.totalPages, pCbPage->pageHeader.page);
 
-       // Convert Language Type
+       /* Convert Language Type */
        convertLangType(pCbPage->pageHeader.dcs.langType, &(pCbPage->pageHeader.langType));
 
        MSG_DEBUG("In Language Type : [%d], Out Language Type : [%d]", pCbPage->pageHeader.dcs.langType, pCbPage->pageHeader.langType);
        MSG_DEBUG("iso639Lang : [%s]", pCbPage->pageHeader.dcs.iso639Lang);
-       // Get Receive Time
+       /* Get Receive Time */
        pCbPage->pageHeader.recvTime = getRecvTime();
 
-       // Decode CB Data
+       /* Decode CB Data */
        int dataLen = pCbMsg->Length - 6;
 
        MSG_DEBUG("codingScheme:[%d]", pCbPage->pageHeader.dcs.codingScheme);
 
-       switch (pCbPage->pageHeader.dcs.codingScheme)
+       switch (pCbPage->pageHeader.dcs.codingScheme) {
+       case SMS_CHARSET_7BIT :
        {
-               case SMS_CHARSET_7BIT :
-               {
-                       MSG_DEBUG("GSM 7 BIT");
+               MSG_DEBUG("GSM 7 BIT");
 
-                       dataLen = (dataLen*8) / 7;
-
-                       SmsPluginUDCodec udCodec;
-                       char pageData[MAX_CBMSG_PAGE_SIZE+1];
-                       int unpackLen = udCodec.unpack7bitChar(&cbData[6], dataLen, 0, pageData);
-
-                       if(pCbPage->pageHeader.dcs.iso639Lang[0])
-                       {
-                               unpackLen = unpackLen - 3;
-                               if (unpackLen > 0)
-                                       memcpy(pCbPage->pageData, &pageData[3], unpackLen);
-                               else
-                                       unpackLen = 0;
-                       } else {
-                               memcpy(pCbPage->pageData, &pageData, unpackLen);
-                       }
+               dataLen = (dataLen*8) / 7;
 
-                       MSG_DEBUG("unpackLen : [%d]", unpackLen);
+               SmsPluginUDCodec udCodec;
+               char pageData[MAX_CBMSG_PAGE_SIZE+1];
+               int unpackLen = udCodec.unpack7bitChar(&cbData[6], dataLen, 0, pageData);
 
-                       pCbPage->pageLength = unpackLen;
-                       pCbPage->pageData[unpackLen] = '\0';
+               if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
+                       unpackLen = unpackLen - 3;
+                       if (unpackLen > 0)
+                               memcpy(pCbPage->pageData, &pageData[3], unpackLen);
+                       else
+                               unpackLen = 0;
+               } else {
+                       memcpy(pCbPage->pageData, &pageData, unpackLen);
                }
-               break;
 
-               case SMS_CHARSET_8BIT :
-               case SMS_CHARSET_UCS2 :
-               {
-                       MSG_DEBUG("UCS2 or 8BIT");
+               MSG_DEBUG("unpackLen : [%d]", unpackLen);
 
-                       if(pCbPage->pageHeader.dcs.iso639Lang[0])
-                       {
-                               memcpy(pCbPage->pageData, &cbData[8], dataLen - 2);
-                               pCbPage->pageLength = dataLen - 2;
-                       } else {
-                               memcpy(pCbPage->pageData, &cbData[6], dataLen);
-                               pCbPage->pageLength = dataLen;
-                       }
+               pCbPage->pageLength = unpackLen;
+               pCbPage->pageData[unpackLen] = '\0';
+       }
+       break;
+
+       case SMS_CHARSET_8BIT :
+       case SMS_CHARSET_UCS2 :
+       {
+               MSG_DEBUG("UCS2 or 8BIT");
+
+               if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
+                       memcpy(pCbPage->pageData, &cbData[8], dataLen - 2);
+                       pCbPage->pageLength = dataLen - 2;
+               } else {
+                       memcpy(pCbPage->pageData, &cbData[6], dataLen);
+                       pCbPage->pageLength = dataLen;
                }
-               break;
+       }
+       break;
        }
 
        MSG_DEBUG("Page Length : [%d], Page Data : [%s]", pCbPage->pageLength, pCbPage->pageData);
@@ -345,7 +328,7 @@ void SmsPluginCbMsgHandler::DecodeEtwsMsg(TelSmsEtwsMsg_t *pEtwsMsg, SMS_ETWS_PR
        memcpy(EtwsData, pEtwsMsg->szMsgData, pEtwsMsg->Length);
        EtwsData[pEtwsMsg->Length] = '\0';
 
-       // print received msg data
+       /* print received msg data */
        MSG_INFO("Received Etws length:%d", pEtwsMsg->Length);
        char EtwsDataTmp[(pEtwsMsg->Length*2)+1];
        memset(EtwsDataTmp, 0x00, sizeof(EtwsDataTmp));
@@ -355,10 +338,10 @@ void SmsPluginCbMsgHandler::DecodeEtwsMsg(TelSmsEtwsMsg_t *pEtwsMsg, SMS_ETWS_PR
        }
        MSG_INFO("[%s]", EtwsDataTmp);
 
-       // received time
+       /* received time */
        pEtwsPn->recvTime = getRecvTime();
 
-       // Serial Number
+       /* Serial Number */
        pEtwsPn->serialNum.geoScope = (EtwsData[0] & 0xC0) >> 6;
        pEtwsPn->serialNum.msgCode = (EtwsData[0] & 0x3F) << 4;
        pEtwsPn->serialNum.msgCode |= (EtwsData[1] & 0xF0) >> 4;
@@ -366,18 +349,17 @@ void SmsPluginCbMsgHandler::DecodeEtwsMsg(TelSmsEtwsMsg_t *pEtwsMsg, SMS_ETWS_PR
 
        MSG_DEBUG("geoScope : [%d], msgCode : [%d], updateNum : [%d]", pEtwsPn->serialNum.geoScope, pEtwsPn->serialNum.msgCode, pEtwsPn->serialNum.updateNum);
 
-       // Message Identifier
+       /* Message Identifier */
        pEtwsPn->msgId = (EtwsData[2] << 8) | EtwsData[3];
        MSG_DEBUG("MSG ID : [%d]", pEtwsPn->msgId);
 
-       // warning type
+       /* warning type */
        pEtwsPn->warningType = (EtwsData[4] << 8) | EtwsData[5];
        MSG_DEBUG("warningType : [0x%04x]", pEtwsPn->msgId);
 
-       // warning security information
-       memcpy(pEtwsPn->warningSecurityInfo, &EtwsData[6], sizeof(pEtwsPn->warningSecurityInfo));       // 50bytes
-       for (unsigned int i = 0; i < sizeof(pEtwsPn->warningSecurityInfo); i++)
-       {
+       /* warning security information */
+       memcpy(pEtwsPn->warningSecurityInfo, &EtwsData[6], sizeof(pEtwsPn->warningSecurityInfo));       /* 50bytes */
+       for (unsigned int i = 0; i < sizeof(pEtwsPn->warningSecurityInfo); i++) {
                MSG_DEBUG("warning secu info [%02x]", pEtwsPn->warningSecurityInfo[i] );
        }
 }
@@ -390,7 +372,7 @@ void SmsPluginCbMsgHandler::Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
        memcpy(cbData, pCbMsg->szMsgData, pCbMsg->Length);
        cbData[pCbMsg->Length] = '\0';
 
-       // print cb data
+       /* print cb data */
        MSG_INFO("Received CB length:%d", pCbMsg->Length);
        char cbDataTmp[(pCbMsg->Length*2)+1];
        memset(cbDataTmp, 0x00, sizeof(cbDataTmp));
@@ -406,7 +388,7 @@ void SmsPluginCbMsgHandler::Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
 
        MSG_DEBUG("MSG ID : [%d]", pCbPage->pageHeader.msgId);
 
-       // Serial Number
+       /* Serial Number */
        pCbPage->pageHeader.serialNum.geoScope = (cbData[3] & 0xC0) >> 6;
 
        pCbPage->pageHeader.serialNum.msgCode = (cbData[3] & 0x3F) << 4;
@@ -416,90 +398,84 @@ void SmsPluginCbMsgHandler::Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
 
        MSG_DEBUG("geoScope : [%d], msgCode : [%d], updateNum : [%d]", pCbPage->pageHeader.serialNum.geoScope, pCbPage->pageHeader.serialNum.msgCode, pCbPage->pageHeader.serialNum.updateNum);
 
-       // DCS
+       /* DCS */
        decodeCbMsgDCS(cbData[5], (unsigned char*)cbData + 6, &(pCbPage->pageHeader.dcs));
 
-       // Convert Language Type
+       /* Convert Language Type */
        convertLangType(pCbPage->pageHeader.dcs.langType, &(pCbPage->pageHeader.langType));
 
        MSG_DEBUG("In Language Type : [%d], Out Language Type : [%d]", pCbPage->pageHeader.dcs.langType, pCbPage->pageHeader.langType);
 
-       // Get Receive Time
+       /* Get Receive Time */
        pCbPage->pageHeader.recvTime = getRecvTime();
        pCbPage->pageHeader.totalPages = cbData[6];
 
-       // Decode CB Data
+       /* Decode CB Data */
        int dataLen = 0;
        int offset = 0;
 
-       switch (pCbPage->pageHeader.dcs.codingScheme)
+       switch (pCbPage->pageHeader.dcs.codingScheme) {
+       case SMS_CHARSET_7BIT :
        {
-               case SMS_CHARSET_7BIT :
-               {
-                       for(int i = 0; i < pCbPage->pageHeader.totalPages; ++i)
-                       {
-                               char cbMessage[MAX_CBMSG_PAGE_SIZE]= {0,};
-                               dataLen = cbData[7+(i+1)*82 + i];
-                               memcpy(cbMessage, &cbData[7+(i*82)+ i], dataLen);
+               for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
+                       char cbMessage[MAX_CBMSG_PAGE_SIZE]= {0,};
+                       dataLen = cbData[7+(i+1)*82 + i];
+                       memcpy(cbMessage, &cbData[7+(i*82)+ i], dataLen);
 
-                               dataLen = (dataLen*8) / 7;
+                       dataLen = (dataLen*8) / 7;
 
-                               if (dataLen > MAX_CBMSG_PAGE_SIZE)
-                                       THROW(MsgException::SMS_PLG_ERROR, "CB Msg Size is over MAX [%d]", dataLen);
+                       if (dataLen > MAX_CBMSG_PAGE_SIZE)
+                               THROW(MsgException::SMS_PLG_ERROR, "CB Msg Size is over MAX [%d]", dataLen);
 
-                               SmsPluginUDCodec udCodec;
-                               int unpackLen = udCodec.unpack7bitChar((const unsigned char *)cbMessage, dataLen, 0, pCbPage->pageData + offset);
-                               offset += unpackLen;
-                       }
-                       pCbPage->pageLength = offset;
+                       SmsPluginUDCodec udCodec;
+                       int unpackLen = udCodec.unpack7bitChar((const unsigned char *)cbMessage, dataLen, 0, pCbPage->pageData + offset);
+                       offset += unpackLen;
                }
-               break;
+               pCbPage->pageLength = offset;
+       }
+       break;
 
-               case SMS_CHARSET_8BIT :
-               case SMS_CHARSET_UCS2 :
-               {
+       case SMS_CHARSET_8BIT :
+       case SMS_CHARSET_UCS2 :
+       {
 #if 0
-                       char cbMessage[MAX_CBMSG_PAGE_SIZE]= {0,};
+               char cbMessage[MAX_CBMSG_PAGE_SIZE]= {0,};
 
-                       for(int i = 0; i < pCbPage->pageHeader.totalPages; ++i)
-                       {
-                               dataLen = cbData[7+(i+1)*82 + i];
-                               memcpy(cbMessage + offset, &cbData[7+(i*82)+ i], dataLen);
-                               offset += dataLen;
-                       }
-                       dataLen = offset;
+               for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
+                       dataLen = cbData[7+(i+1)*82 + i];
+                       memcpy(cbMessage + offset, &cbData[7+(i*82)+ i], dataLen);
+                       offset += dataLen;
+               }
+               dataLen = offset;
 
-                       if(pCbPage->pageHeader.dcs.iso639Lang[0])
-                       {
-                               int tmpDataLen = (dataLen > 2)?(dataLen - 2):0;
-                               memcpy(pCbPage->pageData, cbMessage + 2, tmpDataLen);
-                               pCbPage->pageLength = tmpDataLen;
-                       } else {
-                               memcpy(pCbPage->pageData, cbMessage, dataLen);
-                               pCbPage->pageLength = dataLen;
-                       }
+               if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
+                       int tmpDataLen = (dataLen > 2)?(dataLen - 2):0;
+                       memcpy(pCbPage->pageData, cbMessage + 2, tmpDataLen);
+                       pCbPage->pageLength = tmpDataLen;
+               } else {
+                       memcpy(pCbPage->pageData, cbMessage, dataLen);
+                       pCbPage->pageLength = dataLen;
+               }
 #else
-                       char cbMessage[MAX_CBMSG_PAGE_SIZE]= {0,};
+               char cbMessage[MAX_CBMSG_PAGE_SIZE]= {0,};
 
-                       for(int i = 0; i < pCbPage->pageHeader.totalPages; ++i)
-                       {
-                               if(pCbPage->pageHeader.dcs.iso639Lang[0])
-                               {
-                                       dataLen = cbData[7+(i+1)*82 + i] - 2;
-                                       memcpy(cbMessage + offset, &cbData[7+(i*82)+ i + 2], dataLen);
-                                       offset += dataLen;
-                               } else {
-                                       dataLen = cbData[7+(i+1)*82 + i];
-                                       memcpy(cbMessage + offset, &cbData[7+(i*82)+ i], dataLen);
-                                       offset += dataLen;
-                               }
+               for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
+                       if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
+                               dataLen = cbData[7+(i+1)*82 + i] - 2;
+                               memcpy(cbMessage + offset, &cbData[7+(i*82)+ i + 2], dataLen);
+                               offset += dataLen;
+                       } else {
+                               dataLen = cbData[7+(i+1)*82 + i];
+                               memcpy(cbMessage + offset, &cbData[7+(i*82)+ i], dataLen);
+                               offset += dataLen;
                        }
-                       dataLen = offset;
-                       memcpy(pCbPage->pageData, cbMessage, dataLen);
-                       pCbPage->pageLength = dataLen;
-#endif
                }
-               break;
+               dataLen = offset;
+               memcpy(pCbPage->pageData, cbMessage, dataLen);
+               pCbPage->pageLength = dataLen;
+#endif
+       }
+       break;
        }
        pCbPage->pageHeader.totalPages = 1;
 
@@ -522,46 +498,48 @@ int SmsPluginCbMsgHandler::CMAS_class(unsigned short message_id)
 
        switch (message_id)
        {
-               case 4370 :
-               case 4383 :
-                       ret = MSG_CMAS_PRESIDENTIAL;
-                       break;
-               case 4371 :
-               case 4372 :
-               case 4384 :
-               case 4385 :
-                       ret = MSG_CMAS_EXTREME;
-                       break;
-               case 4373 :
-               case 4374 :
-               case 4375 :
-               case 4376 :
-               case 4377 :
-               case 4378 :
-               case 4386 :
-               case 4387 :
-               case 4388 :
-               case 4389 :
-               case 4390 :
-               case 4391 :
-                       ret = MSG_CMAS_SEVERE;
-                       break;
-               case 4379 :
-               case 4392 :
-                       ret = MSG_CMAS_AMBER;
-                       break;
-               case 4380 :
-               case 4381 :
-               case 4393 :
-               case 4394 :
-                       ret = MSG_CMAS_TEST;
-                       break;
-               case 4382 :
-               case 4395 :
-                       ret = MSG_CMAS_OPERATOR_DEFINED;
-                       break;
-               default :
-                       break;
+       case 4370 :
+       case 4383 :
+               ret = MSG_CMAS_PRESIDENTIAL;
+               break;
+       case 4371 :
+       case 4372 :
+       case 4384 :
+       case 4385 :
+               ret = MSG_CMAS_EXTREME;
+               break;
+       case 4373 :
+       case 4374 :
+       case 4375 :
+       case 4376 :
+       case 4377 :
+       case 4378 :
+       case 4386 :
+       case 4387 :
+       case 4388 :
+       case 4389 :
+       case 4390 :
+       case 4391 :
+               ret = MSG_CMAS_SEVERE;
+               break;
+       case 4379 :
+       case 4392 :
+               ret = MSG_CMAS_AMBER;
+               break;
+       case 4380 :
+       case 4393 :
+               ret = MSG_CMAS_TEST;
+               break;
+       case 4381 :
+       case 4394 :
+               ret = MSG_CMAS_EXERCISE;
+               break;
+       case 4382 :
+       case 4395 :
+               ret = MSG_CMAS_OPERATOR_DEFINED;
+               break;
+       default :
+               break;
        }
 
        return ret;
@@ -575,24 +553,22 @@ bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S *CbPage, bool *pJavaMsg,
        snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, simIndex);
        MsgSettingGetBool(keyName, &bReceive);
 
-       // Receive CB Msg = FALSE
-       if (!bReceive)
-       {
+       /* Receive CB Msg = FALSE */
+       if (!bReceive) {
                MSG_DEBUG("RECEIVE CB = FALSE");
                return false;
        }
 
 #if 0
        char keyname[128];
-       // check Language
+       /* check Language */
        memset(keyName, 0x00, sizeof(keyName));
        snprintf(keyName, sizeof(keyname), "%s/%d", CB_LANGUAGE, MSG_CBLANG_TYPE_ALL);
 
        bool bAllLang = false;
        MsgSettingGetBool(keyName, &bAllLang);
 
-       if (!bAllLang)
-       {
+       if (!bAllLang) {
                MSG_DEBUG("ALL LANGUAGE = FALSE");
 
                memset(keyName, 0x00, sizeof(keyName));
@@ -602,8 +578,7 @@ bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S *CbPage, bool *pJavaMsg,
 
                MsgSettingGetBool(keyName, &bLang);
 
-               if (!bLang || CbPage.pageHeader.langType == MSG_CBLANG_TYPE_MAX)
-               {
+               if (!bLang || CbPage.pageHeader.langType == MSG_CBLANG_TYPE_MAX) {
                        MSG_DEBUG("LANGUAGE [%d] = FALSE", CbPage.pageHeader.langType);
                        return false;
                }
@@ -620,14 +595,12 @@ bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S *CbPage, bool *pJavaMsg,
        if (err != MSG_SUCCESS)
                MSG_ERR("Error value of MsgStoGetCBChannelInfo [%d]", err);
 
-       for (int i = 0; i < cbChannelInfo.channelCnt; i++)
-       {
+       for (int i = 0; i < cbChannelInfo.channelCnt; i++) {
                bActivate = cbChannelInfo.channelInfo[i].bActivate;
                MsgId_from = cbChannelInfo.channelInfo[i].from;
                MsgId_to = cbChannelInfo.channelInfo[i].to;
 
-               if (bActivate == true && CbPage->pageHeader.msgId >= MsgId_from && CbPage->pageHeader.msgId <= MsgId_to)
-               {
+               if (bActivate == true && CbPage->pageHeader.msgId >= MsgId_from && CbPage->pageHeader.msgId <= MsgId_to) {
                        MSG_DEBUG("FIND CHANNEL = [%d]", CbPage->pageHeader.msgId);
                        return true;
                }
@@ -648,33 +621,25 @@ unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S *CbPage)
        SmsPluginStorage *storageHandler = SmsPluginStorage::instance();
        err = storageHandler->isReceivedCBMessage(CbPage);
        // check existing message with cb internal table;
-       if(err != MSG_ERR_DB_NORECORD)
+       if (err != MSG_ERR_DB_NORECORD)
        {
                MSG_DEBUG("already received message: [%d]", CbPage.pageHeader.msgId);
                return 0;
        }
 #endif
 
-       if (CbPage->pageHeader.totalPages > 0)
-       {
-               for (unsigned int i = 0; i < pageList.size(); i++)
-               {
-                       if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode)
-                       {
+       if (CbPage->pageHeader.totalPages > 0) {
+               for (unsigned int i = 0; i < pageList.size(); i++) {
+                       if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode) {
                                MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode);
 
-                               if (pageList[i].msgId == CbPage->pageHeader.msgId)
-                               {
+                               if (pageList[i].msgId == CbPage->pageHeader.msgId) {
                                        int updateNum = CbPage->pageHeader.serialNum.updateNum - pageList[i].updateNum;
 
-                                       if (updateNum > 0) // New Message Content
-                                       {
+                                       if (updateNum > 0) { /* New Message Content */
                                                break;
-                                       }
-                                       else if (updateNum == 0) // Same Message Content
-                                       {
-                                               if (pageList[i].data.count(CbPage->pageHeader.page) != 0)
-                                               {
+                                       } else if (updateNum == 0) { /* Same Message Content */
+                                               if (pageList[i].data.count(CbPage->pageHeader.page) != 0) {
                                                        MSG_DEBUG("The Page Number already exists [%d]", CbPage->pageHeader.page);
                                                        return 0;
                                                }
@@ -693,9 +658,7 @@ unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S *CbPage)
                                                bFind = true;
 
                                                break;
-                                       }
-                                       else // Old Message Content
-                                       {
+                                       } else { /* Old Message Content */
                                                return 0;
                                        }
                                }
@@ -703,8 +666,7 @@ unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S *CbPage)
                }
        }
 
-       if (bFind == false || CbPage->pageHeader.totalPages == 1)
-       {
+       if (bFind == false || CbPage->pageHeader.totalPages == 1) {
                addToPageList(CbPage);
                return 1;
        }
@@ -724,17 +686,12 @@ void SmsPluginCbMsgHandler::MakeCbMsg(SMS_CBMSG_PAGE_S *CbPage, SMS_CBMSG_S *pCb
        cbPageMap::iterator it;
        int offset = 0;
 
-       for (unsigned int i = 0; i < pageList.size(); i++)
-       {
-               if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode)
-               {
+       for (unsigned int i = 0; i < pageList.size(); i++) {
+               if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode) {
                        MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode);
 
-                       if (pageList[i].msgId == CbPage->pageHeader.msgId)
-                       {
-
-                               for (it = pageList[i].data.begin(); it != pageList[i].data.end(); it++)
-                               {
+                       if (pageList[i].msgId == CbPage->pageHeader.msgId) {
+                               for (it = pageList[i].data.begin(); it != pageList[i].data.end(); it++) {
                                        memcpy(pCbMsg->msgData + offset, it->second.pageData, it->second.pageLength);
                                        pCbMsg->msgLength += it->second.pageLength;
                                        offset = pCbMsg->msgLength;
@@ -760,7 +717,7 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSA
 
        pMsgInfo->folderId = MSG_CBMSGBOX_ID;
 
-       // Convert Type values
+       /* Convert Type values */
        pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
 
        if (pCbMsg->cbMsgType == SMS_CBMSG_TYPE_CBS) {
@@ -770,28 +727,26 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSA
                        pMsgInfo->msgType.subType = MSG_CB_SMS;
                else
                        pMsgInfo->msgType.subType = (MSG_SUB_TYPE_T)cmas_class;
-       }
-       else if (pCbMsg->cbMsgType == SMS_CBMSG_TYPE_JAVACBS) {
+       } else if (pCbMsg->cbMsgType == SMS_CBMSG_TYPE_JAVACBS) {
                pMsgInfo->msgType.subType = MSG_JAVACB_SMS;
        }
 
-       switch(pCbMsg->classType)
-       {
-               case SMS_MSG_CLASS_0:
-                       pMsgInfo->msgType.classType = MSG_CLASS_0;
-                       break;
-               case SMS_MSG_CLASS_1:
-                       pMsgInfo->msgType.classType = MSG_CLASS_1;
-                       break;
-               case SMS_MSG_CLASS_2:
-                       pMsgInfo->msgType.classType = MSG_CLASS_2;
-                       break;
-               case SMS_MSG_CLASS_3:
-                       pMsgInfo->msgType.classType = MSG_CLASS_3;
-                       break;
-               default:
-                       pMsgInfo->msgType.classType = MSG_CLASS_NONE;
-                       break;
+       switch (pCbMsg->classType) {
+       case SMS_MSG_CLASS_0:
+               pMsgInfo->msgType.classType = MSG_CLASS_0;
+               break;
+       case SMS_MSG_CLASS_1:
+               pMsgInfo->msgType.classType = MSG_CLASS_1;
+               break;
+       case SMS_MSG_CLASS_2:
+               pMsgInfo->msgType.classType = MSG_CLASS_2;
+               break;
+       case SMS_MSG_CLASS_3:
+               pMsgInfo->msgType.classType = MSG_CLASS_3;
+               break;
+       default:
+               pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+               break;
        }
 
        pMsgInfo->storageId = MSG_STORAGE_PHONE;
@@ -801,7 +756,7 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSA
        pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
        pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
 
-       // Temporary
+       /* Temporary */
        pMsgInfo->nAddressCnt = 1;
 
        pMsgInfo->addressList =  (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
@@ -811,7 +766,7 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSA
        pMsgInfo->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_UNKNOWN;
        pMsgInfo->sim_idx = simIndex;
 
-       //      TODO :: MSG ID should be used to get CB message type
+       /*      TODO :: MSG ID should be used to get CB message type */
        getDisplayName(pCbMsg->msgId, pMsgInfo->addressList[0].addressVal, simIndex);
        MSG_SEC_DEBUG("%s", pMsgInfo->addressList[0].addressVal);
 
@@ -842,14 +797,13 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSA
 
        MSG_DEBUG("LENGTH %d CB MSG %s", pCbMsg->msgLength, pCbMsg->msgData);
 
-       // Convert Data values
+       /* Convert Data values */
        pMsgInfo->dataSize = convertTextToUtf8((unsigned char*)tmpBuf, bufSize, pCbMsg);
 
-       if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN)
-       {
+       if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN) {
                pMsgInfo->bTextSms = false;
 
-               // Save Message Data into File
+               /* Save Message Data into File */
                char fileName[MSG_FILENAME_LEN_MAX+1];
                memset(fileName, 0x00, sizeof(fileName));
 
@@ -861,9 +815,7 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSA
                        THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
 
                strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
-       }
-       else
-       {
+       } else {
                pMsgInfo->bTextSms = true;
 
                memset(pMsgInfo->msgText, 0x00, sizeof(pMsgInfo->msgText));
@@ -880,7 +832,7 @@ void SmsPluginCbMsgHandler::convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S *EtwsMsg, M
 
        pMsgInfo->folderId = MSG_CBMSGBOX_ID;
 
-       // Convert Type values
+       /* Convert Type values */
        pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
 
        if (EtwsMsg->cbMsgType == SMS_CBMSG_TYPE_ETWS)
@@ -893,7 +845,7 @@ void SmsPluginCbMsgHandler::convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S *EtwsMsg, M
        pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
        pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
 
-       // Temporary
+       /* Temporary */
        pMsgInfo->nAddressCnt = 1;
 
        pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
@@ -922,8 +874,7 @@ int SmsPluginCbMsgHandler::convertTextToUtf8 (unsigned char* outBuf, int outBufS
 
        MsgTextConvert *textCvt = MsgTextConvert::instance();
 
-       if (!outBuf || !pCbMsg)
-       {
+       if (!outBuf || !pCbMsg) {
                MSG_DEBUG ("invalid param.\n");
                return 0;
        }
@@ -932,7 +883,7 @@ int SmsPluginCbMsgHandler::convertTextToUtf8 (unsigned char* outBuf, int outBufS
        langInfo.bLockingShift = false;
 
 
-       // Convert Data values
+       /* Convert Data values */
        if (pCbMsg->codingScheme == SMS_CHARSET_7BIT)
                convertedTextSize = textCvt->convertGSM7bitToUTF8(outBuf, outBufSize, (unsigned char*)pCbMsg->msgData, pCbMsg->msgLength, &langInfo);
        else if (pCbMsg->codingScheme == SMS_CHARSET_UCS2)
@@ -968,13 +919,12 @@ void SmsPluginCbMsgHandler::removeFromPageList(SMS_CBMSG_PAGE_S *CbPage)
 {
        unsigned int index;
 
-       for (index = 0; index < pageList.size(); index++)
-       {
-               if (pageList[index].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[index].msgCode == CbPage->pageHeader.serialNum.msgCode)
-               {
+       for (index = 0; index < pageList.size(); index++) {
+               if (pageList[index].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[index].msgCode == CbPage->pageHeader.serialNum.msgCode) {
                        MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[index].geoScope, pageList[index].msgCode);
 
-                       if (pageList[index].msgId == CbPage->pageHeader.msgId) break;
+                       if (pageList[index].msgId == CbPage->pageHeader.msgId)
+                               break;
                }
        }
 
@@ -997,97 +947,92 @@ void SmsPluginCbMsgHandler::decodeCbMsgDCS(unsigned char dcsData, const unsigned
 
        unsigned char codingGrp = (dcsData & 0xF0) >> 4;
 
-       switch (codingGrp)
+       switch (codingGrp) {
+       case 0x00 :
+       case 0x02 :
+       case 0x03 :
        {
-               case 0x00 :
-               case 0x02 :
-               case 0x03 :
-               {
-                       pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
-                       pDcs->langType = (SMS_CBMSG_LANG_TYPE_T)dcsData;
-               }
-               break;
+               pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
+               pDcs->langType = (SMS_CBMSG_LANG_TYPE_T)dcsData;
+       }
+       break;
 
-               case 0x01 :
-               {
-                       if (dcsData == 0x10 || dcsData == 0x11)
-                       {
-                               pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
-                               pDcs->codingScheme = (dcsData & 0x01) ? SMS_CHARSET_UCS2 : SMS_CHARSET_7BIT;
-                               pDcs->langType = SMS_CBMSG_LANG_ISO639;
-                               MSG_DEBUG("codingScheme: [%d]", pDcs->codingScheme);
-                               if (pMsgData[0] && pMsgData[1])
-                               {
-                                       pDcs->iso639Lang[0] = pMsgData[0] & 0x7F;
-                                       pDcs->iso639Lang[1] = (pMsgData[0] & 0X80) >> 7;
-                                       pDcs->iso639Lang[1] |= (pMsgData[1] & 0X3F) << 1;
-                                       pDcs->iso639Lang[2] = 0x13;  /* CR */
-                               }
-                               else
-                               {
-                                       /* Default it to English if pMsgData is NULL */
-                                       pDcs->iso639Lang[0] = 0x45;  /* E */
-                                       pDcs->iso639Lang[1] = 0x4E;  /* N */
-                                       pDcs->iso639Lang[2] = 0x13;  /* CR */
-                               }
+       case 0x01 :
+       {
+               if (dcsData == 0x10 || dcsData == 0x11) {
+                       pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
+                       pDcs->codingScheme = (dcsData & 0x01) ? SMS_CHARSET_UCS2 : SMS_CHARSET_7BIT;
+                       pDcs->langType = SMS_CBMSG_LANG_ISO639;
+                       MSG_DEBUG("codingScheme: [%d]", pDcs->codingScheme);
+                       if (pMsgData[0] && pMsgData[1]) {
+                               pDcs->iso639Lang[0] = pMsgData[0] & 0x7F;
+                               pDcs->iso639Lang[1] = (pMsgData[0] & 0X80) >> 7;
+                               pDcs->iso639Lang[1] |= (pMsgData[1] & 0X3F) << 1;
+                               pDcs->iso639Lang[2] = 0x13;  /* CR */
+                       } else {
+                               /* Default it to English if pMsgData is NULL */
+                               pDcs->iso639Lang[0] = 0x45;  /* E */
+                               pDcs->iso639Lang[1] = 0x4E;  /* N */
+                               pDcs->iso639Lang[2] = 0x13;  /* CR */
                        }
                }
-               break;
+       }
+       break;
 
-               case 0x04 :
-               case 0x05 :
-               case 0x06 :
-               case 0x07 :
-               {
-                       pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
+       case 0x04 :
+       case 0x05 :
+       case 0x06 :
+       case 0x07 :
+       {
+               pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
 
-                       pDcs->bCompressed = (dcsData & 0x20) ? true : false;
-
-                       if (dcsData & 0x10)
-                               pDcs->classType = (SMS_MSG_CLASS_T)(dcsData & 0x03);
-
-                       unsigned char tmpScheme = (dcsData & 0x0C) >> 2;
-
-                       switch (tmpScheme) {
-                               case 0x00:
-                                       pDcs->codingScheme = SMS_CHARSET_7BIT;
-                                       break;
-                               case 0x01:
-                                       pDcs->codingScheme = SMS_CHARSET_8BIT;
-                                       break;
-                               case 0x02:
-                                       pDcs->codingScheme = SMS_CHARSET_UCS2;
-                                       break;
-                               default:
-                                       MSG_DEBUG("tmpScheme: [%d]", tmpScheme);
-                                       break;
-                       }
-               }
-               break;
+               pDcs->bCompressed = (dcsData & 0x20) ? true : false;
 
-               case 0x09 :
-               {
-                       pDcs->bUDH = true;
-                       pDcs->classType = (MSG_CLASS_TYPE_T)(dcsData & 0x03);
-                       pDcs->codingScheme = (SMS_CODING_SCHEME_T)((dcsData & 0x0C) >> 2);
-               }
-               break;
+               if (dcsData & 0x10)
+                       pDcs->classType = (SMS_MSG_CLASS_T)(dcsData & 0x03);
 
-               case 0x0E :
-               {
-                       pDcs->codingGroup = SMS_CBMSG_CODGRP_WAP;
-               }
-               break;
+               unsigned char tmpScheme = (dcsData & 0x0C) >> 2;
 
-               case 0x0F :
-               {
-                       pDcs->codingGroup = SMS_CBMSG_CODGRP_CLASS_CODING;
-                       pDcs->codingScheme = (dcsData & 0x04) ? SMS_CHARSET_8BIT : SMS_CHARSET_7BIT;
-                       pDcs->classType = (MSG_CLASS_TYPE_T)(dcsData & 0x03);
-               }
-               break;
+               switch (tmpScheme) {
+               case 0x00:
+                       pDcs->codingScheme = SMS_CHARSET_7BIT;
+                       break;
+               case 0x01:
+                       pDcs->codingScheme = SMS_CHARSET_8BIT;
+                       break;
+               case 0x02:
+                       pDcs->codingScheme = SMS_CHARSET_UCS2;
+                       break;
                default:
-                       MSG_DEBUG("codingGrp: [0x%x]", codingGrp);
+                       MSG_DEBUG("tmpScheme: [%d]", tmpScheme);
+                       break;
+               }
+       }
+       break;
+
+       case 0x09 :
+       {
+               pDcs->bUDH = true;
+               pDcs->classType = (MSG_CLASS_TYPE_T)(dcsData & 0x03);
+               pDcs->codingScheme = (SMS_CODING_SCHEME_T)((dcsData & 0x0C) >> 2);
+       }
+       break;
+
+       case 0x0E :
+       {
+               pDcs->codingGroup = SMS_CBMSG_CODGRP_WAP;
+       }
+       break;
+
+       case 0x0F :
+       {
+               pDcs->codingGroup = SMS_CBMSG_CODGRP_CLASS_CODING;
+               pDcs->codingScheme = (dcsData & 0x04) ? SMS_CHARSET_8BIT : SMS_CHARSET_7BIT;
+               pDcs->classType = (MSG_CLASS_TYPE_T)(dcsData & 0x03);
+       }
+       break;
+       default:
+               MSG_DEBUG("codingGrp: [0x%x]", codingGrp);
                break;
        }
 }
@@ -1095,46 +1040,45 @@ void SmsPluginCbMsgHandler::decodeCbMsgDCS(unsigned char dcsData, const unsigned
 
 void SmsPluginCbMsgHandler::convertLangType(SMS_CBMSG_LANG_TYPE_T InType , MSG_CB_LANGUAGE_TYPE_T *pOutType)
 {
-       switch (InType)
-       {
-               case SMS_CBMSG_LANG_GERMAN :
-                       *pOutType = MSG_CBLANG_TYPE_GER;
+       switch (InType) {
+       case SMS_CBMSG_LANG_GERMAN :
+               *pOutType = MSG_CBLANG_TYPE_GER;
                break;
 
-               case SMS_CBMSG_LANG_ENGLISH :
-                       *pOutType = MSG_CBLANG_TYPE_ENG;
+       case SMS_CBMSG_LANG_ENGLISH :
+               *pOutType = MSG_CBLANG_TYPE_ENG;
                break;
 
-               case SMS_CBMSG_LANG_ITALIAN :
-                       *pOutType = MSG_CBLANG_TYPE_ITA;
+       case SMS_CBMSG_LANG_ITALIAN :
+               *pOutType = MSG_CBLANG_TYPE_ITA;
                break;
 
-               case SMS_CBMSG_LANG_FRENCH :
-                       *pOutType = MSG_CBLANG_TYPE_FRE;
+       case SMS_CBMSG_LANG_FRENCH :
+               *pOutType = MSG_CBLANG_TYPE_FRE;
                break;
 
-               case SMS_CBMSG_LANG_SPANISH :
-                       *pOutType = MSG_CBLANG_TYPE_SPA;
+       case SMS_CBMSG_LANG_SPANISH :
+               *pOutType = MSG_CBLANG_TYPE_SPA;
                break;
 
-               case SMS_CBMSG_LANG_DUTCH :
-                       *pOutType = MSG_CBLANG_TYPE_NED;
+       case SMS_CBMSG_LANG_DUTCH :
+               *pOutType = MSG_CBLANG_TYPE_NED;
                break;
 
-               case SMS_CBMSG_LANG_SWEDISH :
-                       *pOutType = MSG_CBLANG_TYPE_SWE;
+       case SMS_CBMSG_LANG_SWEDISH :
+               *pOutType = MSG_CBLANG_TYPE_SWE;
                break;
 
-               case SMS_CBMSG_LANG_PORTUGUESE :
-                       *pOutType = MSG_CBLANG_TYPE_POR;
+       case SMS_CBMSG_LANG_PORTUGUESE :
+               *pOutType = MSG_CBLANG_TYPE_POR;
                break;
 
-               case SMS_CBMSG_LANG_TURKISH :
-                       *pOutType = MSG_CBLANG_TYPE_TUR;
+       case SMS_CBMSG_LANG_TURKISH :
+               *pOutType = MSG_CBLANG_TYPE_TUR;
                break;
 
-               default :
-                       *pOutType = MSG_CBLANG_TYPE_MAX;
+       default :
+               *pOutType = MSG_CBLANG_TYPE_MAX;
                break;
        }
 }
@@ -1159,10 +1103,8 @@ void SmsPluginCbMsgHandler::getDisplayName(unsigned short        MsgId, char *pDisplayN
        err = MsgStoGetCBChannelInfo(dbHandle, &cbChannelInfo, simIndex);
        MSG_DEBUG("MsgStoGetCBChannelInfo [err = %d]", err);
 
-       for (int i = 0; i < cbChannelInfo.channelCnt; i++)
-       {
-               if (MsgId >= cbChannelInfo.channelInfo[i].from && MsgId <= cbChannelInfo.channelInfo[i].to)
-               {
+       for (int i = 0; i < cbChannelInfo.channelCnt; i++) {
+               if (MsgId >= cbChannelInfo.channelInfo[i].from && MsgId <= cbChannelInfo.channelInfo[i].to) {
                        MSG_DEBUG("FIND MSG ID = [%d]", MsgId);
 #if 0
                        char strTmp[CB_CHANNEL_NAME_MAX + 1];
@@ -1183,11 +1125,9 @@ void SmsPluginCbMsgHandler::getDisplayName(unsigned short        MsgId, char *pDisplayN
 #endif
 
 #endif
-
                        return;
                }
        }
 
        snprintf(pDisplayName, MAX_ADDRESS_VAL_LEN + 1, "[%d]", MsgId);
 }
-
index 07101ac..b965cc4 100755 (executable)
@@ -76,7 +76,7 @@ bool SmsPluginConcatHandler::IsConcatMsg(SMS_USERDATA_S *pUserData)
 }
 
 
-void SmsPluginConcatHandler::handleConcatMsg(struct tapi_handle *handle, SMS_TPDU_S *pTpdu)
+void SmsPluginConcatHandler::handleConcatMsg(TapiHandle *handle, SMS_TPDU_S *pTpdu)
 {
        MSG_BEGIN();
 
@@ -153,14 +153,19 @@ void SmsPluginConcatHandler::handleConcatMsg(struct tapi_handle *handle, SMS_TPD
                unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
                msgInfo.sim_idx = msg.simIndex;
 
-               dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData);
+               dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData, msg.originAddress.address);
 
                if (dataSize > 0) {
                        if (SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(pTpdu->data.deliver.userData)) == true) {
                                SmsPluginWapPushHandler::instance()->copyDeliverData(&(pTpdu->data.deliver));
                                msgInfo.msgType.mainType = MSG_SMS_TYPE;
                                if (err == MSG_SUCCESS) {
-                                       SmsPluginWapPushHandler::instance()->handleWapPushMsg(pUserData, dataSize, msg.simIndex);
+                                       time_t sent_time = 0;
+                                       if (pTpdu->data.deliver.timeStamp.format == SMS_TIME_ABSOLUTE) {
+                                               sent_time = time(NULL);
+                                       }
+
+                                       SmsPluginWapPushHandler::instance()->handleWapPushMsg(pUserData, dataSize, msg.simIndex, sent_time);
                                }
                        } else {
                                convertConcatToMsginfo(&(pTpdu->data.deliver), pUserData, dataSize, &msgInfo);
@@ -193,7 +198,7 @@ void SmsPluginConcatHandler::handleConcatMsg(struct tapi_handle *handle, SMS_TPD
                                                int totalCnt = MsgSettingGetInt(keyName);
 
                                                if (segCnt > totalCnt) {
-                                                       //send DeliveryResport as MSG_SUCCESS and return when total sim storage cnt is less than segment cnt.
+                                                       /* send DeliveryResport as MSG_SUCCESS and return when total sim storage cnt is less than segment cnt. */
                                                        MSG_INFO("SIM slot total count [%d] is less than total sement count of Class2 message [%d], send delivery report as SUCCESS and save it only PHONE", totalCnt, segCnt);
 
                                                        SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
@@ -216,7 +221,7 @@ void SmsPluginConcatHandler::handleConcatMsg(struct tapi_handle *handle, SMS_TPD
                                                err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
 
                                                if (err != MSG_SUCCESS) {
-                                                       MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+                                                       MSG_WARN("callbackMsgIncoming() Error !! [%d]", err);
                                                }
                                        }
                                } else {
@@ -225,7 +230,7 @@ void SmsPluginConcatHandler::handleConcatMsg(struct tapi_handle *handle, SMS_TPD
                        }
                }
 
-               removeFromConcatList(msg.msgRef, msg.simIndex);
+               removeFromConcatList(msg.msgRef, msg.simIndex, msg.originAddress.address);
        }
 
        /** Send Deliver Report */
@@ -234,7 +239,7 @@ void SmsPluginConcatHandler::handleConcatMsg(struct tapi_handle *handle, SMS_TPD
        MSG_END();
 }
 
-void SmsPluginConcatHandler::handleSimConcatMsg(struct tapi_handle *handle, SMS_TPDU_S *pTpdu, int msgId, int bRead, int *simIdList)
+void SmsPluginConcatHandler::handleSimConcatMsg(TapiHandle *handle, SMS_TPDU_S *pTpdu, int msgId, int bRead, int *simIdList)
 {
        MSG_BEGIN();
 
@@ -293,21 +298,22 @@ void SmsPluginConcatHandler::handleSimConcatMsg(struct tapi_handle *handle, SMS_
                        unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
                        msgInfo.sim_idx = msg.simIndex;
 
-                       dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData);
+                       dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData, msg.originAddress.address);
 
                        if (dataSize > 0) {
 
                                convertConcatToMsginfo(&(pTpdu->data.deliver), pUserData, dataSize, &msgInfo);
-                               // set Sim Message ID
+                               /* set Sim Message ID */
                                msgInfo.msgId = msgId;
 
-                               // set read status
+                               /* set read status */
                                msgInfo.bRead = bRead;
-                               // set storage id
+                               /* set storage id */
                                msgInfo.storageId = MSG_STORAGE_SIM;
                        }
                        for (int index = concatList.size(); index >= 0 ; index--) {
-                               if (concatList[index].msgRef == msg.msgRef && concatList[index].simIndex == msg.simIndex) {
+                               if (concatList[index].msgRef == msg.msgRef && concatList[index].simIndex == msg.simIndex
+                                       && g_strcmp0(concatList[index].originAddress.address, msg.originAddress.address) == 0) {
                                        memcpy(simIdList, concatList[index].simIdList, sizeof(int) * MAX_SIM_SMS_NUM);
                                        for (int i = 0; i < 255; ++i)
                                        {
@@ -316,11 +322,13 @@ void SmsPluginConcatHandler::handleSimConcatMsg(struct tapi_handle *handle, SMS_
                                        break;
                                }
                        }
-                       removeFromConcatList(msg.msgRef, msg.simIndex);
-                       SmsPluginSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true); // Call Event Handler
+                       removeFromConcatList(msg.msgRef, msg.simIndex, msg.originAddress.address);
+                       /* Call Event Handler */
+                       SmsPluginSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true);
                        return;
                }
-               SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false); // Call Event Handler
+               /* Call Event Handler */
+               SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
        } else {
                SMS_CONCAT_MSG_S msg = {0};
 
@@ -373,32 +381,35 @@ void SmsPluginConcatHandler::handleSimConcatMsg(struct tapi_handle *handle, SMS_
                        unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
                        msgInfo.sim_idx = msg.simIndex;
 
-                       dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData);
+                       dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData, msg.originAddress.address);
 
                        if (dataSize > 0) {
                                convertConcatToMsginfo(&(pTpdu->data.submit), pUserData, dataSize, &msgInfo);
 
-                               // set Sim Message ID
+                               /* set Sim Message ID */
                                msgInfo.msgId = msgId;
-                               // set read status
+                               /* set read status */
                                msgInfo.bRead = bRead;
 
                                msgInfo.msgType.subType = MSG_CONCAT_SIM_SMS;
 
-                               // set storage id
+                               /* set storage id */
                                msgInfo.storageId = MSG_STORAGE_SIM;
                        }
                        for (int index = concatList.size(); index >= 0 ; index--) {
-                               if (concatList[index].msgRef == msg.msgRef && concatList[index].simIndex == msg.simIndex) {
+                               if (concatList[index].msgRef == msg.msgRef && concatList[index].simIndex == msg.simIndex
+                                       && g_strcmp0(concatList[index].originAddress.address, msg.originAddress.address) == 0) {
                                        memcpy(simIdList, concatList[index].simIdList, sizeof(int) * MAX_SIM_SMS_NUM);
                                        break;
                                }
                        }
-                       SmsPluginSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true); // Call Event Handler
-                       removeFromConcatList(msg.msgRef, msg.simIndex);
+                       /* Call Event Handler */
+                       SmsPluginSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true);
+                       removeFromConcatList(msg.msgRef, msg.simIndex, msg.originAddress.address);
                        return;
                }
-               SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false); // Call Event Handler
+               /* Call Event Handler */
+               SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
        }
 
        MSG_END();
@@ -409,8 +420,7 @@ void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t Sim
 {
        MSG_BEGIN();
 
-       if (pTpdu->tpduType != SMS_TPDU_DELIVER)
-       {
+       if (pTpdu->tpduType != SMS_TPDU_DELIVER) {
                MSG_DEBUG("The TPDU type is not deliver [%d]", pTpdu->tpduType);
                return;
        }
@@ -418,10 +428,8 @@ void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t Sim
        SMS_CONCAT_MSG_S msg;
        memset(&msg, 0x00, sizeof(SMS_CONCAT_MSG_S));
 
-       for (int i = 0; i < pTpdu->data.deliver.userData.headerCnt; i++)
-       {
-               if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT)
-               {
+       for (int i = 0; i < pTpdu->data.deliver.userData.headerCnt; i++) {
+               if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT) {
                        msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat8bit.msgRef;
                        msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat8bit.totalSeg;
                        msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat8bit.seqNum;
@@ -432,16 +440,13 @@ void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t Sim
 
                        msg.bRead = bRead;
 
-                       if (msg.totalSeg > MAX_SEGMENT_NUM)
-                       {
+                       if (msg.totalSeg > MAX_SEGMENT_NUM) {
                                MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
                                return;
                        }
 
                        break;
-               }
-               else if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT)
-               {
+               } else if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
                        msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat16bit.msgRef;
                        msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat16bit.totalSeg;
                        msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat16bit.seqNum;
@@ -452,8 +457,7 @@ void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t Sim
 
                        msg.bRead = bRead;
 
-                       if (msg.totalSeg > MAX_SEGMENT_NUM)
-                       {
+                       if (msg.totalSeg > MAX_SEGMENT_NUM) {
                                MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
                                return;
                        }
@@ -466,8 +470,7 @@ void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t Sim
 
        addToSimIdList(msg.msgRef, SimMsgId);
 
-       if (segCnt == msg.totalSeg)
-       {
+       if (segCnt == msg.totalSeg) {
                MSG_DEBUG("RECEIVED LAST CONCAT : %d", segCnt);
 
                int dataSize = 0;
@@ -478,19 +481,18 @@ void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t Sim
 
                dataSize = makeConcatUserData(msg.msgRef, &pUserData);
 
-               if (dataSize >= 0)
-               {
+               if (dataSize >= 0) {
                        MSG_DEBUG("TOTAL DATA : %s", pUserData);
 
                        convertSimMsgToMsginfo(&msg, pUserData, dataSize, &msgInfo);
 
-                       // set Sim Message ID
+                       /* set Sim Message ID */
                        msgInfo.msgId = SimMsgId;
 
-                       // set read status
+                       /* set read status */
                        msgInfo.bRead = bRead;
 
-                       /// Print MSG_MESSAGE_INFO_S
+                       /* Print MSG_MESSAGE_INFO_S */
                        MSG_DEBUG("############# Convert  tpdu values to Message Info values ####################");
 
                        MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
@@ -515,23 +517,21 @@ void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t Sim
 
                        MSG_DEBUG("###############################################################");
 
-                       // Remove from List
+                       /* Remove from List */
                        removeFromConcatList(msg.msgRef);
                        removeFromSimIdList(msg.msgRef);
 
-                       //add msgInfo to msg list
+                       /* add msgInfo to msg list */
                        SmsPluginStorage::instance()->addSimMsgToList(&msgInfo, true);
 
-                       // Callback to MSG FW
+                       /* Callback to MSG FW */
                        SmsPluginEventHandler::instance()->callbackGetSimMsg();
                }
-       }
-       else
-       {
-               //add index count to msg list
+       } else {
+               /* add index count to msg list */
                SmsPluginStorage::instance()->addSimMsgToList(NULL, false);
 
-               // Callback to MSG FW
+               /* Callback to MSG FW */
                SmsPluginEventHandler::instance()->callbackGetSimMsg();
        }
 
@@ -541,14 +541,12 @@ void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t Sim
 
 void SmsPluginConcatHandler::handleBrokenMsg()
 {
-       if (concatList.size() <= 0 || simIdList.size() <= 0)
-       {
+       if (concatList.size() <= 0 || simIdList.size() <= 0) {
                MSG_DEBUG("No Broken Concatenated Message");
                return;
        }
 
-       do
-       {
+       do {
                int index = 0, dataSize = 0;
                char* pUserData = NULL;
                unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
@@ -557,8 +555,7 @@ void SmsPluginConcatHandler::handleBrokenMsg()
 
                dataSize = makeConcatUserData(concatList[index].msgRef, &pUserData);
 
-               if (dataSize > 0)
-               {
+               if (dataSize > 0) {
                        MSG_DEBUG("TOTAL DATA : %s", pUserData);
 
                        SMS_CONCAT_MSG_S msg;
@@ -573,13 +570,13 @@ void SmsPluginConcatHandler::handleBrokenMsg()
 
                        convertSimMsgToMsginfo(&msg, pUserData, dataSize, &msgInfo);
 
-                       // set Sim Message ID
+                       /* set Sim Message ID */
                        msgInfo.msgId = 0;
 
-                       // set read status
+                       /* set read status */
                        msgInfo.bRead = concatList[index].bRead;
 
-                       /// Print MSG_MESSAGE_INFO_S
+                       /* Print MSG_MESSAGE_INFO_S */
                        MSG_DEBUG("############# Convert  tpdu values to Message Info values ####################");
                        MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
                        MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
@@ -601,13 +598,13 @@ void SmsPluginConcatHandler::handleBrokenMsg()
                                MSG_SEC_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
                        MSG_DEBUG("###############################################################");
 
-                       //add msgInfo to msg list
+                       /* add msgInfo to msg list */
                        SmsPluginStorage::instance()->addSimMsgToList(&msgInfo, true);
                }
 
                removeFromConcatList(concatList[index].msgRef);
                removeFromSimIdList(concatList[index].msgRef);
-       }while (concatList.size() > 0);
+       } while (concatList.size() > 0);
 }
 #endif
 
@@ -624,7 +621,8 @@ unsigned char SmsPluginConcatHandler::checkConcatMsg(SMS_CONCAT_MSG_S *pConcatMs
        bool bFind = false;
 
        for (unsigned int i = 0; i < concatList.size(); i++) {
-               if (concatList[i].msgRef == pConcatMsg->msgRef && concatList[i].simIndex == pConcatMsg->simIndex) {
+               if (concatList[i].msgRef == pConcatMsg->msgRef && concatList[i].simIndex == pConcatMsg->simIndex
+                       && g_strcmp0(concatList[i].originAddress.address, pConcatMsg->originAddress.address) == 0) {
                        if (concatList[i].data.count(pConcatMsg->seqNum) != 0) {
                                MSG_DEBUG("The Sequence Number already exists [%d]", pConcatMsg->seqNum);
                                return 0;
@@ -689,14 +687,15 @@ unsigned char SmsPluginConcatHandler::checkConcatMsg(SMS_CONCAT_MSG_S *pConcatMs
 }
 
 
-int SmsPluginConcatHandler::makeConcatUserData(unsigned short MsgRef, int simIndex, char **ppTotalData)
+int SmsPluginConcatHandler::makeConcatUserData(unsigned short MsgRef, int simIndex, char **ppTotalData, char *originAddress)
 {
        concatDataMap::iterator it;
 
        int totalSize = 0, offset = 0;
 
        for (unsigned int i = 0; i < concatList.size(); i++) {
-               if (concatList[i].msgRef == MsgRef && concatList[i].simIndex == simIndex) {
+               if (concatList[i].msgRef == MsgRef && concatList[i].simIndex == simIndex
+                       && g_strcmp0(concatList[i].originAddress.address, originAddress) == 0) {
                        totalSize = concatList[i].totalSize;
 
                        if (totalSize <= 0) {
@@ -732,23 +731,22 @@ void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu,
        /** set storage id */
        pMsgInfo->storageId = MSG_STORAGE_PHONE;
 
-       switch(pTpdu->dcs.msgClass)
-       {
-               case SMS_MSG_CLASS_0:
-                       pMsgInfo->msgType.classType = MSG_CLASS_0;
-                       break;
-               case SMS_MSG_CLASS_1:
-                       pMsgInfo->msgType.classType = MSG_CLASS_1;
-                       break;
-               case SMS_MSG_CLASS_2:
-                       pMsgInfo->msgType.classType = MSG_CLASS_2;
-                       break;
-               case SMS_MSG_CLASS_3:
-                       pMsgInfo->msgType.classType = MSG_CLASS_3;
-                       break;
-               default:
-                       pMsgInfo->msgType.classType = MSG_CLASS_NONE;
-                       break;
+       switch (pTpdu->dcs.msgClass) {
+       case SMS_MSG_CLASS_0:
+               pMsgInfo->msgType.classType = MSG_CLASS_0;
+               break;
+       case SMS_MSG_CLASS_1:
+               pMsgInfo->msgType.classType = MSG_CLASS_1;
+               break;
+       case SMS_MSG_CLASS_2:
+               pMsgInfo->msgType.classType = MSG_CLASS_2;
+               break;
+       case SMS_MSG_CLASS_3:
+               pMsgInfo->msgType.classType = MSG_CLASS_3;
+               break;
+       default:
+               pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+               break;
        }
 
        pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
@@ -841,8 +839,8 @@ void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu,
                }
        }
 
-       //int bufSize = (MAX_MSG_DATA_LEN*MAX_SEGMENT_NUM) + 1;
-       int bufSize = (DataSize*4) + 1; // For UTF8
+       /* For UTF8 */
+       int bufSize = (DataSize*4) + 1;
 
        char tmpBuf[bufSize];
        memset(tmpBuf, 0x00, sizeof(tmpBuf));
@@ -916,23 +914,22 @@ void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_SUBMIT_S *pTpdu, c
        /** set storage id */
        pMsgInfo->storageId = MSG_STORAGE_PHONE;
 
-       switch(pTpdu->dcs.msgClass)
-       {
-               case SMS_MSG_CLASS_0:
-                       pMsgInfo->msgType.classType = MSG_CLASS_0;
-                       break;
-               case SMS_MSG_CLASS_1:
-                       pMsgInfo->msgType.classType = MSG_CLASS_1;
-                       break;
-               case SMS_MSG_CLASS_2:
-                       pMsgInfo->msgType.classType = MSG_CLASS_2;
-                       break;
-               case SMS_MSG_CLASS_3:
-                       pMsgInfo->msgType.classType = MSG_CLASS_3;
-                       break;
-               default:
-                       pMsgInfo->msgType.classType = MSG_CLASS_NONE;
-                       break;
+       switch (pTpdu->dcs.msgClass) {
+       case SMS_MSG_CLASS_0:
+               pMsgInfo->msgType.classType = MSG_CLASS_0;
+               break;
+       case SMS_MSG_CLASS_1:
+               pMsgInfo->msgType.classType = MSG_CLASS_1;
+               break;
+       case SMS_MSG_CLASS_2:
+               pMsgInfo->msgType.classType = MSG_CLASS_2;
+               break;
+       case SMS_MSG_CLASS_3:
+               pMsgInfo->msgType.classType = MSG_CLASS_3;
+               break;
+       default:
+               pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+               break;
        }
 
        pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
@@ -970,8 +967,8 @@ void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_SUBMIT_S *pTpdu, c
                }
        }
 
-       //int bufSize = (MAX_MSG_DATA_LEN*MAX_SEGMENT_NUM) + 1;
-       int bufSize = (DataSize*4) + 1; // For UTF8
+       /* For UTF8 */
+       int bufSize = (DataSize*4) + 1;
 
        char tmpBuf[bufSize];
        memset(tmpBuf, 0x00, sizeof(tmpBuf));
@@ -1024,31 +1021,30 @@ void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_SUBMIT_S *pTpdu, c
 #ifdef CONCAT_SIM_MSG_OPERATION
 void SmsPluginConcatHandler::convertSimMsgToMsginfo(const SMS_CONCAT_MSG_S *pConcatMsg, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo)
 {
-       // Convert Type  values
+       /* Convert Type  values */
        pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
        pMsgInfo->msgType.subType = MSG_CONCAT_SIM_SMS;
 
-       // set folder id (temporary)
+       /* set folder id (temporary) */
        pMsgInfo->folderId = MSG_INBOX_ID;
 
        pMsgInfo->storageId = MSG_STORAGE_SIM;
 
-       switch (pConcatMsg->dcs.msgClass)
-       {
-               case SMS_MSG_CLASS_0:
-                       pMsgInfo->msgType.classType = MSG_CLASS_0;
-                       break;
-               case SMS_MSG_CLASS_1:
-                       pMsgInfo->msgType.classType = MSG_CLASS_1;
-                       break;
-               case SMS_MSG_CLASS_2:
-                       pMsgInfo->msgType.classType = MSG_CLASS_2;
-                       break;
-               case SMS_MSG_CLASS_3:
-                       pMsgInfo->msgType.classType = MSG_CLASS_3;
-                       break;
-               default:
-                       pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+       switch (pConcatMsg->dcs.msgClass) {
+       case SMS_MSG_CLASS_0:
+               pMsgInfo->msgType.classType = MSG_CLASS_0;
+               break;
+       case SMS_MSG_CLASS_1:
+               pMsgInfo->msgType.classType = MSG_CLASS_1;
+               break;
+       case SMS_MSG_CLASS_2:
+               pMsgInfo->msgType.classType = MSG_CLASS_2;
+               break;
+       case SMS_MSG_CLASS_3:
+               pMsgInfo->msgType.classType = MSG_CLASS_3;
+               break;
+       default:
+               pMsgInfo->msgType.classType = MSG_CLASS_NONE;
        }
 
        pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
@@ -1114,7 +1110,7 @@ void SmsPluginConcatHandler::convertSimMsgToMsginfo(const SMS_CONCAT_MSG_S *pCon
 
        pMsgInfo->displayTime = rawtime;
 
-       // Convert Address values
+       /* Convert Address values */
        pMsgInfo->nAddressCnt = 1;
        pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
        strncpy(pMsgInfo->addressList[0].addressVal, pConcatMsg->originAddress.address, MAX_ADDRESS_VAL_LEN);
@@ -1123,13 +1119,11 @@ void SmsPluginConcatHandler::convertSimMsgToMsginfo(const SMS_CONCAT_MSG_S *pCon
        pMsgInfo->msgPort.dstPort = 0;
        pMsgInfo->msgPort.srcPort = 0;
 
-       // Insert SMS_CONCAT_SIM_MSG_S into File
+       /* Insert SMS_CONCAT_SIM_MSG_S into File */
        SMS_CONCAT_SIM_MSG_S concatSimMsg = {0};
 
-       for (unsigned int i = 0; i < simIdList.size(); i++)
-       {
-               if (simIdList[i].msgRef == pConcatMsg->msgRef)
-               {
+       for (unsigned int i = 0; i < simIdList.size(); i++) {
+               if (simIdList[i].msgRef == pConcatMsg->msgRef) {
                        MSG_DEBUG("Get SIM ID [%d] - List Index [%d]", simIdList[i].simId, concatSimMsg.simIdCnt);
 
                        concatSimMsg.simIdList[concatSimMsg.simIdCnt] = simIdList[i].simId;
@@ -1142,9 +1136,8 @@ void SmsPluginConcatHandler::convertSimMsgToMsginfo(const SMS_CONCAT_MSG_S *pCon
        char tmpBuf[bufSize];
        memset(tmpBuf, 0x00, sizeof(tmpBuf));
 
-       // Convert Data values
-       if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_7BIT)
-       {
+       /* Convert Data values */
+       if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_7BIT) {
                SMS_LANG_INFO_S langInfo = {0};
 
                langInfo.bSingleShift = false;
@@ -1152,15 +1145,11 @@ void SmsPluginConcatHandler::convertSimMsgToMsginfo(const SMS_CONCAT_MSG_S *pCon
 
                pMsgInfo->encodeType = MSG_ENCODE_GSM7BIT;
                pMsgInfo->dataSize = SmsPluginTextConvert::instance()->convertGSM7bitToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize, &langInfo);
-       }
-       else if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_8BIT)
-       {
+       } else if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_8BIT) {
                pMsgInfo->encodeType = MSG_ENCODE_8BIT;
                memcpy(tmpBuf, pUserData, DataSize);
                pMsgInfo->dataSize = DataSize;
-       }
-       else if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_UCS2)
-       {
+       } else if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_UCS2) {
                pMsgInfo->encodeType = MSG_ENCODE_UCS2;
                pMsgInfo->dataSize = SmsPluginTextConvert::instance()->convertUCS2ToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize);
        }
@@ -1172,7 +1161,7 @@ void SmsPluginConcatHandler::convertSimMsgToMsginfo(const SMS_CONCAT_MSG_S *pCon
        if (pMsgInfo->dataSize > 0)
                memcpy(concatSimMsg.msgData, tmpBuf, pMsgInfo->dataSize);
 
-       // Save Message Data into File
+       /* Save Message Data into File */
        char fileName[MAX_COMMON_INFO_SIZE+1];
        memset(fileName, 0x00, sizeof(fileName));
 
@@ -1190,10 +1179,11 @@ void SmsPluginConcatHandler::convertSimMsgToMsginfo(const SMS_CONCAT_MSG_S *pCon
 #endif
 
 
-void SmsPluginConcatHandler::removeFromConcatList(unsigned short MsgRef, int simIndex)
+void SmsPluginConcatHandler::removeFromConcatList(unsigned short MsgRef, int simIndex, char *originAddress)
 {
        for (int index = concatList.size()-1; index >= 0 ; index--) {
-               if (concatList[index].msgRef == MsgRef && concatList[index].simIndex == simIndex) {
+               if (concatList[index].msgRef == MsgRef && concatList[index].simIndex == simIndex
+                       && g_strcmp0(concatList[index].originAddress.address, originAddress) == 0) {
                        MSG_DEBUG("remove concatlist of the index [%d]", index);
                        concatList.erase(concatList.begin()+index);
                        break;
@@ -1215,10 +1205,8 @@ void SmsPluginConcatHandler::addToSimIdList(unsigned short MsgRef, msg_sim_id_t
 
 void SmsPluginConcatHandler::removeFromSimIdList(unsigned short MsgRef)
 {
-       for (int index = simIdList.size()-1; index >= 0 ; index--)
-       {
-               if (simIdList[index].msgRef == MsgRef)
-               {
+       for (int index = simIdList.size()-1; index >= 0 ; index--) {
+               if (simIdList[index].msgRef == MsgRef) {
                        MSG_DEBUG("remove simIdList of the index [%d]", index);
 
                        simIdList.erase(simIdList.begin()+index);
index 64939ff..081ae5e 100755 (executable)
@@ -20,8 +20,7 @@
 #include "SmsPluginDSHandler.h"
 #include "MsgGconfWrapper.h"
 
-extern "C"
-{
+extern "C" {
        #include <tapi_common.h>
        #include <TelNetwork.h>
        #include <ITapiNetwork.h>
@@ -66,8 +65,7 @@ int SmsPluginDSHandler::initTelHandle()
                goto FINISH;
        }
 
-       while(cp_list[cnt] && cnt < MAX_TELEPHONY_HANDLE_CNT)
-       {
+       while (cp_list[cnt] && cnt < MAX_TELEPHONY_HANDLE_CNT) {
                MSG_SEC_INFO("cp_list[%d]:[%s]", cnt, cp_list[cnt]);
                handle_list.handle[cnt]= tel_init(cp_list[cnt]);
                cnt++;
@@ -84,8 +82,7 @@ void SmsPluginDSHandler::deinitTelHandle()
 {
        int ret = 0;
 
-       for (int i = 0; i < handle_list.count; i++)
-       {
+       for (int i = 0; i < handle_list.count; i++) {
                ret = tel_deinit(handle_list.handle[i]);
                MSG_DEBUG("tel_deinit ret=[%d]", ret);
                handle_list.handle[i] = NULL;
@@ -97,11 +94,11 @@ void SmsPluginDSHandler::deinitTelHandle()
        return;
 }
 
-struct tapi_handle *SmsPluginDSHandler::getTelHandle(int sim_idx)
+TapiHandle *SmsPluginDSHandler::getTelHandle(int sim_idx)
 {
-       if (sim_idx > 0 && sim_idx < MAX_TELEPHONY_HANDLE_CNT)
+       if (sim_idx > 0 && sim_idx < MAX_TELEPHONY_HANDLE_CNT) {
                return handle_list.handle[sim_idx-1];
-       else {
+       else {
                int SIM_Status = 0;
                SIM_Status = MsgSettingGetInt(VCONFKEY_TELEPHONY_SIM_SLOT);
                if (SIM_Status == 1) {
@@ -117,11 +114,10 @@ struct tapi_handle *SmsPluginDSHandler::getTelHandle(int sim_idx)
        return handle_list.handle[handle_list.count - 1];
 }
 
-int SmsPluginDSHandler::getSimIndex(struct tapi_handle *handle)
+int SmsPluginDSHandler::getSimIndex(TapiHandle *handle)
 {
-       for(int index=0; index < handle_list.count; ++index)
-       {
-               if(handle_list.handle[index] == handle)
+       for (int index = 0; index < handle_list.count; ++index) {
+               if (handle_list.handle[index] == handle)
                        return index+1;
        }
        return 0;
index 7416749..3b3e6fe 100755 (executable)
@@ -33,6 +33,7 @@
 #include "SmsPluginConcatHandler.h"
 #include "SmsPluginEventHandler.h"
 #include "SmsPluginDSHandler.h"
+#include "SmsPluginParamCodec.h"
 
 
 /*==================================================================================================
@@ -88,16 +89,18 @@ void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus)
                        sentInfo.reqInfo.msgInfo.networkStatus = NetStatus;
 
                        if (NetStatus == MSG_NETWORK_SEND_SUCCESS) {
-                               //contacts-service is not used for gear
+                               /* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
                                MSG_DEBUG("Add phone log");
                                MsgAddPhoneLog(&(sentInfo.reqInfo.msgInfo));
 #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                               sentInfo.reqInfo.msgInfo.folderId = MSG_SENTBOX_ID; // It should be set after adding phone log.
+                               sentInfo.reqInfo.msgInfo.folderId = MSG_SENTBOX_ID; /* It should be set after adding phone log. */
                        } else {
                                sentInfo.reqInfo.msgInfo.bRead = false;
                        }
 
+                       SmsPluginStorage::instance()->updateSmsMessage(&(sentInfo.reqInfo.msgInfo));
+
                        callbackStorageChange(MSG_STORAGE_CHANGE_UPDATE, &(sentInfo.reqInfo.msgInfo));
                }
 
@@ -105,7 +108,7 @@ void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus)
                MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bKeepCopy [%d]", sentInfo.reqInfo.sendOptInfo.bKeepCopy);
                /** Check sending options */
                if (sentInfo.reqInfo.sendOptInfo.bSetting && !sentInfo.reqInfo.sendOptInfo.bKeepCopy && NetStatus == MSG_NETWORK_SEND_SUCCESS) {
-//                     SmsPluginStorage::instance()->deleteSmsMessage(sentInfo.reqInfo.msgInfo.msgId);
+                       SmsPluginStorage::instance()->deleteSmsMessage(sentInfo.reqInfo.msgInfo.msgId);
                        callbackStorageChange(MSG_STORAGE_CHANGE_DELETE, &(sentInfo.reqInfo.msgInfo));
                }
 
@@ -123,11 +126,12 @@ void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus)
 }
 
 
-void SmsPluginEventHandler::handleMsgIncoming(struct tapi_handle *handle, SMS_TPDU_S *pTpdu)
+void SmsPluginEventHandler::handleMsgIncoming(TapiHandle *handle, SMS_TPDU_S *pTpdu)
 {
 
        /** Make MSG_MESSAGE_INFO_S */
        MSG_MESSAGE_INFO_S msgInfo;
+       MSG_MESSAGE_INFO_S stored_msgInfo;
 
        /** initialize msgInfo */
        memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
@@ -148,7 +152,7 @@ void SmsPluginEventHandler::handleMsgIncoming(struct tapi_handle *handle, SMS_TP
        bUdhMwiMethod = false;
        udhMwiCnt = 0;
 
-       if(pTpdu->data.deliver.dcs.msgClass == SMS_MSG_CLASS_2)
+       if (pTpdu->data.deliver.dcs.msgClass == SMS_MSG_CLASS_2)
                msgInfo.storageId = MSG_STORAGE_UNKNOWN;
        else
                msgInfo.storageId = MSG_STORAGE_PHONE;
@@ -168,17 +172,20 @@ void SmsPluginEventHandler::handleMsgIncoming(struct tapi_handle *handle, SMS_TP
                }
        }
 
+       bool bStoreVoiceMsg = false;
+
        if (bUdhMwiMethod == false) {
                /** check MWI and set info to SIM for DCS & Address method */
                if (pTpdu->tpduType == SMS_TPDU_DELIVER && pTpdu->data.deliver.dcs.bMWI == true) {
+                       int MwiCnt = 0;
                        MSG_DEBUG("MWI message - DCS method");
 
                        if (pTpdu->data.deliver.dcs.bIndActive == false) {
                                SmsPluginSetting::instance()->setMwiInfo(msgInfo.sim_idx, msgInfo.msgType.subType, 0);
-                               SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
-                               return;
+                               MwiCnt = 0;
                        } else {
                                SmsPluginSetting::instance()->setMwiInfo(msgInfo.sim_idx, msgInfo.msgType.subType, 1);
+                               MwiCnt = 1;
 
                                /* For address method */
                                if (pTpdu->data.deliver.pid == 0x20 && pTpdu->data.deliver.originAddress.ton == SMS_TON_ALPHANUMERIC) {
@@ -209,24 +216,36 @@ void SmsPluginEventHandler::handleMsgIncoming(struct tapi_handle *handle, SMS_TP
                                                free(voiceAlphaId);
                                                voiceAlphaId = NULL;
                                        }
+                               }
+                       }
 
-                                       memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
-                                       snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "New voice message");
+                       if (pTpdu->data.deliver.dcs.codingGroup == SMS_GROUP_STORE) {
+                               bStoreVoiceMsg = true;
+                               memset(&stored_msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+                               memcpy(&stored_msgInfo, &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
+                               stored_msgInfo.msgType.subType = MSG_NORMAL_SMS;
+                       }
 
-                               }
+                       memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
+                       switch (msgInfo.msgType.subType) {
+                       case MSG_MWI_VOICE_SMS :
+                               snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d", MwiCnt);
+                               break;
+                       case MSG_MWI_FAX_SMS :
+                               snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new fax message", MwiCnt);
+                               break;
+                       case MSG_MWI_EMAIL_SMS :
+                               snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new email message", MwiCnt);
+                               break;
+                       default :
+                               snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new special message", MwiCnt);
+                               break;
                        }
+                       msgInfo.dataSize = strlen(msgInfo.msgText);
 
                        if (pTpdu->data.deliver.dcs.codingGroup == SMS_GROUP_DISCARD)
                                msgInfo.bStore = false;
                }
-       } else {
-               MSG_DEBUG("MWI message - UDH method");
-               if (udhMwiCnt <= 0) {
-                       MSG_DEBUG("MWI count is 0");
-                       SmsPluginSetting::instance()->setMwiInfo(msgInfo.sim_idx, msgInfo.msgType.subType, 0);
-                       SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
-                       return;
-               }
        }
 
        /** Short Message Type 0 - Just Send Deliver Report */
@@ -309,6 +328,9 @@ void SmsPluginEventHandler::handleMsgIncoming(struct tapi_handle *handle, SMS_TP
                        if (err == MSG_SUCCESS) {
                                MSG_DEBUG("callback to msg fw");
                                err = listener.pfMsgIncomingCb(&msgInfo);
+                               if (bStoreVoiceMsg) {
+                                       err = listener.pfMsgIncomingCb(&stored_msgInfo);
+                               }
                        } else {
                                if (msgInfo.msgType.classType == MSG_CLASS_0) {
                                        MSG_DEBUG("callback for class0 message to msg fw");
@@ -324,7 +346,7 @@ void SmsPluginEventHandler::handleMsgIncoming(struct tapi_handle *handle, SMS_TP
                                SmsPluginTransport::instance()->sendDeliverReport(handle, err);
                }
 
-               // Tizen Validation System
+               /* Tizen Validation System */
                char *msisdn = NULL;
                char keyName[MAX_VCONFKEY_NAME_LEN];
                memset(keyName, 0x00, sizeof(keyName));
@@ -371,7 +393,7 @@ void SmsPluginEventHandler::handleResendMessage(void)
 }
 
 
-void SmsPluginEventHandler::handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen,int simIndex)
+void SmsPluginEventHandler::handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, int simIndex)
 {
        MSG_SYNCML_MESSAGE_DATA_S syncMLData;
 
@@ -447,8 +469,16 @@ msg_error_t SmsPluginEventHandler::callbackInitSimBySat()
 
 msg_error_t SmsPluginEventHandler::callbackStorageChange(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
 {
-       /** Callback to MSG FW */
-       listener.pfStorageChangeCb(storageChangeType, pMsgInfo);
+       msg_id_list_s msgIdList;
+       msg_message_id_t msgIds[1];
+       memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
+
+       msgIdList.nCount = 1;
+       msgIds[0] = pMsgInfo->msgId;
+       msgIdList.msgIdList = msgIds;
+
+       /* Callback to MSG FW */
+       listener.pfStorageChangeCb(storageChangeType, &msgIdList);
 
        return MSG_SUCCESS;
 }
@@ -457,17 +487,16 @@ msg_error_t SmsPluginEventHandler::callbackStorageChange(msg_storage_change_type
 void SmsPluginEventHandler::convertTpduToMsginfo(SMS_TPDU_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
 {
 
-       switch(pTpdu->tpduType)
-       {
-               case SMS_TPDU_SUBMIT :
-                       convertSubmitTpduToMsginfo(&pTpdu->data.submit, msgInfo);
-                       break;
-               case SMS_TPDU_DELIVER :
-                       convertDeliverTpduToMsginfo(&pTpdu->data.deliver, msgInfo);
-                       break;
-               case SMS_TPDU_STATUS_REP :
-                       convertStatusRepTpduToMsginfo(&pTpdu->data.statusRep, msgInfo);
-                       break;
+       switch (pTpdu->tpduType) {
+       case SMS_TPDU_SUBMIT :
+               convertSubmitTpduToMsginfo(&pTpdu->data.submit, msgInfo);
+               break;
+       case SMS_TPDU_DELIVER :
+               convertDeliverTpduToMsginfo(&pTpdu->data.deliver, msgInfo);
+               break;
+       case SMS_TPDU_STATUS_REP :
+               convertStatusRepTpduToMsginfo(&pTpdu->data.statusRep, msgInfo);
+               break;
        }
 }
 
@@ -483,23 +512,22 @@ void SmsPluginEventHandler::convertSubmitTpduToMsginfo(const SMS_SUBMIT_S *pTpdu
        /** set folder id (temporary) */
        msgInfo->folderId = MSG_SENTBOX_ID;
 
-       switch(pTpdu->dcs.msgClass)
-       {
-               case SMS_MSG_CLASS_0:
-                       msgInfo->msgType.classType = MSG_CLASS_0;
-                       break;
-               case SMS_MSG_CLASS_1:
-                       msgInfo->msgType.classType = MSG_CLASS_1;
-                       break;
-               case SMS_MSG_CLASS_2:
-                       msgInfo->msgType.classType = MSG_CLASS_2;
-                       break;
-               case SMS_MSG_CLASS_3:
-                       msgInfo->msgType.classType = MSG_CLASS_3;
-                       break;
-               default:
-                       msgInfo->msgType.classType = MSG_CLASS_NONE;
-                       break;
+       switch (pTpdu->dcs.msgClass) {
+       case SMS_MSG_CLASS_0:
+               msgInfo->msgType.classType = MSG_CLASS_0;
+               break;
+       case SMS_MSG_CLASS_1:
+               msgInfo->msgType.classType = MSG_CLASS_1;
+               break;
+       case SMS_MSG_CLASS_2:
+               msgInfo->msgType.classType = MSG_CLASS_2;
+               break;
+       case SMS_MSG_CLASS_3:
+               msgInfo->msgType.classType = MSG_CLASS_3;
+               break;
+       default:
+               msgInfo->msgType.classType = MSG_CLASS_NONE;
+               break;
        }
 
        msgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
@@ -517,6 +545,7 @@ void SmsPluginEventHandler::convertSubmitTpduToMsginfo(const SMS_SUBMIT_S *pTpdu
 //dont_call: Calling localtime(time_t const *) is a DC.SECURE_CODING_CRITICAL defect.
 //     time_t curTime;
 //     localtime(&curTime);
+       msgInfo->displayTime = time(NULL);
 
        /** Convert Address values */
        msgInfo->nAddressCnt = 1;
@@ -561,8 +590,7 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp
        msgInfo->folderId = MSG_INBOX_ID;
 
        time_t rawtime = 0;
-       if(msgInfo->storageId == MSG_STORAGE_SIM)
-       {
+       if (msgInfo->storageId == MSG_STORAGE_SIM) {
        /*** Comment below lines to save local UTC time..... (it could be used later.)
        ***/
                if (pTpdu->timeStamp.format == SMS_TIME_ABSOLUTE) {
@@ -620,24 +648,23 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp
 
        msgInfo->displayTime = rawtime;
 
-       switch(pTpdu->dcs.msgClass)
-       {
-               case SMS_MSG_CLASS_0:
-                       msgInfo->msgType.classType = MSG_CLASS_0;
-                       break;
-               case SMS_MSG_CLASS_1:
-                       msgInfo->msgType.classType = MSG_CLASS_1;
-                       break;
-               case SMS_MSG_CLASS_2:
-                       msgInfo->msgType.classType = MSG_CLASS_2;
-                       msgInfo->storageId = MSG_STORAGE_SIM;
-                       break;
-               case SMS_MSG_CLASS_3:
-                       msgInfo->msgType.classType = MSG_CLASS_3;
-                       break;
-               default:
-                       msgInfo->msgType.classType = MSG_CLASS_NONE;
-                       break;
+       switch (pTpdu->dcs.msgClass) {
+       case SMS_MSG_CLASS_0:
+               msgInfo->msgType.classType = MSG_CLASS_0;
+               break;
+       case SMS_MSG_CLASS_1:
+               msgInfo->msgType.classType = MSG_CLASS_1;
+               break;
+       case SMS_MSG_CLASS_2:
+               msgInfo->msgType.classType = MSG_CLASS_2;
+               msgInfo->storageId = MSG_STORAGE_SIM;
+               break;
+       case SMS_MSG_CLASS_3:
+               msgInfo->msgType.classType = MSG_CLASS_3;
+               break;
+       default:
+               msgInfo->msgType.classType = MSG_CLASS_NONE;
+               break;
        }
 
        if (pTpdu->dcs.bMWI) {
@@ -695,6 +722,12 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp
                                msgInfo->bStore = false;
 
                        udhMwiCnt = pTpdu->userData.header[i].udh.specialInd.waitMsgNum;
+
+                       if (udhMwiCnt < 0) {
+                               MSG_DEBUG("Message waiting number is smaller than 0. It will be treated as 0. [%d]", udhMwiCnt);
+                               udhMwiCnt = 0;
+                       }
+
                        MSG_DEBUG("Message waiting number : [%d]", udhMwiCnt);
 
                        SmsPluginSetting::instance()->setMwiInfo(msgInfo->sim_idx, msgInfo->msgType.subType, udhMwiCnt);
@@ -720,8 +753,17 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp
                } else if (pTpdu->userData.header[i].udhType == SMS_UDH_ALTERNATE_REPLY_ADDRESS) {
                        strncpy(msgInfo->addressList[0].addressVal, pTpdu->userData.header[i].udh.alternateAddress.address, MAX_ADDRESS_VAL_LEN);
                } else if (pTpdu->userData.header[i].udhType >= SMS_UDH_EMS_FIRST && pTpdu->userData.header[i].udhType <= SMS_UDH_EMS_LAST) {
+                       /* TODO: Raw text should be changed to string design id. Currently there's no design id in message-app-lite */
+/*                     char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSGF_POP_ERROR_UNSUPPORTED_MSG");
+                       snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
+*/
                        snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "Unsupported Message");
                        msgInfo->dataSize = strlen(msgInfo->msgText);
+/*                     if (msg_text) {
+                               free(msg_text);
+                               msg_text = NULL;
+                       }
+*/
                        return;
                }
        }
@@ -731,20 +773,19 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp
                memset(msgInfo->msgText, 0x00, sizeof(msgInfo->msgText));
                msgInfo->dataSize = 0;
 
-               switch(pTpdu->dcs.codingScheme)
-               {
-                       case SMS_CHARSET_7BIT:
-                               msgInfo->encodeType = MSG_ENCODE_GSM7BIT;
-                               break;
-                       case SMS_CHARSET_8BIT:
-                               msgInfo->encodeType = MSG_ENCODE_8BIT;
-                               break;
-                       case SMS_CHARSET_UCS2:
-                               msgInfo->encodeType = MSG_ENCODE_UCS2;
-                               break;
-                       default:
-                               msgInfo->encodeType = MSG_ENCODE_8BIT;
-                               break;
+               switch (pTpdu->dcs.codingScheme) {
+               case SMS_CHARSET_7BIT:
+                       msgInfo->encodeType = MSG_ENCODE_GSM7BIT;
+                       break;
+               case SMS_CHARSET_8BIT:
+                       msgInfo->encodeType = MSG_ENCODE_8BIT;
+                       break;
+               case SMS_CHARSET_UCS2:
+                       msgInfo->encodeType = MSG_ENCODE_UCS2;
+                       break;
+               default:
+                       msgInfo->encodeType = MSG_ENCODE_8BIT;
+                       break;
                }
 
                return;
@@ -805,43 +846,34 @@ void SmsPluginEventHandler::convertStatusRepTpduToMsginfo(const SMS_STATUS_REPOR
                msgInfo->storageId = MSG_STORAGE_PHONE;
        }
 
-       switch(pTpdu->dcs.msgClass)
-       {
-               case SMS_MSG_CLASS_0:
-                       msgInfo->msgType.classType = MSG_CLASS_0;
-                       break;
-               case SMS_MSG_CLASS_1:
-                       msgInfo->msgType.classType = MSG_CLASS_1;
-                       break;
-               case SMS_MSG_CLASS_2:
-                       msgInfo->msgType.classType = MSG_CLASS_2;
-                       break;
-               case SMS_MSG_CLASS_3:
-                       msgInfo->msgType.classType = MSG_CLASS_3;
-                       break;
-               default:
-                       msgInfo->msgType.classType = MSG_CLASS_NONE;
-                       break;
+       switch (pTpdu->dcs.msgClass) {
+       case SMS_MSG_CLASS_0:
+               msgInfo->msgType.classType = MSG_CLASS_0;
+               break;
+       case SMS_MSG_CLASS_1:
+               msgInfo->msgType.classType = MSG_CLASS_1;
+               break;
+       case SMS_MSG_CLASS_2:
+               msgInfo->msgType.classType = MSG_CLASS_2;
+               break;
+       case SMS_MSG_CLASS_3:
+               msgInfo->msgType.classType = MSG_CLASS_3;
+               break;
+       default:
+               msgInfo->msgType.classType = MSG_CLASS_NONE;
+               break;
        }
 
        MSG_DEBUG("delivery status : [%d]", pTpdu->status);
 
        if (pTpdu->status == SMS_STATUS_RECEIVE_SUCCESS)
-       {
                msgInfo->networkStatus = MSG_NETWORK_DELIVER_SUCCESS;
-       }
-       else if(pTpdu->status == SMS_STATUS_TRY_REQUEST_PENDING)
-       {
+       else if (pTpdu->status == SMS_STATUS_TRY_REQUEST_PENDING)
                msgInfo->networkStatus = MSG_NETWORK_DELIVER_PENDING;
-       }
-       else if(pTpdu->status == SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED)
-       {
+       else if (pTpdu->status == SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED)
                msgInfo->networkStatus = MSG_NETWORK_DELIVER_EXPIRED;
-       }
        else
-       {
                msgInfo->networkStatus = MSG_NETWORK_DELIVER_FAIL;
-       }
 
        msgInfo->bRead = false;
        msgInfo->bProtected = false;
@@ -851,63 +883,7 @@ void SmsPluginEventHandler::convertStatusRepTpduToMsginfo(const SMS_STATUS_REPOR
 
        memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
 
-       time_t rawtime = time(NULL);
-
-/*** Comment below lines to save local UTC time..... (it could be used later.)
-
-       if (pTpdu->timeStamp.format == SMS_TIME_ABSOLUTE) {
-
-               MSG_DEBUG("year : %d", pTpdu->timeStamp.time.absolute.year);
-               MSG_DEBUG("month : %d", pTpdu->timeStamp.time.absolute.month);
-               MSG_DEBUG("day : %d", pTpdu->timeStamp.time.absolute.day);
-               MSG_DEBUG("hour : %d", pTpdu->timeStamp.time.absolute.hour);
-               MSG_DEBUG("minute : %d", pTpdu->timeStamp.time.absolute.minute);
-               MSG_DEBUG("second : %d", pTpdu->timeStamp.time.absolute.second);
-               MSG_DEBUG("timezone : %d", pTpdu->timeStamp.time.absolute.timeZone);
-
-               char displayTime[32];
-               struct tm * timeTM;
-
-               struct tm timeinfo;
-               memset(&timeinfo, 0x00, sizeof(tm));
-
-               timeinfo.tm_year = (pTpdu->timeStamp.time.absolute.year + 100);
-               timeinfo.tm_mon = (pTpdu->timeStamp.time.absolute.month - 1);
-               timeinfo.tm_mday = pTpdu->timeStamp.time.absolute.day;
-               timeinfo.tm_hour = pTpdu->timeStamp.time.absolute.hour;
-               timeinfo.tm_min = pTpdu->timeStamp.time.absolute.minute;
-               timeinfo.tm_sec = pTpdu->timeStamp.time.absolute.second;
-               timeinfo.tm_isdst = 0;
-
-               rawtime = mktime(&timeinfo);
-
-               MSG_DEBUG("tzname[0] [%s]", tzname[0]);
-               MSG_DEBUG("tzname[1] [%s]", tzname[1]);
-               MSG_DEBUG("timezone [%d]", timezone);
-               MSG_DEBUG("daylight [%d]", daylight);
-
-               memset(displayTime, 0x00, sizeof(displayTime));
-               strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
-               MSG_DEBUG("displayTime [%s]", displayTime);
-
-               rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4));
-
-               timeTM = localtime(&rawtime);
-               memset(displayTime, 0x00, sizeof(displayTime));
-               strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
-               MSG_DEBUG("displayTime [%s]", displayTime);
-
-               rawtime -= timezone;
-
-               timeTM = localtime(&rawtime);
-               memset(displayTime, 0x00, sizeof(displayTime));
-               strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
-               MSG_DEBUG("displayTime [%s]", displayTime);
-       }
-
-***/
-
-       msgInfo->displayTime = rawtime;
+       msgInfo->displayTime = time(NULL);
 
        /** Convert Address values */
        msgInfo->nAddressCnt = 1;
@@ -939,14 +915,29 @@ void SmsPluginEventHandler::convertStatusRepTpduToMsginfo(const SMS_STATUS_REPOR
        msgInfo->dataSize = 0;
 
        if (pTpdu->status <= SMS_STATUS_SMSC_SPECIFIC_LAST) {
-               strncpy(msgInfo->msgText, "IDS_MSGF_BODY_MESSAGE_DELIVERED", MAX_MSG_TEXT_LEN);
+               char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSGF_BODY_MESSAGE_DELIVERED");
+               snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
                msgInfo->dataSize = strlen(msgInfo->msgText);
+               if (msg_text) {
+                       free(msg_text);
+                       msg_text = NULL;
+               }
        } else if (pTpdu->status == SMS_STATUS_TEMP_SERVICE_REJECTED) {
-               strncpy(msgInfo->msgText, "IDS_MSGF_BODY_MMSDELIVERYMSGREJECTED", MAX_MSG_TEXT_LEN);
+               char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSGF_BODY_MMSDELIVERYMSGREJECTED");
+               snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
                msgInfo->dataSize = strlen(msgInfo->msgText);
+               if (msg_text) {
+                       free(msg_text);
+                       msg_text = NULL;
+               }
        } else if (pTpdu->status == SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED) {
-               strncpy(msgInfo->msgText, "IDS_MSGF_BODY_MESSAGE_HAS_EXPIRED", MAX_MSG_TEXT_LEN);
+               char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSGF_BODY_MESSAGE_HAS_EXPIRED");
+               snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
                msgInfo->dataSize = strlen(msgInfo->msgText);
+               if (msg_text) {
+                       free(msg_text);
+                       msg_text = NULL;
+               }
        } else {
                strncpy(msgInfo->msgText, "Message delivery failed.", MAX_MSG_TEXT_LEN);
                msgInfo->dataSize = strlen(msgInfo->msgText);
@@ -956,28 +947,27 @@ void SmsPluginEventHandler::convertStatusRepTpduToMsginfo(const SMS_STATUS_REPOR
 
 MSG_SUB_TYPE_T SmsPluginEventHandler::convertMsgSubType(SMS_PID_T pid)
 {
-       switch (pid)
-       {
-               case SMS_PID_TYPE0 :
-                       return MSG_TYPE0_SMS;
-               case SMS_PID_REPLACE_TYPE1 :
-                       return MSG_REPLACE_TYPE1_SMS;
-               case SMS_PID_REPLACE_TYPE2 :
-                       return MSG_REPLACE_TYPE2_SMS;
-               case SMS_PID_REPLACE_TYPE3 :
-                       return MSG_REPLACE_TYPE3_SMS;
-               case SMS_PID_REPLACE_TYPE4 :
-                       return MSG_REPLACE_TYPE4_SMS;
-               case SMS_PID_REPLACE_TYPE5 :
-                       return MSG_REPLACE_TYPE5_SMS;
-               case SMS_PID_REPLACE_TYPE6 :
-                       return MSG_REPLACE_TYPE6_SMS;
-               case SMS_PID_REPLACE_TYPE7 :
-                       return MSG_REPLACE_TYPE7_SMS;
-               case SMS_PID_RETURN_CALL :
-                       return MSG_MWI_OTHER_SMS;
-               default :
-                       return MSG_NORMAL_SMS;
+       switch (pid) {
+       case SMS_PID_TYPE0 :
+               return MSG_TYPE0_SMS;
+       case SMS_PID_REPLACE_TYPE1 :
+               return MSG_REPLACE_TYPE1_SMS;
+       case SMS_PID_REPLACE_TYPE2 :
+               return MSG_REPLACE_TYPE2_SMS;
+       case SMS_PID_REPLACE_TYPE3 :
+               return MSG_REPLACE_TYPE3_SMS;
+       case SMS_PID_REPLACE_TYPE4 :
+               return MSG_REPLACE_TYPE4_SMS;
+       case SMS_PID_REPLACE_TYPE5 :
+               return MSG_REPLACE_TYPE5_SMS;
+       case SMS_PID_REPLACE_TYPE6 :
+               return MSG_REPLACE_TYPE6_SMS;
+       case SMS_PID_REPLACE_TYPE7 :
+               return MSG_REPLACE_TYPE7_SMS;
+       case SMS_PID_RETURN_CALL :
+               return MSG_MWI_OTHER_SMS;
+       default :
+               return MSG_NORMAL_SMS;
        }
 
 }
@@ -993,7 +983,7 @@ void SmsPluginEventHandler::SetSentInfo(SMS_SENT_INFO_S *pSentInfo)
 }
 
 
-void SmsPluginEventHandler::setDeviceStatus(struct tapi_handle *handle)
+void SmsPluginEventHandler::setDeviceStatus(TapiHandle *handle)
 {
        if (handle == devHandle) {
                mx.lock();
@@ -1004,7 +994,7 @@ void SmsPluginEventHandler::setDeviceStatus(struct tapi_handle *handle)
 }
 
 
-bool SmsPluginEventHandler::getDeviceStatus(struct tapi_handle *handle)
+bool SmsPluginEventHandler::getDeviceStatus(TapiHandle *handle)
 {
        int ret = 0;
 
index 6cd6d0d..a0e9b06 100755 (executable)
@@ -32,8 +32,7 @@
 #include "SmsPluginDSHandler.h"
 #include <gio/gio.h>
 
-extern "C"
-{
+extern "C" {
        #include <tapi_common.h>
        #include <TelSms.h>
        #include <TapiUtility.h>
@@ -65,13 +64,10 @@ void MsgResourceMonitorDeinit(void);
 
 msg_error_t MsgPlgCreateHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
 {
-       if (pPluginHandle == NULL)
-       {
+       if (pPluginHandle == NULL) {
                MSG_DEBUG("SMS plugin: create handler error ");
                return MSG_ERR_NULL_POINTER;
-       }
-       else
-       {
+       } else {
                pPluginHandle->pfInitialize = SmsPlgInitialize;
                pPluginHandle->pfFinalize = SmsPlgFinalize;
                pPluginHandle->pfRegisterListener = SmsPlgRegisterListener;
@@ -95,8 +91,7 @@ msg_error_t MsgPlgCreateHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
 
 msg_error_t MsgPlgDestroyHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
 {
-       if (pPluginHandle != NULL)
-       {
+       if (pPluginHandle != NULL) {
                free(pPluginHandle);
                pPluginHandle = NULL;
        }
@@ -146,14 +141,13 @@ msg_error_t SmsPlgInitialize()
 
        SmsPluginCallback::instance()->registerEvent();
 
-       for(int i=1; i <= simCnt; ++i)
-       {
-               struct tapi_handle *handle;
+       for (int i = 1; i <= simCnt; ++i) {
+               TapiHandle *handle;
                handle = SmsPluginDSHandler::instance()->getTelHandle(i);
                SmsPluginSetting::instance()->setSimChangeStatus(handle, true);
        }
 
-       // set resource monitor
+       /* set resource monitor */
        MsgResourceMonitorInit();
 
        MSG_END();
@@ -194,7 +188,7 @@ msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo)
 {
        msg_error_t err = MSG_SUCCESS;
 
-       // Add Submit SMS into DB
+       /* Add Submit SMS into DB */
        if (pReqInfo->msgInfo.msgId == 0) {
                if (pReqInfo->msgInfo.msgPort.valid == false) {
                        err = SmsPluginStorage::instance()->checkMessage(&(pReqInfo->msgInfo));
@@ -217,16 +211,15 @@ msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo)
                }
        }
 
-       // Check SIM is present or not
+       /* Check SIM is present or not */
        char keyName[MAX_VCONFKEY_NAME_LEN] = {0,};
        snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pReqInfo->msgInfo.sim_idx);
        MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName);
 
-       if (simStatus == MSG_SIM_STATUS_NOT_FOUND)
-       {
+       if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
                MSG_DEBUG("SIM is not present..");
 
-               // Update Msg Status
+               /* Update Msg Status */
                if (pReqInfo->msgInfo.msgPort.valid == false)
                        SmsPluginStorage::instance()->updateSentMsg(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
 
@@ -256,7 +249,7 @@ msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo)
 
 msg_error_t SmsPlgSaveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList)
 {
-       // Check SIM is present or not
+       /*  Check SIM is present or not */
        char keyName[MAX_VCONFKEY_NAME_LEN];
        memset(keyName, 0x00, sizeof(keyName));
        snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pMsgInfo->sim_idx);
@@ -269,17 +262,12 @@ msg_error_t SmsPlgSaveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_
 
        msg_error_t err = MSG_SUCCESS;
 
-       try
-       {
+       try {
                err = SmsPluginSimMsg::instance()->saveSimMessage(pMsgInfo, pSimIdList);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_STORAGE;
-       }
-       catch (exception& e)
-       {
+       } catch (exception& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_STORAGE;
        }
@@ -290,7 +278,7 @@ msg_error_t SmsPlgSaveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_
 
 msg_error_t SmsPlgDeleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId)
 {
-       // Check SIM is present or not
+       /* Check SIM is present or not */
        char keyName[MAX_VCONFKEY_NAME_LEN]={0,};
        snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, sim_idx);
        MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName);
@@ -300,17 +288,12 @@ msg_error_t SmsPlgDeleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMs
                return MSG_ERR_NO_SIM;
        }
 
-       try
-       {
+       try {
                SmsPluginSimMsg::instance()->deleteSimMessage(sim_idx, SimMsgId);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_STORAGE;
-       }
-       catch (exception& e)
-       {
+       } catch (exception& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_STORAGE;
        }
@@ -321,7 +304,7 @@ msg_error_t SmsPlgDeleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMs
 
 msg_error_t SmsPlgSetReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId)
 {
-       // Check SIM is present or not
+       /* Check SIM is present or not */
        char keyName[MAX_VCONFKEY_NAME_LEN]={0,};
        snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, sim_idx);
        MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName);
@@ -331,17 +314,12 @@ msg_error_t SmsPlgSetReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId
                return MSG_ERR_NO_SIM;
        }
 
-       try
-       {
+       try {
                SmsPluginSimMsg::instance()->setReadStatus(sim_idx, SimMsgId);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_STORAGE;
-       }
-       catch (exception& e)
-       {
+       } catch (exception& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_STORAGE;
        }
@@ -352,7 +330,7 @@ msg_error_t SmsPlgSetReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId
 
 msg_error_t SmsPlgSetMemoryStatus(msg_sim_slot_id_t simIndex, msg_error_t Error)
 {
-       // Check SIM is present or not
+       /* Check SIM is present or not */
        char keyName[MAX_VCONFKEY_NAME_LEN];
 
        memset(keyName, 0x00, sizeof(keyName));
@@ -368,24 +346,18 @@ msg_error_t SmsPlgSetMemoryStatus(msg_sim_slot_id_t simIndex, msg_error_t Error)
        int status = TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE;
 
        if (Error == MSG_ERR_SIM_STORAGE_FULL || Error == MSG_ERR_MESSAGE_COUNT_FULL)
-       {
                status = TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL;
-       }
 
        MSG_DEBUG("Set Status : [%d]", status);
 
-       struct tapi_handle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+       TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
 
        tapiRet = tel_set_sms_memory_status(handle, status, TapiEventMemoryStatus, NULL);
 
        if (tapiRet == TAPI_API_SUCCESS)
-       {
                MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
-       }
        else
-       {
                MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! return : [%d] #######", tapiRet);
-       }
 
        return MSG_SUCCESS;
 }
@@ -393,17 +365,20 @@ msg_error_t SmsPlgSetMemoryStatus(msg_sim_slot_id_t simIndex, msg_error_t Error)
 
 msg_error_t SmsPlgSetConfigData(const MSG_SETTING_S *pSetting)
 {
-       try
-       {
-               SmsPluginSetting::instance()->setConfigData(pSetting);
+       /* Check SIM is present or not */
+       MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(MSG_SIM_CHANGED);
+
+       if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
+               MSG_DEBUG("SIM is not present..");
+               return MSG_ERR_NO_SIM;
        }
-       catch (MsgException& e)
-       {
+
+       try {
+               SmsPluginSetting::instance()->setConfigData(pSetting);
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
-       }
-       catch (exception& e)
-       {
+       } catch (exception& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
        }
@@ -414,17 +389,20 @@ msg_error_t SmsPlgSetConfigData(const MSG_SETTING_S *pSetting)
 
 msg_error_t SmsPlgGetConfigData(MSG_SETTING_S *pSetting)
 {
-       try
-       {
-               SmsPluginSetting::instance()->getConfigData(pSetting);
+       /* Check SIM is present or not */
+       MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(MSG_SIM_CHANGED);
+
+       if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
+               MSG_DEBUG("SIM is not present..");
+               return MSG_ERR_NO_SIM;
        }
-       catch (MsgException& e)
-       {
+
+       try {
+               SmsPluginSetting::instance()->getConfigData(pSetting);
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
-       }
-       catch (exception& e)
-       {
+       } catch (exception& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
        }
@@ -437,19 +415,14 @@ msg_error_t SmsPlgAddMessage(MSG_MESSAGE_INFO_S *pMsgInfo,  MSG_SENDINGOPT_INFO_
 {
 
        int *simIdList = (int*)pFileData;
-       try
-       {
+       try {
                SmsPluginStorage::instance()->addSmsSendOption(pMsgInfo, pSendOptInfo);
                if (simIdList)
                        SmsPluginStorage::instance()->addSimMessage(pMsgInfo, simIdList);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
-       }
-       catch (exception& e)
-       {
+       } catch (exception& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
        }
@@ -461,17 +434,12 @@ msg_error_t SmsPlgAddMessage(MSG_MESSAGE_INFO_S *pMsgInfo,  MSG_SENDINGOPT_INFO_
 msg_error_t SmsPlgGetDefaultNetworkSimId(int *simId)
 {
 
-       try
-       {
+       try {
                SmsPluginDSHandler::instance()->getDefaultNetworkSimId(simId);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
-       }
-       catch (exception& e)
-       {
+       } catch (exception& e) {
                MSG_FATAL("%s", e.what());
                return MSG_ERR_PLUGIN_SETTING;
        }
@@ -490,7 +458,7 @@ static void on_change_received(GDBusConnection *connection, const gchar *sender_
                gint memStatus;
                g_variant_get(parameters, "(i)", &memStatus);
                MSG_DEBUG("memStatus = [%d]", memStatus);
-               if(memStatus == 0) {
+               if (memStatus == 0) {
                        int sim_count = SmsPluginDSHandler::instance()->getTelHandleCount();
 
                        for (int i = 0; i < sim_count; i++) {
@@ -502,7 +470,7 @@ static void on_change_received(GDBusConnection *connection, const gchar *sender_
 
 void MsgResourceMonitorInit(void)
 {
-    MSG_BEGIN();
+       MSG_BEGIN();
 
        GError *error = NULL;
 
index ca1e7e7..2f953f1 100755 (executable)
@@ -52,22 +52,19 @@ int SmsPluginParamCodec::encodeAddress(const SMS_ADDRESS_S *pAddress, char **ppP
 
        *ppParam = new char[MAX_ADD_PARAM_LEN];
 
-       // Set Address Length
-       if (temp[0] == '+')
-       {
+       /* Set Address Length */
+       if (temp[0] == '+') {
                (*ppParam)[offset++] = strlen(temp) - 1;
                temp++;
 
                ton = SMS_TON_INTERNATIONAL;
-       }
-       else
-       {
+       } else {
                (*ppParam)[offset++] = strlen(temp);
 
                ton = pAddress->ton;
        }
 
-       // Set TON, NPI
+       /* Set TON, NPI */
        (*ppParam)[offset++] = 0x80 + (ton << 4) + pAddress->npi;
 
        MSG_DEBUG("Address length is %d.", (*ppParam)[0]);
@@ -86,8 +83,7 @@ int SmsPluginParamCodec::encodeTime(const SMS_TIMESTAMP_S *pTimeStamp, char **pp
 {
        int offset = 0;
 
-       if(pTimeStamp->format == SMS_TIME_ABSOLUTE)
-       {
+       if (pTimeStamp->format == SMS_TIME_ABSOLUTE) {
                int timeZone = pTimeStamp->time.absolute.timeZone;
                *ppParam = new char[MAX_ABS_TIME_PARAM_LEN];
 
@@ -98,8 +94,7 @@ int SmsPluginParamCodec::encodeTime(const SMS_TIMESTAMP_S *pTimeStamp, char **pp
                (*ppParam)[offset++] = ((pTimeStamp->time.absolute.minute % 10) << 4) + (pTimeStamp->time.absolute.minute / 10);
                (*ppParam)[offset++] = ((pTimeStamp->time.absolute.second % 10) << 4) + (pTimeStamp->time.absolute.second / 10);
 
-               if(timeZone < 0)
-               {
+               if (timeZone < 0) {
                        timeZone *= -1;
                        (*ppParam)[offset] = 0x08;
                }
@@ -107,9 +102,7 @@ int SmsPluginParamCodec::encodeTime(const SMS_TIMESTAMP_S *pTimeStamp, char **pp
 
 
                return offset;
-       }
-       else if(pTimeStamp->format == SMS_TIME_RELATIVE)
-       {
+       } else if (pTimeStamp->format == SMS_TIME_RELATIVE) {
                *ppParam = new char[MAX_REL_TIME_PARAM_LEN+1];
 
                memcpy(*ppParam, &(pTimeStamp->time.relative.time), MAX_REL_TIME_PARAM_LEN);
@@ -127,60 +120,54 @@ int SmsPluginParamCodec::encodeDCS(const SMS_DCS_S *pDCS, char **ppParam)
 
        **ppParam = 0x00;
 
-       switch (pDCS->codingGroup)
+       switch (pDCS->codingGroup) {
+       case SMS_GROUP_GENERAL:
        {
-               case SMS_GROUP_GENERAL:
-               {
-                       if (pDCS->msgClass != SMS_MSG_CLASS_NONE)
-                       {
-                               **ppParam = 0x10 + pDCS->msgClass;
-                       }
-
-                       if (pDCS->bCompressed)
-                       {
-                               **ppParam |= 0x20;
-                       }
-               }
+               if (pDCS->msgClass != SMS_MSG_CLASS_NONE)
+                       **ppParam = 0x10 + pDCS->msgClass;
+
+               if (pDCS->bCompressed)
+                       **ppParam |= 0x20;
+       }
                break;
 
-               case SMS_GROUP_CODING_CLASS:
-               {
-                       **ppParam = 0xF0 + pDCS->msgClass;
-               }
+       case SMS_GROUP_CODING_CLASS:
+       {
+               **ppParam = 0xF0 + pDCS->msgClass;
+       }
                break;
 
-               case SMS_GROUP_DELETION:
-                       //not supported
+       case SMS_GROUP_DELETION:
+               /* not supported */
                break;
 
-               case SMS_GROUP_DISCARD:
-                       //not supported
+       case SMS_GROUP_DISCARD:
+               /* not supported */
                break;
 
-               case SMS_GROUP_STORE:
-                       //not supported
+       case SMS_GROUP_STORE:
+               /* not supported */
                break;
 
-               default:
-                       return 0;
+       default:
+               return 0;
        }
 
-       switch (pDCS->codingScheme)
-       {
-               case SMS_CHARSET_7BIT:
+       switch (pDCS->codingScheme) {
+       case SMS_CHARSET_7BIT:
 
                break;
 
-               case SMS_CHARSET_8BIT:
-                       **ppParam |= 0x04;
+       case SMS_CHARSET_8BIT:
+               **ppParam |= 0x04;
                break;
 
-               case SMS_CHARSET_UCS2:
-                       **ppParam |= 0x08;
+       case SMS_CHARSET_UCS2:
+               **ppParam |= 0x08;
                break;
 
-               default:
-                       return 0;
+       default:
+               return 0;
        }
 
        return 1;
@@ -192,18 +179,14 @@ int SmsPluginParamCodec::encodeSMSC(const char *pAddress, unsigned char *pEncode
        char newAddr[MAX_SMSC_LEN+1];
        memset(newAddr, 0x00, sizeof(newAddr));
 
-//MSG_DEBUG("SMSC [%s]", pAddress);
-
+/*     MSG_DEBUG("SMSC [%s]", pAddress);
+*/
        if (pAddress[0] == '+')
-       {
                strncpy(newAddr, pAddress+1, MAX_SMSC_LEN);
-       }
        else
-       {
                strncpy(newAddr, pAddress, MAX_SMSC_LEN);
-       }
 
-       // Set Address
+       /* Set Address */
        int encodeLen = convertDigitToBcd(newAddr, strlen(newAddr), pEncodeAddr);
 
        pEncodeAddr[encodeLen] = '\0';
@@ -231,22 +214,21 @@ int SmsPluginParamCodec::encodeSMSC(const SMS_ADDRESS_S *pAddress, unsigned char
        else
                dataSize = 2 + (addrLen/2) + 1;
 
-       if (dataSize > MAX_SMSC_LEN)
-       {
+       if (dataSize > MAX_SMSC_LEN) {
                MSG_DEBUG("addrLen is too long [%d]", addrLen);
                MSG_DEBUG("dataSize is too long [%d]", dataSize);
 
                return 0;
        }
 
-       // Set Address Length
-       // Check IPC 4.0 -> addrLen/2
+       /* Set Address Length
+          Check IPC 4.0 -> addrLen/2 */
        pSMSC[0] = addrLen;
 
-       // Set TON, NPI
+       /* Set TON, NPI */
        pSMSC[1] = 0x80 + (pAddress->ton << 4) + pAddress->npi;
 
-       // Set Address
+       /* Set Address */
        convertDigitToBcd(newAddr, addrLen, &(pSMSC[2]));
 
        pSMSC[dataSize] = '\0';
@@ -274,11 +256,10 @@ int SmsPluginParamCodec::decodeAddress(const unsigned char *pTpdu, SMS_ADDRESS_S
        pAddress->ton = (pTpdu[offset] & 0x70) >> 4;
        pAddress->npi = pTpdu[offset++] & 0x0F;
 
-MSG_DEBUG("ton [%d]", pAddress->ton);
-MSG_DEBUG("npi [%d]", pAddress->npi);
+       MSG_DEBUG("ton [%d]", pAddress->ton);
+       MSG_DEBUG("npi [%d]", pAddress->npi);
 
-       if (pAddress->ton == SMS_TON_ALPHANUMERIC)
-       {
+       if (pAddress->ton == SMS_TON_ALPHANUMERIC) {
                MSG_DEBUG("Alphanumeric address");
 
                char* tmpAddress = new char[MAX_ADDRESS_LEN];
@@ -295,22 +276,18 @@ MSG_DEBUG("npi [%d]", pAddress->npi);
 
                if (tmpAddress)
                        delete[] tmpAddress;
-       }
-       else if (pAddress->ton == SMS_TON_INTERNATIONAL)
-       {
+       } else if (pAddress->ton == SMS_TON_INTERNATIONAL) {
                convertBcdToDigit(&(pTpdu[offset]), bcdLen, &((pAddress->address)[1]));
                if (pAddress->address[1] != '\0')
                        pAddress->address[0] = '+';
-       }
-       else
-       {
+       } else {
                convertBcdToDigit(&(pTpdu[offset]), bcdLen, &((pAddress->address)[0]));
        }
 
        offset +=       bcdLen;
 
-//MSG_DEBUG("address [%s]", pAddress->address);
-
+/*     MSG_DEBUG("address [%s]", pAddress->address);
+*/
        return offset;
 }
 
@@ -319,7 +296,7 @@ int SmsPluginParamCodec::decodeTime(const unsigned char *pTpdu, SMS_TIMESTAMP_S
 {
        int offset = 0;
 
-       // decode in ABSOLUTE time type.
+       /* decode in ABSOLUTE time type. */
        pTimeStamp->format = SMS_TIME_ABSOLUTE;
 
        pTimeStamp->time.absolute.year = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
@@ -360,8 +337,7 @@ int SmsPluginParamCodec::decodeDCS(const unsigned char *pTpdu, SMS_DCS_S *pDCS)
        pDCS->bIndActive = false;
        pDCS->indType = SMS_OTHER_INDICATOR;
 
-       if (((dcs & 0xC0) >> 6) == 0)
-       {
+       if (((dcs & 0xC0) >> 6) == 0) {
                pDCS->codingGroup = SMS_GROUP_GENERAL;
                pDCS->bCompressed = (dcs & 0x20) >> 5;
                pDCS->codingScheme = (dcs & 0x0C) >> 2;
@@ -370,25 +346,19 @@ int SmsPluginParamCodec::decodeDCS(const unsigned char *pTpdu, SMS_DCS_S *pDCS)
                        pDCS->msgClass = SMS_MSG_CLASS_NONE;
                else
                        pDCS->msgClass = dcs & 0x03;
-       }
-       else if (((dcs & 0xF0) >> 4) == 0x0F)
-       {
+       } else if (((dcs & 0xF0) >> 4) == 0x0F) {
                pDCS->codingGroup = SMS_GROUP_CODING_CLASS;
                pDCS->bCompressed = false;
                pDCS->codingScheme = (dcs & 0x0C) >> 2;
 
                pDCS->msgClass = dcs & 0x03;
-       }
-       else if (((dcs & 0xC0) >> 6) == 1)
-       {
+       } else if (((dcs & 0xC0) >> 6) == 1) {
                pDCS->codingGroup = SMS_GROUP_DELETION;
                pDCS->bCompressed = false;
                pDCS->msgClass = SMS_MSG_CLASS_NONE;
 
-               // TODO: finish here. ??
-       }
-       else if (((dcs & 0xF0) >> 4) == 0x0C)
-       {
+               /* TODO: finish here. ?? */
+       } else if (((dcs & 0xF0) >> 4) == 0x0C) {
                pDCS->codingGroup = SMS_GROUP_DISCARD;
                pDCS->bCompressed = false;
                pDCS->msgClass = SMS_MSG_CLASS_NONE;
@@ -396,9 +366,7 @@ int SmsPluginParamCodec::decodeDCS(const unsigned char *pTpdu, SMS_DCS_S *pDCS)
                pDCS->bMWI = true;
                pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1)? true:false;
                pDCS->indType = (SMS_INDICATOR_TYPE_T)(dcs & 0x03);
-       }
-       else if (((dcs & 0xF0) >> 4) == 0x0D)
-       {
+       } else if (((dcs & 0xF0) >> 4) == 0x0D) {
                pDCS->codingGroup = SMS_GROUP_STORE;
                pDCS->codingScheme = SMS_CHARSET_7BIT;
                pDCS->bCompressed = false;
@@ -407,9 +375,7 @@ int SmsPluginParamCodec::decodeDCS(const unsigned char *pTpdu, SMS_DCS_S *pDCS)
                pDCS->bMWI = true;
                pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1)? true:false;
                pDCS->indType = (SMS_INDICATOR_TYPE_T)(dcs & 0x03);
-       }
-       else if (((dcs & 0xF0) >> 4) == 0x0E)
-       {
+       } else if (((dcs & 0xF0) >> 4) == 0x0E) {
                pDCS->codingGroup = SMS_GROUP_STORE;
                pDCS->codingScheme = SMS_CHARSET_UCS2;
                pDCS->bCompressed = false;
@@ -418,9 +384,7 @@ int SmsPluginParamCodec::decodeDCS(const unsigned char *pTpdu, SMS_DCS_S *pDCS)
                pDCS->bMWI = true;
                pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1)? true:false;
                pDCS->indType = (SMS_INDICATOR_TYPE_T)(dcs & 0x03);
-       }
-       else
-       {
+       } else {
                pDCS->codingGroup = SMS_GROUP_UNKNOWN;
 
                pDCS->bCompressed = (dcs & 0x20) >> 5;
@@ -438,13 +402,10 @@ void SmsPluginParamCodec::decodeSMSC(unsigned char* pAddress, int AddrLen, MSG_S
        if (pAddress == NULL || AddrLen == 0)
                return;
 
-       if (ton == SMS_TON_INTERNATIONAL)
-       {
+       if (ton == SMS_TON_INTERNATIONAL) {
                pDecodeAddr[0] = '+';
                convertBcdToDigit(pAddress, AddrLen, &(pDecodeAddr[1]));
-       }
-       else
-       {
+       } else {
                convertBcdToDigit(pAddress, AddrLen, pDecodeAddr);
        }
 }
@@ -458,11 +419,10 @@ int SmsPluginParamCodec::convertDigitToBcd(char *pDigit, int DigitLen, unsigned
        int offset = 0;
        unsigned char temp;
 
-//MSG_DEBUG("DigitLen [%d]", DigitLen);
-//MSG_DEBUG("pDigit [%s]", pDigit);
+/*     MSG_DEBUG("DigitLen [%d]", DigitLen);
+       MSG_DEBUG("pDigit [%s]", pDigit); */
 
-       for (int i = 0; i < DigitLen; i++)
-       {
+       for (int i = 0; i < DigitLen; i++) {
                if (pDigit[i] == '*')
                        temp = 0x0A;
                else if (pDigit[i] == '#')
@@ -479,9 +439,7 @@ int SmsPluginParamCodec::convertDigitToBcd(char *pDigit, int DigitLen, unsigned
        }
 
        if ((DigitLen%2) == 1)
-       {
                pBcd[offset++] |= 0xF0;
-       }
 
        return offset;
 }
@@ -492,8 +450,7 @@ int SmsPluginParamCodec::convertBcdToDigit(const unsigned char *pBcd, int BcdLen
        int offset = 0;
        unsigned char temp;
 
-       for (int i = 0; i < BcdLen; i++)
-       {
+       for (int i = 0; i < BcdLen; i++) {
                temp = pBcd[i] & 0x0F;
 
                if (temp == 0x0A)
@@ -507,8 +464,7 @@ int SmsPluginParamCodec::convertBcdToDigit(const unsigned char *pBcd, int BcdLen
 
                temp = (pBcd[i] & 0xF0) >> 4;
 
-               if (temp == 0x0F)
-               {
+               if (temp == 0x0F) {
                        pDigit[offset] = '\0';
                        return offset;
                }
@@ -540,9 +496,9 @@ bool SmsPluginParamCodec::checkCphsVmiMsg(const unsigned char *pTpdu, int *setTy
        if (addrLen == 0x04 && pTpdu[offset++] == 0xD0) {
                if (pTpdu[offset] == 0x11 || pTpdu[offset] == 0x10) {
                        MSG_DEBUG("####### VMI msg ######");
-                       *setType = (int)(pTpdu[offset] & 0x01); // 0 : clear, 1 : set
+                       *setType = (int)(pTpdu[offset] & 0x01); /* 0 : clear, 1 : set */
 
-                       *indType = (int)(pTpdu[offset+1] & 0x01); // 0 : indicator 1, 1 : indicator 2
+                       *indType = (int)(pTpdu[offset+1] & 0x01); /* 0 : indicator 1, 1 : indicator 2 */
 
                        ret = true;
                }
@@ -550,3 +506,66 @@ bool SmsPluginParamCodec::checkCphsVmiMsg(const unsigned char *pTpdu, int *setTy
 
        return ret;
 }
+
+time_t SmsPluginParamCodec::convertTime(const SMS_TIMESTAMP_S *time_stamp)
+{
+       time_t rawtime;
+
+       if (time_stamp->format == SMS_TIME_ABSOLUTE) {
+               MSG_DEBUG("year : %d", time_stamp->time.absolute.year);
+               MSG_DEBUG("month : %d", time_stamp->time.absolute.month);
+               MSG_DEBUG("day : %d", time_stamp->time.absolute.day);
+               MSG_DEBUG("hour : %d", time_stamp->time.absolute.hour);
+               MSG_DEBUG("minute : %d", time_stamp->time.absolute.minute);
+               MSG_DEBUG("second : %d", time_stamp->time.absolute.second);
+               MSG_DEBUG("timezone : %d", time_stamp->time.absolute.timeZone);
+
+               char displayTime[32];
+               struct tm * timeTM;
+
+               struct tm timeinfo;
+               memset(&timeinfo, 0x00, sizeof(tm));
+
+               timeinfo.tm_year = (time_stamp->time.absolute.year + 100);
+               timeinfo.tm_mon = (time_stamp->time.absolute.month - 1);
+               timeinfo.tm_mday = time_stamp->time.absolute.day;
+               timeinfo.tm_hour = time_stamp->time.absolute.hour;
+               timeinfo.tm_min = time_stamp->time.absolute.minute;
+               timeinfo.tm_sec = time_stamp->time.absolute.second;
+               timeinfo.tm_isdst = 0;
+
+               rawtime = mktime(&timeinfo);
+
+               MSG_DEBUG("tzname[0] [%s]", tzname[0]);
+               MSG_DEBUG("tzname[1] [%s]", tzname[1]);
+               MSG_DEBUG("timezone [%d]", timezone);
+               MSG_DEBUG("daylight [%d]", daylight);
+
+               memset(displayTime, 0x00, sizeof(displayTime));
+               strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
+               MSG_DEBUG("displayTime [%s]", displayTime);
+
+               rawtime -= (time_stamp->time.absolute.timeZone * (3600/4));
+
+               timeTM = localtime(&rawtime);
+               memset(displayTime, 0x00, sizeof(displayTime));
+               strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+               MSG_DEBUG("displayTime [%s]", displayTime);
+
+/* timezone value is tiemzone + daylight. So should not add daylight */
+#ifdef __MSG_DAYLIGHT_APPLIED__
+               rawtime -= (timezone - daylight*3600);
+#else
+               rawtime -= timezone;
+#endif
+
+               timeTM = localtime(&rawtime);
+               memset(displayTime, 0x00, sizeof(displayTime));
+               strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+               MSG_DEBUG("displayTime [%s]", displayTime);
+       } else {
+               rawtime = time(NULL);
+       }
+
+       return rawtime;
+}
index 1ca9df7..dc2216e 100755 (executable)
@@ -31,8 +31,7 @@
 #include "SmsPluginSatHandler.h"
 #include "SmsPluginDSHandler.h"
 
-extern "C"
-{
+extern "C" {
        #include <tapi_common.h>
        #include <TelSms.h>
        #include <TapiUtility.h>
@@ -71,7 +70,7 @@ SmsPluginSatHandler* SmsPluginSatHandler::instance()
 }
 
 
-void SmsPluginSatHandler::refreshSms(struct tapi_handle *handle, void *pData)
+void SmsPluginSatHandler::refreshSms(TapiHandle *handle, void *pData)
 {
        /*
        TelSatRefreshInd_t* pRefreshData = (TelSatRefreshInd_t*)pData;
@@ -138,7 +137,7 @@ void SmsPluginSatHandler::refreshSms(struct tapi_handle *handle, void *pData)
 }
 
 
-void SmsPluginSatHandler::sendSms(struct tapi_handle *handle, void *pData)
+void SmsPluginSatHandler::sendSms(TapiHandle *handle, void *pData)
 {
        TelSatSendSmsIndSmsData_t* pSmsData = (TelSatSendSmsIndSmsData_t*)pData;
 
@@ -146,15 +145,15 @@ void SmsPluginSatHandler::sendSms(struct tapi_handle *handle, void *pData)
 
        MSG_DEBUG("commandId [%d]", commandId);
 
-       // The TPDU Maximum Length at SAT side is 175
-       // This is because Sat can send 160 bytes unpacked and header
+       /* The TPDU Maximum Length at SAT side is 175
+          This is because Sat can send 160 bytes unpacked and header */
        unsigned char tpdu[MAX_SAT_TPDU_LEN+1];
        int tpduLen = 0;
 
        memset(tpdu, 0x00, sizeof(tpdu));
        memcpy(tpdu, pSmsData->smsTpdu.data, pSmsData->smsTpdu.dataLen);
 
-       // Modify Parameters, Pack User Data
+       /* Modify Parameters, Pack User Data */
        tpduLen = handleSatTpdu(tpdu, pSmsData->smsTpdu.dataLen, pSmsData->bIsPackingRequired);
 
        if (tpduLen <= 0) {
@@ -170,10 +169,10 @@ void SmsPluginSatHandler::sendSms(struct tapi_handle *handle, void *pData)
                return;
        }
 
-       // Make Telephony Structure
+       /* Make Telephony Structure */
        TelSmsDatapackageInfo_t pkgInfo;
 
-       // Set TPDU data
+       /* Set TPDU data */
        memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
        memcpy((void*)pkgInfo.szData, tpdu, tpduLen);
 
@@ -181,21 +180,18 @@ void SmsPluginSatHandler::sendSms(struct tapi_handle *handle, void *pData)
        pkgInfo.MsgLength = tpduLen;
        pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
 
-       // Set SMSC Address
+       /* Set SMSC Address */
        SMS_ADDRESS_S smsc = {0,};
        int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
 
-       if (pSmsData->address.diallingNumberLen > 0)
-       {
+       if (pSmsData->address.diallingNumberLen > 0) {
                smsc.ton = pSmsData->address.ton;
                smsc.npi = pSmsData->address.npi;
                snprintf(smsc.address, sizeof(smsc.address), "%s", pSmsData->address.diallingNumber);
 
                MSG_SEC_DEBUG("SCA TON[%d], NPI[%d], LEN[%d], ADDR[%s]", smsc.ton, smsc.npi, strlen(smsc.address), smsc.address);
-       }
-       else
-       {
-               // Set SMSC Options
+       } else {
+               /* Set SMSC Options */
                SmsPluginTransport::instance()->setSmscOptions(simIndex, &smsc);
        }
 
@@ -205,32 +201,30 @@ void SmsPluginSatHandler::sendSms(struct tapi_handle *handle, void *pData)
        memset(smscAddr, 0x00, sizeof(smscAddr));
        smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr);
 
-       if (smscLen <= 0) return;
+       if (smscLen <= 0)
+               return;
 
-       // Set SMSC Address
+       /* Set SMSC Address */
        memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
        memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
        pkgInfo.Sca[smscLen] = '\0';
 
        int tapiRet = TAPI_API_SUCCESS;
 
-       // Send SMS
+       /* Send SMS */
        tapiRet = tel_send_sms(handle, &pkgInfo, 0, TapiEventSatSmsSentStatus, NULL);
 
-       if (tapiRet == TAPI_API_SUCCESS)
-       {
+       if (tapiRet == TAPI_API_SUCCESS) {
                MSG_DEBUG("########  TelTapiSmsSend Success !!! return : %d #######", tapiRet);
 
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("########  TelTapiSmsSend Fail !!! return : %d #######", tapiRet);
                sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_BEYOND_ME_CAPABILITIES);
        }
 }
 
 
-void SmsPluginSatHandler::ctrlSms(struct tapi_handle *handle, void *pData)
+void SmsPluginSatHandler::ctrlSms(TapiHandle *handle, void *pData)
 {
        if (!pData) {
                MSG_DEBUG("pData is NULL");
@@ -254,33 +248,24 @@ void SmsPluginSatHandler::ctrlSms(struct tapi_handle *handle, void *pData)
        return;
 
 #if 0
-       if (bSendSms == true) // Send SMS By SAT
-       {
-               if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED)
-               {
+       if (bSendSms == true) { /* Send SMS By SAT */
+               if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED) {
                        MSG_DEBUG("SIM does not allow to send SMS");
 
                        sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM);
-               }
-               else if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD)
-               {
+               } else if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD) {
                        MSG_DEBUG("SIM allows to send SMS with modification");
 
                        sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SUCCESS);
                }
-       }
-       else // Send SMS By APP
-       {
+       } else { /* Send SMS By APP */
                msg_network_status_t netStatus = MSG_NETWORK_NOT_SEND;
 
-               if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED)
-               {
+               if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED) {
                        MSG_DEBUG("SIM does not allow to send SMS");
 
                        netStatus = MSG_NETWORK_SEND_FAIL;
-               }
-               else if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD)
-               {
+               } else if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD) {
                        MSG_DEBUG("SIM allows to send SMS with modification");
 
                        netStatus = MSG_NETWORK_SEND_SUCCESS;
@@ -293,7 +278,7 @@ void SmsPluginSatHandler::ctrlSms(struct tapi_handle *handle, void *pData)
 }
 
 
-void SmsPluginSatHandler::ctrlSms(struct tapi_handle *handle, SMS_NETWORK_STATUS_T smsStatus)
+void SmsPluginSatHandler::ctrlSms(TapiHandle *handle, SMS_NETWORK_STATUS_T smsStatus)
 {
        MSG_DEBUG("SMS network status = [%d]", smsStatus);
 
@@ -513,11 +498,11 @@ int SmsPluginSatHandler::handleSatTpdu(unsigned char *pTpdu, unsigned char TpduL
 
        int pos = 0;
 
-       // TP-MTI, TP-RD, TP-VPF,  TP-RP, TP-UDHI, TP-SRR
-       // TP-VPF
+       /* TP-MTI, TP-RD, TP-VPF,  TP-RP, TP-UDHI, TP-SRR */
+       /* TP-VPF */
        SMS_VPF_T vpf = (SMS_VPF_T)(pTpdu[pos++] & 0x18) >> 3;
 
-       // TP-MR
+       /* TP-MR */
        unsigned char tmpRef = pTpdu[pos];
 
        MSG_DEBUG("current Msg Ref : %d", tmpRef);
@@ -531,22 +516,21 @@ int SmsPluginSatHandler::handleSatTpdu(unsigned char *pTpdu, unsigned char TpduL
 //     pTpdu[pos++] = SmsPluginTransport::instance()->getMsgRef();
 
 
-       // TP-DA
+       /* TP-DA */
        SMS_ADDRESS_S destAddr = {0};
        int addrLen = SmsPluginParamCodec::decodeAddress(&pTpdu[pos], &destAddr);
 
        pos += addrLen;
 
-       // TP-PID
+       /* TP-PID */
        pos++;
 
-       // TP-DCS
+       /* TP-DCS */
        SMS_DCS_S dcs = {0};
 
        int dcsLen = SmsPluginParamCodec::decodeDCS(&pTpdu[pos], &dcs);
 
-       if (bIsPackingRequired == true)
-       {
+       if (bIsPackingRequired == true) {
                dcs.codingScheme = SMS_CHARSET_7BIT;
 
                char* pDcs = NULL;
@@ -559,22 +543,17 @@ int SmsPluginSatHandler::handleSatTpdu(unsigned char *pTpdu, unsigned char TpduL
 
        pos++;
 
-       // TP-VP
+       /* TP-VP */
        if (vpf == SMS_VPF_RELATIVE)
-       {
                pos += MAX_REL_TIME_PARAM_LEN;
-       }
        else if (vpf == SMS_VPF_ABSOLUTE)
-       {
                pos += MAX_ABS_TIME_PARAM_LEN;
-       }
 
-       // TP-UDL
+       /* TP-UDL */
        int udl = pTpdu[pos];
        int retLen = 0;
 
-       if (bIsPackingRequired == true)
-       {
+       if (bIsPackingRequired == true) {
                SMS_USERDATA_S userData = {0};
 
                userData.headerCnt = 0;
@@ -582,14 +561,28 @@ int SmsPluginSatHandler::handleSatTpdu(unsigned char *pTpdu, unsigned char TpduL
                memcpy(userData.data, &pTpdu[pos+1], udl);
                userData.data[udl] = '\0';
 
-MSG_DEBUG("user data : [%s]", userData.data);
-
-               int encodeSize = SmsPluginUDCodec::encodeUserData(&userData, dcs.codingScheme, (char*)&pTpdu[pos]);
+               MSG_DEBUG("user data : [%s]", userData.data);
+
+               // check for user data whether it is 7-bit packed or not.
+               bool is7bitPacked = false;
+               int bitValue = 0;
+               for (int i = 0; i < userData.length; i++) {
+                       bitValue = userData.data[i] & ( 1 << 7);
+                       if (bitValue != 0) {
+                               is7bitPacked = true;
+                               MSG_DEBUG("user data is already 7-bit packed !!");
+                               break;
+                       }
+               }
 
-               retLen = pos + encodeSize;
-       }
-       else
-       {
+               if (!is7bitPacked) {
+                       MSG_DEBUG("packing 8-bit user data to 7-bit charset !!");
+                       int encodeSize = SmsPluginUDCodec::encodeUserData(&userData, dcs.codingScheme, (char*)&pTpdu[pos]);
+                       retLen = pos + encodeSize;
+               } else {
+                       retLen = TpduLen;
+               }
+       } else {
                retLen = TpduLen;
        }
 
@@ -597,24 +590,21 @@ MSG_DEBUG("user data : [%s]", userData.data);
 }
 
 
-void SmsPluginSatHandler::sendResult(struct tapi_handle *handle, SMS_SAT_CMD_TYPE_T CmdType, int ResultType)
+void SmsPluginSatHandler::sendResult(TapiHandle *handle, SMS_SAT_CMD_TYPE_T CmdType, int ResultType)
 {
        TelSatAppsRetInfo_t satRetInfo;
        memset(&satRetInfo, 0, sizeof(TelSatAppsRetInfo_t));
 
        satRetInfo.commandId = commandId;
 
-       MSG_DEBUG("satRetInfo.commandId [%d]", satRetInfo.commandId);
+       MSG_INFO("satRetInfo.commandId [%d]", satRetInfo.commandId);
 
-       if (CmdType == SMS_SAT_CMD_REFRESH)
-       {
+       if (CmdType == SMS_SAT_CMD_REFRESH) {
                satRetInfo.commandType = TAPI_SAT_CMD_TYPE_REFRESH;
 
                satRetInfo.appsRet.refresh.appType = TAPI_SAT_REFRESH_MSG;
                satRetInfo.appsRet.refresh.resp = (TelSatResultType_t)ResultType;
-       }
-       else if (CmdType == SMS_SAT_CMD_SEND_SMS)
-       {
+       } else if (CmdType == SMS_SAT_CMD_SEND_SMS) {
                satRetInfo.commandType = TAPI_SAT_CMD_TYPE_SEND_SMS;
 
                satRetInfo.appsRet.sendSms.resp = (TelSatResultType_t)ResultType;
@@ -625,13 +615,9 @@ void SmsPluginSatHandler::sendResult(struct tapi_handle *handle, SMS_SAT_CMD_TYP
        tapiRet = tel_send_sat_app_exec_result(handle, &satRetInfo);
 
        if (tapiRet == TAPI_API_SUCCESS)
-       {
                MSG_DEBUG("TelTapiSatSendAppExecutionResult() SUCCESS");
-       }
        else
-       {
-               MSG_DEBUG("TelTapiSatSendAppExecutionResult() FAIL [%d]", tapiRet);
-       }
+               MSG_ERR("TelTapiSatSendAppExecutionResult() FAIL [%d]", tapiRet);
 
        bInitSim = false;
        bSMSPChanged = false;
index cf88ba7..1b00ccb 100755 (executable)
@@ -36,8 +36,7 @@
 #include "SmsPluginSetting.h"
 #include "SmsPluginDSHandler.h"
 
-extern "C"
-{
+extern "C" {
        #include <tapi_common.h>
        #include <TelSms.h>
        #include <TapiUtility.h>
@@ -59,15 +58,15 @@ SmsPluginSetting* SmsPluginSetting::pInstance = NULL;
 
 SmsPluginSetting::SmsPluginSetting()
 {
-       // Initialize member variables
+       /* Initialize member variables */
        for (int i = 0; i <= MAX_TELEPHONY_HANDLE_CNT; i++) {
-               memset(&smscList[i], 0x00, sizeof(MSG_SMSC_LIST_S));
                memset(&smscData[i], 0x00, sizeof(MSG_SMSC_DATA_S));
-               memset(&cbOpt[i], 0x00, sizeof(MSG_CBMSG_OPT_S));
-               memset(&simMailboxList[i], 0x00, sizeof(SMS_SIM_MAILBOX_LIST_S));
-               memset(&simMwiInfo[i], 0x00, sizeof(SMS_SIM_MWI_INFO_S));
                simStatus[i] = MSG_SIM_STATUS_NOT_FOUND;
        }
+       smscList.clear();
+       simMailboxList.clear();
+       simMwiInfo.clear();
+       cbOpt.clear();
        memset(&meImei, 0x00, sizeof(meImei));
 
        bTapiResult = false;
@@ -82,8 +81,10 @@ SmsPluginSetting::SmsPluginSetting()
 
 SmsPluginSetting::~SmsPluginSetting()
 {
-
-
+       smscList.erase(smscList.begin(), smscList.end());
+       simMailboxList.erase(simMailboxList.begin(), simMailboxList.end());
+       simMwiInfo.erase(simMwiInfo.begin(), simMwiInfo.end());
+       cbOpt.erase(cbOpt.begin(), cbOpt.end());
 }
 
 
@@ -101,7 +102,7 @@ void* SmsPluginSetting::initSimInfo(void *data)
        static Mutex mm;
        MutexLocker lock(mm);
 
-       SmsPluginSetting::instance()->processInitSimInfo(data);
+       instance()->processInitSimInfo(data);
 
        return NULL;
 }
@@ -110,8 +111,8 @@ void* SmsPluginSetting::processInitSimInfo(void *data)
 {
        MSG_BEGIN();
 
-       //Handle sim info initialization separately
-       struct tapi_handle *handle = (struct tapi_handle *)data;
+       /* Handle sim info initialization separately */
+       TapiHandle *handle = (TapiHandle *)data;
        instance()->updateSimStatus(handle);
 
        MSG_END();
@@ -119,7 +120,7 @@ void* SmsPluginSetting::processInitSimInfo(void *data)
 }
 
 
-void SmsPluginSetting::updateSimStatus(struct tapi_handle *handle)
+void SmsPluginSetting::updateSimStatus(TapiHandle *handle)
 {
        MSG_BEGIN();
 
@@ -136,13 +137,13 @@ void SmsPluginSetting::updateSimStatus(struct tapi_handle *handle)
 
        int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
 
-       // Get IMSI
+       /* Get IMSI */
        TelSimImsiInfo_t imsiInfo;
        memset(&imsiInfo, 0x00, sizeof(TelSimImsiInfo_t));
 
        tapiRet = tel_get_sim_imsi(handle, &imsiInfo);
        if (tapiRet != TAPI_API_SUCCESS) {
-               MSG_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet);
+               MSG_SEC_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet);
        }
 
        /* Save Subcriber ID */
@@ -180,16 +181,13 @@ void SmsPluginSetting::updateSimStatus(struct tapi_handle *handle)
                }
        }
 
-       // init config data.
+       /* init config data. */
        initConfigData(handle);
 
-       try
-       {
-               // init sim messages.
+       try {
+               /* init sim messages. */
                SmsPluginSimMsg::instance()->initSimMessage(handle);
-       }
-       catch (MsgException& e)
-       {
+       } catch (MsgException& e) {
                MSG_FATAL("%s", e.what());
                return;
        }
@@ -201,7 +199,7 @@ void SmsPluginSetting::updateSimStatus(struct tapi_handle *handle)
 }
 
 
-void SmsPluginSetting::initConfigData(struct tapi_handle *handle)
+void SmsPluginSetting::initConfigData(TapiHandle *handle)
 {
        MSG_BEGIN();
 
@@ -209,7 +207,7 @@ void SmsPluginSetting::initConfigData(struct tapi_handle *handle)
 
        int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
        /*==================== SMSC setting ====================*/
-       // Init SMS Parameter
+       /* Init SMS Parameter */
        int paramCnt = 0;
        int failCnt = 0;
        bool bSelectedFound = false;
@@ -222,8 +220,7 @@ void SmsPluginSetting::initConfigData(struct tapi_handle *handle)
        MSG_SMSC_DATA_S tmpSmscData = {};
        MSG_SMSC_LIST_S tmpSmscList = {0,};
 
-       for (int index = 0; index < paramCnt; index++)
-       {
+       for (int index = 0; index < paramCnt; index++) {
                memset(&tmpSmscData, 0x00, sizeof(MSG_SMSC_DATA_S));
                if (getParam(handle, index, &tmpSmscData) == false) {
                        failCnt++;
@@ -240,7 +237,7 @@ void SmsPluginSetting::initConfigData(struct tapi_handle *handle)
                MSG_DEBUG("npi[%d]", tmpSmscList.smscData[index].smscAddr.npi);
                MSG_SEC_DEBUG("address[%s]", tmpSmscList.smscData[index].smscAddr.address);
 
-               //First smsc is selected index
+               /* First smsc is selected index */
                if (!bSelectedFound) {
                        tmpSmscList.selected = selectedParam;
                        bSelectedFound = !bSelectedFound;
@@ -256,8 +253,7 @@ void SmsPluginSetting::initConfigData(struct tapi_handle *handle)
        }
 
        /*==================== CB configuration ====================*/
-       if (simStatus[sim_idx] != MSG_SIM_STATUS_NOT_FOUND)
-       {
+       if (simStatus[sim_idx] != MSG_SIM_STATUS_NOT_FOUND) {
                MSG_DEBUG("simStatus == [%d]", simStatus[sim_idx]);
 
                MSG_CBMSG_OPT_S cbMsgOpt = {0,};
@@ -272,8 +268,7 @@ void SmsPluginSetting::initConfigData(struct tapi_handle *handle)
 
                        if (cbMsgOpt.bReceive == false && bAPReceive == false) {
                                MSG_DEBUG("CB is off in CP and in AP. No need to send CB request to CP. ");
-                       }
-                       else {
+                       } else {
                                MSG_DEBUG("########  Add CB Option Success !!! #######");
                                MSG_SETTING_S cbSetting;
                                getCbOpt(&cbSetting, sim_idx);
@@ -302,11 +297,12 @@ void SmsPluginSetting::initConfigData(struct tapi_handle *handle)
                if (simStatus[sim_idx] == MSG_SIM_STATUS_CHANGED) {
                        char keyName[MAX_VCONFKEY_NAME_LEN];
 
-                       MSG_DEBUG("=================SIM CHANGED===================");
+                       MSG_INFO("=================SIM CHANGED===================");
+                       /* reset default voicemail number and voicemail number */
 
                        memset(keyName, 0x00, sizeof(keyName));
-                       snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
-                       if (MsgSettingSetString(keyName, VOICEMAIL_DEFAULT_NUMBER) != MSG_SUCCESS)
+                       snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_DEFAULT_NUMBER, sim_idx);
+                       if (MsgSettingSetString(keyName, "") != MSG_SUCCESS)
                                MSG_DEBUG("MsgSettingSetString is failed!!");
 
                        memset(keyName, 0x00, sizeof(keyName));
@@ -323,10 +319,52 @@ void SmsPluginSetting::initConfigData(struct tapi_handle *handle)
                        MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_2, sim_idx);
                }
 
+               /*==================== Default Voice mail Setting ====================*/
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_DEFAULT_NUMBER, sim_idx);
+               char *num = MsgSettingGetString(keyName);
+
+               if (num && num[0] != '\0') {
+                       MSG_DEBUG("Voicemail Default Number [%s]", num);
+
+                       memset(keyName, 0x00, sizeof(keyName));
+                       snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
+
+                       if (MsgSettingSetString(keyName, num) != MSG_SUCCESS)
+                               MSG_DEBUG("MsgSettingSetInt is failed!!");
+
+                       free(num);
+                       num = NULL;
+               } else {
+                       MSG_DEBUG("Voicemail Default Number is NULL");
+
+                       memset(keyName, 0x00, sizeof(keyName));
+                       snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
+
+                       char *voicemail = MsgSettingGetString(keyName);
+
+                       if (!voicemail || voicemail[0] == '\0') {
+                               if (MsgSettingSetString(keyName, "") != MSG_SUCCESS)
+                                       MSG_DEBUG("MsgSettingSetInt is failed!!");
+                       }
+               }
 
                /*==================== Voice mail information update ====================*/
                if (getVoiceMailInfo(handle) == true) {
                        MSG_DEBUG("########  getVoiceMailInfo Success !!! #######");
+                       memset(keyName, 0x00, sizeof(keyName));
+                       snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
+
+                       char *voiceNumber = MsgSettingGetString(keyName);
+
+                       if (!voiceNumber || (voiceNumber && voiceNumber[0] == '\0')) {
+                               MSG_WARN("Voice Number is Empty!!");
+                       }
+
+                       if (voiceNumber) {
+                               free(voiceNumber);
+                               voiceNumber = NULL;
+                       }
                } else {
                        MSG_WARN("########  getVoiceMailInfo Fail !!! #######");
                }
@@ -337,7 +375,7 @@ void SmsPluginSetting::initConfigData(struct tapi_handle *handle)
                } else {
                        MSG_WARN("########  getMwiInfo Fail !!! #######");
 
-                       // Get MWI from vconf and insert notification
+                       /* Get MWI from vconf and insert notification */
                        int mwiCnt = 0;
                        char keyName[MAX_VCONFKEY_NAME_LEN];
                        memset(keyName, 0x00, sizeof(keyName));
@@ -365,7 +403,7 @@ void SmsPluginSetting::initConfigData(struct tapi_handle *handle)
 }
 
 
-void SmsPluginSetting::SimRefreshCb(struct tapi_handle *handle)
+void SmsPluginSetting::SimRefreshCb(TapiHandle *handle)
 {
        pthread_t thd;
 
@@ -380,8 +418,7 @@ void SmsPluginSetting::SimRefreshCb(struct tapi_handle *handle)
 
 void* SmsPluginSetting::init_config_data(void *data)
 {
-       struct tapi_handle *handle = (struct tapi_handle *)data;
-
+       TapiHandle *handle = (TapiHandle *)data;
        instance()->initConfigData(handle);
        return NULL;
 }
@@ -391,29 +428,28 @@ void SmsPluginSetting::setConfigData(const MSG_SETTING_S *pSetting)
 {
        MSG_DEBUG("Setting Type : [%d]", pSetting->type);
 
-       switch (pSetting->type)
-       {
+       switch (pSetting->type) {
 #if 0
-               case MSG_SMS_SENDOPT :
-                       setNetworkMode(&pSetting->option.smsSendOpt);
-                       break;
+       case MSG_SMS_SENDOPT :
+               setNetworkMode(&pSetting->option.smsSendOpt);
+               break;
 #endif
-               case MSG_SMSC_LIST :
-                       setParamList(&pSetting->option.smscList);
-                       addSMSCList((MSG_SMSC_LIST_S *)(&pSetting->option.smscList));
-//                     setSmscInfo(&pSetting->option.smscList);
-                       break;
-               case MSG_CBMSG_OPT :
-                       if (setCbConfig(&pSetting->option.cbMsgOpt) == false) {
-                               THROW(MsgException::SMS_PLG_ERROR, "Failed to set config.");
-                       }
-                       break;
-               case MSG_VOICEMAIL_OPT:
-                       setVoiceMailInfo(&pSetting->option.voiceMailOpt);
-                       break;
-               default :
-                       THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
-                       break;
+       case MSG_SMSC_LIST :
+               setParamList(&pSetting->option.smscList);
+               addSMSCList((MSG_SMSC_LIST_S *)(&pSetting->option.smscList));
+//             setSmscInfo(&pSetting->option.smscList);
+               break;
+       case MSG_CBMSG_OPT :
+               if (setCbConfig(&pSetting->option.cbMsgOpt) == false) {
+                       THROW(MsgException::SMS_PLG_ERROR, "Failed to set config.");
+               }
+               break;
+       case MSG_VOICEMAIL_OPT:
+               setVoiceMailInfo(&pSetting->option.voiceMailOpt);
+               break;
+       default :
+               THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+               break;
        }
 }
 
@@ -422,21 +458,20 @@ void SmsPluginSetting::getConfigData(MSG_SETTING_S *pSetting)
 {
        MSG_DEBUG("Setting Type : [%d]", pSetting->type);
 
-       switch (pSetting->type)
-       {
-               case MSG_SMSC_LIST :
-//                     getParamList(&pSetting->option.smscList);
-                       getSmscListInfo(pSetting->option.smscList.simIndex, &(pSetting->option.smscList));
+       switch (pSetting->type) {
+       case MSG_SMSC_LIST :
+//             getParamList(&pSetting->option.smscList);
+               getSmscListInfo(pSetting->option.smscList.simIndex, &(pSetting->option.smscList));
                break;
 
-               case MSG_CBMSG_OPT :
-                       if (getCbConfig(&pSetting->option.cbMsgOpt) == false) {
-                               THROW(MsgException::SMS_PLG_ERROR, "Get CB config option failed.");
-                       }
+       case MSG_CBMSG_OPT :
+               if (getCbConfig(&pSetting->option.cbMsgOpt) == false) {
+                       THROW(MsgException::SMS_PLG_ERROR, "Get CB config option failed.");
+               }
                break;
 
-               default :
-                       THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+       default :
+               THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
                break;
        }
 }
@@ -452,8 +487,7 @@ void SmsPluginSetting::addSMSCList(MSG_SMSC_LIST_S *pSmscList)
        MSG_DEBUG("total_count[%d]", pSmscList->totalCnt);
        MSG_DEBUG("selected index[%d]", pSmscList->selected);
 
-       for (int i = 0; i < pSmscList->totalCnt; i++)
-       {
+       for (int i = 0; i < pSmscList->totalCnt; i++) {
                MSG_DEBUG("pid[%d]", pSmscList->smscData[i].pid);
                MSG_DEBUG("val_period[%d]", pSmscList->smscData[i].valPeriod);
                MSG_SEC_DEBUG("name[%s]", pSmscList->smscData[i].name);
@@ -465,27 +499,33 @@ void SmsPluginSetting::addSMSCList(MSG_SMSC_LIST_S *pSmscList)
 
        sim_index = pSmscList->simIndex;
 
-       smscList[sim_index].simIndex = pSmscList->simIndex;
-       smscList[sim_index].totalCnt = pSmscList->totalCnt;
-       smscList[sim_index].selected = pSmscList->selected;
-
-       for (int i = 0; i < pSmscList->totalCnt; i++) {
-
-               smscList[sim_index].smscData[i].pid = pSmscList->smscData[i].pid;
-               smscList[sim_index].smscData[i].valPeriod = pSmscList->smscData[i].valPeriod;
-
-               memset(smscList[sim_index].smscData[i].name, 0x00, SMSC_NAME_MAX+1);
-               memcpy(smscList[sim_index].smscData[i].name, pSmscList->smscData[i].name, SMSC_NAME_MAX);
-
-               memset(smscList[sim_index].smscData[i].smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
-               memcpy(smscList[sim_index].smscData[i].smscAddr.address, pSmscList->smscData[i].smscAddr.address, SMSC_ADDR_MAX);
-
-               if (pSmscList->smscData[i].smscAddr.address[0] == '+')
-                       smscList[sim_index].smscData[i].smscAddr.ton = MSG_TON_INTERNATIONAL;
-               else
-                       smscList[sim_index].smscData[i].smscAddr.ton = MSG_TON_NATIONAL;
-
-               smscList[sim_index].smscData[i].smscAddr.npi = MSG_NPI_ISDN; // app cannot set this value
+       smscListMap::iterator it = smscList.find(pSmscList->simIndex);
+       if (it == smscList.end()) {
+               pair<int, MSG_SMSC_LIST_S> newList(sim_index, *pSmscList);
+               smscList.insert(newList);
+       } else {
+               /* update the list. */
+               MSG_SMSC_LIST_S &pTmpSmscList = it->second;
+               pTmpSmscList.simIndex = pSmscList->simIndex;
+               pTmpSmscList.totalCnt = pSmscList->totalCnt;
+               pTmpSmscList.selected = pSmscList->selected;
+
+               for (int i = 0; i < pSmscList->totalCnt; i++) {
+                       pTmpSmscList.smscData[i].pid = pSmscList->smscData[i].pid;
+                       pTmpSmscList.smscData[i].valPeriod = pSmscList->smscData[i].valPeriod;
+                       memset(pTmpSmscList.smscData[i].name, 0x00, SMSC_NAME_MAX+1);
+                       memcpy(pTmpSmscList.smscData[i].name, pSmscList->smscData[i].name, SMSC_NAME_MAX);
+
+                       memset(pTmpSmscList.smscData[i].smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
+                       memcpy(pTmpSmscList.smscData[i].smscAddr.address, pSmscList->smscData[i].smscAddr.address, SMSC_ADDR_MAX);
+
+                       if (pTmpSmscList.smscData[i].smscAddr.address[0] == '+')
+                               pTmpSmscList.smscData[i].smscAddr.ton = MSG_TON_INTERNATIONAL;
+                       else
+                               pTmpSmscList.smscData[i].smscAddr.ton = MSG_TON_NATIONAL;
+
+                       pTmpSmscList.smscData[i].smscAddr.npi = MSG_NPI_ISDN; // app cannot set this value
+               }
        }
 
        MSG_END();
@@ -500,14 +540,20 @@ void SmsPluginSetting::getSmscListInfo(int simIndex, MSG_SMSC_LIST_S *pSmscList)
        }
 
        if (simIndex <= 0) {
-               struct tapi_handle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+               TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
                simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
        }
 
-       if (simIndex == -1)
-               memset(pSmscList, 0x00, sizeof(MSG_SMSC_LIST_S));
-       else
-               memcpy(pSmscList, &smscList[simIndex], sizeof(MSG_SMSC_LIST_S));
+       memset(pSmscList, 0x00, sizeof(MSG_SMSC_LIST_S));
+
+       if (simIndex != -1) {
+               smscListMap::iterator it = smscList.find(simIndex);
+               if (it != smscList.end()) {
+                       MSG_SMSC_LIST_S &pTmpSmscList = it->second;
+                       memcpy(pSmscList, &pTmpSmscList, sizeof(MSG_SMSC_LIST_S));
+                       MSG_SEC_DEBUG("SMSC number for sim index [%d] is [%s]", pSmscList->simIndex, pSmscList->smscData[pSmscList->selected].smscAddr.address);
+               }
+       }
 
        return;
 }
@@ -522,8 +568,7 @@ msg_error_t SmsPluginSetting::addCbOpt(MSG_CBMSG_OPT_S *pCbOpt)
 
        MSG_DEBUG("Channel Count [%d]", pCbOpt->channelData.channelCnt);
 
-       for (int i = 0; i < pCbOpt->channelData.channelCnt; i++)
-       {
+       for (int i = 0; i < pCbOpt->channelData.channelCnt; i++) {
                MSG_DEBUG("Channel FROM [%d], Channel TO [%d]", pCbOpt->channelData.channelInfo[i].from, pCbOpt->channelData.channelInfo[i].to);
        }
 
@@ -623,7 +668,7 @@ void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
        smsParam.ParamIndicator = 0x00;
 
        if (strlen(pSMSCList->smscData[index].smscAddr.address) > 0) {
-               smsParam.ParamIndicator |= 0x02 ;  //enable 2nd Bit
+               smsParam.ParamIndicator |= 0x02 ;  /* enable 2nd Bit */
                MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
 
                if (pSMSCList->smscData[index].smscAddr.address[0] == '+')
@@ -631,7 +676,7 @@ void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
                else
                        smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_NATIONAL;
 
-               smsParam.TpSvcCntrAddr.Npi = TAPI_SIM_NPI_ISDN_TEL; // app cannot set this value
+               smsParam.TpSvcCntrAddr.Npi = TAPI_SIM_NPI_ISDN_TEL; /* app cannot set this value */
 
                MSG_DEBUG("SMSC TON = [%d] NPI = [%d]", smsParam.TpSvcCntrAddr.Ton, smsParam.TpSvcCntrAddr.Npi);
 
@@ -643,13 +688,13 @@ void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
        }
 
        /*Setting the PID value*/
-       smsParam.ParamIndicator |= 0x04 ;  //enable 3nd Bit
+       smsParam.ParamIndicator |= 0x04 ;  /* enable 3rd Bit */
        MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
 
        smsParam.TpProtocolId = (unsigned short)convertPid(pSMSCList->smscData[index].pid);
 
        /*Setting the ValidityPeriod value*/
-       smsParam.ParamIndicator |= 0x10 ;  //enable 5nd Bit
+       smsParam.ParamIndicator |= 0x10 ;  /* enable 5th Bit */
        MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
 
        smsParam.TpValidityPeriod = (unsigned short)pSMSCList->smscData[index].valPeriod;
@@ -658,7 +703,7 @@ void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
        MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
 
        /* Get TAPI handle */
-       struct tapi_handle *handle = SmsPluginDSHandler::instance()->getTelHandle(pSMSCList->simIndex);
+       TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pSMSCList->simIndex);
 
        ret = tel_set_sms_parameters(handle, (const TelSmsParams_t*)&smsParam, TapiEventSetConfigData, NULL);
 
@@ -679,7 +724,7 @@ void SmsPluginSetting::getParamList(MSG_SMSC_LIST_S *pSMSCList)
        int paramCnt = 0;
 
        MSG_SEC_DEBUG("SIM index [%d]", pSMSCList->simIndex);
-       struct tapi_handle *handle = SmsPluginDSHandler::instance()->getTelHandle(pSMSCList->simIndex);
+       TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pSMSCList->simIndex);
        paramCnt = getParamCount(handle);
 
        MSG_DEBUG("Parameter Count [%d]", paramCnt);
@@ -723,7 +768,7 @@ void SmsPluginSetting::getParamList(MSG_SMSC_LIST_S *pSMSCList)
 }
 
 
-int SmsPluginSetting::getParamCount(struct tapi_handle *handle)
+int SmsPluginSetting::getParamCount(TapiHandle *handle)
 {
        int ret = TAPI_API_SUCCESS;
 
@@ -739,7 +784,7 @@ int SmsPluginSetting::getParamCount(struct tapi_handle *handle)
 }
 
 
-bool SmsPluginSetting::getParam(struct tapi_handle *handle, int Index, MSG_SMSC_DATA_S *pSmscData)
+bool SmsPluginSetting::getParam(TapiHandle *handle, int Index, MSG_SMSC_DATA_S *pSmscData)
 {
        int ret = TAPI_API_SUCCESS;
 
@@ -771,7 +816,7 @@ void SmsPluginSetting::setSmscInfo(const MSG_SMSC_LIST_S *pSmscList)
 
        int ret = TAPI_API_SUCCESS;
 
-       struct tapi_handle *handle = NULL;
+       TapiHandle *handle = NULL;
 
        handle = SmsPluginDSHandler::instance()->getTelHandle(pSmscList->simIndex);
 
@@ -790,7 +835,7 @@ void SmsPluginSetting::setSmscInfo(const MSG_SMSC_LIST_S *pSmscList)
                else
                        sca.Ton = TAPI_SIM_TON_NATIONAL;
 
-               sca.Npi = TAPI_SIM_NPI_ISDN_TEL; // app cannot set this value
+               sca.Npi = TAPI_SIM_NPI_ISDN_TEL; /* app cannot set this value */
 
                MSG_SEC_DEBUG("SMSC TON = [%d], NPI = [%d], Address = [%s]", sca.Ton, sca.Npi, pSmscData->smscAddr.address);
 
@@ -813,7 +858,7 @@ void SmsPluginSetting::setSmscInfo(const MSG_SMSC_LIST_S *pSmscList)
 
 bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
 {
-       struct tapi_handle *handle = NULL;
+       TapiHandle *handle = NULL;
        int simCnt = SmsPluginDSHandler::instance()->getTelHandleCount();
 
        TelSmsCbConfig_t cbConfig = {};
@@ -822,7 +867,7 @@ bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
        int ret = TAPI_API_SUCCESS;
 
        if (pCbOpt->bReceive == true)
-               cbEnabled = 2;// Need to get a Enumeration from TAPI, currently it is not available
+               cbEnabled = 2;/* Need to get a Enumeration from TAPI, currently it is not available */
 
        MSG_DEBUG("simIndex:%d, cbEnabled:%d", pCbOpt->simIndex, cbEnabled);
 
@@ -847,14 +892,13 @@ bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
 
                        handle = SmsPluginDSHandler::instance()->getTelHandle(i);
                        memset(&cbConfig, 0x00, sizeof(TelSmsCbConfig_t));
-
-                       MSG_SETTING_S cbSetting;
-                       getCbOpt(&cbSetting, i);
-
                        cbConfig.CBEnabled = cbEnabled;
                        cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
 
-                       /*cbConfig.CBEnabled = (int)pCbOpt->bReceive;
+                       /*MSG_SETTING_S cbSetting;
+                       getCbOpt(&cbSetting, i);
+
+                       cbConfig.CBEnabled = (int)pCbOpt->bReceive;
                        cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
                        cbConfig.MsgIdMaxCount = cbSetting.option.cbMsgOpt.maxSimCnt;
                        cbConfig.MsgIdRangeCount = cbSetting.option.cbMsgOpt.channelData.channelCnt;
@@ -939,7 +983,7 @@ bool SmsPluginSetting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
 {
        int ret = TAPI_API_SUCCESS;
 
-       struct tapi_handle *handle = NULL;
+       TapiHandle *handle = NULL;
 
        if (pCbOpt->simIndex == 0) {
                MSG_DEBUG("SIM Index for getCBConfig = 0, CANNOT get cbconfig from SIM 0");
@@ -970,10 +1014,11 @@ bool SmsPluginSetting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
 
 void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
 {
+       MSG_BEGIN();
        MutexLocker lock(mx);
 
        int ret = TAPI_API_SUCCESS;
-       bool *bShowError = NULL; //When invalid voicemail data exists on SIM, update error should not be handled.
+       bool *bShowError = NULL; /* When invalid voicemail data exists on SIM, update error should not be handled. */
 
        int simIndex = pVoiceOpt->simIndex;
 
@@ -986,7 +1031,13 @@ void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
        bool bExistVoicetype = false;
        int i = 0;
 
-       if (simMailboxList[simIndex].count < 0) { /* Not available */
+       smsSimMailboxListMap::iterator it = simMailboxList.find(simIndex);
+       if (it == simMailboxList.end()) {
+               return;
+       }
+
+       SMS_SIM_MAILBOX_LIST_S &pTmpSimMailboxList = it->second;
+       if (pTmpSimMailboxList.count < 0) { /* Not available */
                return;
        }
 
@@ -994,7 +1045,7 @@ void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
        if (!bShowError)
                return;
 
-       if (simMailboxList[simIndex].count == 0) {
+       if (pTmpSimMailboxList.count == 0) {
                char num[MAX_PHONE_NUMBER_LEN + 1] = {0,};
 
                mailboxInfo.mb_type = TAPI_SIM_MAILBOX_VOICE;
@@ -1016,8 +1067,8 @@ void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
                *bShowError = false;
 
        } else {
-               for (i = 0; i < simMailboxList[simIndex].count; i++) {
-                       if (simMailboxList[simIndex].list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
+               for (i = 0; i < pTmpSimMailboxList.count; i++) {
+                       if (pTmpSimMailboxList.list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
                                bExistVoicetype = true;
                                break;
                        }
@@ -1026,48 +1077,51 @@ void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
                if (bExistVoicetype == false) {
                        *bShowError = false;
                        /* There is no mailbox information for voicemail type on SIM. */
-                       for (i = 0; i < simMailboxList[simIndex].count; i++) {
-                               if (simMailboxList[simIndex].list[i].mb_type < TAPI_SIM_MAILBOX_VOICE || simMailboxList[simIndex].list[i].mb_type > TAPI_SIM_MAILBOX_OTHER) {
-                                       simMailboxList[simIndex].list[i].mb_type = TAPI_SIM_MAILBOX_VOICE;
+                       for (i = 0; i < pTmpSimMailboxList.count; i++) {
+                               if (pTmpSimMailboxList.list[i].mb_type < TAPI_SIM_MAILBOX_VOICE || pTmpSimMailboxList.list[i].mb_type > TAPI_SIM_MAILBOX_OTHER) {
+                                       pTmpSimMailboxList.list[i].mb_type = TAPI_SIM_MAILBOX_VOICE;
                                        break;
                                }
                        }
                }
 
                /* if strlen of voicemail number retrieved from SIM is zero, error is not shown */
-               if(simMailboxList[simIndex].list[i].num_len == 0) {
+               if (pTmpSimMailboxList.list[i].num_len == 0) {
                        MSG_DEBUG("In SIM voicemail does not exist");
                        *bShowError = false;
+               } else if (pTmpSimMailboxList.list[i].num_len > 0) {
+                       MSG_DEBUG("In SIM voicemail exist");
+                       *bShowError = true;
                }
 
                MSG_INFO("bShowError = %d", *bShowError);
 
-               memset(&simMailboxList[simIndex].list[i].num, 0x00, sizeof(simMailboxList[simIndex].list[i].num));
-               snprintf(simMailboxList[simIndex].list[i].num, sizeof(simMailboxList[simIndex].list[i].num), "%s", pVoiceOpt->mailNumber);
-               MSG_DEBUG("Mailbox number config [%s]", simMailboxList[simIndex].list[i].num);
-
-               mailboxInfo.b_cphs = simMailboxList[simIndex].list[i].b_cphs;
-               mailboxInfo.alpha_id_max_len = simMailboxList[simIndex].list[i].alpha_id_max_len;
-               mailboxInfo.mb_type = (TelSimMailboxType_t)simMailboxList[simIndex].list[i].mb_type;
-               mailboxInfo.profile_num = simMailboxList[simIndex].list[i].profile_num;
-               mailboxInfo.rec_index = (simMailboxList[simIndex].list[i].rec_index == 0) ? 1 : simMailboxList[simIndex].list[i].rec_index;
-               mailboxInfo.ton = (TelSimTypeOfNum_t)simMailboxList[simIndex].list[i].ton;
-               mailboxInfo.npi = (TelSimNumberingPlanIdentity_t)simMailboxList[simIndex].list[i].npi;
-               snprintf(mailboxInfo.alpha_id, sizeof(mailboxInfo.alpha_id), "%s", simMailboxList[simIndex].list[i].alpha_id);
-
-               if (simMailboxList[simIndex].list[i].num[0] == '+') {
-                       snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", &(simMailboxList[simIndex].list[i].num[1]));
+               memset(&pTmpSimMailboxList.list[i].num, 0x00, sizeof(pTmpSimMailboxList.list[i].num));
+               snprintf(pTmpSimMailboxList.list[i].num, sizeof(pTmpSimMailboxList.list[i].num), "%s", pVoiceOpt->mailNumber);
+               MSG_DEBUG("Mailbox number config [%s]", pTmpSimMailboxList.list[i].num);
+
+               mailboxInfo.b_cphs = pTmpSimMailboxList.list[i].b_cphs;
+               mailboxInfo.alpha_id_max_len = pTmpSimMailboxList.list[i].alpha_id_max_len;
+               mailboxInfo.mb_type = (TelSimMailboxType_t)pTmpSimMailboxList.list[i].mb_type;
+               mailboxInfo.profile_num = pTmpSimMailboxList.list[i].profile_num;
+               mailboxInfo.rec_index = (pTmpSimMailboxList.list[i].rec_index == 0) ? 1 : pTmpSimMailboxList.list[i].rec_index;
+               mailboxInfo.ton = (TelSimTypeOfNum_t)pTmpSimMailboxList.list[i].ton;
+               mailboxInfo.npi = (TelSimNumberingPlanIdentity_t)pTmpSimMailboxList.list[i].npi;
+               snprintf(mailboxInfo.alpha_id, sizeof(mailboxInfo.alpha_id), "%s", pTmpSimMailboxList.list[i].alpha_id);
+
+               if (pTmpSimMailboxList.list[i].num[0] == '+') {
+                       snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", &(pTmpSimMailboxList.list[i].num[1]));
                        mailboxInfo.ton = TAPI_SIM_TON_INTERNATIONAL;
                } else {
-                       snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", simMailboxList[simIndex].list[i].num);
+                       snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", pTmpSimMailboxList.list[i].num);
                }
                MSG_DEBUG("Mailbox number to save sim [%s]", mailboxInfo.num);
 
-               mailboxInfo.cc_id = simMailboxList[simIndex].list[i].cc_id;
-               mailboxInfo.ext1_id = simMailboxList[simIndex].list[i].ext1_id;
+               mailboxInfo.cc_id = pTmpSimMailboxList.list[i].cc_id;
+               mailboxInfo.ext1_id = pTmpSimMailboxList.list[i].ext1_id;
        }
 
-       struct tapi_handle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+       TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
 
        ret = tel_set_sim_mailbox_info(handle, &mailboxInfo, TapiEventSetMailboxInfo, (void*)bShowError);
 
@@ -1080,21 +1134,24 @@ void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
        if (getResultFromSim() == true) {
                MSG_DEBUG("######## Set mailbox info Success !!! #######");
        } else {
-               if(bShowError)
+               if (bShowError)
                        free(bShowError);
                THROW(MsgException::SMS_PLG_ERROR, "########  Set mailbox info Failed !!!#######");
                MSG_ERR("######## Set mailbox info Failed !!! #######");
        }
 
-       if(bShowError)
+       if (bShowError)
                free(bShowError);
 
+       MSG_END();
        return;
 }
 
 
-bool SmsPluginSetting::getVoiceMailInfo(struct tapi_handle *handle)
+bool SmsPluginSetting::getVoiceMailInfo(TapiHandle *handle)
 {
+       MutexLocker lock(mx);
+
        int ret = TAPI_API_SUCCESS;
 
        ret = tel_get_sim_mailbox_info(handle, TapiEventGetMailboxInfo, NULL);
@@ -1121,7 +1178,7 @@ void SmsPluginSetting::getMeImei(char *pImei)
 {
        int ret = TAPI_API_SUCCESS;
 
-       struct tapi_handle *handle = NULL;
+       TapiHandle *handle = NULL;
        handle = SmsPluginDSHandler::instance()->getTelHandle(1);
 
        if (handle == NULL) {
@@ -1173,24 +1230,35 @@ void SmsPluginSetting::setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count)
        int ret = TAPI_API_SUCCESS;
        TelSimMessageWaitingReq_t mwReq = {0,};
 
-       MSG_DEBUG("SET MWI INFO, CPHS? [%s]", simMwiInfo[simIndex].b_cphs?"Yes":"No");
+       simMwiInfoMap::iterator iter = simMwiInfo.find(simIndex);
+       if(iter == simMwiInfo.end()) {
+               MSG_DEBUG("IT is not present");
+               return;
+       }
+
+       MSG_DEBUG("IT is present");
+
+       SMS_SIM_MWI_INFO_S &pTmpsimMwiInfo = iter->second;
 
-       if (simMwiInfo[simIndex].b_cphs) {
+       MSG_DEBUG("SET MWI INFO, CPHS? [%s]", pTmpsimMwiInfo.b_cphs?"Yes":"No");
+
+       if (pTmpsimMwiInfo.b_cphs) {
+               MSG_DEBUG("b_cphs is set");
                if (type == MSG_MWI_VOICE_SMS)
-                       simMwiInfo[simIndex].cphs_mwi.b_voice1 = (count > 0 ? 1:0);
+                       pTmpsimMwiInfo.cphs_mwi.b_voice1 = (count > 0 ? 1:0);
                else if (type == MSG_MWI_VOICE2_SMS)
-                       simMwiInfo[simIndex].cphs_mwi.b_voice2 = (count > 0 ? 1:0);
+                       pTmpsimMwiInfo.cphs_mwi.b_voice2 = (count > 0 ? 1:0);
                else if (type == MSG_MWI_FAX_SMS)
-                       simMwiInfo[simIndex].cphs_mwi.b_fax = (count > 0 ? 1:0);
+                       pTmpsimMwiInfo.cphs_mwi.b_fax = (count > 0 ? 1:0);
                else {
                        MSG_DEBUG("There is no type [%d] in CPHS.", type);
                        return;
                }
 
-               mwReq.mw_data_u.cphs_mw.b_voice1 = simMwiInfo[simIndex].cphs_mwi.b_voice1;
-               mwReq.mw_data_u.cphs_mw.b_voice2 = simMwiInfo[simIndex].cphs_mwi.b_voice2;
-               mwReq.mw_data_u.cphs_mw.b_fax = simMwiInfo[simIndex].cphs_mwi.b_fax;
-               mwReq.mw_data_u.cphs_mw.b_data = simMwiInfo[simIndex].cphs_mwi.b_data;
+               mwReq.mw_data_u.cphs_mw.b_voice1 = pTmpsimMwiInfo.cphs_mwi.b_voice1;
+               mwReq.mw_data_u.cphs_mw.b_voice2 = pTmpsimMwiInfo.cphs_mwi.b_voice2;
+               mwReq.mw_data_u.cphs_mw.b_fax = pTmpsimMwiInfo.cphs_mwi.b_fax;
+               mwReq.mw_data_u.cphs_mw.b_data = pTmpsimMwiInfo.cphs_mwi.b_data;
 
                MSG_DEBUG("MWI voice 1 = [%d]", mwReq.mw_data_u.cphs_mw.b_voice1);
                MSG_DEBUG("MWI voice 2 = [%d]", mwReq.mw_data_u.cphs_mw.b_voice2);
@@ -1198,22 +1266,29 @@ void SmsPluginSetting::setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count)
                MSG_DEBUG("MWI data = [%d]", mwReq.mw_data_u.cphs_mw.b_data);
 
        } else {
+               MSG_DEBUG("b_cphs is not set");
+
                if (type == MSG_MWI_VOICE_SMS)
-                       simMwiInfo[simIndex].mwi_list.mw_info[0].voice_count = count;
+                       pTmpsimMwiInfo.mwi_list.mw_info[0].voice_count = count;
                else if (type == MSG_MWI_FAX_SMS)
-                       simMwiInfo[simIndex].mwi_list.mw_info[0].fax_count = count;
+                       pTmpsimMwiInfo.mwi_list.mw_info[0].fax_count = count;
                else if (type == MSG_MWI_EMAIL_SMS)
-                       simMwiInfo[simIndex].mwi_list.mw_info[0].email_count = count;
-               else // MSG_MWI_OTHER_SMS
-                       simMwiInfo[simIndex].mwi_list.mw_info[0].other_count = count;
-
-               mwReq.mw_data_u.mw.rec_index = simMwiInfo[simIndex].mwi_list.mw_info[0].rec_index;
-               mwReq.mw_data_u.mw.indicator_status = simMwiInfo[simIndex].mwi_list.mw_info[0].indicator_status;
-               mwReq.mw_data_u.mw.voice_count = simMwiInfo[simIndex].mwi_list.mw_info[0].voice_count;
-               mwReq.mw_data_u.mw.fax_count = simMwiInfo[simIndex].mwi_list.mw_info[0].fax_count;
-               mwReq.mw_data_u.mw.email_count = simMwiInfo[simIndex].mwi_list.mw_info[0].email_count;
-               mwReq.mw_data_u.mw.other_count = simMwiInfo[simIndex].mwi_list.mw_info[0].other_count;
-               mwReq.mw_data_u.mw.video_count = simMwiInfo[simIndex].mwi_list.mw_info[0].video_count;
+                       pTmpsimMwiInfo.mwi_list.mw_info[0].email_count = count;
+               else /* MSG_MWI_OTHER_SMS */
+                       pTmpsimMwiInfo.mwi_list.mw_info[0].other_count = count;
+
+               mwReq.mw_data_u.mw.rec_index = pTmpsimMwiInfo.mwi_list.mw_info[0].rec_index;
+
+               if (count <= 0)
+                       mwReq.mw_data_u.mw.indicator_status = 0x00;
+               else
+                       mwReq.mw_data_u.mw.indicator_status = 0x01;
+
+               mwReq.mw_data_u.mw.voice_count = pTmpsimMwiInfo.mwi_list.mw_info[0].voice_count;
+               mwReq.mw_data_u.mw.fax_count = pTmpsimMwiInfo.mwi_list.mw_info[0].fax_count;
+               mwReq.mw_data_u.mw.email_count = pTmpsimMwiInfo.mwi_list.mw_info[0].email_count;
+               mwReq.mw_data_u.mw.other_count = pTmpsimMwiInfo.mwi_list.mw_info[0].other_count;
+               mwReq.mw_data_u.mw.video_count = pTmpsimMwiInfo.mwi_list.mw_info[0].video_count;
 
                MSG_DEBUG("MWI record index = [%d]", mwReq.mw_data_u.mw.rec_index);
                MSG_DEBUG("MWI ind status = [%d]", mwReq.mw_data_u.mw.indicator_status);
@@ -1224,9 +1299,9 @@ void SmsPluginSetting::setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count)
                MSG_DEBUG("MWI video = [%d]", mwReq.mw_data_u.mw.video_count);
        }
 
-       mwReq.b_cphs = simMwiInfo[simIndex].b_cphs;
+       mwReq.b_cphs = pTmpsimMwiInfo.b_cphs;
 
-       struct tapi_handle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+       TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
 
        ret = tel_set_sim_messagewaiting_info(handle, &mwReq, TapiEventSetMwiInfo, NULL);
 
@@ -1240,7 +1315,7 @@ void SmsPluginSetting::setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count)
 }
 
 
-bool SmsPluginSetting::getMwiInfo(struct tapi_handle *handle)
+bool SmsPluginSetting::getMwiInfo(TapiHandle *handle)
 {
        MutexLocker lock(mx);
 
@@ -1266,7 +1341,7 @@ bool SmsPluginSetting::getMwiInfo(struct tapi_handle *handle)
 }
 
 
-bool SmsPluginSetting::getMsisdnInfo(struct tapi_handle *handle)
+bool SmsPluginSetting::getMsisdnInfo(TapiHandle *handle)
 {
        MutexLocker lock(mx);
 
@@ -1292,7 +1367,7 @@ bool SmsPluginSetting::getMsisdnInfo(struct tapi_handle *handle)
 }
 
 
-bool SmsPluginSetting::getSimServiceTable(struct tapi_handle *handle)
+bool SmsPluginSetting::getSimServiceTable(TapiHandle *handle)
 {
        MutexLocker lock(mx);
 
@@ -1373,7 +1448,7 @@ void SmsPluginSetting::setParamEvent(struct tapi_handle *handle, const MSG_SMSC_
 }
 
 
-bool SmsPluginSetting::getParamEvent(struct tapi_handle *handle, MSG_SMSC_DATA_S *pSmscData)
+bool SmsPluginSetting::getParamEvent(TapiHandle *handle, MSG_SMSC_DATA_S *pSmscData)
 {
        int ret = 0;
 
@@ -1400,8 +1475,10 @@ bool SmsPluginSetting::getParamEvent(struct tapi_handle *handle, MSG_SMSC_DATA_S
 }
 
 
-void SmsPluginSetting::setCbConfigEvent(struct tapi_handle *handle, const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess)
+void SmsPluginSetting::setCbConfigEvent(TapiHandle *handle, const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess)
 {
+       MSG_BEGIN();
+
        mx.lock();
 
        char keyName[MAX_VCONFKEY_NAME_LEN];
@@ -1409,28 +1486,53 @@ void SmsPluginSetting::setCbConfigEvent(struct tapi_handle *handle, const MSG_CB
        bTapiResult = bSuccess;
 
        int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-       memset(&cbOpt[simIndex], 0x00, sizeof(MSG_CBMSG_OPT_S));
 
        if (bTapiResult == true) {
                MSG_DEBUG("Success to get cb config data");
 
-               memcpy(&cbOpt[simIndex], pCbOpt, sizeof(MSG_CBMSG_OPT_S));
+               pair <int, MSG_CBMSG_OPT_S> newCbOpt (simIndex, *pCbOpt);
+               cbOptMap::iterator it = cbOpt.find(simIndex);
+
+               if (it == cbOpt.end()) {
+                       MSG_DEBUG("IT is not present");
+               } else {
+                       MSG_DEBUG("IT present");
+                       cbOpt.erase(it);
+               }
+               cbOpt.insert(newCbOpt);
 
                memset(keyName, 0x00, sizeof(keyName));
                snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
                if (MsgSettingSetInt(keyName, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
                        MSG_DEBUG("Error to set config data [%s]", keyName);
                }
+       } else {
+               MSG_DEBUG("Failed to get cb config data");
+
+               cbOptMap::iterator it = cbOpt.find(simIndex);
+
+               if (it == cbOpt.end()) {
+                       MSG_DEBUG("IT not present");
+                       MSG_CBMSG_OPT_S pTmpCbOpt;
+
+                       memset(&pTmpCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
+                       pair <int, MSG_CBMSG_OPT_S> newCbOpt (simIndex, pTmpCbOpt);
+
+                       cbOpt.insert(newCbOpt);
+               }
        }
 
        cv.signal();
 
        mx.unlock();
+       MSG_END();
 }
 
 
 bool SmsPluginSetting::getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt)
 {
+       MSG_BEGIN();
+
        int ret = 0;
 
        mx.lock();
@@ -1450,15 +1552,29 @@ bool SmsPluginSetting::getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt)
        memset(pCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
 
        if (bTapiResult == true) {
-               memcpy(pCbOpt, &cbOpt[simIndex], sizeof(MSG_CBMSG_OPT_S));
+               cbOptMap::iterator it = cbOpt.find(simIndex);
+
+               if (it == cbOpt.end()) {
+                       MSG_DEBUG("IT is not present");
+                       return false;
+               }
+
+               MSG_DEBUG("IT is present");
+
+               MSG_CBMSG_OPT_S &pTmpCbOpt = it->second;
+               memcpy(pCbOpt, &pTmpCbOpt, sizeof(MSG_CBMSG_OPT_S));
        }
 
+       MSG_END();
        return bTapiResult;
 }
 
 
-void SmsPluginSetting::setMailboxInfoEvent(struct tapi_handle *handle, SMS_SIM_MAILBOX_LIST_S *pMailboxList, bool bSuccess, bool bMbdn)
+void SmsPluginSetting::setMailboxInfoEvent(TapiHandle *handle, SMS_SIM_MAILBOX_LIST_S *pMailboxList, bool bSuccess, bool bMbdn)
 {
+       MSG_BEGIN();
+
+       MSG_DEBUG("bSuccess = %d, bMbdn = %d", bSuccess, bMbdn);
        mx.lock();
 
        bTapiResult = bSuccess;
@@ -1467,7 +1583,17 @@ void SmsPluginSetting::setMailboxInfoEvent(struct tapi_handle *handle, SMS_SIM_M
 
        bMbdnEnable[simIndex] = bMbdn;
 
-       memset(&simMailboxList[simIndex], 0x00, sizeof(SMS_SIM_MAILBOX_LIST_S));
+       /* print incoming mailbox list */
+       if (pMailboxList) {
+               MSG_DEBUG("Input list is count = %d ", pMailboxList->count);
+
+               for (int i = 0; i < pMailboxList->count; i++) {
+                       MSG_DEBUG("List index = %d", i);
+                       MSG_DEBUG("ton = %d, num = %s, alpha_id = %s", pMailboxList->list[i].ton, pMailboxList->list[i].num, pMailboxList->list[i].alpha_id);
+               }
+       } else {
+               MSG_INFO("pMailboxList is NULL");
+       }
 
        if (bTapiResult == true) {
                int i = 0;
@@ -1475,7 +1601,17 @@ void SmsPluginSetting::setMailboxInfoEvent(struct tapi_handle *handle, SMS_SIM_M
                char keyName[MAX_VCONFKEY_NAME_LEN];
 
                if (pMailboxList && pMailboxList->count > 0) {
-                       memcpy(&simMailboxList[simIndex], pMailboxList, sizeof(SMS_SIM_MAILBOX_LIST_S));
+                       pair <int, SMS_SIM_MAILBOX_LIST_S> newList(simIndex, *pMailboxList);
+
+                       smsSimMailboxListMap::iterator it = simMailboxList.find(simIndex);
+                       if (it == simMailboxList.end()) {
+                               MSG_DEBUG("IT not present !!!");
+                               simMailboxList.insert(newList);
+                       } else {
+                               MSG_DEBUG("IT present !!!");
+                               simMailboxList.erase(it);
+                               simMailboxList.insert(newList);
+                       }
 
                        /* Temp :: Save voicemail number with VOICE1 line number */
                        for (i = 0; i < pMailboxList->count ; i++) {
@@ -1497,18 +1633,22 @@ void SmsPluginSetting::setMailboxInfoEvent(struct tapi_handle *handle, SMS_SIM_M
                                }
                        }
 
+                       smsSimMailboxListMap::iterator iter = simMailboxList.find(simIndex);
+
+                       SMS_SIM_MAILBOX_LIST_S &pTmpMailboxList = iter->second;
+
                        char mailNumber[MAX_PHONE_NUMBER_LEN+1];
                        memset(mailNumber, 0x00 , sizeof(mailNumber));
 
                        MSG_SEC_DEBUG("Mailbox list[%d] ton=[%d], address=[%s], alpha_id=[%s]", \
-                                       i, simMailboxList[simIndex].list[i].ton, simMailboxList[simIndex].list[i].num, \
-                                       simMailboxList[simIndex].list[i].alpha_id);
+                                       i, pTmpMailboxList.list[i].ton, pTmpMailboxList.list[i].num, \
+                                       pTmpMailboxList.list[i].alpha_id);
 
-                       if (simMailboxList[simIndex].list[i].ton == MSG_TON_INTERNATIONAL && simMailboxList[simIndex].list[i].num[0] != '+') {
-                               snprintf(mailNumber, MAX_PHONE_NUMBER_LEN, "+%s", simMailboxList[simIndex].list[i].num);
-                               MSG_DEBUG("MSG_TON_INTERNATIONAL [%s]", mailNumber);
+                       if (pTmpMailboxList.list[i].ton == MSG_TON_INTERNATIONAL && pTmpMailboxList.list[i].num[0] != '+') {
+                               snprintf(mailNumber, sizeof(mailNumber), "+%s", pTmpMailboxList.list[i].num);
+                               MSG_WARN("MSG_TON_INTERNATIONAL [%s]", mailNumber);
                        } else {
-                               snprintf(mailNumber, MAX_PHONE_NUMBER_LEN, "%s", simMailboxList[simIndex].list[i].num);
+                               snprintf(mailNumber, sizeof(mailNumber), "%s", pTmpMailboxList.list[i].num);
                                MSG_DEBUG("[%s]", mailNumber);
                        }
 
@@ -1519,7 +1659,7 @@ void SmsPluginSetting::setMailboxInfoEvent(struct tapi_handle *handle, SMS_SIM_M
                                        MSG_DEBUG("MsgSettingSetString is failed!!");
                        }
 
-                       if (simMailboxList[simIndex].list[i].alpha_id[0] != '\0') {
+                       if (pTmpMailboxList.list[i].alpha_id[0] != '\0') {
                                char unpackAlphaId[MAX_SIM_XDN_ALPHA_ID_LEN+8];
                                int tmpLen = 0;
                                MSG_LANG_INFO_S langInfo = {0,};
@@ -1529,10 +1669,10 @@ void SmsPluginSetting::setMailboxInfoEvent(struct tapi_handle *handle, SMS_SIM_M
                                langInfo.bSingleShift = false;
                                langInfo.bLockingShift = false;
 
-                               tmpLen = strlen(simMailboxList[simIndex].list[i].alpha_id);
+                               tmpLen = strlen(pTmpMailboxList.list[i].alpha_id);
 
                                MsgTextConvert *textCvt = MsgTextConvert::instance();
-                               textCvt->convertGSM7bitToUTF8((unsigned char*)unpackAlphaId, sizeof(unpackAlphaId), (unsigned char*)simMailboxList[simIndex].list[i].alpha_id, tmpLen, &langInfo);
+                               textCvt->convertGSM7bitToUTF8((unsigned char*)unpackAlphaId, sizeof(unpackAlphaId), (unsigned char*)pTmpMailboxList.list[i].alpha_id, tmpLen, &langInfo);
 
                                MSG_DEBUG("UTF8 ALPHA_ID = [%s]", unpackAlphaId);
 
@@ -1542,23 +1682,31 @@ void SmsPluginSetting::setMailboxInfoEvent(struct tapi_handle *handle, SMS_SIM_M
                                        MSG_DEBUG("MsgSettingSetString is failed!!");
                        }
                }
+       } else {
+               /* insert empty list with sim index */
+               SMS_SIM_MAILBOX_LIST_S pDummySimMailboxList;
+
+               memset(&pDummySimMailboxList, 0x00, sizeof(SMS_SIM_MAILBOX_LIST_S));
+               pair <int, SMS_SIM_MAILBOX_LIST_S> newTmpList (simIndex, pDummySimMailboxList);
+               simMailboxList.insert(newTmpList);
        }
 
        cv.signal();
 
        mx.unlock();
+       MSG_END();
 }
 
 bool SmsPluginSetting::getMailboxInfoEvent()
 {
        int ret = 0;
 
-       mx.lock();
+       //mx.lock();
 
        bTapiResult = false;
        ret = cv.timedwait(mx.pMutex(), MAX_TAPI_SIM_API_TIMEOUT);
 
-       mx.unlock();
+       //mx.unlock();
 
        if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
@@ -1578,21 +1726,32 @@ void SmsPluginSetting::setMwiInfoEvent(struct tapi_handle *handle, SMS_SIM_MWI_I
 
        int index = SmsPluginDSHandler::instance()->getSimIndex(handle);
 
-       memset(&simMwiInfo[index], 0x00, sizeof(SMS_SIM_MWI_INFO_S));
-
        if (bTapiResult == true) {
                int mwiCnt = 0;
                char keyName[MAX_VCONFKEY_NAME_LEN];
 
-               memcpy(&simMwiInfo[index], pMwiInfo, sizeof(SMS_SIM_MWI_INFO_S));
+               pair <int, SMS_SIM_MWI_INFO_S> newList (index, *pMwiInfo);
+               simMwiInfoMap::iterator it = simMwiInfo.find(index);
+
+               if (it == simMwiInfo.end()) {
+                       MSG_DEBUG("IT not present");
+               } else {
+                       MSG_DEBUG("IT present");
+                       simMwiInfo.erase(it);
+               }
+               simMwiInfo.insert(newList);
+
+               simMwiInfoMap::iterator iter = simMwiInfo.find(index);
+
+               SMS_SIM_MWI_INFO_S &pTmpsimMwiInfoList = iter->second;
 
                /* Save MW count with VOICE line1 number */
-               if (simMwiInfo[index].b_cphs == true) {
-                       mwiCnt = simMwiInfo[index].cphs_mwi.b_voice1;
+               if (pTmpsimMwiInfoList.b_cphs == true) {
+                       mwiCnt = pTmpsimMwiInfoList.cphs_mwi.b_voice1;
                } else {
-                       mwiCnt = simMwiInfo[index].mwi_list.mw_info[0].voice_count; // Normal case
+                       mwiCnt = pTmpsimMwiInfoList.mwi_list.mw_info[0].voice_count; // Normal case
                }
-               // TODO :: Add operation for voice mail of line 2
+               /* TODO :: Add operation for voice mail of line 2 */
 
                memset(keyName, 0x00, sizeof(keyName));
                snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, index);
@@ -1604,6 +1763,21 @@ void SmsPluginSetting::setMwiInfoEvent(struct tapi_handle *handle, SMS_SIM_MWI_I
                if (mwiCnt > 0) {
                        deliverVoiceMsgNoti(index, mwiCnt);
                }
+       } else {
+               SMS_SIM_MWI_INFO_S pTmpsimMwiInfo;
+
+               memset(&pTmpsimMwiInfo, 0x00, sizeof(SMS_SIM_MWI_INFO_S));
+
+               pair <int, SMS_SIM_MWI_INFO_S> newList (index, pTmpsimMwiInfo);
+               simMwiInfoMap::iterator it = simMwiInfo.find(index);
+
+               if (it == simMwiInfo.end()) {
+                       MSG_DEBUG("IT not present");
+               } else {
+                       MSG_DEBUG("IT present");
+                       simMwiInfo.erase(it);
+               }
+               simMwiInfo.insert(newList);
        }
 
        cv.signal();
@@ -1673,7 +1847,7 @@ bool SmsPluginSetting::getResultFromSim()
 
        MSG_DEBUG("getResultFromSim() is called .");
 
-       //mx.lock(); //  Caller of this function MUST acquire the mutex before calling the TAPI API
+       //mx.lock(); /*  Caller of this function MUST acquire the mutex before calling the TAPI API */
 
        ret = cv.timedwait(mx.pMutex(), MAX_TAPI_SIM_API_TIMEOUT);
 
@@ -1692,28 +1866,27 @@ SMS_PID_T SmsPluginSetting::convertPid(MSG_SMS_PID_T pid)
 {
        SMS_PID_T retPid;
 
-       switch (pid)
-       {
-               case MSG_PID_TEXT :
-                       retPid = SMS_PID_NORMAL;
+       switch (pid) {
+       case MSG_PID_TEXT :
+               retPid = SMS_PID_NORMAL;
                break;
-               case MSG_PID_VOICE :
-                       retPid = SMS_PID_VOICE;
+       case MSG_PID_VOICE :
+               retPid = SMS_PID_VOICE;
                break;
-               case MSG_PID_FAX :
-                       retPid = SMS_PID_TELEX;
+       case MSG_PID_FAX :
+               retPid = SMS_PID_TELEX;
                break;
-               case MSG_PID_X400 :
-                       retPid = SMS_PID_x400;
+       case MSG_PID_X400 :
+               retPid = SMS_PID_x400;
                break;
-               case MSG_PID_ERMES :
-                       retPid = SMS_PID_ERMES;
+       case MSG_PID_ERMES :
+               retPid = SMS_PID_ERMES;
                break;
-               case MSG_PID_EMAIL :
-                       retPid = SMS_PID_EMAIL;
+       case MSG_PID_EMAIL :
+               retPid = SMS_PID_EMAIL;
                break;
-               default :
-                       retPid = SMS_PID_NORMAL;
+       default :
+               retPid = SMS_PID_NORMAL;
                break;
        }
 
@@ -1744,8 +1917,7 @@ void SmsPluginSetting::deliverVoiceMsgNoti(int simIndex, int mwiCnt)
        voiceNum = MsgSettingGetString(keyName);
 
        if (voiceNum) {
-               snprintf(msgInfo.addressList[0].addressVal, sizeof(msgInfo.addressList[0].addressVal),
-                               "%s", voiceNum);
+               snprintf(msgInfo.addressList[0].addressVal, sizeof(msgInfo.addressList[0].addressVal), "%s", voiceNum);
                free(voiceNum);
                voiceNum = NULL;
        }
@@ -1769,14 +1941,15 @@ void SmsPluginSetting::deliverVoiceMsgNoti(int simIndex, int mwiCnt)
                MSG_DEBUG("callbackIncoming is failed.");
 #else
        MsgInsertNotification(&msgInfo);
-       MsgChangePmState();
+       if (MsgCheckNotificationSettingEnable())
+               MsgChangePmState();
 #endif
 
        MSG_END();
 }
 
 
-void SmsPluginSetting::setSimChangeStatus(struct tapi_handle *handle, bool bInitializing)
+void SmsPluginSetting::setSimChangeStatus(TapiHandle *handle, bool bInitializing)
 {
        MSG_BEGIN();
 
@@ -1804,7 +1977,7 @@ void SmsPluginSetting::setSimChangeStatus(struct tapi_handle *handle, bool bInit
                                simStatus[simIndex] = MSG_SIM_STATUS_NORMAL;
                        }
 //                     tel_handle_list.push_back(handle);
-                       // Modified to call initSimInfo for SIM separately
+                       /* Modified to call initSimInfo for SIM separately */
                        MSG_DEBUG("calling initSimInfo");
                        if (pthread_create(&thd, NULL, &initSimInfo, handle) < 0) {
                                MSG_DEBUG("pthread_create() error");
index 4a73e7b..986cbb3 100755 (executable)
@@ -41,7 +41,7 @@ SmsPluginSimMsg* SmsPluginSimMsg::pInstance = NULL;
 
 SmsPluginSimMsg::SmsPluginSimMsg()
 {
-       // Initialize member variables
+       /* Initialize member variables */
        simMsgId = 0;
        delSimMsgId = -1;
        usedCnt = 0;
@@ -71,7 +71,7 @@ SmsPluginSimMsg* SmsPluginSimMsg::instance()
 }
 
 
-void SmsPluginSimMsg::initSimMessage(struct tapi_handle *handle)
+void SmsPluginSimMsg::initSimMessage(TapiHandle *handle)
 {
        MSG_BEGIN();
 
@@ -79,7 +79,7 @@ void SmsPluginSimMsg::initSimMessage(struct tapi_handle *handle)
        int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
 
        snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
-       // Set SIM count of vconf to 0
+       /* Set SIM count of vconf to 0 */
        if (MsgSettingSetInt(keyName, 0) != MSG_SUCCESS) {
                MSG_DEBUG("Error to set config data [%s]", keyName);
        }
@@ -98,12 +98,11 @@ void SmsPluginSimMsg::initSimMessage(struct tapi_handle *handle)
        int simIdList[MAX_SIM_SMS_NUM];
        int unreadSimMsg = 0;
 
-       for (int i = 0; i < tmpMsgCnt.usedCount; i++)
-       {
+       for (int i = 0; i < tmpMsgCnt.usedCount; i++) {
                memset(&tmpMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
                memset(simIdList, 0, sizeof(int) * MAX_SIM_SMS_NUM);
 
-               // Get SIM Msg
+               /* Get SIM Msg */
                if (getSimMsg(handle, tmpMsgCnt.indexList[i], &tmpMsgInfo, simIdList) == false)
                        continue;
 
@@ -123,7 +122,7 @@ void SmsPluginSimMsg::initSimMessage(struct tapi_handle *handle)
        MSG_DEBUG("Unread SIM message count = [%d]", unreadSimMsg);
 #ifndef MSG_NOTI_INTEGRATION
        if (unreadSimMsg > 0) {
-               MsgRefreshNotification(MSG_NOTI_TYPE_SIM, true, false);
+               MsgRefreshNotification(MSG_NOTI_TYPE_SIM, true, MSG_ACTIVE_NOTI_TYPE_NONE);
        }
 #endif
 
@@ -139,7 +138,7 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
 {
        bool bSimSst = true;
 
-       struct tapi_handle *handle = SmsPluginDSHandler::instance()->getTelHandle(pMsgInfo->sim_idx);
+       TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pMsgInfo->sim_idx);
        char keyName[MAX_VCONFKEY_NAME_LEN];
        memset(keyName, 0x00, sizeof(keyName));
        snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SERVICE_TABLE, pMsgInfo->sim_idx);
@@ -150,35 +149,32 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
        if (bSimSst == false)
                return MSG_ERR_STORE_RESTRICT;
 
-       // Reset Out Parameter
+       /* Reset Out Parameter */
        pSimIdList->count = 0;
 
        SMS_TPDU_S tpdu;
        memset(&tpdu, 0x00, sizeof(SMS_TPDU_S));
-       if(pMsgInfo->direction == MSG_DIRECTION_TYPE_MO)
-       {
+       if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO) {
                tpdu.tpduType = SMS_TPDU_SUBMIT;
                tpdu.data.submit.dcs.msgClass = SMS_MSG_CLASS_NONE;
                //SmsPluginTransport::instance()->setSmsSendOptions(&(tpdu.data.submit));
                tpdu.data.submit.vpf = SMS_VPF_NOT_PRESENT;
-       }
-       else
-       {
+               tpdu.data.submit.dcs.codingScheme = SMS_CHARSET_AUTO;
+       } else {
                tpdu.tpduType = SMS_TPDU_DELIVER;
                setSmsOptions(pMsgInfo, &(tpdu.data.deliver));
-               // Set TimeStamp
+               /* Set TimeStamp */
                convertTimeStamp(pMsgInfo, &(tpdu.data.deliver));
+               tpdu.data.deliver.dcs.codingScheme = SMS_CHARSET_AUTO;
        }
 
-       for(int i=0; i <pMsgInfo->nAddressCnt; ++i)
-       {
+       for (int i = 0; i <pMsgInfo->nAddressCnt; ++i) {
                SMS_SUBMIT_DATA_S submitData;
                memset(&submitData, 0x00, sizeof(SMS_SUBMIT_DATA_S));
                int bufLen = 0;
                char buf[MAX_TPDU_DATA_LEN];
 
-               if(pMsgInfo->direction == MSG_DIRECTION_TYPE_MO) // SUBMIT MSG
-               {
+               if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO) { /* SUBMIT MSG */
                        SmsPluginTransport::instance()->msgInfoToSubmitData(pMsgInfo, &submitData, &(tpdu.data.submit.dcs.codingScheme), i);
 
                        int addLen = strlen(submitData.destAddress.address);
@@ -194,7 +190,7 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
                                tpdu.data.submit.destAddress.address[MAX_ADDRESS_LEN] = '\0';
                        }
 
-               } else { // DELIVER MSG
+               } else { /* DELIVER MSG */
                        SmsPluginTransport::instance()->msgInfoToSubmitData(pMsgInfo, &submitData, &(tpdu.data.deliver.dcs.codingScheme), i);
 
                        int addLen = strlen(submitData.destAddress.address);
@@ -211,18 +207,16 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
                        }
                }
 
-               // Check sim message full.
-               if (checkSimMsgFull(pMsgInfo->sim_idx, submitData.segCount) == true)
-               {
+               /* Check sim message full. */
+               if (checkSimMsgFull(pMsgInfo->sim_idx, submitData.segCount) == true) {
                        MSG_DEBUG("SIM storage is full.");
                        MsgInsertTicker("Sim memory full. Delete some items", SMS_MESSAGE_SIM_MESSAGE_FULL, true, 0);
 
                        return MSG_ERR_SIM_STORAGE_FULL;
                }
 
-               if(submitData.segCount > 1)
-               {
-                       if(pMsgInfo->direction == MSG_DIRECTION_TYPE_MO){ // SUBMIT MSG
+               if (submitData.segCount > 1) {
+                       if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO){ /* SUBMIT MSG */
                                tpdu.data.submit.bHeaderInd = true;
                        } else {
                                tpdu.data.deliver.bHeaderInd = true;
@@ -230,9 +224,8 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
 
                }
 
-               for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++)
-               {
-                       if(pMsgInfo->direction == MSG_DIRECTION_TYPE_MO){
+               for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++) {
+                       if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO){
                                memcpy(&(tpdu.data.submit.userData), &(submitData.userData[segCnt]), sizeof(SMS_USERDATA_S));
                        } else {
                                memcpy(&(tpdu.data.deliver.userData), &(submitData.userData[segCnt]), sizeof(SMS_USERDATA_S));
@@ -240,26 +233,26 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
 
                        memset(buf, 0x00, sizeof(buf));
 
-                       // Encode SMS-DELIVER TPDU
+                       /* Encode SMS-DELIVER TPDU */
                        bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
 
-                       // Make Telephony Structure
+                       /* Make Telephony Structure */
                        TelSmsData_t simSmsData;
                        memset((void*)&simSmsData, 0x00, sizeof(simSmsData));
 
-                       // Set TPDU data
+                       /* Set TPDU data */
                        memcpy((void*)simSmsData.SmsData.szData, buf, bufLen);
 
                        simSmsData.SmsData.szData[bufLen] = 0;
                        simSmsData.SmsData.MsgLength = bufLen;
                        simSmsData.SmsData.format = TAPI_NETTEXT_NETTYPE_3GPP;
 
-                       if(pMsgInfo->direction == MSG_DIRECTION_TYPE_MT) { // MT messages
+                       if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MT) { /* MT messages */
                                if (pMsgInfo->bRead == true)
                                        simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_READ;
                                else
                                        simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNREAD;
-                       } else { // MO messages
+                       } else { /* MO messages */
                                if (pMsgInfo->networkStatus == MSG_NETWORK_SEND_SUCCESS)
                                        simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_SENT;
                                else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_SUCCESS)
@@ -270,17 +263,14 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
                                        simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNSENT;
                        }
 
-                       // Save SMS in SIM
+                       /* Save SMS in SIM */
                        int ret = 0;
 
                        ret = tel_write_sms_in_sim(handle, &simSmsData, TapiEventSaveSimMsg, NULL);
 
-                       if (ret == TAPI_API_SUCCESS)
-                       {
+                       if (ret == TAPI_API_SUCCESS) {
                                MSG_DEBUG("########  tel_write_sms_in_sim Success !!!#######");
-                       }
-                       else
-                       {
+                       } else {
                                MSG_DEBUG("########  tel_write_sms_in_sim Fail !!! return : [%d] #######", ret);
 
                                return MSG_ERR_PLUGIN_STORAGE;
@@ -294,8 +284,7 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
 
                        int usedCnt = 0;
 
-                       if (bResult == true)
-                       {
+                       if (bResult == true) {
                                MSG_DEBUG("########  Saving Msg was Successful !!! SIM ID : [%d] #######", SimId);
 
                                char keyName[MAX_VCONFKEY_NAME_LEN];
@@ -306,15 +295,11 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
                                usedCnt++;
 
                                if (MsgSettingSetInt(keyName, usedCnt) != MSG_SUCCESS)
-                               {
                                        MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
-                               }
 
                                pSimIdList->simId[pSimIdList->count] = SimId;
                                pSimIdList->count++;
-                       }
-                       else
-                       {
+                       } else {
                                MSG_DEBUG("########  Saving Msg was Failed !!! SIM ID : [%d] #######", SimId);
 
                                return MSG_ERR_PLUGIN_STORAGE;
@@ -335,7 +320,7 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
        int replaceSimId = -1;
        int replaceMsgId = 0;
 
-       struct tapi_handle *handle = SmsPluginDSHandler::instance()->getTelHandle(pMsgInfo->sim_idx);
+       TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pMsgInfo->sim_idx);
 
        char keyName[MAX_VCONFKEY_NAME_LEN];
        memset(keyName, 0x00, sizeof(keyName));
@@ -344,20 +329,19 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
                MSG_DEBUG("MsgSettingGetBool [%s] failed", keyName);
        /* No return, default value is true. */
 
-       if (bSimSst == false)
-       {
+       if (bSimSst == false) {
                SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
                return MSG_SUCCESS;
        }
 
-       // Reset Flag
+       /* Reset Flag */
        SMS_TPDU_S tpdu;
 
        tpdu.tpduType = SMS_TPDU_DELIVER;
 
        convertTimeStamp(pMsgInfo, &(tpdu.data.deliver));
 
-       // Set SMS TPDU Options
+       /* Set SMS TPDU Options */
        setSmsOptions(pMsgInfo, &(tpdu.data.deliver));
 
        SMS_SUBMIT_DATA_S submitData;
@@ -373,12 +357,11 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
                        replaceMsgId = 0;
        }
 
-       // Check SIM ID
-       if (replaceSimId < 0) { // Normal message type
-               // Check sim message full.
-               if (checkSimMsgFull(pMsgInfo->sim_idx, submitData.segCount) == true)
-               {
-                       MSG_DEBUG("SIM storage is full.");
+       /* Check SIM ID */
+       if (replaceSimId < 0) { /* Normal message type */
+               /* Check sim message full. */
+               if (checkSimMsgFull(pMsgInfo->sim_idx, submitData.segCount) == true) {
+                       MSG_ERR("SIM storage is full.");
 
                        SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_ERR_SIM_STORAGE_FULL);
 
@@ -400,14 +383,14 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
 
                if (submitData.segCount > 1)
                        tpdu.data.deliver.bHeaderInd = true;
-       } else { // Replace message type
+       } else { /* Replace message type */
                tapiRet = tel_delete_sms_in_sim(handle, replaceSimId, TapiEventDeleteSimMsg, NULL);
 
                if (tapiRet == TAPI_API_SUCCESS) {
                        MSG_DEBUG("########  tel_delete_sms_in_sim Success !!! #######");
 
                        simId = -1;
-                       if(getDelSimEvent(&simId) == true) {
+                       if (getDelSimEvent(&simId) == true) {
                                err = SmsPluginStorage::instance()->deleteSimMessage(pMsgInfo->sim_idx, replaceSimId);
                        }
                        MSG_DEBUG("tel_delete_sms_in_sim() : Err=[%d], Replace Sim Id=[%d], Result Sim id=[%d]", err, replaceSimId, simId);
@@ -418,7 +401,7 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
        }
 
        for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++) {
-               // Create TelSmsData_t data
+               /* Create TelSmsData_t data */
                TelSmsData_t simSmsData = {0,};
 
                if (submitData.segCount == 1) {
@@ -431,14 +414,15 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
 
                        memset(buf, 0x00, sizeof(buf));
 
-                       // Encode SMS-DELIVER TPDU
+                       /* Encode SMS-DELIVER TPDU */
                        bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
 
-                       // Set TPDU data
+                       /* Set TPDU data */
+                       int copyLen = (bufLen > TAPI_NETTEXT_SMDATA_SIZE_MAX) ? TAPI_NETTEXT_SMDATA_SIZE_MAX : bufLen;
                        memcpy((void*)simSmsData.SmsData.Sca, &simMsgDataInfo.sca, sizeof(simSmsData.SmsData.Sca));
-                       memcpy((void*)simSmsData.SmsData.szData, buf, bufLen);
-                       simSmsData.SmsData.szData[bufLen] = 0;
-                       simSmsData.SmsData.MsgLength = bufLen;
+                       memcpy((void*)simSmsData.SmsData.szData, buf, (size_t)copyLen);
+                       simSmsData.SmsData.szData[copyLen] = 0;
+                       simSmsData.SmsData.MsgLength = copyLen;
                }
 
                simSmsData.SmsData.format = TAPI_NETTEXT_NETTYPE_3GPP;
@@ -466,6 +450,7 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
                                return MSG_ERR_PLUGIN_STORAGE;
                        }
                }
+
                msg_sim_id_t retSimId;
                if (!getSimEvent(&retSimId))
                        return MSG_ERR_PLUGIN_STORAGE;
@@ -479,17 +464,13 @@ void SmsPluginSimMsg::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t S
 {
        int tapiRet = TAPI_API_SUCCESS;
 
-       struct tapi_handle *handle = SmsPluginDSHandler::instance()->getTelHandle(sim_idx);
+       TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(sim_idx);
        tapiRet = tel_delete_sms_in_sim(handle, (int)SimMsgId, TapiEventDeleteSimMsg, NULL);
 
        if (tapiRet == TAPI_API_SUCCESS)
-       {
                MSG_DEBUG("########  tel_delete_sms_in_sim Success !!! #######");
-       }
        else
-       {
                THROW(MsgException::SMS_PLG_ERROR, "########  tel_delete_sms_in_sim Fail !!! return : [%d] #######", tapiRet);
-       }
 
        int SimId = 0;
        bool bResult = false;
@@ -498,8 +479,7 @@ void SmsPluginSimMsg::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t S
 
        int usedCnt = 0, totalCnt = 0;
 
-       if (bResult == true)
-       {
+       if (bResult == true) {
                MSG_DEBUG("########  Deleting Msg was Successful !!! SIM ID : [%d] #######", SimId);
                char keyName[MAX_VCONFKEY_NAME_LEN];
                memset(keyName, 0x00, sizeof(keyName));
@@ -509,18 +489,13 @@ void SmsPluginSimMsg::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t S
                snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx);
                totalCnt = MsgSettingGetInt(keyName);
 
-               if (usedCnt == totalCnt)
-               {
+               if (usedCnt == totalCnt) {
                        tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, NULL, NULL);
 
                        if (tapiRet == TAPI_API_SUCCESS)
-                       {
                                MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
-                       }
                        else
-                       {
                                MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! return : [%d] #######", tapiRet);
-                       }
                }
 
                usedCnt--;
@@ -529,12 +504,8 @@ void SmsPluginSimMsg::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t S
                snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
 
                if (MsgSettingSetInt(keyName, usedCnt) != MSG_SUCCESS)
-               {
                        MSG_DEBUG("Error to set config data [%s]", keyName);
-               }
-       }
-       else
-       {
+       } else {
                THROW(MsgException::SMS_PLG_ERROR, "########  Deleting Msg was Failed !!! SIM ID : [%d] #######", SimId);
        }
 }
@@ -567,18 +538,14 @@ void SmsPluginSimMsg::setReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimM
        MSG_DEBUG("Sim Message ID [%d]", SimMsgId);
 
        int ret = TAPI_API_SUCCESS;
-       struct tapi_handle *handle = SmsPluginDSHandler::instance()->getTelHandle(sim_idx);
+       TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(sim_idx);
 
        ret = tel_set_sms_message_status(handle, (int)SimMsgId, TAPI_NETTEXT_STATUS_READ, TapiEventSetMsgStatus, (void *)&SimMsgId);
 
        if (ret == TAPI_API_SUCCESS)
-       {
                MSG_DEBUG("########  tel_set_sms_message_status Success !!! return : %d #######", ret);
-       }
        else
-       {
                THROW(MsgException::SMS_PLG_ERROR, "########  tel_set_sms_message_status Fail !!! return : %d #######", ret);
-       }
 
        msg_sim_id_t SimId = 0;
        bool bResult = false;
@@ -586,64 +553,46 @@ void SmsPluginSimMsg::setReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimM
        bResult = getSimEvent(&SimId);
 
        if (bResult == true)
-       {
                MSG_DEBUG("######## Setting Read Status was Successful !!!, sim id=[%d] #######", SimId);
-       }
        else
-       {
                THROW(MsgException::SMS_PLG_ERROR, "######## Setting Read Status was Failed !!! #######");
-       }
 }
 
 
-void SmsPluginSimMsg::getSimMsgCount(struct tapi_handle *handle, MSG_SIM_COUNT_S *pSimMsgCnt)
+void SmsPluginSimMsg::getSimMsgCount(TapiHandle *handle, MSG_SIM_COUNT_S *pSimMsgCnt)
 {
        int ret = TAPI_API_SUCCESS;
 
        ret = tel_get_sms_count(handle, TapiEventGetSimMsgCnt, NULL);
 
        if (ret == TAPI_API_SUCCESS)
-       {
                MSG_DEBUG("######## tel_get_sms_count() Success !!! #######");
-       }
        else
-       {
                THROW(MsgException::SMS_PLG_ERROR, "########  tel_get_sms_count() Fail !!! return : %d #######", ret);
-       }
 
        if (getSimMsgCntEvent(handle, pSimMsgCnt) == true)
-       {
                MSG_DEBUG("######## Get Sim Msg Count was Successful !!! #######");
-       }
        else
-       {
                THROW(MsgException::SMS_PLG_ERROR, "######## Get Sim Msg Count was Failed !!! #######");
-       }
 }
 
 
-bool SmsPluginSimMsg::getSimMsg(struct tapi_handle *handle, msg_sim_id_t SimMsgId, MSG_MESSAGE_INFO_S *pMsgInfo, int *simIdList)
+bool SmsPluginSimMsg::getSimMsg(TapiHandle *handle, msg_sim_id_t SimMsgId, MSG_MESSAGE_INFO_S *pMsgInfo, int *simIdList)
 {
        int ret = TAPI_API_SUCCESS;
 
        ret = tel_read_sms_in_sim(handle, SimMsgId, TapiEventGetSimMsg, simIdList);
 
-       if (ret == TAPI_API_SUCCESS)
-       {
+       if (ret == TAPI_API_SUCCESS) {
                MSG_DEBUG("######## tel_read_sms_in_sim() Success !!! Sim ID : [%d] #######", SimMsgId);
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("########  tel_read_sms_in_sim() Fail !!! return : %d #######", ret);
                return false;
        }
 
-       if (getSimMsgEvent(handle, pMsgInfo) == true)
-       {
+       if (getSimMsgEvent(handle, pMsgInfo) == true) {
                MSG_DEBUG("######## Get Sim Msg was Successful !!! #######");
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("######## Get Sim Msg was Failed !!! #######");
                return false;
        }
@@ -679,10 +628,10 @@ void SmsPluginSimMsg::convertTimeStamp(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_D
 {
        MSG_BEGIN();
 
-       // encode time stamp
+       /* encode time stamp */
        pDeliver->timeStamp.format = SMS_TIME_ABSOLUTE;
 
-       // encode absolute time
+       /* encode absolute time */
        struct tm timeinfo = {0,};
        tzset();
        localtime_r(&pMsgInfo->displayTime, &timeinfo);
@@ -712,32 +661,27 @@ void SmsPluginSimMsg::convertTimeStamp(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_D
 }
 
 
-void SmsPluginSimMsg::setSimMsgCntEvent(struct tapi_handle *handle, const MSG_SIM_COUNT_S *pSimMsgCnt)
+void SmsPluginSimMsg::setSimMsgCntEvent(TapiHandle *handle, const MSG_SIM_COUNT_S *pSimMsgCnt)
 {
        mx.lock();
 
-       MSG_DEBUG("Sim Message Count is %d.", pSimMsgCnt->usedCount);
+       MSG_INFO("Sim Message Count is %d.", pSimMsgCnt->usedCount);
 
        int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
        char keyName[MAX_VCONFKEY_NAME_LEN]= {0,};
 
-       for (int i=0; i < pSimMsgCnt->usedCount; i++)
-       {
+       for (int i = 0; i < pSimMsgCnt->usedCount; i++) {
                MSG_DEBUG("Sim Message Index is %d.", pSimMsgCnt->indexList[i]);
        }
 
        snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
        if (MsgSettingSetInt(keyName, pSimMsgCnt->usedCount) != MSG_SUCCESS)
-       {
-               MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
-       }
+               MSG_ERR("Error to set config data [%s]", SIM_USED_COUNT);
 
        memset(keyName, 0, sizeof(keyName));
        snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx);
        if (MsgSettingSetInt(keyName, (int)pSimMsgCnt->totalCount) != MSG_SUCCESS)
-       {
-               MSG_DEBUG("Error to set config data [%s]", SIM_TOTAL_COUNT);
-       }
+               MSG_ERR("Error to set config data [%s]", SIM_TOTAL_COUNT);
 
        memset(&simMsgCnt, 0x00, sizeof(MSG_SIM_COUNT_S));
        memcpy(&simMsgCnt, pSimMsgCnt, sizeof(MSG_SIM_COUNT_S));
@@ -748,7 +692,7 @@ void SmsPluginSimMsg::setSimMsgCntEvent(struct tapi_handle *handle, const MSG_SI
 }
 
 
-bool SmsPluginSimMsg::getSimMsgCntEvent(struct tapi_handle *handle, MSG_SIM_COUNT_S *pSimMsgCnt)
+bool SmsPluginSimMsg::getSimMsgCntEvent(TapiHandle *handle, MSG_SIM_COUNT_S *pSimMsgCnt)
 {
        int ret = 0;
 
@@ -758,9 +702,8 @@ bool SmsPluginSimMsg::getSimMsgCntEvent(struct tapi_handle *handle, MSG_SIM_COUN
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
-               MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+       if (ret == ETIMEDOUT) {
+               MSG_ERR("WARNING: TAPI callback TIME-OUT");
                return false;
        }
 
@@ -769,7 +712,7 @@ bool SmsPluginSimMsg::getSimMsgCntEvent(struct tapi_handle *handle, MSG_SIM_COUN
        return true;
 }
 
-void SmsPluginSimMsg::setSimMsgEvent(struct tapi_handle *handle, const MSG_MESSAGE_INFO_S *pMsgInfo, bool bSuccess)
+void SmsPluginSimMsg::setSimMsgEvent(TapiHandle *handle, const MSG_MESSAGE_INFO_S *pMsgInfo, bool bSuccess)
 {
        mx.lock();
 
@@ -778,8 +721,7 @@ void SmsPluginSimMsg::setSimMsgEvent(struct tapi_handle *handle, const MSG_MESSA
        memset(&simMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
        memset(&simAddrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
 
-       if (bTapiResult  == true)
-       {
+       if (bTapiResult  == true) {
                MSG_DEBUG("Success to get sim msg - Id : [%d]", pMsgInfo->msgId);
 
                memcpy(&simMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
@@ -793,7 +735,7 @@ void SmsPluginSimMsg::setSimMsgEvent(struct tapi_handle *handle, const MSG_MESSA
 }
 
 
-bool SmsPluginSimMsg::getSimMsgEvent(struct tapi_handle *handle, MSG_MESSAGE_INFO_S *pMsgInfo)
+bool SmsPluginSimMsg::getSimMsgEvent(TapiHandle *handle, MSG_MESSAGE_INFO_S *pMsgInfo)
 {
        int ret = 0;
 
@@ -804,16 +746,14 @@ bool SmsPluginSimMsg::getSimMsgEvent(struct tapi_handle *handle, MSG_MESSAGE_INF
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
+       if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
                return false;
        }
 
        memset(pMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
 
-       if (bTapiResult == true)
-       {
+       if (bTapiResult == true) {
                memcpy(pMsgInfo, &simMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
                pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)calloc(1, sizeof(MSG_ADDRESS_INFO_S));
                memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
@@ -826,7 +766,7 @@ bool SmsPluginSimMsg::getSimMsgEvent(struct tapi_handle *handle, MSG_MESSAGE_INF
 }
 
 
-void SmsPluginSimMsg::setSaveSimMsgEvent(struct tapi_handle *handle, int simId, int result)
+void SmsPluginSimMsg::setSaveSimMsgEvent(TapiHandle *handle, int simId, int result)
 {
        msg_error_t err = MSG_SUCCESS;
 
@@ -868,7 +808,7 @@ void SmsPluginSimMsg::setSaveSimMsgEvent(struct tapi_handle *handle, int simId,
 }
 
 
-void SmsPluginSimMsg::setSaveClass2MsgEvent(struct tapi_handle *handle, int simId, int result, MSG_MESSAGE_INFO_S *pMsgInfo)
+void SmsPluginSimMsg::setSaveClass2MsgEvent(TapiHandle *handle, int simId, int result, MSG_MESSAGE_INFO_S *pMsgInfo)
 {
        msg_error_t err = MSG_SUCCESS;
 //     int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
@@ -905,9 +845,7 @@ void SmsPluginSimMsg::setSaveClass2MsgEvent(struct tapi_handle *handle, int simI
                        err = SmsPluginEventHandler::instance()->callbackMsgIncoming(pMsgInfo);
 
                        if (err != MSG_SUCCESS)
-                       {
                                MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
-                       }
                }
 
                if (isNewSimMsg == true) {
@@ -918,9 +856,7 @@ void SmsPluginSimMsg::setSaveClass2MsgEvent(struct tapi_handle *handle, int simI
                        usedCnt++;
 
                        if (MsgSettingSetInt(keyName, usedCnt) != MSG_SUCCESS)
-                       {
                                MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
-                       }
                }
 
                if (simMsgDataInfo.totalSegment >= 1 && simIdList[simMsgDataInfo.totalSegment-1] != 0) {
@@ -933,7 +869,7 @@ void SmsPluginSimMsg::setSaveClass2MsgEvent(struct tapi_handle *handle, int simI
                        err = MSG_ERR_UNKNOWN;
        }
 
-       // Send Deliver Report
+       /* Send Deliver Report */
        SmsPluginTransport::instance()->sendDeliverReport(handle, err);
 }
 
@@ -962,8 +898,7 @@ bool SmsPluginSimMsg::getSimEvent(msg_sim_id_t *pSimId)
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
+       if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
                return false;
        }
@@ -1001,8 +936,7 @@ bool SmsPluginSimMsg::getDelSimEvent(int *pSimId)
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
+       if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
                return false;
        }
index 5f42011..c1e41b0 100755 (executable)
@@ -159,7 +159,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf
                        MSG_DEBUG("Query Failed : [%s]", sqlQuery);
                        return MSG_ERR_DB_EXEC;
                }
-       } else if(pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_EXPIRED) {
+       } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_EXPIRED) {
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
                                MSGFW_SMS_REPORT_TABLE_NAME, 0, (int)pMsgInfo->displayTime, msgId, normalNum);
@@ -169,7 +169,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf
                        MSG_DEBUG("Query Failed : [%s]", sqlQuery);
                        return MSG_ERR_DB_EXEC;
                }
-       } else if(pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_PENDING) {
+       } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_PENDING) {
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
                                MSGFW_SMS_REPORT_TABLE_NAME, 3, (int)pMsgInfo->displayTime, msgId, normalNum);
@@ -179,7 +179,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf
                        MSG_DEBUG("Query Failed : [%s]", sqlQuery);
                        return MSG_ERR_DB_EXEC;
                }
-       } else if(pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_FAIL) {
+       } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_FAIL) {
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
                                MSGFW_SMS_REPORT_TABLE_NAME, 8, (int)pMsgInfo->displayTime, msgId, normalNum);
@@ -332,63 +332,10 @@ msg_error_t SmsPluginStorage::addSimMessage(MSG_MESSAGE_INFO_S *pSimMsgInfo, int
 
        char sqlQuery[MAX_QUERY_LEN+1];
 
-//     dbHandle->beginTrans();
-
-# if 0
-       msg_message_id_t msgId = 0;
-       msg_thread_id_t convId = 0;
-
-       err = MsgStoAddAddress(dbHandle, pSimMsgInfo, &convId);
-
-       if (err != MSG_SUCCESS) {
-               dbHandle->endTrans(false);
-               return err;
-       }
-
-       pSimMsgInfo->threadId = convId;
-
-       err = dbHandle->getRowId(MSGFW_MESSAGE_TABLE_NAME, &msgId);
-
-       if (err != MSG_SUCCESS) {
-               dbHandle->endTrans(false);
-               return err;
-       }
-
-       //simId = pSimMsgInfo->msgId;
-       pSimMsgInfo->msgId = msgId;
-
-       /**  Add Message */
-       memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
-       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d, %d, %ld, %d, %d, %d, %d, %d, %d, %ld, %d, ?, '', '', ?, 0, 0, 0);",
-                       MSGFW_MESSAGE_TABLE_NAME, msgId, convId, pSimMsgInfo->folderId, pSimMsgInfo->storageId,
-                       pSimMsgInfo->msgType.mainType, pSimMsgInfo->msgType.subType, pSimMsgInfo->displayTime, pSimMsgInfo->dataSize,
-                       pSimMsgInfo->networkStatus, pSimMsgInfo->bRead, pSimMsgInfo->bProtected, pSimMsgInfo->priority,
-                       pSimMsgInfo->direction, 0, pSimMsgInfo->bBackup);
-
-       MSG_DEBUG("QUERY : %s", sqlQuery);
-
-       if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
-               dbHandle->endTrans(false);
-               return MSG_ERR_DB_PREPARE;
-       }
-
-       dbHandle->bindText(pSimMsgInfo->subject, 1);
-
-       dbHandle->bindText(pSimMsgInfo->msgText, 2);
-
-       if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
-               dbHandle->endTrans(false);
-               return MSG_ERR_DB_STEP;
-       }
-
-       dbHandle->finalizeQuery();
-#endif
-       if(simIdList) {
+       if (simIdList) {
                MSG_DEBUG("simIdList exist.");
-               for(int i=0; i < MAX_SIM_SMS_NUM; ++i)
-               {
-                       if(simIdList[i]) {
+               for (int i = 0; i < MAX_SIM_SMS_NUM; ++i) {
+                       if (simIdList[i]) {
                                simId = simIdList[i] - 1;
                                memset(sqlQuery, 0x00, sizeof(sqlQuery));
                                snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d);",
@@ -397,16 +344,14 @@ msg_error_t SmsPluginStorage::addSimMessage(MSG_MESSAGE_INFO_S *pSimMsgInfo, int
                                MSG_DEBUG("QUERY : %s", sqlQuery);
 
                                if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
-//                                     dbHandle->endTrans(false);
                                        return MSG_ERR_DB_EXEC;
                                }
-                       } else
+                       } else {
                                break;
+                       }
                }
        }
 
-//     dbHandle->endTrans(true);
-
        return err;
 
 }
@@ -474,7 +419,7 @@ msg_error_t SmsPluginStorage::checkMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
                        pMsgInfo->folderId = 0;
                        err = MSG_SUCCESS;
                }
-               else if(pMsgInfo->msgType.classType == MSG_CLASS_2 &&
+               else if (pMsgInfo->msgType.classType == MSG_CLASS_2 &&
                                (pMsgInfo->msgType.subType == MSG_NORMAL_SMS || pMsgInfo->msgType.subType == MSG_REJECT_SMS)) {
                        err = addClass2Message(pMsgInfo);
                }
@@ -708,7 +653,7 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
                }
        }
 
-       MsgRefreshAllNotification(true, false, false);
+       MsgRefreshAllNotification(true, false, MSG_ACTIVE_NOTI_TYPE_NONE);
 
        return MSG_SUCCESS;
 }
@@ -719,6 +664,19 @@ msg_error_t SmsPluginStorage::addClass2Message(MSG_MESSAGE_INFO_S *pMsgInfo)
        MSG_BEGIN();
 
        msg_error_t err = MSG_SUCCESS;
+       bool bSimSst = true;
+
+       char keyName[MAX_VCONFKEY_NAME_LEN];
+       memset(keyName, 0x00, sizeof(keyName));
+       snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SERVICE_TABLE, pMsgInfo->sim_idx);
+
+       if (MsgSettingGetBool(keyName, &bSimSst) != MSG_SUCCESS) {
+               MSG_ERR("MsgSettingGetBool [%s] failed", keyName);
+       }
+
+       if (bSimSst == false) {
+               return MSG_ERR_SIM_STORAGE_FULL;
+       }
        pthread_t thd;
        memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
        memset(&addrInfo, 0, sizeof(MSG_ADDRESS_INFO_S));
@@ -726,12 +684,9 @@ msg_error_t SmsPluginStorage::addClass2Message(MSG_MESSAGE_INFO_S *pMsgInfo)
        memcpy(&addrInfo, pMsgInfo->addressList, sizeof(MSG_ADDRESS_INFO_S));
        msgInfo.addressList = &addrInfo;
 
-       if(pthread_create(&thd, NULL, &class2_thread, (void *)&msgInfo) < 0)
-       {
+       if (pthread_create(&thd, NULL, &class2_thread, (void *)&msgInfo) < 0)
                MSG_DEBUG("pthread_create() error");
 
-       }
-       //pthread_join(thd, (void **)&err);
        pthread_detach(thd);
 
 #if 0
@@ -761,7 +716,7 @@ void* SmsPluginStorage::class2_thread(void *data)
        if (err == MSG_SUCCESS) {
                MSG_DEBUG("Success to saveClass2Message.");
        } else {
-               MSG_DEBUG("Fail to saveClass2Message : [%d]", err);
+               MSG_ERR("Fail to saveClass2Message : [%d]", err);
        }
 
        MSG_END();
@@ -852,28 +807,29 @@ msg_error_t SmsPluginStorage::addSmsSendOption(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN
                MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSendOptInfo->bDeliverReq);
                MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSendOptInfo->option.smsSendOptInfo.bReplyPath);
 
-//             if (pSendOptInfo->bDeliverReq || pSendOptInfo->option.smsSendOptInfo.bReplyPath) {
-//                     pSendOptInfo->bSetting = true;
-                       MsgSettingGetBool(MSG_KEEP_COPY, &pSendOptInfo->bKeepCopy);
-//             }
+               MsgSettingGetBool(MSG_KEEP_COPY, &pSendOptInfo->bKeepCopy);
        }
 
-//     if (pSendOptInfo->bSetting == true) {
-               MsgDbHandler *dbHandle = getDbHandle();
+       MsgDbHandler *dbHandle = getDbHandle();
 
-               char sqlQuery[MAX_QUERY_LEN+1];
+       char sqlQuery[MAX_QUERY_LEN+1];
 
-               memset(sqlQuery, 0x00, sizeof(sqlQuery));
-               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d);",
-                               MSGFW_SMS_SENDOPT_TABLE_NAME, pMsg->msgId, pSendOptInfo->bDeliverReq,
-                               pSendOptInfo->bKeepCopy, pSendOptInfo->option.smsSendOptInfo.bReplyPath, pMsg->encodeType);
+       dbHandle->beginTrans();
 
-               MSG_DEBUG("Query = [%s]", sqlQuery);
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d);",
+                       MSGFW_SMS_SENDOPT_TABLE_NAME, pMsg->msgId, pSendOptInfo->bDeliverReq,
+                       pSendOptInfo->bKeepCopy, pSendOptInfo->option.smsSendOptInfo.bReplyPath, pMsg->encodeType);
 
-               if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
-                       err = MSG_ERR_DB_EXEC;
-               }
-//     }
+       MSG_DEBUG("Query = [%s]", sqlQuery);
+
+       if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+               MSG_ERR("execQuery() is failed");
+               dbHandle->endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle->endTrans(true);
 
        MSG_END();
 
@@ -992,13 +948,13 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou
        err = dbHandle->getTable(sqlQuery, &rowCnt, &index);
        MSG_DEBUG("rowCnt: %d", rowCnt);
 
-       if (err == MSG_ERR_DB_NORECORD) {
-               dbHandle->freeTable();
-               return MSG_SUCCESS;
-       }
-       else if ( err != MSG_SUCCESS) {
+       if (err != MSG_SUCCESS) {
                dbHandle->freeTable();
-               return err;
+
+               if (err == MSG_ERR_DB_NORECORD)
+                       return MSG_SUCCESS;
+               else
+                       return err;
        }
 
        char contentType[MAX_WAPPUSH_CONTENT_TYPE_LEN + 1] = {0,};
@@ -1019,12 +975,12 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou
 
                //MSG_DEBUG("content_type: %s, app_id: %s", content_type, app_id);
                _content_type = strcasestr(pPushHeader, contentType);
-               if(_content_type) {
+               if (_content_type) {
                        _app_id = strcasestr(pPushHeader, appId);
-                       if(appcode)
+                       if (appcode)
                                default_appcode = appcode;
 
-                       if(_app_id) {
+                       if (_app_id) {
                                PUSH_APPLICATION_INFO_S pInfo = {0, };
                                pInfo.appcode = appcode;
                                MSG_SEC_DEBUG("appcode: %d, app_id: %s", pInfo.appcode, appId);
@@ -1037,9 +993,8 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou
                }
        }
 
-       if(!found && default_appcode != SMS_WAP_APPLICATION_LBS)
-       {
-               // perform default action.
+       if (!found && default_appcode != SMS_WAP_APPLICATION_LBS) {
+               /* perform default action. */
                PUSH_APPLICATION_INFO_S pInfo = {0, };
                pInfo.appcode = default_appcode;
                memset(appId, 0, MAX_WAPPUSH_ID_LEN + 1);
@@ -1057,14 +1012,13 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou
 msg_error_t SmsPluginStorage::getnthPushEvent(int index, int *appcode)
 {
        msg_error_t err = MSG_SUCCESS;
-       if((unsigned int)index > pushAppInfoList.size() - 1)
+       if ((unsigned int)index > pushAppInfoList.size() - 1)
                return MSG_ERR_INVALID_PARAMETER;
 
        std::list<PUSH_APPLICATION_INFO_S>::iterator it = pushAppInfoList.begin();
        int count = 0;
-       for (; it != pushAppInfoList.end(); it++)
-       {
-               if(index == count){
+       for (; it != pushAppInfoList.end(); it++) {
+               if (index == count){
                        *appcode = it->appcode;
                        break;
                }
@@ -1085,3 +1039,70 @@ msg_error_t SmsPluginStorage::releasePushEvent()
 
        return err;
 }
+
+
+msg_error_t SmsPluginStorage::updateSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+       MSG_BEGIN();
+       MsgDbHandler *dbHandle = getDbHandle();
+       char sqlQuery[MAX_QUERY_LEN+1] = {0,};
+       msg_thread_id_t convId = 0;
+
+       dbHandle->beginTrans();
+
+       if (pMsgInfo->nAddressCnt > 0) {
+               pMsgInfo->threadId = 0;
+               msg_error_t err = MsgStoAddAddress(dbHandle, pMsgInfo, &convId);
+
+               if (err != MSG_SUCCESS) {
+                       dbHandle->endTrans(false);
+                       return err;
+               }
+       }
+
+       int fileSize = 0;
+
+       char *pFileData = NULL;
+       unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter);
+
+       /* Get File Data */
+       if (pMsgInfo->bTextSms == false) {
+               if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false) {
+                       dbHandle->endTrans(false);
+                       return MSG_ERR_STORAGE_ERROR;
+               }
+       }
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET CONV_ID = %d, FOLDER_ID = %d, STORAGE_ID = %d, MAIN_TYPE = %d, SUB_TYPE = %d, \
+                       DISPLAY_TIME = %lu, DATA_SIZE = %d, NETWORK_STATUS = %d, READ_STATUS = %d, PROTECTED = %d, PRIORITY = %d, MSG_DIRECTION = %d, \
+                       BACKUP = %d, SUBJECT = ?, MSG_TEXT = ?, SIM_INDEX = %d \
+                       WHERE MSG_ID = %d;",
+                       MSGFW_MESSAGE_TABLE_NAME, convId, pMsgInfo->folderId, pMsgInfo->storageId, pMsgInfo->msgType.mainType, pMsgInfo->msgType.subType, pMsgInfo->displayTime, pMsgInfo->dataSize,
+                       pMsgInfo->networkStatus, pMsgInfo->bRead, pMsgInfo->bProtected, pMsgInfo->priority, pMsgInfo->direction, pMsgInfo->bBackup, pMsgInfo->sim_idx, pMsgInfo->msgId);
+
+       if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
+               dbHandle->endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle->bindText(pMsgInfo->subject, 1);
+
+       if (pMsgInfo->bTextSms == false)
+               dbHandle->bindText(pFileData, 2);
+       else
+               dbHandle->bindText(pMsgInfo->msgText, 2);
+
+       MSG_DEBUG("%s", sqlQuery);
+
+       if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
+               dbHandle->finalizeQuery();
+               dbHandle->endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       dbHandle->finalizeQuery();
+       dbHandle->endTrans(true);
+
+       MSG_END();
+       return MSG_SUCCESS;
+}
index 789f14b..50e1abe 100755 (executable)
@@ -48,22 +48,21 @@ int SmsPluginTpduCodec::encodeTpdu(const SMS_TPDU_S *pSmsTpdu, char *pTpdu)
 {
        int tpduLen = 0;
 
-       switch (pSmsTpdu->tpduType)
-       {
-               case SMS_TPDU_SUBMIT:
-                       tpduLen = encodeSubmit(&(pSmsTpdu->data.submit), pTpdu);
+       switch (pSmsTpdu->tpduType) {
+       case SMS_TPDU_SUBMIT:
+               tpduLen = encodeSubmit(&(pSmsTpdu->data.submit), pTpdu);
                break;
 
-               case SMS_TPDU_DELIVER:
-                       tpduLen = encodeDeliver(&(pSmsTpdu->data.deliver), pTpdu);
+       case SMS_TPDU_DELIVER:
+               tpduLen = encodeDeliver(&(pSmsTpdu->data.deliver), pTpdu);
                break;
 
-               case SMS_TPDU_DELIVER_REP:
-                       tpduLen = encodeDeliverReport(&(pSmsTpdu->data.deliverRep), pTpdu);
+       case SMS_TPDU_DELIVER_REP:
+               tpduLen = encodeDeliverReport(&(pSmsTpdu->data.deliverRep), pTpdu);
                break;
 
-               case SMS_TPDU_STATUS_REP:
-                       tpduLen = encodeStatusReport(&(pSmsTpdu->data.statusRep), pTpdu);
+       case SMS_TPDU_STATUS_REP:
+               tpduLen = encodeStatusReport(&(pSmsTpdu->data.statusRep), pTpdu);
                break;
        }
 
@@ -77,21 +76,20 @@ int SmsPluginTpduCodec::decodeTpdu(const unsigned char *pTpdu, int TpduLen, SMS_
 
        char mti = pTpdu[0] & 0x03;
 
-       switch (mti)
-       {
-               case 0x00:
-                       pSmsTpdu->tpduType = SMS_TPDU_DELIVER;
-                       decodeLen = decodeDeliver(pTpdu, TpduLen, &(pSmsTpdu->data.deliver));
+       switch (mti) {
+       case 0x00:
+               pSmsTpdu->tpduType = SMS_TPDU_DELIVER;
+               decodeLen = decodeDeliver(pTpdu, TpduLen, &(pSmsTpdu->data.deliver));
                break;
 
-               case 0x01:
-                       pSmsTpdu->tpduType = SMS_TPDU_SUBMIT;
-                       decodeLen = decodeSubmit(pTpdu, TpduLen, &(pSmsTpdu->data.submit));
+       case 0x01:
+               pSmsTpdu->tpduType = SMS_TPDU_SUBMIT;
+               decodeLen = decodeSubmit(pTpdu, TpduLen, &(pSmsTpdu->data.submit));
                break;
 
-               case 0x02:
-                       pSmsTpdu->tpduType = SMS_TPDU_STATUS_REP;
-                       decodeLen = decodeStatusReport(pTpdu, TpduLen, &(pSmsTpdu->data.statusRep));
+       case 0x02:
+               pSmsTpdu->tpduType = SMS_TPDU_STATUS_REP;
+               decodeLen = decodeStatusReport(pTpdu, TpduLen, &(pSmsTpdu->data.statusRep));
                break;
        }
 
@@ -112,78 +110,75 @@ int SmsPluginTpduCodec::encodeSubmit(const SMS_SUBMIT_S *pSubmit, char *pTpdu)
        char* vpTime = NULL;
        unique_ptr<char*, void(*)(char**)> vpBuf(&vpTime, unique_ptr_deleter);
 
-       //TP-MTI
+       /* TP-MTI */
        pTpdu[offset] = 0x01;
 
-       //TP-RD
-       if(pSubmit->bRejectDup == true)
+       /* TP-RD */
+       if (pSubmit->bRejectDup == true)
                pTpdu[offset] |= 0x04;
 
-       //TP-VPF
-       switch (pSubmit->vpf)
-       {
-               case SMS_VPF_NOT_PRESENT:
-                       break;
-               case SMS_VPF_ENHANCED:
-                       pTpdu[offset] |= 0x08;
-                       break;
-               case SMS_VPF_RELATIVE:
-                       pTpdu[offset] |= 0x10;
-                       break;
-               case SMS_VPF_ABSOLUTE:
-                       pTpdu[offset] |= 0x18;
-                       break;
-               default:
-                       break;
+       /* TP-VPF */
+       switch (pSubmit->vpf) {
+       case SMS_VPF_NOT_PRESENT:
+               break;
+       case SMS_VPF_ENHANCED:
+               pTpdu[offset] |= 0x08;
+               break;
+       case SMS_VPF_RELATIVE:
+               pTpdu[offset] |= 0x10;
+               break;
+       case SMS_VPF_ABSOLUTE:
+               pTpdu[offset] |= 0x18;
+               break;
+       default:
+               break;
        }
 
-       //TP-SRR
+       /* TP-SRR */
        if (pSubmit->bStatusReport == true)
                pTpdu[offset] |= 0x20;
 
        MSG_DEBUG("TP-SRR pSubmit->bStatusReport : %d.", pSubmit->bStatusReport);
 
-       //TP-UDHI
+       /* TP-UDHI */
        if (pSubmit->bHeaderInd == true)
                pTpdu[offset] |= 0x40;
 
-       //TP-RP
+       /* TP-RP */
        if (pSubmit->bReplyPath == true)
                pTpdu[offset] |= 0x80;
 
        offset++;
 
-       //TP-MR
+       /* TP-MR */
        pTpdu[offset++] = pSubmit->msgRef;
 
        MSG_DEBUG("TP-MR pSubmit->msgRef : %d.", pSubmit->msgRef);
 
-       //TP-DA
+       /* TP-DA */
        length = SmsPluginParamCodec::encodeAddress(&pSubmit->destAddress, &address);
        memcpy(&(pTpdu[offset]), address, length);
        offset += length;
 
        MSG_DEBUG("TP-DA length : %d.", length);
 
-       //TP-PID
+       /* TP-PID */
        pTpdu[offset++] = pSubmit->pid;
 
        MSG_DEBUG("TP-PID pSubmit->pid : %d.", pSubmit->pid);
 
-       //TP-DCS
+       /* TP-DCS */
        length = SmsPluginParamCodec::encodeDCS(&pSubmit->dcs, &dcs);
        memcpy(&(pTpdu[offset]), dcs, length);
        offset += length;
 
        MSG_DEBUG("TP-DCS length : %d.", length);
 
-       //TP-VP
-       if (pSubmit->vpf != SMS_VPF_NOT_PRESENT)
-       {
+       /* TP-VP */
+       if (pSubmit->vpf != SMS_VPF_NOT_PRESENT) {
                length = SmsPluginParamCodec::encodeTime(&pSubmit->validityPeriod, &vpTime);
 
-               if (length > 0)
-               {
+               if (length > 0) {
                        memcpy(&(pTpdu[offset]), vpTime, length);
                        offset += length;
                }
@@ -191,7 +186,7 @@ int SmsPluginTpduCodec::encodeSubmit(const SMS_SUBMIT_S *pSubmit, char *pTpdu)
 
        encodeSize = SmsPluginUDCodec::encodeUserData(&(pSubmit->userData), pSubmit->dcs.codingScheme, &(pTpdu[offset]));
 
-MSG_DEBUG("encodeSize : %d", encodeSize);
+       MSG_DEBUG("encodeSize : %d", encodeSize);
 
        offset += encodeSize;
 
@@ -221,46 +216,46 @@ int SmsPluginTpduCodec::encodeDeliver(const SMS_DELIVER_S *pDeliver, char *pTpdu
        char* scts = NULL;
        unique_ptr<char*, void(*)(char**)> timeBuf(&scts, unique_ptr_deleter);
 
-       // TP-MTI : 00
+       /* TP-MTI : 00 */
        pTpdu[offset] = 0x00;
 
-       // TP-MMS
+       /* TP-MMS */
        if (pDeliver->bMoreMsg == false)
                pTpdu[offset] |= 0x04;
 
-       // TP-SRI
+       /* TP-SRI */
        if (pDeliver->bStatusReport == true)
                pTpdu[offset] |= 0x20;
 
-       // TP-UDHI
+       /* TP-UDHI */
        if (pDeliver->bHeaderInd == true)
                pTpdu[offset] |= 0x40;
 
-       // TP-RP
+       /* TP-RP */
        if (pDeliver->bReplyPath == true)
                pTpdu[offset] |= 0x80;
 
        offset++;
 
-       // TP-OA
+       /* TP-OA */
        length = SmsPluginParamCodec::encodeAddress(&pDeliver->originAddress, &address);
        memcpy(&(pTpdu[offset]), address, length);
        offset += length;
 
-       // TP-PID
+       /* TP-PID */
        pTpdu[offset++] = pDeliver->pid;
 
-       // TP-DCS
+       /* TP-DCS */
        length = SmsPluginParamCodec::encodeDCS(&pDeliver->dcs, &dcs);
        memcpy(&(pTpdu[offset]), dcs, length);
        offset += length;
 
-       // TP-SCTS
+       /* TP-SCTS */
        length = SmsPluginParamCodec::encodeTime(&pDeliver->timeStamp, &scts);
        memcpy(&(pTpdu[offset]), scts, length);
        offset += length;
 
-       // TP-UDL & TP-UD
+       /* TP-UDL & TP-UD */
        encodeSize = SmsPluginUDCodec::encodeUserData(&(pDeliver->userData), pDeliver->dcs.codingScheme, &(pTpdu[offset]));
 
        MSG_DEBUG("encodeSize : %d", encodeSize);
@@ -275,31 +270,30 @@ int SmsPluginTpduCodec::encodeDeliverReport(const SMS_DELIVER_REPORT_S *pDeliver
 {
        int offset = 0;
 
-       // TP-MTI : 00
+       /* TP-MTI : 00 */
        pTpdu[offset] = 0x00;
 
-       // TP-UDHI
+       /* TP-UDHI */
        if (pDeliverRep->bHeaderInd == true)
                pTpdu[offset] |= 0x40;
 
        offset++;
 
-       // TP-FCS
+       /* TP-FCS */
        if (pDeliverRep->reportType == SMS_REPORT_NEGATIVE) {
                pTpdu[offset++] = pDeliverRep->failCause;
                MSG_DEBUG("Delivery report : fail cause = [%02x]", pDeliverRep->failCause);
        }
 
-       // TP-PI
+       /* TP-PI */
        pTpdu[offset++] = pDeliverRep->paramInd;
 
-       // TP-PID
+       /* TP-PID */
        if (pDeliverRep->paramInd & 0x01)
                pTpdu[offset++] = pDeliverRep->pid;
 
-       // TP-DCS
-       if (pDeliverRep->paramInd & 0x02)
-       {
+       /* TP-DCS */
+       if (pDeliverRep->paramInd & 0x02) {
                int length = 0;
 
                char* dcs = NULL;
@@ -311,9 +305,8 @@ int SmsPluginTpduCodec::encodeDeliverReport(const SMS_DELIVER_REPORT_S *pDeliver
                offset += length;
        }
 
-       // TP-UDL & TP-UD
-       if (pDeliverRep->paramInd & 0x04)
-       {
+       /* TP-UDL & TP-UD */
+       if (pDeliverRep->paramInd & 0x04) {
                int encodeSize = 0;
 
                encodeSize = SmsPluginUDCodec::encodeUserData(&(pDeliverRep->userData), pDeliverRep->dcs.codingScheme, &(pTpdu[offset]));
@@ -342,54 +335,53 @@ int SmsPluginTpduCodec::encodeStatusReport(const SMS_STATUS_REPORT_S *pStatusRep
        char* dt = NULL;
        unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter);
 
-       // TP-MTI : 10
+       /* TP-MTI : 10 */
        pTpdu[offset] = 0x02;
 
-       // TP-MMS
+       /* TP-MMS */
        if (pStatusRep->bMoreMsg == true)
                pTpdu[offset] |= 0x04;
 
-       // TP-SRQ
+       /* TP-SRQ */
        if (pStatusRep->bStatusReport == true)
                pTpdu[offset] |= 0x20;
 
-       // TP-UDHI
+       /* TP-UDHI */
        if (pStatusRep->bHeaderInd == true)
                pTpdu[offset] |= 0x40;
 
        offset++;
 
-       // TP-MR
+       /* TP-MR */
        pTpdu[offset++] = pStatusRep->msgRef;
 
-       // TP-RA
+       /* TP-RA */
        length = SmsPluginParamCodec::encodeAddress(&pStatusRep->recipAddress, &address);
        memcpy(&(pTpdu[offset]), address, length);
        offset += length;
 
-       // TP-SCTS
+       /* TP-SCTS */
        length = SmsPluginParamCodec::encodeTime(&pStatusRep->timeStamp, &scts);
        memcpy(&(pTpdu[offset]), scts, length);
        offset += length;
 
-       // TP-DT
+       /* TP-DT */
        length = SmsPluginParamCodec::encodeTime(&pStatusRep->dischargeTime, &dt);
        memcpy(&(pTpdu[offset]), dt, length);
        offset += length;
 
-       // TP-Status
+       /* TP-Status */
        pTpdu[offset++] = pStatusRep->status;
 
-       // TP-PI
+       /* TP-PI */
        pTpdu[offset++] = pStatusRep->paramInd;
 
-       // TP-PID
+       /* TP-PID */
        if (pStatusRep->paramInd & 0x01)
                pTpdu[offset++] = pStatusRep->pid;
 
-       // TP-DCS
-       if (pStatusRep->paramInd & 0x02)
-       {
+       /* TP-DCS */
+       if (pStatusRep->paramInd & 0x02) {
                int length = 0;
 
                char* dcs = NULL;
@@ -401,9 +393,8 @@ int SmsPluginTpduCodec::encodeStatusReport(const SMS_STATUS_REPORT_S *pStatusRep
                offset += length;
        }
 
-       // TP-UDL & TP-UD
-       if (pStatusRep->paramInd & 0x04)
-       {
+       /* TP-UDL & TP-UD */
+       if (pStatusRep->paramInd & 0x04) {
                int encodeSize = 0;
 
                encodeSize = SmsPluginUDCodec::encodeUserData(&(pStatusRep->userData), pStatusRep->dcs.codingScheme, &(pTpdu[offset]));
@@ -423,28 +414,36 @@ int SmsPluginTpduCodec::decodeSubmit(const unsigned char *pTpdu, int TpduLen, SM
 {
        int offset = 0, udLen = 0;
 
-       // TP-RD
+       char tpduTmp[(TpduLen*2)+1];
+       memset(tpduTmp, 0x00, sizeof(tpduTmp));
+       for (int i = 0; i < TpduLen; i++) {
+               snprintf(tpduTmp+(i*2), sizeof(tpduTmp)-(i*2), "%02X", pTpdu[i]);
+       }
+       MSG_DEBUG("Sumbit TPDU.");
+       MSG_INFO("[%s]", tpduTmp);
+
+       /* TP-RD */
        if (pTpdu[offset] & 0x04)
                pSubmit->bRejectDup = false;
        else
                pSubmit->bRejectDup = true;
 
-       // TP-VPF
+       /* TP-VPF */
        pSubmit->vpf = (SMS_VPF_T)(pTpdu[offset] & 0x18);
 
-       // TP-SRR
+       /* TP-SRR */
        if (pTpdu[offset] & 0x20)
                pSubmit->bStatusReport = true;
        else
                pSubmit->bStatusReport = false;
 
-       // TP-UDHI
+       /* TP-UDHI */
        if (pTpdu[offset] & 0x40)
                pSubmit->bHeaderInd = true;
        else
                pSubmit->bHeaderInd = false;
 
-       // TP-RP
+       /* TP-RP */
        if (pTpdu[offset] & 0x80)
                pSubmit->bReplyPath = true;
        else
@@ -452,25 +451,24 @@ int SmsPluginTpduCodec::decodeSubmit(const unsigned char *pTpdu, int TpduLen, SM
 
        offset++;
 
-       // TP-MR
+       /* TP-MR */
        pSubmit->msgRef = pTpdu[offset++];
 
-       // TP-DA
+       /* TP-DA */
        offset += SmsPluginParamCodec::decodeAddress(pTpdu+offset, &(pSubmit->destAddress));
 
-       // TP-PID
+       /* TP-PID */
        pSubmit->pid = pTpdu[offset++];
 
-       // TP-DCS
+       /* TP-DCS */
        offset += SmsPluginParamCodec::decodeDCS(pTpdu+offset, &(pSubmit->dcs));
 
-       // TP-VP
-       if (pSubmit->vpf != SMS_VPF_NOT_PRESENT)
-       {
-               // Decode VP
+       /* TP-VP */
+       if (pSubmit->vpf != SMS_VPF_NOT_PRESENT) {
+               /* Decode VP */
        }
 
-       // TP-UDL & TP-UD
+       /* TP-UDL & TP-UD */
        udLen = SmsPluginUDCodec::decodeUserData(pTpdu+offset, TpduLen, pSubmit->bHeaderInd, pSubmit->dcs.codingScheme, &(pSubmit->userData));
 
        return udLen;
@@ -491,25 +489,25 @@ int SmsPluginTpduCodec::decodeDeliver(const unsigned char *pTpdu, int TpduLen, S
        MSG_INFO("[%s]", tpduTmp);
 
 
-       // TP-MMS
+       /* TP-MMS */
        if (pTpdu[offset] & 0x04)
                pDeliver->bMoreMsg = false;
        else
                pDeliver->bMoreMsg = true;
 
-       // TP-SRI
+       /* TP-SRI */
        if (pTpdu[offset] & 0x20)
                pDeliver->bStatusReport = true;
        else
                pDeliver->bStatusReport = false;
 
-       // TP-UDHI
+       /* TP-UDHI */
        if (pTpdu[offset] & 0x40)
                pDeliver->bHeaderInd = true;
        else
                pDeliver->bHeaderInd = false;
 
-       // TP-RP
+       /* TP-RP */
        if (pTpdu[offset] & 0x80)
                pDeliver->bReplyPath = true;
        else
@@ -519,16 +517,16 @@ int SmsPluginTpduCodec::decodeDeliver(const unsigned char *pTpdu, int TpduLen, S
 
        tmpOffset = offset;
 #if 1
-       // TP-OA
+       /* TP-OA */
        offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pDeliver->originAddress));
 
-       // TP-PID
+       /* TP-PID */
        pDeliver->pid = pTpdu[offset++];
 
-       // TP-DCS
+       /* TP-DCS */
        offset += SmsPluginParamCodec::decodeDCS(&pTpdu[offset], &(pDeliver->dcs));
 
-       // Support KSC5601 :: Coding group bits == 0x84
+       /* Support KSC5601 :: Coding group bits == 0x84 */
        if (pTpdu[offset-1] == 0x84) {
                pDeliver->dcs.codingScheme = SMS_CHARSET_EUCKR;
        }
@@ -587,10 +585,10 @@ int SmsPluginTpduCodec::decodeDeliver(const unsigned char *pTpdu, int TpduLen, S
                }
        }
 
-       // TP-SCTS
+       /* TP-SCTS */
        offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pDeliver->timeStamp));
 
-       // TP-UD
+       /* TP-UD */
        udLen = SmsPluginUDCodec::decodeUserData(&pTpdu[offset], TpduLen, pDeliver->bHeaderInd, pDeliver->dcs.codingScheme, &(pDeliver->userData), &(pDeliver->udData));
 
        return udLen;
@@ -620,19 +618,19 @@ int SmsPluginTpduCodec::decodeStatusReport(const unsigned char *pTpdu, int TpduL
        char* dt = NULL;
        unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter);
 
-       // TP-MMS
+       /* TP-MMS */
        if (pTpdu[offset] & 0x04)
                pStatusRep->bMoreMsg = false;
        else
                pStatusRep->bMoreMsg = true;
 
-       // TP-SRQ
+       /* TP-SRQ */
        if (pTpdu[offset] & 0x20)
                pStatusRep->bStatusReport = true;
        else
                pStatusRep->bStatusReport = false;
 
-       // TP-UDHI
+       /* TP-UDHI */
        if (pTpdu[offset] & 0x40)
                pStatusRep->bHeaderInd = true;
        else
@@ -640,29 +638,28 @@ int SmsPluginTpduCodec::decodeStatusReport(const unsigned char *pTpdu, int TpduL
 
        offset++;
 
-       // TP-MR
+       /* TP-MR */
        pStatusRep->msgRef = pTpdu[offset++];
 
-       // TP-RA
+       /* TP-RA */
        offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pStatusRep->recipAddress));
 
-       // TP-SCTS
-       // Decode timestamp
+       /* TP-SCTS */
+       /* Decode timestamp */
        offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pStatusRep->timeStamp));
 
-       // TP-DT
-       // Decode timestamp
+       /* TP-DT */
+       /* Decode timestamp */
        offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pStatusRep->dischargeTime));
 
-       // TP-Status
+       /* TP-Status */
        pStatusRep->status = pTpdu[offset++];
 
-       // TP-PI
+       /* TP-PI */
        pStatusRep->paramInd = pTpdu[offset++];
 
-       // No Parameters
-       if (pStatusRep->paramInd == 0)
-       {
+       /* No Parameters */
+       if (pStatusRep->paramInd == 0) {
                pStatusRep->pid = SMS_PID_NORMAL;
 
                pStatusRep->dcs.bCompressed = false;
@@ -679,23 +676,18 @@ int SmsPluginTpduCodec::decodeStatusReport(const unsigned char *pTpdu, int TpduL
                memset(pStatusRep->userData.data, 0x00, MAX_USER_DATA_LEN+1);
        }
 
-       // TP-PID
+       /* TP-PID */
        if (pStatusRep->paramInd & 0x01)
                pStatusRep->pid = pTpdu[offset++];
 
-       // TP-DCS
+       /* TP-DCS */
        if (pStatusRep->paramInd & 0x02)
-       {
                offset += SmsPluginParamCodec::decodeDCS(&pTpdu[offset], &(pStatusRep->dcs));
-       }
 
-       // TP-UDL & TP-UD
+       /* TP-UDL & TP-UD */
        if (pStatusRep->paramInd & 0x04)
-       {
-               // Decode User Data
+               /* Decode User Data */
                udLen = SmsPluginUDCodec::decodeUserData(&pTpdu[offset], TpduLen, pStatusRep->bHeaderInd, pStatusRep->dcs.codingScheme, &(pStatusRep->userData));
-       }
 
        return udLen;
 }
-
index 37d0675..ee15199 100755 (executable)
@@ -34,9 +34,9 @@
 #include "SmsPluginDSHandler.h"
 #include "SmsPluginSetting.h"
 
-extern "C"
-{
+extern "C" {
        #include <ITapiNetText.h>
+       #include <TelNetwork.h>
 }
 
 
@@ -81,56 +81,55 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo)
 
        tpdu.tpduType = SMS_TPDU_SUBMIT;
 
-       // Get SMS Send Options - Setting
+       /* Get SMS Send Options - Setting */
        getSmsSendOption(pReqInfo->msgInfo.sim_idx, &(tpdu.data.submit));
 
-       // Set SMS Send Options - Each Message
+       /* Set SMS Send Options - Each Message */
        setSmsSendOption(pReqInfo, &tpdu);
 
-       // Set coding scheme
+       /* Set coding scheme */
        setSmsDcsOption(pReqInfo, &tpdu);
 
-       // Set SMS report request
+       /* Set SMS report request */
        setSmsReportOption(pReqInfo, &tpdu);
 
-       // Set SMSC Options
+       /* Set SMSC Options */
        SMS_ADDRESS_S smsc = {0,};
        setSmscOptions(pReqInfo->msgInfo.sim_idx, &smsc);
 
-       // Get TAPI handle
-       struct tapi_handle *handle = SmsPluginDSHandler::instance()->getTelHandle(pReqInfo->msgInfo.sim_idx);
+       /* Get TAPI handle */
+       TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pReqInfo->msgInfo.sim_idx);
 
-       // Get address informations.
+       /* Get address informations. */
        MsgDbHandler *dbHandle = getDbHandle();
-       //contacts-service is not used for gear
+       /* contacts-service is not used for gear */
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
        MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, 0, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList);
-#else // MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-       //contactNameOrder is never used
+#else /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
+       /* contactNameOrder is never used */
        MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList);
-#endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
 
        MSG_DEBUG("pReqInfo->msgInfo.nAddressCnt [%d]", pReqInfo->msgInfo.nAddressCnt);
 
-       // Get MSISDN
+       /* Get MSISDN */
        char *msisdn = NULL;
        char keyName[MAX_VCONFKEY_NAME_LEN];
        memset(keyName, 0x00, sizeof(keyName));
        snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, pReqInfo->msgInfo.sim_idx);
        msisdn = MsgSettingGetString(keyName);
 
-       for (int i = 0; i < pReqInfo->msgInfo.nAddressCnt; i++)
-       {
-               // Make SMS_SUBMIT_DATA_S from MSG_REQUEST_INFO_S
+       for (int i = 0; i < pReqInfo->msgInfo.nAddressCnt; i++) {
+               /* Make SMS_SUBMIT_DATA_S from MSG_REQUEST_INFO_S */
                SMS_SUBMIT_DATA_S submitData = {{0},};
                msgInfoToSubmitData(&(pReqInfo->msgInfo), &submitData, &(tpdu.data.submit.dcs.codingScheme), i);
 
-               // Insert message reference into db
+               /* Insert message reference into db */
                if (tpdu.data.submit.bStatusReport == true) {
                        SmsPluginStorage::instance()->insertMsgRef(&(pReqInfo->msgInfo), tpdu.data.submit.msgRef, i);
                }
 
-               // Encode SMSC Address
+               /* Encode SMSC Address */
                unsigned char smscAddr[MAX_SMSC_LEN];
                memset(smscAddr, 0x00, sizeof(smscAddr));
 
@@ -169,14 +168,13 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo)
                        tpdu.data.submit.destAddress.address[MAX_ADDRESS_LEN] = '\0';
                }
 
-MSG_DEBUG("ton [%d]", tpdu.data.submit.destAddress.ton);
-MSG_DEBUG("npi [%d]", tpdu.data.submit.destAddress.npi);
-MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
+               MSG_DEBUG("ton [%d]", tpdu.data.submit.destAddress.ton);
+               MSG_DEBUG("npi [%d]", tpdu.data.submit.destAddress.npi);
+               MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
 
                bool bStatusReport = false;
 
-               for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++)
-               {
+               for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++) {
                        if (submitData.userData[segCnt].headerCnt > 0) {
                                tpdu.data.submit.bHeaderInd = true;
                        } else {
@@ -201,10 +199,8 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
                        bool bRetryByMoCtrl = false;
                        bool bSatMoCtrl = false;
 
-
-                       for (int cnt = 0; cnt < MAX_SMS_SEND_RETRY; ++cnt)
-                       {
-                               // Encode SMS-SUBMIT TPDU
+                       for (int cnt = 0; cnt < MAX_SMS_SEND_RETRY; ++cnt) {
+                               /* Encode SMS-SUBMIT TPDU */
                                memset(buf, 0x00, sizeof(buf));
 
                                if (cnt > 0)
@@ -212,10 +208,10 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
 
                                bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
 
-                               // Make Telephony Structure
+                               /* Make Telephony Structure */
                                TelSmsDatapackageInfo_t pkgInfo;
 
-                               // Set TPDU data
+                               /* Set TPDU data */
                                memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
                                memcpy((void*)pkgInfo.szData, buf, bufLen);
 
@@ -223,7 +219,7 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
                                pkgInfo.MsgLength = bufLen;
                                pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
 
-                               // Set SMSC data
+                               /* Set SMSC data */
                                memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
                                memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
                                pkgInfo.Sca[smscLen] = '\0';
@@ -244,28 +240,34 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
 
                                memcpy(&(sentInfo.reqInfo), pReqInfo, sizeof(SMS_REQUEST_INFO_S));
 
-                               if ((segCnt+1) == submitData.segCount && (i+1)==pReqInfo->msgInfo.nAddressCnt)
-                               {
+                               if ((segCnt + 1) == submitData.segCount && (i + 1)==pReqInfo->msgInfo.nAddressCnt) {
                                        sentInfo.bLast = true;
                                        bMoreMsg = FALSE;
-                               }
-                               else
-                               {
+                               } else {
                                        sentInfo.bLast = false;
                                        bMoreMsg = TRUE;
                                }
 
                                SmsPluginEventHandler::instance()->SetSentInfo(&sentInfo);
 
+                               int svc_type;
+                               tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
+
+                               if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G){
+                                       MSG_DEBUG("Network service is not available : [%d]", svc_type);
+                                       SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_PENDING);
+                                       MsgInsertTicker("Unable to send message. It will be sent when service available.", SMS_MESSAGE_SENDING_PENDING, false, 0);
+                                       goto _RETURN_FUNC;
+                               }
+
                                curStatus = SMS_NETWORK_SENDING;
 
-                               // Send SMS
+                               /* Send SMS */
                                int tapiRet = TAPI_API_SUCCESS;
 
                                tapiRet = tel_send_sms(handle, &pkgInfo, bMoreMsg, TapiEventSentStatus, (void *)&curMoCtrlData);
 
-                               if (tapiRet == TAPI_API_SUCCESS)
-                               {
+                               if (tapiRet == TAPI_API_SUCCESS) {
                                        MSG_DEBUG("########  tel_send_sms Success !!! return : [%d] #######", tapiRet);
 
                                        memset(keyName, 0x00, sizeof(keyName));
@@ -274,7 +276,7 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
                                                MSG_DEBUG("MsgSettingGetBool [%s] failed", keyName);
 
                                        if (bSatMoCtrl) {
-                                               // Get SAT MO SM control
+                                               /* Get SAT MO SM control */
                                                retMoCtrlStatus = getMoCtrlStatus();
                                                MSG_DEBUG("retMoCtrlStatus  = [%d]", retMoCtrlStatus);
 
@@ -283,7 +285,7 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
                                                        if (bRetryByMoCtrl == false) {
                                                                bRetryByMoCtrl = true;
 
-                                                               // Modify Address with control data
+                                                               /* Modify Address with control data */
                                                                memset(smsc.address, 0x00, sizeof(smsc.address));
                                                                memcpy(smsc.address, curMoCtrlData.rpDestAddr.string, sizeof(smsc.address)-1);
 
@@ -304,9 +306,7 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
                                                        }
                                                }
                                        }
-                               }
-                               else
-                               {
+                               } else {
                                        SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
 
                                        if (msisdn) {
@@ -316,7 +316,7 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
                                        THROW(MsgException::SMS_PLG_ERROR, "########  tel_send_sms Fail !!! return : [%d] #######", tapiRet);
                                }
 
-                               // Tizen Validation System
+                               /* Tizen Validation System */
                                MSG_SMS_VLD_INFO("%d, SMS Send Start, %s->%s, %s",  pReqInfo->msgInfo.msgId, \
                                                                                                                                                        (msisdn == NULL)?"ME":msisdn, \
                                                                                                                                                        pReqInfo->msgInfo.addressList[0].addressVal, \
@@ -331,13 +331,11 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
                        }
 
 #ifdef MSG_SMS_REPORT
-                       if (err == MSG_SUCCESS && tmpInfo.msgInfo.msgPort.valid == false)
-                       {
-                               if(pReqInfo->sendOptInfo.bDeliverReq == true)
-                               {
+                       if (err == MSG_SUCCESS && tmpInfo.msgInfo.msgPort.valid == false)       {
+                               if (pReqInfo->sendOptInfo.bDeliverReq == true) {
                                        MSG_DEBUG("Update Delivery Report Status : [%d] Msg ID : [%d]", err, tmpInfo.msgInfo.msgId);
 
-                                       // Adding delivery report status info.
+                                       /* Adding delivery report status info. */
                                        MsgStoAddDeliveryReportStatus( tmpInfo.msgInfo.msgId, (unsigned char)tmpInfo.msgInfo.referenceId);
                                }
                        }
@@ -348,8 +346,7 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
                                                                                                                                        pReqInfo->msgInfo.addressList[0].addressVal, \
                                                                                                                                        (retStatus == SMS_NETWORK_SEND_SUCCESS)?"Success":"Fail");
 
-                       if (retStatus == SMS_NETWORK_SEND_SUCCESS)
-                       {
+                       if (retStatus == SMS_NETWORK_SEND_SUCCESS) {
                                bool bTTS = false;
 
                                if (MsgSettingGetBool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &bTTS) != MSG_SUCCESS) {
@@ -362,11 +359,12 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
                                        }
                                        MSG_DEBUG("########  Msg Sent was Successful !!! #######");
                                }
-                       }
-                       else
-                       {
+                       } else {
                                if (retStatus == SMS_NETWORK_SEND_FAIL_TIMEOUT || retStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY || retStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD)
                                        SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
+                               else if (retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED)
+                                       /* SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL_FDN_ENABLED); */
+                                       SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
 
                                if (retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED) {
                                        MsgInsertTicker("Unable to send the message while Fixed dialling mode is enabled", SMS_FDN_RESTRICTED, true, 0);
@@ -381,7 +379,8 @@ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
                                THROW(MsgException::SMS_PLG_ERROR, "########  Msg Sent was Failed !!! return : [%d] #######", retStatus);
                        }
 
-                       if (tpdu.data.submit.userData.headerCnt > 0) tpdu.data.submit.userData.headerCnt--;
+                       if (tpdu.data.submit.userData.headerCnt > 0)
+                               tpdu.data.submit.userData.headerCnt--;
 
                }
        }
@@ -396,7 +395,7 @@ _RETURN_FUNC :
 }
 
 
-void SmsPluginTransport::sendDeliverReport(struct tapi_handle *handle, msg_error_t err)
+void SmsPluginTransport::sendDeliverReport(TapiHandle *handle, msg_error_t err)
 {
        MSG_BEGIN();
 
@@ -410,27 +409,19 @@ void SmsPluginTransport::sendDeliverReport(struct tapi_handle *handle, msg_error
 
        int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
 
-       if (err == MSG_SUCCESS)
-       {
+       if (err == MSG_SUCCESS) {
                tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
                response = TAPI_NETTEXT_SENDSMS_SUCCESS;
 
-               if(isMemAvailable == false)
-               {
+               if (isMemAvailable == false) {
                        tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, TapiEventMemoryStatus, NULL);
 
                        if (tapiRet == TAPI_API_SUCCESS)
-                       {
                                MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
-                       }
                        else
-                       {
                                MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
-                       }
                }
-       }
-       else if (err == MSG_ERR_SIM_STORAGE_FULL)
-       {
+       } else if (err == MSG_ERR_SIM_STORAGE_FULL) {
                tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
                tpdu.data.deliverRep.failCause = SMS_FC_SIM_STORAGE_FULL;
 
@@ -449,9 +440,7 @@ void SmsPluginTransport::sendDeliverReport(struct tapi_handle *handle, msg_error
                        MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
                }
 #endif
-       }
-       else if (err == MSG_ERR_MESSAGE_COUNT_FULL)
-       {
+       } else if (err == MSG_ERR_MESSAGE_COUNT_FULL) {
                tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
                tpdu.data.deliverRep.failCause = SMS_FC_MSG_CAPA_EXCEEDED;
                response = TAPI_NETTEXT_ME_FULL;
@@ -459,20 +448,14 @@ void SmsPluginTransport::sendDeliverReport(struct tapi_handle *handle, msg_error
                tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, TapiEventMemoryStatus, NULL);
 
                if (tapiRet == TAPI_API_SUCCESS)
-               {
                        MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
-               }
                else
-               {
                        MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
-               }
-       }
-       else
-       {
+       } else {
                tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
                tpdu.data.deliverRep.failCause = SMS_FC_UNSPEC_ERROR;
-               //response = TAPI_NETTEXT_PROTOCOL_ERROR;
-               // For gcf test [34.2.5.3 class2 message]
+               /*response = TAPI_NETTEXT_PROTOCOL_ERROR;
+                For gcf test [34.2.5.3 class2 message] */
                response = TAPI_NETTEXT_SIM_FULL;
 
        }
@@ -482,7 +465,7 @@ void SmsPluginTransport::sendDeliverReport(struct tapi_handle *handle, msg_error
        tpdu.data.deliverRep.bHeaderInd = false;
        tpdu.data.deliverRep.paramInd = 0x00;
 
-       // Encode SMS-DELIVER-REPORT TPDU
+       /* Encode SMS-DELIVER-REPORT TPDU */
        int bufLen = 0;
 
        char buf[MAX_TPDU_DATA_LEN];
@@ -491,20 +474,18 @@ void SmsPluginTransport::sendDeliverReport(struct tapi_handle *handle, msg_error
        bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
 
 #ifdef MSG_FOR_DEBUG
-       /////// print DeliverReport tpdu
+       /* print DeliverReport tpdu */
        printf("\n\n######## DeliverReport tpdu #########\n");
-       for(int i=0; i < bufLen; i++)
-       {
+       for (int i=0; i < bufLen; i++) {
                printf("[%02x] ", buf[i]);
        }
        printf("\n#################################\n\n");
-       //////
 #endif
 
-       // Make Telephony Structure
+       /* Make Telephony Structure */
        TelSmsDatapackageInfo_t pkgInfo;
 
-       // Set TPDU data
+       /* Set TPDU data */
        memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
        memcpy((void*)pkgInfo.szData, buf, bufLen);
 
@@ -512,13 +493,13 @@ void SmsPluginTransport::sendDeliverReport(struct tapi_handle *handle, msg_error
        pkgInfo.MsgLength = bufLen;
        pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
 
-       // Set SMSC Address
+       /* Set SMSC Address */
        SMS_ADDRESS_S smsc;
 
-       // Set SMSC Options
+       /* Set SMSC Options */
        setSmscOptions(simIndex, &smsc);
 
-       // Encode SMSC Address
+       /* Encode SMSC Address */
        unsigned char smscAddr[MAX_SMSC_LEN];
        memset(smscAddr, 0x00, sizeof(smscAddr));
 
@@ -526,27 +507,23 @@ void SmsPluginTransport::sendDeliverReport(struct tapi_handle *handle, msg_error
 
        if (smscLen <= 0) return;
 
-       // Set SMSC data
+       /* Set SMSC data */
        memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
        memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
        pkgInfo.Sca[smscLen] = '\0';
 
-       // Send Deliver Report
+       /* Send Deliver Report */
        tapiRet = tel_send_sms_deliver_report(handle, &pkgInfo, response, TapiEventDeliveryReportCNF, NULL);
 
        if (tapiRet == TAPI_API_SUCCESS)
-       {
                MSG_DEBUG("########  tel_send_sms_deliver_report() Success !!! #######");
-       }
        else
-       {
                MSG_DEBUG("########  tel_send_sms_deliver_report() Fail !!! return : [%d] #######", tapiRet);
-       }
 
        MSG_END();
 }
 
-void SmsPluginTransport::sendClass0DeliverReport(struct tapi_handle *handle, msg_error_t err)
+void SmsPluginTransport::sendClass0DeliverReport(TapiHandle *handle, msg_error_t err)
 {
        MSG_BEGIN();
 
@@ -560,60 +537,41 @@ void SmsPluginTransport::sendClass0DeliverReport(struct tapi_handle *handle, msg
 
        int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
 
-       if (err == MSG_SUCCESS)
-       {
+       if (err == MSG_SUCCESS) {
                tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
                response = TAPI_NETTEXT_SENDSMS_SUCCESS;
 
                tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, TapiEventMemoryStatus, NULL);
 
                if (tapiRet == TAPI_API_SUCCESS)
-               {
                        MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
-               }
                else
-               {
                        MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
-               }
-       }
-       else if (err == MSG_ERR_SIM_STORAGE_FULL)
-       {
+       } else if (err == MSG_ERR_SIM_STORAGE_FULL) {
                tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
                response = TAPI_NETTEXT_SENDSMS_SUCCESS;
 
                tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, TapiEventMemoryStatus, NULL);
 
                if (tapiRet == TAPI_API_SUCCESS)
-               {
                        MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
-               }
                else
-               {
                        MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
-               }
-       }
-       else if (err == MSG_ERR_MESSAGE_COUNT_FULL)
-       {
+       } else if (err == MSG_ERR_MESSAGE_COUNT_FULL) {
                tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
                response = TAPI_NETTEXT_SENDSMS_SUCCESS;
 
                tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, TapiEventMemoryStatus, NULL);
 
                if (tapiRet == TAPI_API_SUCCESS)
-               {
                        MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
-               }
                else
-               {
                        MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
-               }
-       }
-       else
-       {
+       } else {
                tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
                tpdu.data.deliverRep.failCause = SMS_FC_UNSPEC_ERROR;
-               //response = TAPI_NETTEXT_PROTOCOL_ERROR;
-               // For gcf test [34.2.5.3 class2 message]
+               /*response = TAPI_NETTEXT_PROTOCOL_ERROR;
+                For gcf test [34.2.5.3 class2 message] */
                response = TAPI_NETTEXT_SIM_FULL;
 
        }
@@ -623,7 +581,7 @@ void SmsPluginTransport::sendClass0DeliverReport(struct tapi_handle *handle, msg
        tpdu.data.deliverRep.bHeaderInd = false;
        tpdu.data.deliverRep.paramInd = 0x00;
 
-       // Encode SMS-DELIVER-REPORT TPDU
+       /* Encode SMS-DELIVER-REPORT TPDU */
        int bufLen = 0;
 
        char buf[MAX_TPDU_DATA_LEN];
@@ -631,10 +589,10 @@ void SmsPluginTransport::sendClass0DeliverReport(struct tapi_handle *handle, msg
 
        bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
 
-       // Make Telephony Structure
+       /* Make Telephony Structure */
        TelSmsDatapackageInfo_t pkgInfo;
 
-       // Set TPDU data
+       /* Set TPDU data */
        memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
        memcpy((void*)pkgInfo.szData, buf, bufLen);
 
@@ -642,13 +600,13 @@ void SmsPluginTransport::sendClass0DeliverReport(struct tapi_handle *handle, msg
        pkgInfo.MsgLength = bufLen;
        pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
 
-       // Set SMSC Address
+       /* Set SMSC Address */
        SMS_ADDRESS_S smsc;
 
-       // Set SMSC Options
+       /* Set SMSC Options */
        setSmscOptions(simIndex, &smsc);
 
-       // Encode SMSC Address
+       /* Encode SMSC Address */
        unsigned char smscAddr[MAX_SMSC_LEN];
        memset(smscAddr, 0x00, sizeof(smscAddr));
 
@@ -656,22 +614,18 @@ void SmsPluginTransport::sendClass0DeliverReport(struct tapi_handle *handle, msg
 
        if (smscLen <= 0) return;
 
-       // Set SMSC data
+       /* Set SMSC data */
        memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
        memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
        pkgInfo.Sca[smscLen] = '\0';
 
-       // Send Deliver Report
+       /* Send Deliver Report */
        tapiRet = tel_send_sms_deliver_report(handle, &pkgInfo, response, TapiEventDeliveryReportCNF, NULL);
 
        if (tapiRet == TAPI_API_SUCCESS)
-       {
                MSG_DEBUG("########  tel_send_sms_deliver_report() Success !!! #######");
-       }
        else
-       {
                MSG_DEBUG("########  tel_send_sms_deliver_report() Fail !!! return : [%d] #######", tapiRet);
-       }
 
        MSG_END();
 }
@@ -679,7 +633,7 @@ void SmsPluginTransport::sendClass0DeliverReport(struct tapi_handle *handle, msg
 
 void SmsPluginTransport::getSmsSendOption(int simIndex, SMS_SUBMIT_S *pSubmit)
 {
-       // Set SMS Send Options
+       /* Set SMS Send Options */
        pSubmit->bRejectDup = false;
        pSubmit->bHeaderInd = false;
 
@@ -715,7 +669,7 @@ void SmsPluginTransport::getSmsSendOption(int simIndex, SMS_SUBMIT_S *pSubmit)
 
        MSG_DEBUG("PID : %d", pSubmit->pid);
 
-       pSubmit->vpf = SMS_VPF_NOT_PRESENT; // default value
+       pSubmit->vpf = SMS_VPF_NOT_PRESENT; /* default value */
 
        MSG_DEBUG("valPeriod : %d", valPeriod);
        MSG_DEBUG("vpf : %d", pSubmit->vpf);
@@ -729,8 +683,7 @@ void SmsPluginTransport::setSmsSendOption(SMS_REQUEST_INFO_S *pReqInfo, SMS_TPDU
                return;
        }
 
-       if (pReqInfo->sendOptInfo.bSetting == true)
-       {
+       if (pReqInfo->sendOptInfo.bSetting == true) {
                pSmsTpdu->data.submit.bStatusReport = pReqInfo->sendOptInfo.bDeliverReq;
                pSmsTpdu->data.submit.bReplyPath = pReqInfo->sendOptInfo.option.smsSendOptInfo.bReplyPath;
        }
@@ -745,11 +698,11 @@ void SmsPluginTransport::setSmsDcsOption(SMS_REQUEST_INFO_S *pReqInfo, SMS_TPDU_
        }
 
        if (pReqInfo->msgInfo.msgPort.valid == true) {
-               // Set Coding Scheme for apps that use port number
+               /* Set Coding Scheme for apps that use port number */
                pSmsTpdu->data.submit.dcs.codingScheme = (SMS_CODING_SCHEME_T)pReqInfo->msgInfo.encodeType;
                MSG_DEBUG("DCS is changed by application : [%d]", pSmsTpdu->data.submit.dcs.codingScheme);
        } else {
-               // Change coding scheme if it is set coding scheme by apps
+               /* Change coding scheme if it is set coding scheme by apps */
                if (pSmsTpdu->data.submit.dcs.codingScheme == SMS_CHARSET_7BIT && pReqInfo->msgInfo.encodeType != MSG_ENCODE_GSM7BIT) {
                        pSmsTpdu->data.submit.dcs.codingScheme = (SMS_CODING_SCHEME_T)pReqInfo->msgInfo.encodeType;
                        MSG_DEBUG("DCS is changed by application : [%d]", pSmsTpdu->data.submit.dcs.codingScheme);
@@ -766,16 +719,15 @@ void SmsPluginTransport::setSmsReportOption(SMS_REQUEST_INFO_S *pReqInfo, SMS_TP
        }
 
 #ifdef MSG_SMS_REPORT
-       // Update Msg Ref into Report Table
-       if (pSmsTpdu->data.submit.bStatusReport == true)
-       {
+       /* Update Msg Ref into Report Table */
+       if (pSmsTpdu->data.submit.bStatusReport == true) {
                MSG_DEBUG("Update Msg Ref [%d] in Report Table", pSmsTpdu->data.submit.msgRef);
 
                SmsPluginStorage::instance()->updateMsgRef(pReqInfo->msgInfo.msgId, pSmsTpdu->data.submit.msgRef);
        }
 #endif
 
-       // Set Message Reference
+       /* Set Message Reference */
        if (pSmsTpdu->data.submit.bStatusReport == true) {
                pSmsTpdu->data.submit.msgRef = (pReqInfo->msgInfo.msgId % 256);
        }
@@ -784,7 +736,7 @@ void SmsPluginTransport::setSmsReportOption(SMS_REQUEST_INFO_S *pReqInfo, SMS_TP
 
 void SmsPluginTransport::setSmscOptions(int simIndex, SMS_ADDRESS_S *pSmsc)
 {
-       // Set SMSC Options
+       /* Set SMSC Options */
        MSG_SMSC_LIST_S smscList = {0,};
        SmsPluginSetting::instance()->getSmscListInfo(simIndex, &smscList);
 
@@ -811,7 +763,7 @@ void SmsPluginTransport::setSmscOptions(int simIndex, SMS_ADDRESS_S *pSmsc)
 
 void SmsPluginTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SUBMIT_DATA_S *pData, SMS_CODING_SCHEME_T *pCharType, int addrIndex)
 {
-       // Destination Address
+       /* Destination Address */
        pData->destAddress.ton = SMS_TON_UNKNOWN;
        pData->destAddress.npi = SMS_NPI_ISDN;
 
@@ -822,7 +774,7 @@ void SmsPluginTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo,
        MSG_DEBUG("npi [%d]", pData->destAddress.npi);
        MSG_SEC_DEBUG("address [%s]", pData->destAddress.address);
 
-       int decodeLen = 0, bufSize = (MAX_GSM_7BIT_DATA_LEN*MAX_SEGMENT_NUM) + 1;       // SMS_CHARSET_7BIT
+       int decodeLen = 0, bufSize = (MAX_GSM_7BIT_DATA_LEN*MAX_SEGMENT_NUM) + 1; /* SMS_CHARSET_7BIT */
 
        unsigned char decodeData[bufSize];
        memset(decodeData, 0x00, sizeof(decodeData));
@@ -835,77 +787,59 @@ void SmsPluginTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo,
 
        bool bAbnormal = false;
 
-       // User Data
-       if (pMsgInfo->bTextSms == true)
-       {
-               if (*pCharType == SMS_CHARSET_7BIT)
-               {
+       /* User Data */
+       if (pMsgInfo->bTextSms == true) {
+               if (*pCharType == SMS_CHARSET_7BIT) {
                        decodeLen = textCvt->convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, &langId, &bAbnormal);
-               }
-               else if (*pCharType == SMS_CHARSET_8BIT)
-               {
+               } else if (*pCharType == SMS_CHARSET_8BIT) {
                        memcpy(decodeData, pMsgInfo->msgText, pMsgInfo->dataSize);
                        decodeLen = pMsgInfo->dataSize;
-               }
-               else if (*pCharType == SMS_CHARSET_UCS2)
-               {
+               } else if (*pCharType == SMS_CHARSET_UCS2) {
                        decodeLen = textCvt->convertUTF8ToUCS2(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize);
-               }
-               else if (*pCharType == SMS_CHARSET_AUTO)
-               {
-                       decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, &langId, &encodeType);
+               } else if (*pCharType == SMS_CHARSET_AUTO) {
+                       decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, &encodeType);
                        *pCharType = encodeType;
                }
-       }
-       else
-       {
+       } else {
                int fileSize = 0;
 
                char* pFileData = NULL;
                unique_ptr<char*, void(*)(char**)> FileBuf(&pFileData, unique_ptr_deleter);
 
-               // Read Message Data from File
+               /* Read Message Data from File */
                if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false)
                        THROW(MsgException::FILE_ERROR, "MsgOpenAndReadFile error");
 
                MSG_DEBUG("file size : [%d] file data : [%s]", fileSize, pFileData);
 
-               if (*pCharType == SMS_CHARSET_7BIT)
-               {
+               if (*pCharType == SMS_CHARSET_7BIT) {
                        decodeLen = textCvt->convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &langId, &bAbnormal);
-               }
-               else if (*pCharType == SMS_CHARSET_8BIT)
-               {
+               } else if (*pCharType == SMS_CHARSET_8BIT) {
                        memcpy(decodeData, pFileData, fileSize);
                        decodeLen = fileSize;
-               }
-               else if (*pCharType == SMS_CHARSET_UCS2)
-               {
+               } else if (*pCharType == SMS_CHARSET_UCS2) {
                        decodeLen = textCvt->convertUTF8ToUCS2(decodeData, bufSize, (unsigned char*)pFileData, fileSize);
-               }
-               else if (*pCharType == SMS_CHARSET_AUTO)
-               {
-                       decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &langId, &encodeType);
+               } else if (*pCharType == SMS_CHARSET_AUTO) {
+                       decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &encodeType);
                        *pCharType = encodeType;
                }
 
-               // Delete File
+               /* Delete File */
                if (pMsgInfo->nAddressCnt == (addrIndex + 1))
                        MsgDeleteFile(pMsgInfo->msgData);
        }
 
-MSG_DEBUG("decode length : [%d]", decodeLen);
-MSG_DEBUG("character type : [%d]", *pCharType);
-MSG_DEBUG("Language Identifier : [%d]", langId);
-MSG_SEC_DEBUG("reply address : [%s]", pMsgInfo->replyAddress);
+       MSG_DEBUG("decode length : [%d]", decodeLen);
+       MSG_DEBUG("character type : [%d]", *pCharType);
+       MSG_DEBUG("Language Identifier : [%d]", langId);
+       MSG_SEC_DEBUG("reply address : [%s]", pMsgInfo->replyAddress);
 
        int addrLen = 0;
 
        char* encodedAddr = NULL;
        unique_ptr<char*, void(*)(char**)> addressBuf(&encodedAddr, unique_ptr_deleter);
 
-       if (strlen(pMsgInfo->replyAddress) > 0)
-       {
+       if (strlen(pMsgInfo->replyAddress) > 0) {
                SMS_ADDRESS_S replyAddr = {};
 
                replyAddr.ton = SMS_TON_NATIONAL;
@@ -923,20 +857,23 @@ MSG_SEC_DEBUG("reply address : [%s]", pMsgInfo->replyAddress);
 
        segSize = getSegmentSize(*pCharType, decodeLen, pMsgInfo->msgPort.valid, langId, addrLen);
 
-       if (segSize == 0)
-               THROW(MsgException::SMS_PLG_ERROR, "DIVIDE_BY_ZERO : %d", segSize);
-
-       pData->segCount = ceil((double)decodeLen/(double)segSize);
+       if (segSize == 0) {
+               if (decodeLen == 0) /* to handle empty message -> (pMsgInfo->msgText = NULL) */
+                       pData->segCount = 1;
+               else
+                       THROW(MsgException::SMS_PLG_ERROR, "DIVIDE_BY_ZERO : %d", segSize);
+       } else {
+               pData->segCount = ceil((double)decodeLen/(double)segSize);
+       }
 
-MSG_DEBUG("segment size : [%d], pData->segCount : [%d]", segSize, pData->segCount);
+       MSG_DEBUG("segment size : [%d], pData->segCount : [%d]", segSize, pData->segCount);
 
        if (pData->segCount > MAX_SEGMENT_NUM)
                THROW(MsgException::SMS_PLG_ERROR, "Segment Count is over maximum : %d", pData->segCount);
 
        int headerCnt = 0;
 
-       for (unsigned int i = 0; i < pData->segCount; i++)
-       {
+       for (unsigned int i = 0; i < pData->segCount; i++) {
                headerCnt = 0;
 
                if ((i + 1) == pData->segCount)
@@ -948,14 +885,13 @@ MSG_DEBUG("segment size : [%d], pData->segCount : [%d]", segSize, pData->segCoun
                memcpy(pData->userData[i].data, &(decodeData[index]), pData->userData[i].length);
                pData->userData[i].data[pData->userData[i].length] = 0;
 
-MSG_DEBUG("user data len [%d]", pData->userData[i].length);
-MSG_DEBUG("user data [%s]", pData->userData[i].data);
+               MSG_DEBUG("user data len [%d]", pData->userData[i].length);
+               MSG_DEBUG("user data [%s]", pData->userData[i].data);
 
                index += segSize;
 
-               // Set User Data Header for Concatenated Message
-               if (pData->segCount > 1)
-               {
+               /* Set User Data Header for Concatenated Message */
+               if (pData->segCount > 1) {
                        pData->userData[i].header[headerCnt].udhType = SMS_UDH_CONCAT_8BIT;
                        pData->userData[i].header[headerCnt].udh.concat8bit.msgRef = msgRef8bit;
                        pData->userData[i].header[headerCnt].udh.concat8bit.totalSeg = pData->segCount;
@@ -964,9 +900,8 @@ MSG_DEBUG("user data [%s]", pData->userData[i].data);
                        headerCnt++;
                }
 
-               // Set User Data Header Port Information
-               if (pMsgInfo->msgPort.valid == true)
-               {
+               /* Set User Data Header Port Information */
+               if (pMsgInfo->msgPort.valid == true) {
                        pData->userData[i].header[headerCnt].udhType = SMS_UDH_APP_PORT_16BIT;
                        pData->userData[i].header[headerCnt].udh.appPort16bit.destPort = pMsgInfo->msgPort.dstPort;
                        pData->userData[i].header[headerCnt].udh.appPort16bit.originPort = pMsgInfo->msgPort.srcPort;
@@ -974,9 +909,8 @@ MSG_DEBUG("user data [%s]", pData->userData[i].data);
                        headerCnt++;
                }
 
-               // Set User Data Header for Alternate Reply Address
-               if (strlen(pMsgInfo->replyAddress) > 0)
-               {
+               /* Set User Data Header for Alternate Reply Address */
+               if (strlen(pMsgInfo->replyAddress) > 0) {
                        pData->userData[i].header[headerCnt].udhType = SMS_UDH_ALTERNATE_REPLY_ADDRESS;
 
                        pData->userData[i].header[headerCnt].udh.alternateAddress.ton = SMS_TON_NATIONAL;
@@ -988,9 +922,8 @@ MSG_DEBUG("user data [%s]", pData->userData[i].data);
                        headerCnt++;
                }
 
-               // Set User Data Header for National Language Single Shift
-               if (*pCharType == SMS_CHARSET_7BIT && langId != MSG_LANG_ID_RESERVED)
-               {
+               /* Set User Data Header for National Language Single Shift */
+               if (*pCharType == SMS_CHARSET_7BIT && langId != MSG_LANG_ID_RESERVED) {
                        pData->userData[i].header[headerCnt].udhType = SMS_UDH_SINGLE_SHIFT;
                        pData->userData[i].header[headerCnt].udh.singleShift.langId = langId;
 
@@ -1009,45 +942,36 @@ int SmsPluginTransport::getSegmentSize(SMS_CODING_SCHEME_T CodingScheme, int Dat
        int headerLen = 1, concat = 5, port = 6, lang = 3, reply = 2;
        int headerSize = 0, segSize = 0, maxSize = 0;
 
-       if (CodingScheme == SMS_CHARSET_7BIT)
-       {
+       if (CodingScheme == SMS_CHARSET_7BIT) {
                MSG_DEBUG("SMS_CHARSET_7BIT");
                maxSize = MAX_GSM_7BIT_DATA_LEN;
-       }
-       else if (CodingScheme == SMS_CHARSET_8BIT || CodingScheme == SMS_CHARSET_UCS2)
-       {
+       } else if (CodingScheme == SMS_CHARSET_8BIT || CodingScheme == SMS_CHARSET_UCS2) {
                MSG_DEBUG("SMS_CHARSET_8BIT or SMS_CHARSET_UCS2 [%d]", CodingScheme);
                maxSize = MAX_UCS2_DATA_LEN;
        }
 
-       if (bPortNum == true)
-       {
+       if (bPortNum == true) {
                MSG_DEBUG("Port Number Exists");
                headerSize += port;
        }
 
-       if (LangId != MSG_LANG_ID_RESERVED)
-       {
+       if (LangId != MSG_LANG_ID_RESERVED) {
                MSG_DEBUG("National Language Exists");
                headerSize += lang;
        }
 
-       if (ReplyAddrLen > 0)
-       {
+       if (ReplyAddrLen > 0) {
                MSG_DEBUG("Reply Address Exists");
                headerSize += reply;
                headerSize += ReplyAddrLen;
        }
 
-       if (CodingScheme == SMS_CHARSET_7BIT)
-       {
+       if (CodingScheme == SMS_CHARSET_7BIT) {
                if ((DataLen+headerSize) > maxSize)
                        segSize = ((140*8) - ((headerLen + concat + headerSize)*8)) / 7;
                else
                        segSize = DataLen;
-       }
-       else if (CodingScheme == SMS_CHARSET_8BIT || CodingScheme == SMS_CHARSET_UCS2)
-       {
+       } else if (CodingScheme == SMS_CHARSET_8BIT || CodingScheme == SMS_CHARSET_UCS2) {
                if ((DataLen+headerSize) > maxSize)
                        segSize = 140 - (headerLen + concat + headerSize);
                else
@@ -1062,23 +986,22 @@ void SmsPluginTransport::setConcatHeader(SMS_UDH_S *pSrcHeader, SMS_UDH_S *pDstH
 {
        pDstHeader->udhType = pSrcHeader->udhType;
 
-       switch (pDstHeader->udhType)
+       switch (pDstHeader->udhType) {
+       case SMS_UDH_CONCAT_8BIT :
        {
-               case SMS_UDH_CONCAT_8BIT :
-               {
-                       pDstHeader->udh.concat8bit.msgRef = pSrcHeader->udh.concat8bit.msgRef;
-                       pDstHeader->udh.concat8bit.totalSeg = pSrcHeader->udh.concat8bit.totalSeg;
-                       pDstHeader->udh.concat8bit.seqNum = pSrcHeader->udh.concat8bit.seqNum;
-               }
-               break;
+               pDstHeader->udh.concat8bit.msgRef = pSrcHeader->udh.concat8bit.msgRef;
+               pDstHeader->udh.concat8bit.totalSeg = pSrcHeader->udh.concat8bit.totalSeg;
+               pDstHeader->udh.concat8bit.seqNum = pSrcHeader->udh.concat8bit.seqNum;
+       }
+       break;
 
-               case SMS_UDH_CONCAT_16BIT :
-               {
-                       pDstHeader->udh.concat16bit.msgRef = pSrcHeader->udh.concat16bit.msgRef;
-                       pDstHeader->udh.concat16bit.totalSeg = pSrcHeader->udh.concat16bit.totalSeg;
-                       pDstHeader->udh.concat16bit.seqNum = pSrcHeader->udh.concat16bit.seqNum;
-               }
-               break;
+       case SMS_UDH_CONCAT_16BIT :
+       {
+               pDstHeader->udh.concat16bit.msgRef = pSrcHeader->udh.concat16bit.msgRef;
+               pDstHeader->udh.concat16bit.totalSeg = pSrcHeader->udh.concat16bit.totalSeg;
+               pDstHeader->udh.concat16bit.seqNum = pSrcHeader->udh.concat16bit.seqNum;
+       }
+       break;
        }
 }
 
@@ -1103,8 +1026,7 @@ SMS_NETWORK_STATUS_T SmsPluginTransport::getNetStatus()
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
+       if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: SENT STATUS TIME-OUT");
                curStatus = SMS_NETWORK_SEND_FAIL_TIMEOUT;
        }
@@ -1138,8 +1060,7 @@ int SmsPluginTransport::getMoCtrlStatus()
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
+       if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: SENT STATUS TIME-OUT");
                return -1;
        }
@@ -1158,28 +1079,27 @@ SMS_PID_T SmsPluginTransport::convertPid(MSG_SMS_PID_T pid)
 {
        SMS_PID_T retPid;
 
-       switch (pid)
-       {
-               case MSG_PID_TEXT :
-                       retPid = SMS_PID_NORMAL;
+       switch (pid) {
+       case MSG_PID_TEXT :
+               retPid = SMS_PID_NORMAL;
                break;
-               case MSG_PID_VOICE :
-                       retPid = SMS_PID_VOICE;
+       case MSG_PID_VOICE :
+               retPid = SMS_PID_VOICE;
                break;
-               case MSG_PID_FAX :
-                       retPid = SMS_PID_TELEX;
+       case MSG_PID_FAX :
+               retPid = SMS_PID_TELEX;
                break;
-               case MSG_PID_X400 :
-                       retPid = SMS_PID_x400;
+       case MSG_PID_X400 :
+               retPid = SMS_PID_x400;
                break;
-               case MSG_PID_ERMES :
-                       retPid = SMS_PID_ERMES;
+       case MSG_PID_ERMES :
+               retPid = SMS_PID_ERMES;
                break;
-               case MSG_PID_EMAIL :
-                       retPid = SMS_PID_EMAIL;
+       case MSG_PID_EMAIL :
+               retPid = SMS_PID_EMAIL;
                break;
-               default :
-                       retPid = SMS_PID_NORMAL;
+       default :
+               retPid = SMS_PID_NORMAL;
                break;
        }
 
index fb72329..33b1df5 100755 (executable)
@@ -53,8 +53,7 @@ SmsPluginUAManager* SmsPluginUAManager::instance()
 
 void SmsPluginUAManager::run()
 {
-       while (1)
-       {
+       while (1) {
                lock();
                while (smsTranQ.empty()) {
                        wait();
@@ -66,21 +65,16 @@ void SmsPluginUAManager::run()
                request.msgInfo.addressList = NULL;
                unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&request.msgInfo.addressList, unique_ptr_deleter);
 
-               try
-               {
+               try {
                        SmsPluginTransport::instance()->submitRequest(&request);
-               }
-               catch (MsgException& e)
-               {
+               } catch (MsgException& e) {
                        MSG_FATAL("%s", e.what());
 
                        lock();
                        smsTranQ.pop_front();
                        unlock();
                        continue;
-               }
-               catch (exception& e)
-               {
+               } catch (exception& e) {
                        MSG_FATAL("%s", e.what());
                        lock();
                        smsTranQ.pop_front();
index d5b51e6..e43d8a6 100755 (executable)
@@ -40,17 +40,16 @@ int SmsPluginUDCodec::encodeUserData(const SMS_USERDATA_S *pUserData, SMS_CODING
 {
        int encodeSize = 0;
 
-       switch (CodingScheme)
-       {
-               case SMS_CHARSET_7BIT:
-                       encodeSize = encodeGSMData(pUserData, pEncodeData);
-                       break;
-               case SMS_CHARSET_8BIT:
-                       encodeSize = encode8bitData(pUserData, pEncodeData);
-                       break;
-               case SMS_CHARSET_UCS2:
-                       encodeSize = encodeUCS2Data(pUserData, pEncodeData);
-                       break;
+       switch (CodingScheme) {
+       case SMS_CHARSET_7BIT:
+               encodeSize = encodeGSMData(pUserData, pEncodeData);
+               break;
+       case SMS_CHARSET_8BIT:
+               encodeSize = encode8bitData(pUserData, pEncodeData);
+               break;
+       case SMS_CHARSET_UCS2:
+               encodeSize = encodeUCS2Data(pUserData, pEncodeData);
+               break;
        }
 
        return encodeSize;
@@ -63,17 +62,16 @@ int SmsPluginUDCodec::decodeUserData(const unsigned char *pTpdu, const int tpduL
 
        memset(pUserData, 0x00, sizeof(SMS_USERDATA_S));
 
-       switch (CodingScheme)
-       {
-               case SMS_CHARSET_7BIT:
-                       decodeSize = decodeGSMData(pTpdu, tpduLen, bHeaderInd, pUserData, NULL);
-                       break;
-               case SMS_CHARSET_8BIT:
-                       decodeSize = decode8bitData(pTpdu, bHeaderInd, pUserData, NULL);
-                       break;
-               case SMS_CHARSET_UCS2:
-                       decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, NULL);
-                       break;
+       switch (CodingScheme) {
+       case SMS_CHARSET_7BIT:
+               decodeSize = decodeGSMData(pTpdu, tpduLen, bHeaderInd, pUserData, NULL);
+               break;
+       case SMS_CHARSET_8BIT:
+               decodeSize = decode8bitData(pTpdu, bHeaderInd, pUserData, NULL);
+               break;
+       case SMS_CHARSET_UCS2:
+               decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, NULL);
+               break;
        }
 
        return decodeSize;
@@ -86,20 +84,19 @@ int SmsPluginUDCodec::decodeUserData(const unsigned char *pTpdu, const int tpduL
 
        memset(pUserData, 0x00, sizeof(SMS_USERDATA_S));
 
-       switch (CodingScheme)
-       {
-               case SMS_CHARSET_7BIT:
-                       decodeSize = decodeGSMData(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
-                       break;
-               case SMS_CHARSET_8BIT:
-                       decodeSize = decode8bitData(pTpdu, bHeaderInd, pUserData, pTPUD);
-                       break;
-               case SMS_CHARSET_UCS2:
-                       decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
-                       break;
-               case SMS_CHARSET_EUCKR:
-                       decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
-                       break;
+       switch (CodingScheme) {
+       case SMS_CHARSET_7BIT:
+               decodeSize = decodeGSMData(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
+               break;
+       case SMS_CHARSET_8BIT:
+               decodeSize = decode8bitData(pTpdu, bHeaderInd, pUserData, pTPUD);
+               break;
+       case SMS_CHARSET_UCS2:
+               decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
+               break;
+       case SMS_CHARSET_EUCKR:
+               decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
+               break;
        }
 
        return decodeSize;
@@ -116,38 +113,34 @@ int SmsPluginUDCodec::encodeGSMData(const SMS_USERDATA_S *pUserData, char *pEnco
        else
                offset = 1;
 
-MSG_DEBUG("pUserData->headerCnt [%d]", pUserData->headerCnt);
+       MSG_DEBUG("pUserData->headerCnt [%d]", pUserData->headerCnt);
 
-       // Encode User Data Header
-       for (int i = 0; i < pUserData->headerCnt; i++)
-       {
+       /* Encode User Data Header */
+       for (int i = 0; i < pUserData->headerCnt; i++) {
                headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
 
-MSG_DEBUG("headerLen [%d]", headerLen);
+               MSG_DEBUG("headerLen [%d]", headerLen);
 
                udhl += headerLen;
                offset += headerLen;
        }
 
-MSG_DEBUG("udhl [%d]", udhl);
+       MSG_DEBUG("udhl [%d]", udhl);
 
        if (udhl > 0)
-               fillBits = ((udhl+1)*8)%7; // + UDHL
+               fillBits = ((udhl+1)*8)%7; /* + UDHL */
 
        if (fillBits > 0)
                fillBits = 7 - fillBits;
 
-MSG_DEBUG("fillBits [%d]", fillBits);
-MSG_DEBUG("dataLen [%d]", pUserData->length);
+       MSG_DEBUG("fillBits [%d]", fillBits);
+       MSG_DEBUG("dataLen [%d]", pUserData->length);
 
-       // Set UDL, UDHL
-       if (udhl > 0)
-       {
+       /* Set UDL, UDHL */
+       if (udhl > 0) {
                pEncodeData[0] = (((udhl+1)*8) + fillBits + (pUserData->length*7)) / 7;
                pEncodeData[1] =  udhl;
-       }
-       else
-       {
+       } else {
                pEncodeData[0] = (char)pUserData->length;
        }
 
@@ -155,8 +148,8 @@ MSG_DEBUG("dataLen [%d]", pUserData->length);
 
        encodeLen = offset + packSize;
 
-MSG_DEBUG("packSize [%d]", packSize);
-MSG_DEBUG("encodeLen [%d]", encodeLen);
+       MSG_DEBUG("packSize [%d]", packSize);
+       MSG_DEBUG("encodeLen [%d]", encodeLen);
 
 #if 0
 printf("\n\n[encodeGSMData] userData data.\n");
@@ -181,26 +174,22 @@ int SmsPluginUDCodec::encode8bitData(const SMS_USERDATA_S *pUserData, char *pEnc
        else
                offset = 1;
 
-       // Encode User Data Header
-       for (int i = 0; i < pUserData->headerCnt; i++)
-       {
+       /* Encode User Data Header */
+       for (int i = 0; i < pUserData->headerCnt; i++) {
                headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
 
                udhl += headerLen;
                offset += headerLen;
        }
 
-MSG_DEBUG("fillBits [%d]", fillBits);
-MSG_DEBUG("dataLen [%d]", pUserData->length);
+       MSG_DEBUG("fillBits [%d]", fillBits);
+       MSG_DEBUG("dataLen [%d]", pUserData->length);
 
-       // Set UDL, UDHL
-       if (udhl > 0)
-       {
+       /* Set UDL, UDHL */
+       if (udhl > 0) {
                pEncodeData[0] = (udhl+1) + fillBits + pUserData->length;
                pEncodeData[1] =  udhl;
-       }
-       else
-       {
+       } else {
                pEncodeData[0] = (char)pUserData->length;
        }
 
@@ -222,26 +211,22 @@ int SmsPluginUDCodec::encodeUCS2Data(const SMS_USERDATA_S *pUserData, char *pEnc
        else
                offset = 1;
 
-       // Encode User Data Header
-       for (int i = 0; i < pUserData->headerCnt; i++)
-       {
+       /* Encode User Data Header */
+       for (int i = 0; i < pUserData->headerCnt; i++) {
                headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
 
                udhl += headerLen;
                offset += headerLen;
        }
 
-MSG_DEBUG("fillBits [%d]", fillBits);
-MSG_DEBUG("dataLen [%d]", pUserData->length);
+       MSG_DEBUG("fillBits [%d]", fillBits);
+       MSG_DEBUG("dataLen [%d]", pUserData->length);
 
-       // Set UDL, UDHL
-       if (udhl > 0)
-       {
+       /* Set UDL, UDHL */
+       if (udhl > 0) {
                pEncodeData[0] = (udhl+1) + fillBits + pUserData->length;
                pEncodeData[1] =  udhl;
-       }
-       else
-       {
+       } else {
                pEncodeData[0] = (char)pUserData->length;
        }
 
@@ -266,41 +251,37 @@ int SmsPluginUDCodec::decodeGSMData(const unsigned char *pTpdu, const int tpduLe
 {
        int offset = 0, udl = 0, udhl = 0, headerLen = 0, fillBits = 0, octetUdl = 0;
 
-       // UDL
+       /* UDL */
        udl = pTpdu[offset++];
        octetUdl = (udl*7)/8;
 
-MSG_DEBUG("udl = %d, tpdulen = %d, octetUdl = %d.", udl, tpduLen, octetUdl);
-MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
+       MSG_DEBUG("udl = %d, tpdulen = %d, octetUdl = %d.", udl, tpduLen, octetUdl);
+       MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
 
-       if (udl > MAX_GSM_7BIT_DATA_LEN || octetUdl > tpduLen)
-       {
+       if (udl > MAX_GSM_7BIT_DATA_LEN || octetUdl > tpduLen) {
                pUserData->length = 0;
                pUserData->headerCnt = 0;
                return 0;
        }
 
-       // Setting for Wap Push
-       if (pTPUD != NULL)
-       {
+       /* Setting for Wap Push */
+       if (pTPUD != NULL) {
                pTPUD->udl = udl;
 
                memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
                pTPUD->ud[udl] = '\0';
        }
 
-       // Decode User Data Header
-       if (bHeaderInd == true)
-       {
-               // UDHL
+       /* Decode User Data Header */
+       if (bHeaderInd == true) {
+               /* UDHL */
                udhl = pTpdu[offset++];
 
                MSG_DEBUG("udhl = %d", udhl);
 
                pUserData->headerCnt = 0;
 
-               for (int i = 0; offset < udhl; i++)
-               {
+               for (int i = 0; offset < udhl; i++) {
                        headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
 
                        if (headerLen <= 0) {
@@ -325,30 +306,25 @@ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
 
                        pUserData->headerCnt++;
                }
-       }
-       else
+       } else {
                pUserData->headerCnt = 0;
+       }
 
        MSG_DEBUG("headerCnt = %d", pUserData->headerCnt);
 
-       if (udhl > 0)
-       {
+       if (udhl > 0) {
                fillBits = ((udl*7) - ((udhl+1)*8)) % 7;
                udl = ((udl*7) - ((udhl+1)*8)) / 7;
        }
 
-MSG_DEBUG("fillBits = %d", fillBits);
-MSG_DEBUG("udhl = %d", udhl);
-MSG_DEBUG("udl = %d", udl);
+       MSG_DEBUG("fillBits = %d", fillBits);
+       MSG_DEBUG("udhl = %d", udhl);
+       MSG_DEBUG("udl = %d", udl);
 
-MSG_DEBUG("offset = %d", offset);
+       MSG_DEBUG("offset = %d", offset);
 
        pUserData->length = unpack7bitChar(&(pTpdu[offset]), udl, fillBits, pUserData->data);
 
-       //MSG_DEBUG("data = [%s]", pUserData->data);
-       //MSG_DEBUG("length = [%d]", pUserData->length);
-
-
        return pUserData->length;
 }
 
@@ -357,39 +333,35 @@ int SmsPluginUDCodec::decode8bitData(const unsigned char *pTpdu, bool bHeaderInd
 {
        int offset = 0, udl = 0, udhl = 0, headerLen = 0;
 
-       // UDL
+       /* UDL */
        udl = pTpdu[offset++];
 
-       if (udl > MAX_UCS2_DATA_LEN)
-       {
+       if (udl > MAX_UCS2_DATA_LEN) {
                pUserData->length = 0;
                return 0;
        }
 
-       // Setting for Wap Push
-       if (pTPUD != NULL)
-       {
+       /* Setting for Wap Push */
+       if (pTPUD != NULL) {
                pTPUD->udl = udl;
 
                memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
                pTPUD->ud[udl] = '\0';
        }
 
-MSG_DEBUG("udl = %d", udl);
-MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
+       MSG_DEBUG("udl = %d", udl);
+       MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
 
-       // Decode User Data Header
-       if (bHeaderInd == true)
-       {
-               // UDHL
+       /* Decode User Data Header */
+       if (bHeaderInd == true) {
+               /* UDHL */
                udhl = pTpdu[offset++];
 
                MSG_DEBUG("udhl = %d", udhl);
 
                pUserData->headerCnt = 0;
 
-               for (int i = 0; offset < udhl; i++)
-               {
+               for (int i = 0; offset < udhl; i++) {
                        headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
 
                        if (headerLen <= 0) {
@@ -414,19 +386,19 @@ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
 
                        pUserData->headerCnt++;
                }
-       }
-       else
+       } else {
                pUserData->headerCnt = 0;
+       }
 
-MSG_DEBUG("headerCnt = %d", pUserData->headerCnt);
+       MSG_DEBUG("headerCnt = %d", pUserData->headerCnt);
 
        if (udhl > 0)
                pUserData->length = (udl) - (udhl+1);
        else
                pUserData->length = udl;
 
-MSG_DEBUG("pUserData->length = %d", pUserData->length);
-MSG_DEBUG("offset = %d", offset);
+       MSG_DEBUG("pUserData->length = %d", pUserData->length);
+       MSG_DEBUG("offset = %d", offset);
 
        memcpy(pUserData->data, &(pTpdu[offset]), pUserData->length);
 
@@ -438,40 +410,36 @@ int SmsPluginUDCodec::decodeUCS2Data(const unsigned char *pTpdu, const int tpduL
 {
        int offset = 0, udl = 0, udhl = 0, headerLen = 0;
 
-       // UDL
+       /* UDL */
        udl = pTpdu[offset++];
 
-MSG_DEBUG("udl = %d, tpdulen = %d.", udl, tpduLen);
-MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
+       MSG_DEBUG("udl = %d, tpdulen = %d.", udl, tpduLen);
+       MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
 
-       if (udl > MAX_UCS2_DATA_LEN || udl > tpduLen)
-       {
+       if (udl > MAX_UCS2_DATA_LEN || udl > tpduLen) {
                pUserData->length = 0;
                pUserData->headerCnt = 0;
                return 0;
        }
 
-       // Setting for Wap Push
-       if (pTPUD != NULL)
-       {
+       /* Setting for Wap Push */
+       if (pTPUD != NULL) {
                pTPUD->udl = udl;
 
                memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
                pTPUD->ud[udl] = '\0';
        }
 
-       // Decode User Data Header
-       if (bHeaderInd == true)
-       {
-               // UDHL
+       /* Decode User Data Header */
+       if (bHeaderInd == true) {
+               /* UDHL */
                udhl = pTpdu[offset++];
 
                MSG_DEBUG("udhl = %d", udhl);
 
                pUserData->headerCnt = 0;
 
-               for (int i = 0; offset < udhl; i++)
-               {
+               for (int i = 0; offset < udhl; i++) {
                        headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
 
                        if (headerLen <= 0) {
@@ -496,17 +464,17 @@ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
 
                        pUserData->headerCnt++;
                }
-       }
-       else
+       } else {
                pUserData->headerCnt = 0;
+       }
 
        if (udhl > 0)
                pUserData->length = (udl) - (udhl+1);
        else
                pUserData->length = udl;
 
-MSG_DEBUG("pUserData->length = %d", pUserData->length);
-MSG_DEBUG("offset = %d", offset);
+       MSG_DEBUG("pUserData->length = %d", pUserData->length);
+       MSG_DEBUG("offset = %d", offset);
 
        memcpy(pUserData->data, &(pTpdu[offset]), pUserData->length);
        pUserData->data[pUserData->length] = 0;
@@ -522,117 +490,118 @@ int SmsPluginUDCodec::encodeHeader(const SMS_UDH_S header, char *pEncodeHeader)
        char* encodedAddr = NULL;
        unique_ptr<char*, void(*)(char**)> addressBuf(&encodedAddr, unique_ptr_deleter);
 
-       switch (header.udhType)
-       {
-               case SMS_UDH_CONCAT_8BIT :
-                       // IEI
-                       pEncodeHeader[offset++] = SMS_UDH_CONCAT_8BIT;
+       switch (header.udhType) {
+       case SMS_UDH_CONCAT_8BIT :
+               /* IEI */
+               pEncodeHeader[offset++] = SMS_UDH_CONCAT_8BIT;
+
+               /* IEDL */
+               pEncodeHeader[offset++] = 0x03;
 
-                       // IEDL
-                       pEncodeHeader[offset++] = 0x03;
+               /* Reference Number */
+               pEncodeHeader[offset++] = header.udh.concat8bit.msgRef;
 
-                       // Reference Number
-                       pEncodeHeader[offset++] = header.udh.concat8bit.msgRef;
+               /* Number of Segments */
+               pEncodeHeader[offset++] = header.udh.concat8bit.totalSeg;
 
-                       // Number of Segments
-                       pEncodeHeader[offset++] = header.udh.concat8bit.totalSeg;
+               /* Sequence Number */
+               pEncodeHeader[offset++] = header.udh.concat8bit.seqNum;
 
-                       // Sequence Number
-                       pEncodeHeader[offset++] = header.udh.concat8bit.seqNum;
                break;
 
-               case SMS_UDH_CONCAT_16BIT :
-                       // IEI
-                       pEncodeHeader[offset++] = SMS_UDH_CONCAT_16BIT;
+       case SMS_UDH_CONCAT_16BIT :
+               /* IEI */
+               pEncodeHeader[offset++] = SMS_UDH_CONCAT_16BIT;
 
-                       // IEDL
-                       pEncodeHeader[offset++] = 0x04;
+               /* IEDL */
+               pEncodeHeader[offset++] = 0x04;
 
-                       // Reference Number
-                       pEncodeHeader[offset++] = (char)(header.udh.concat16bit.msgRef >> 8);
-                       pEncodeHeader[offset++] = header.udh.concat16bit.msgRef & 0x00FF;
+               /* Reference Number */
+               pEncodeHeader[offset++] = (char)(header.udh.concat16bit.msgRef >> 8);
+               pEncodeHeader[offset++] = header.udh.concat16bit.msgRef & 0x00FF;
 
-                       // Number of Segments
-                       pEncodeHeader[offset++] = header.udh.concat16bit.totalSeg;
+               /* Number of Segments */
+               pEncodeHeader[offset++] = header.udh.concat16bit.totalSeg;
+
+               /* Sequence Number */
+               pEncodeHeader[offset++] = header.udh.concat16bit.seqNum;
 
-                       // Sequence Number
-                       pEncodeHeader[offset++] = header.udh.concat16bit.seqNum;
                break;
 
-               case SMS_UDH_APP_PORT_8BIT :
-                       // IEI
-                       pEncodeHeader[offset++] = SMS_UDH_APP_PORT_8BIT;
+       case SMS_UDH_APP_PORT_8BIT :
+               /* IEI */
+               pEncodeHeader[offset++] = SMS_UDH_APP_PORT_8BIT;
+
+               /* IEDL */
+               pEncodeHeader[offset++] = 0x02;
 
-                       // IEDL
-                       pEncodeHeader[offset++] = 0x02;
+               /* Dest Port */
+               pEncodeHeader[offset++] = header.udh.appPort8bit.destPort;
 
-                       // Dest Port
-                       pEncodeHeader[offset++] = header.udh.appPort8bit.destPort;
+               /* Origin Port */
+               pEncodeHeader[offset++] = header.udh.appPort8bit.originPort;
 
-                       // Origin Port
-                       pEncodeHeader[offset++] = header.udh.appPort8bit.originPort;
                break;
 
-               case SMS_UDH_APP_PORT_16BIT :
-                       // IEI
-                       pEncodeHeader[offset++] = SMS_UDH_APP_PORT_16BIT;
+       case SMS_UDH_APP_PORT_16BIT :
+               /* IEI */
+               pEncodeHeader[offset++] = SMS_UDH_APP_PORT_16BIT;
 
-                       // IEDL
-                       pEncodeHeader[offset++] = 0x04;
+               /* IEDL */
+               pEncodeHeader[offset++] = 0x04;
 
-                       // Dest Port
-                       pEncodeHeader[offset++] = (char)(header.udh.appPort16bit.destPort >> 8);
-                       pEncodeHeader[offset++] = header.udh.appPort16bit.destPort & 0x00FF;
+               /* Dest Port */
+               pEncodeHeader[offset++] = (char)(header.udh.appPort16bit.destPort >> 8);
+               pEncodeHeader[offset++] = header.udh.appPort16bit.destPort & 0x00FF;
 
-                       // Origin Port
-                       pEncodeHeader[offset++] = (char)(header.udh.appPort16bit.originPort >> 8);
-                       pEncodeHeader[offset++] = header.udh.appPort16bit.originPort & 0x00FF;
-               break;
+               /* Origin Port */
+               pEncodeHeader[offset++] = (char)(header.udh.appPort16bit.originPort >> 8);
+               pEncodeHeader[offset++] = header.udh.appPort16bit.originPort & 0x00FF;
 
-               case SMS_UDH_ALTERNATE_REPLY_ADDRESS :
-                       // IEI
-                       pEncodeHeader[offset++] = SMS_UDH_ALTERNATE_REPLY_ADDRESS;
+               break;
 
-                       addrLen = SmsPluginParamCodec::encodeAddress(&(header.udh.alternateAddress), &encodedAddr);
+       case SMS_UDH_ALTERNATE_REPLY_ADDRESS :
+               /* IEI */
+               pEncodeHeader[offset++] = SMS_UDH_ALTERNATE_REPLY_ADDRESS;
 
-//MSG_DEBUG("addrLen : %d", addrLen);
+               addrLen = SmsPluginParamCodec::encodeAddress(&(header.udh.alternateAddress), &encodedAddr);
 
-//for (int i = 0; i < addrLen; i++)
-//     MSG_DEBUG("header.udh.alternateAddress.address : [%02x]", encodedAddr[i]);
+               /* IEDL */
+               pEncodeHeader[offset++] = addrLen;
 
-                       // IEDL
-                       pEncodeHeader[offset++] = addrLen;
+               /* Alternate Reply Address */
+               memcpy(&pEncodeHeader[offset], encodedAddr, addrLen);
 
-                       // Alternate Reply Address
-                       memcpy(&pEncodeHeader[offset], encodedAddr, addrLen);
+               offset += addrLen;
 
-                       offset += addrLen;
                break;
 
-               case SMS_UDH_SINGLE_SHIFT :
-                       // IEI
-                       pEncodeHeader[offset++] = SMS_UDH_SINGLE_SHIFT;
+       case SMS_UDH_SINGLE_SHIFT :
+               /* IEI */
+               pEncodeHeader[offset++] = SMS_UDH_SINGLE_SHIFT;
 
-                       // IEDL
-                       pEncodeHeader[offset++] = 0x01;
+               /* IEDL */
+               pEncodeHeader[offset++] = 0x01;
+
+               /* National Language Identifier */
+               pEncodeHeader[offset++] = header.udh.singleShift.langId;
 
-                       // National Language Identifier
-                       pEncodeHeader[offset++] = header.udh.singleShift.langId;
                break;
 
-               case SMS_UDH_LOCKING_SHIFT :
-                       // IEI
-                       pEncodeHeader[offset++] = SMS_UDH_LOCKING_SHIFT;
+       case SMS_UDH_LOCKING_SHIFT :
+               /* IEI */
+               pEncodeHeader[offset++] = SMS_UDH_LOCKING_SHIFT;
+
+               /* IEDL */
+               pEncodeHeader[offset++] = 0x01;
 
-                       // IEDL
-                       pEncodeHeader[offset++] = 0x01;
+               /* National Language Identifier */
+               pEncodeHeader[offset++] = header.udh.lockingShift.langId;
 
-                       // National Language Identifier
-                       pEncodeHeader[offset++] = header.udh.lockingShift.langId;
                break;
 
-               case SMS_UDH_NONE :
-               default :
+       case SMS_UDH_NONE :
+       default :
                break;
        }
 
@@ -647,130 +616,138 @@ int SmsPluginUDCodec::decodeHeader(const unsigned char *pTpdu, SMS_UDH_S *pHeade
 
        pHeader->udhType = pTpdu[offset++];
 
-       switch (pHeader->udhType)
+       switch (pHeader->udhType) {
+       case SMS_UDH_CONCAT_8BIT :
        {
-               case SMS_UDH_CONCAT_8BIT :
-               {
-                       IEDL = pTpdu[offset++];
+               IEDL = pTpdu[offset++];
 
-                       if (IEDL == 0) return 0;
+               if (IEDL == 0)
+                       return 0;
 
-                       pHeader->udh.concat8bit.msgRef = pTpdu[offset++];
-                       pHeader->udh.concat8bit.totalSeg = pTpdu[offset++];
-                       pHeader->udh.concat8bit.seqNum = pTpdu[offset++];
+               pHeader->udh.concat8bit.msgRef = pTpdu[offset++];
+               pHeader->udh.concat8bit.totalSeg = pTpdu[offset++];
+               pHeader->udh.concat8bit.seqNum = pTpdu[offset++];
 
-MSG_DEBUG("concat8bit.msgRef [%02x]", pHeader->udh.concat8bit.msgRef);
-MSG_DEBUG("concat8bit.totalSeg [%02x]", pHeader->udh.concat8bit.totalSeg);
-MSG_DEBUG("concat8bit.seqNum [%02x]", pHeader->udh.concat8bit.seqNum);
-               }
-               break;
+               MSG_DEBUG("concat8bit.msgRef [%02x]", pHeader->udh.concat8bit.msgRef);
+               MSG_DEBUG("concat8bit.totalSeg [%02x]", pHeader->udh.concat8bit.totalSeg);
+               MSG_DEBUG("concat8bit.seqNum [%02x]", pHeader->udh.concat8bit.seqNum);
+       }
+       break;
 
-               case SMS_UDH_CONCAT_16BIT :
-               {
-                       IEDL = pTpdu[offset++];
+       case SMS_UDH_CONCAT_16BIT :
+       {
+               IEDL = pTpdu[offset++];
 
-                       if (IEDL == 0) return 0;
+               if (IEDL == 0)
+                       return 0;
 
-                       pHeader->udh.concat16bit.msgRef = pTpdu[offset++];
-                       pHeader->udh.concat16bit.msgRef = (unsigned short)((pHeader->udh.concat16bit.msgRef << 8) | pTpdu[offset++]);
-                       pHeader->udh.concat16bit.totalSeg = pTpdu[offset++];
-                       pHeader->udh.concat16bit.seqNum = pTpdu[offset++];
+               pHeader->udh.concat16bit.msgRef = pTpdu[offset++];
+               pHeader->udh.concat16bit.msgRef = (unsigned short)((pHeader->udh.concat16bit.msgRef << 8) | pTpdu[offset++]);
+               pHeader->udh.concat16bit.totalSeg = pTpdu[offset++];
+               pHeader->udh.concat16bit.seqNum = pTpdu[offset++];
 
-MSG_DEBUG("concat16bit.msgRef [%04x]", pHeader->udh.concat16bit.msgRef);
-MSG_DEBUG("concat16bit.totalSeg [%02x]", pHeader->udh.concat16bit.totalSeg);
-MSG_DEBUG("concat16bit.seqNum [%02x]", pHeader->udh.concat16bit.seqNum);
-               }
-               break;
+               MSG_DEBUG("concat16bit.msgRef [%04x]", pHeader->udh.concat16bit.msgRef);
+               MSG_DEBUG("concat16bit.totalSeg [%02x]", pHeader->udh.concat16bit.totalSeg);
+               MSG_DEBUG("concat16bit.seqNum [%02x]", pHeader->udh.concat16bit.seqNum);
+       }
+       break;
 
-               case SMS_UDH_APP_PORT_8BIT :
-               {
-                       IEDL = pTpdu[offset++];
+       case SMS_UDH_APP_PORT_8BIT :
+       {
+               IEDL = pTpdu[offset++];
 
-                       if (IEDL == 0) return 0;
+               if (IEDL == 0)
+                       return 0;
 
-                       pHeader->udh.appPort8bit.destPort = pTpdu[offset++];
-                       pHeader->udh.appPort8bit.originPort = pTpdu[offset++];
+               pHeader->udh.appPort8bit.destPort = pTpdu[offset++];
+               pHeader->udh.appPort8bit.originPort = pTpdu[offset++];
 
-MSG_DEBUG("appPort8bit.destPort [%02x]", pHeader->udh.appPort8bit.destPort);
-MSG_DEBUG("appPort8bit.originPort [%02x]", pHeader->udh.appPort8bit.originPort);
-               }
-               break;
+               MSG_DEBUG("appPort8bit.destPort [%02x]", pHeader->udh.appPort8bit.destPort);
+               MSG_DEBUG("appPort8bit.originPort [%02x]", pHeader->udh.appPort8bit.originPort);
+       }
+       break;
 
-               case SMS_UDH_APP_PORT_16BIT :
-               {
-                       IEDL = pTpdu[offset++];
+       case SMS_UDH_APP_PORT_16BIT :
+       {
+               IEDL = pTpdu[offset++];
 
-                       if (IEDL == 0) return 0;
+               if (IEDL == 0)
+                       return 0;
 
-                       pHeader->udh.appPort16bit.destPort = pTpdu[offset++];
-                       pHeader->udh.appPort16bit.destPort = (unsigned short)((pHeader->udh.appPort16bit.destPort << 8) | pTpdu[offset++]);
-                       pHeader->udh.appPort16bit.originPort = pTpdu[offset++];
-                       pHeader->udh.appPort16bit.originPort = (unsigned short)((pHeader->udh.appPort16bit.originPort << 8) | pTpdu[offset++]);
+               pHeader->udh.appPort16bit.destPort = pTpdu[offset++];
+               pHeader->udh.appPort16bit.destPort = (unsigned short)((pHeader->udh.appPort16bit.destPort << 8) | pTpdu[offset++]);
+               pHeader->udh.appPort16bit.originPort = pTpdu[offset++];
+               pHeader->udh.appPort16bit.originPort = (unsigned short)((pHeader->udh.appPort16bit.originPort << 8) | pTpdu[offset++]);
 
-MSG_DEBUG("appPort16bit.destPort [%04x]", pHeader->udh.appPort16bit.destPort);
-MSG_DEBUG("appPort16bit.originPort [%04x]", pHeader->udh.appPort16bit.originPort);
-               }
-               break;
+               MSG_DEBUG("appPort16bit.destPort [%04x]", pHeader->udh.appPort16bit.destPort);
+               MSG_DEBUG("appPort16bit.originPort [%04x]", pHeader->udh.appPort16bit.originPort);
+       }
+       break;
 
-               case SMS_UDH_SPECIAL_SMS :
-               {
-                       IEDL = pTpdu[offset++];
+       case SMS_UDH_SPECIAL_SMS :
+       {
+               IEDL = pTpdu[offset++];
 
-                       if (IEDL != 2) return 0;
-MSG_DEBUG("Decoding special sms udh.");
+               if (IEDL != 2)
+                       return 0;
 
-                       pHeader->udh.specialInd.bStore = (bool) (pTpdu[offset] & 0x80);
-                       pHeader->udh.specialInd.msgInd = (unsigned short) (pTpdu[offset++] & 0x7F);
-                       pHeader->udh.specialInd.waitMsgNum = (unsigned short) pTpdu[offset];
-               }
-               break;
+               MSG_DEBUG("Decoding special sms udh.");
 
-               case SMS_UDH_ALTERNATE_REPLY_ADDRESS :
-               {
-                       IEDL = pTpdu[offset++];
+               pHeader->udh.specialInd.bStore = (bool) (pTpdu[offset] & 0x80);
+               pHeader->udh.specialInd.msgInd = (unsigned short) (pTpdu[offset++] & 0x7F);
+               pHeader->udh.specialInd.waitMsgNum = (unsigned short) pTpdu[offset];
+       }
+       break;
 
-                       if (IEDL == 0) return 0;
+       case SMS_UDH_ALTERNATE_REPLY_ADDRESS :
+       {
+               IEDL = pTpdu[offset++];
 
-                       offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pHeader->udh.alternateAddress));
+               if (IEDL == 0)
+                       return 0;
 
-                       MSG_SEC_DEBUG("alternate reply address [%s]", pHeader->udh.alternateAddress.address);
-               }
-               break;
+               offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pHeader->udh.alternateAddress));
 
-               case SMS_UDH_SINGLE_SHIFT :
-               {
-                       IEDL = pTpdu[offset++];
+               MSG_SEC_DEBUG("alternate reply address [%s]", pHeader->udh.alternateAddress.address);
+       }
+       break;
 
-                       if (IEDL == 0) return 0;
+       case SMS_UDH_SINGLE_SHIFT :
+       {
+               IEDL = pTpdu[offset++];
 
-                       pHeader->udh.singleShift.langId = pTpdu[offset++];
+               if (IEDL == 0)
+                       return 0;
 
-MSG_DEBUG("singleShift.langId [%02x]", pHeader->udh.singleShift.langId);
-               }
-               break;
+               pHeader->udh.singleShift.langId = pTpdu[offset++];
 
-               case SMS_UDH_LOCKING_SHIFT :
-               {
-                       IEDL = pTpdu[offset++];
+               MSG_DEBUG("singleShift.langId [%02x]", pHeader->udh.singleShift.langId);
+       }
+       break;
 
-                       if (IEDL == 0) return 0;
+       case SMS_UDH_LOCKING_SHIFT :
+       {
+               IEDL = pTpdu[offset++];
 
-                       pHeader->udh.lockingShift.langId = pTpdu[offset++];
+               if (IEDL == 0)
+                       return 0;
 
-MSG_DEBUG("lockingShift.langId [%02x]", pHeader->udh.lockingShift.langId);
-               }
-               break;
+               pHeader->udh.lockingShift.langId = pTpdu[offset++];
 
-               default :
-               {
-                       MSG_DEBUG("Not Supported Header Type [%02x]", pHeader->udhType);
+               MSG_DEBUG("lockingShift.langId [%02x]", pHeader->udh.lockingShift.langId);
+       }
+       break;
 
-                       IEDL = pTpdu[offset++];
+       default :
+       {
+               MSG_DEBUG("Not Supported Header Type [%02x]", pHeader->udhType);
 
-                       MSG_DEBUG("IEDL [%d]", IEDL);
-                       return (offset + IEDL);
-               }
-               break;
+               IEDL = pTpdu[offset++];
+
+               MSG_DEBUG("IEDL [%d]", IEDL);
+               return (offset + IEDL);
+       }
+       break;
        }
 
        return offset;
@@ -781,60 +758,37 @@ int SmsPluginUDCodec::pack7bitChar(const unsigned char *pUserData, int dataLen,
 {
        int srcIdx = 0, dstIdx = 0, shift = fillBits;
 
-//MSG_DEBUG("dataLen = %d", dataLen);
-
        if (shift > 0)
                dstIdx = 1;
 
-       while (srcIdx < dataLen)
-       {
-               if (shift == 0)
-               {
-//                     if (srcIdx > 0) srcIdx++;
-
-//MSG_DEBUG("pUserData [%02x]", pUserData[srcIdx]);
-//MSG_DEBUG("shift = %d", shift);
-
+       while (srcIdx < dataLen) {
+               if (shift == 0) {
                        pPackData[dstIdx] = pUserData[srcIdx];
 
-//MSG_DEBUG("pPackData [%02x]", pPackData[dstIdx]);
                        shift = 7;
                        srcIdx++;
                        dstIdx++;
 
-                       if (srcIdx >= dataLen) break;
+                       if (srcIdx >= dataLen)
+                               break;
                }
 
-               if (shift > 1)
-               {
-//MSG_DEBUG("pUserData [%02x]", pUserData[srcIdx]);
-
-//MSG_DEBUG("shift = %d", shift);
-
+               if (shift > 1) {
                        pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
                        pPackData[dstIdx] = pUserData[srcIdx] >> (8-shift);
                        shift--;
-//MSG_DEBUG("pPackData [%02x]", pPackData[dstIdx]);
 
                        srcIdx++;
                        dstIdx++;
-               }
-               else if (shift == 1)
-               {
-//MSG_DEBUG("pUserData [%02x]", pUserData[srcIdx]);
-//MSG_DEBUG("shift = %d", shift);
+               } else if (shift == 1) {
                        pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
 
-//MSG_DEBUG("pPackData [%02x]", pPackData[dstIdx-1]);
-
                        srcIdx++;
 
                        shift--;
                }
        }
 
-//MSG_DEBUG("dstIdx = %d", dstIdx);
-
        return dstIdx;
 }
 
@@ -848,35 +802,27 @@ MSG_DEBUG("dataLen = %d", dataLen);
        if (shift > 0)
                srcIdx = 1;
 
-       for (; dstIdx < dataLen; dstIdx++)
-       {
-               if (shift == 0)
-               {
-//MSG_DEBUG("shift = %d", shift);
-
+       for (; dstIdx < dataLen; dstIdx++) {
+               if (shift == 0) {
                        pUnpackData[dstIdx] = pTpdu[srcIdx] & 0x7F;
 
-//MSG_DEBUG("UserData[%d] = %02x", dstIdx, pUnpackData[dstIdx]);
                        shift = 7;
                        srcIdx++;
                        dstIdx++;
 
-                       if (dstIdx >= dataLen) break;
+                       if (dstIdx >= dataLen)
+                               break;
                }
 
-               if (shift > 0)
-               {
-//MSG_DEBUG("shift = %d", shift);
-
+               if (shift > 0) {
                        pUnpackData[dstIdx] = (pTpdu[srcIdx-1] >> shift) + (pTpdu[srcIdx] << (8 - shift));
 
                        pUnpackData[dstIdx] &= 0x7F;
 
-//MSG_DEBUG("UserData[%d] = %02x", dstIdx, pUnpackData[dstIdx]);
-
                        shift--;
 
-                       if (shift > 0) srcIdx++;
+                       if (shift > 0)
+                               srcIdx++;
                }
        }
 
index 58ac6ce..eab0306 100755 (executable)
@@ -83,7 +83,7 @@ const SMS_PUSH_APP_INFO_S pushDefaultApplication [] =
 char gWapCodeBufferLeft[WSP_CODE_BUFFER_LEFT_LEN_MAX];
 char gWapCodeBufferRight[WSP_CODE_BUFFER_RIGHT_LEN_MAX];
 
-const unsigned long wspUintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00200000, 0x10000000};
+const unsigned long wspUintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00200000, 0x10000000 };
 
 const unsigned char wspHeaderFieldCount  = 0x43;
 const unsigned char wspContentsTypeCount = 0x34;
@@ -91,8 +91,7 @@ const unsigned long wspLanguageCount    = 0x11a;
 const unsigned char wspSecurityTypeCount = 0x04;
 
 
-static const SMS_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] =
-{
+static const SMS_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] = {
        { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
        { (char*)"application/vnd.wap.connectivity-wbxml", 0x36 },
        { (char*)"application/pkcs7-mime",  0x37 },
@@ -125,81 +124,79 @@ static const SMS_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] =
 };
 
 
-const char* wspHeaderFieldName[] =
-{
-       (char*)"Accept",  //0x00
+const char* wspHeaderFieldName[] = {
+       (char*)"Accept",  /* 0x00 */
        (char*)"Accept-Charset",
        (char*)"Accept-Encoding",
        (char*)"Accept-Language",
        (char*)"Accept-Ranges",
-       (char*)"Age", //0x05
+       (char*)"Age", /* 0x05 */
        (char*)"Allow",
        (char*)"Authorization",
        (char*)"Cache-Control",
        (char*)"Connection",
-       (char*)"Content-Base", //0x0a
+       (char*)"Content-Base", /* 0x0a */
        (char*)"Content-Encoding",
        (char*)"Content-Language",
        (char*)"Content-Length",
        (char*)"Content-Location",
        (char*)"Content-MD5",
-       (char*)"Content-Range", //0x10
+       (char*)"Content-Range", /* 0x10 */
        (char*)"Content-Type",
        (char*)"Date",
        (char*)"ETag",
        (char*)"Expires",
-       (char*)"From", //0x15
+       (char*)"From", /* 0x15 */
        (char*)"Host",
        (char*)"If-Modified-Since",
        (char*)"If-Match",
        (char*)"If-None-Match",
-       (char*)"If-Range", //0x1a
+       (char*)"If-Range", /* 0x1a */
        (char*)"If-Unmodified-Since",
        (char*)"Location",
        (char*)"Last-Modified",
        (char*)"Max-Forwards",
        (char*)"Pragma",
-       (char*)"Proxy-Authenticate", //0x20
+       (char*)"Proxy-Authenticate", /* 0x20 */
        (char*)"Proxy-Authorization",
        (char*)"Public",
        (char*)"Range",
        (char*)"Referer",
-       (char*)"Retry-After", //0x25
+       (char*)"Retry-After", /* 0x25 */
        (char*)"Server",
        (char*)"Transfer-Encodig",
        (char*)"Upgrade",
        (char*)"User-Agent",
-       (char*)"Vary", //0x2a
+       (char*)"Vary", /* 0x2a */
        (char*)"Via",
        (char*)"Warning",
        (char*)"Www-Authenticate",
        (char*)"Content-Disposition",
        (char*)"X-Wap-Application-Id",
-       (char*)"X-Wap-Content-URI", //0x30
+       (char*)"X-Wap-Content-URI", /* 0x30 */
        (char*)"X-Wap-Iinitiator-URI",
-       (char*)"Accept-Application", // Back
+       (char*)"Accept-Application", /* Back */
        (char*)"Bearer-Indication",
        (char*)"Push-Flag",
-       (char*)"Profile", //0x35
+       (char*)"Profile", /* 0x35 */
        (char*)"Profile-Diff",
-       (char*)"Profile-Warning", // end of WAP 1.2
+       (char*)"Profile-Warning", /* end of WAP 1.2 */
        (char*)"Expect",
        (char*)"Te",
-       (char*)"Trailer", //0x3a
-       (char*)"Accept-Charset", //Back
-       (char*)"Accept-Encoding", // Back
-       (char*)"Cache-Control", // back
+       (char*)"Trailer", /* 0x3a */
+       (char*)"Accept-Charset", /* Back */
+       (char*)"Accept-Encoding", /* Back */
+       (char*)"Cache-Control", /* back */
        (char*)"Content-Range",
        (char*)"X-Wap-Tod",
-       (char*)"Content-ID", //x40
+       (char*)"Content-ID", /* 0x40 */
        (char*)"Set-Cookie",
        (char*)"Cookie",
        (char*)"Encoding-Version"
 };
 
 
-const SMS_WSP_CHARSET_S wspCharset[] =
-{
+const SMS_WSP_CHARSET_S wspCharset[] = {
        { (char*)"big5", 0x07ea },
        { (char*)"iso-10646-ucs-2", 0x03e8 },
        { (char*)"iso-8859-1", 0x04 },
@@ -220,16 +217,14 @@ const SMS_WSP_CHARSET_S wspCharset[] =
 
 
 
-const char* wspEncodeMethod[] =
-{
+const char* wspEncodeMethod[] = {
        (char*)"Gzip",
        (char*)"Compress",
        (char*)"Deflate"
 };
 
 
-const SMS_WSP_CONTENTS_TYPE_S wspContentsType[] =
-{
+const SMS_WSP_CONTENTS_TYPE_S wspContentsType[] = {
        { (char*)"*/*", 0x00 },
        { (char*)"text/*", 0x01 },
        { (char*)"text/html", 0x02 },
@@ -306,8 +301,7 @@ const SMS_WSP_CONTENTS_TYPE_S wspContentsType[] =
        { (char*)"application/vnd.wv.csp.cir", 0x46 }
 };
 
-static const SMS_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]=
-{
+static const SMS_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]= {
        { (char*)"application/vnd.wap.emn+wbxml", 0x30A},
        { (char*)"application/vnd.omaloc-supl-init", 0x312},
        { (char*)"application/vnd.oma.drm.roap-trigger+wbxml", 0x316}
@@ -315,8 +309,7 @@ static const SMS_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]=
 
 const unsigned long wspUnregisteredContentsTypeCount = sizeof(wspUnregisterContentsType)/sizeof(SMS_WAP_UNREGISTER_CONTENTS_TYPE_S);
 
-const SMS_WSP_LANGUAGE_S wspLanguage[] =
-{
+const SMS_WSP_LANGUAGE_S wspLanguage[] = {
        { (char*)"English", 0x19 },
        { (char*)"en", 0x19 },
        { (char*)"Korean", 0x3d },
@@ -603,8 +596,7 @@ const SMS_WSP_LANGUAGE_S wspLanguage[] =
 };
 
 
-const SMS_WSP_HEADER_PARAMETER_S wspHeaderApplId[] =
-{
+const SMS_WSP_HEADER_PARAMETER_S wspHeaderApplId[] = {
        { (char*)"x-wap-application:*",  0x00 },
        { (char*)"x-wap-application:push.sia",  0x01},
        { (char*)"x-wap-application:wml.ua",  0x02 },
@@ -633,8 +625,7 @@ const SMS_WSP_HEADER_PARAMETER_S wspHeaderApplId[] =
 };
 
 
-const char* wspCacheControl[] =
-{
+const char* wspCacheControl[] = {
        (char*)"No-cache",
        (char*)"No-store",
        (char*)"Max-age",
@@ -648,8 +639,7 @@ const char* wspCacheControl[] =
        (char*)"Proxy-revalidate"
 };
 
-const SMS_WSP_METHOD_TYPE_S wspMethodType[] =
-{
+const SMS_WSP_METHOD_TYPE_S wspMethodType[] = {
        { (char*)"GET", 0x40 },
        { (char*)"OPTIONS", 0x41 },
        { (char*)"HEAD", 0x42 },
@@ -660,8 +650,7 @@ const SMS_WSP_METHOD_TYPE_S wspMethodType[] =
 };
 
 
-const SMS_WSP_SECURITY_TYPE_S wspSecurityType[] =
-{
+const SMS_WSP_SECURITY_TYPE_S wspSecurityType[] = {
        {(char*)"NETWPIN",0x00},
        {(char*)"USERPIN",0x01},
        {(char*)"USERNETWPIN",0x02},
@@ -670,8 +659,7 @@ const SMS_WSP_SECURITY_TYPE_S wspSecurityType[] =
 
 
 
-const char* wspWeek[] =
-{
+const char* wspWeek[] = {
        (char*)"Sun",
        (char*)"Mon",
        (char*)"Tue",
@@ -682,8 +670,7 @@ const char* wspWeek[] =
 };
 
 
-const char* wspWeekDay[] =
-{
+const char* wspWeekDay[] = {
        (char*)"Sunday",
        (char*)"Monday",
        (char*)"Tuesday",
@@ -693,8 +680,7 @@ const char* wspWeekDay[] =
        (char*)"Saturday"
 };
 
-const char* wspMonth[] =
-{
+const char* wspMonth[] = {
        (char*)"Jan",
        (char*)"Feb",
        (char*)"Mar",
@@ -748,7 +734,7 @@ bool SmsPluginWapPushHandler::IsWapPushMsg(SMS_USERDATA_S *pUserData)
                return false;
        }
 
-       int PortCount = sizeof(wapPushPortList)/sizeof(wapPushPortList[0]);
+       int PortCount = sizeof(wapPushPortList) / sizeof(wapPushPortList[0]);
 
        MSG_DEBUG("Port Count [%d]", PortCount);
 
@@ -825,7 +811,7 @@ void SmsPluginWapPushHandler::copyDeliverData(SMS_DELIVER_S *pDeliver)
 }
 
 
-void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSize, int simIndex)
+void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSize, int simIndex, time_t sent_time)
 {
        MSG_BEGIN();
 
@@ -833,8 +819,7 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi
        MSG_DEBUG("DataSize [%d]", DataSize);
 
        MSG_DEBUG("[pUserData]");
-       for (int i = 0; i < DataSize; i++)
-       {
+       for (int i = 0; i < DataSize; i++) {
                printf("[%02x]", pUserData[i]);
        }
        printf("\n\n");
@@ -864,7 +849,7 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi
        /** pass PDU type */
        iPDU++;
 
-       pushHeaderLen = wspRetriveUintvarDecode( pPDUTypeData, &iPDU );
+       pushHeaderLen = wspRetriveUintvarDecode(pPDUTypeData, &iPDU);
 
        MSG_DEBUG("PDUTypeDataLen [%d]", PDUTypeDataLen);
        MSG_DEBUG("pushHeaderLen [%d]", pushHeaderLen);
@@ -890,8 +875,7 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi
        MSG_DEBUG("wspHeaderLen [%d]", wspHeaderLen);
 
        MSG_DEBUG("[pWspHeader]");
-       for (int i = 0; i < wspHeaderLen; i++)
-       {
+       for (int i = 0; i < wspHeaderLen; i++) {
                printf("[%02x]", pWspHeader[i]);
        }
        printf("\n\n");
@@ -929,7 +913,7 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi
        if (pushBodyLen > 0) {
                pPushBody = new char[pushBodyLen];
 
-               if (pPushBody == NULL)  {
+               if (pPushBody == NULL) {
                        MSG_DEBUG("pPushBody Memory Allocation Failed");
                        return;
                } else {
@@ -940,7 +924,7 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi
                return;
        }
 
-       handleWapPushCallback((char *)pPushHeader, (char *)pPushBody, (int)pushBodyLen, (char *)pWspHeader, (int)wspHeaderLen, (char *)pWspBody, (int)wspBodyLen, simIndex);
+       handleWapPushCallback((char *)pPushHeader, (char *)pPushBody, (int)pushBodyLen, (char *)pWspHeader, (int)wspHeaderLen, (char *)pWspBody, (int)wspBodyLen, simIndex, sent_time);
 
        MSG_END();
 }
@@ -1104,91 +1088,91 @@ static void launchProcessByAppcode(int appcode)
        GVariant *result_agent = NULL;
        GVariant *result_service = NULL;
 
-       switch(appcode){
-               case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
-               case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
-               case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
-               case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
-               case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
-               case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
-               case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
-                       {
-                               connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
+       switch (appcode) {
+       case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
+       case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
+       case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
+       case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
+       case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
+       case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
+       case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
+               {
+                       connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
 
-                               dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_NONE,
-                                                                                       NULL, "org.tizen.omadmagent", "/org/tizen/omadmagent",
-                                                                                       "org.tizen.omadmagent", NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
+                       dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_NONE,
+                                                                               NULL, "org.tizen.omadmagent", "/org/tizen/omadmagent",
+                                                                               "org.tizen.omadmagent", NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
 
-                               result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("invoking agent proxy call failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
+                       result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("invoking agent proxy call failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
 
-                               connection_service = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
+                       connection_service = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
 
-                               dbus_proxy_service =g_dbus_proxy_new_sync(connection_service, G_DBUS_PROXY_FLAGS_NONE, NULL,
-                                                                                       "org.tizen.omadmservice", "/org/tizen/omadmservice",
-                                                                                       "org.tizen.omadmservice", NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to service proxy failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
+                       dbus_proxy_service =g_dbus_proxy_new_sync(connection_service, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                                                                               "org.tizen.omadmservice", "/org/tizen/omadmservice",
+                                                                               "org.tizen.omadmservice", NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("Connecting to service proxy failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
 
-                               result_service = g_dbus_proxy_call_sync(dbus_proxy_service, "wakeup", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("invoking service proxy call failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
+                       result_service = g_dbus_proxy_call_sync(dbus_proxy_service, "wakeup", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("invoking service proxy call failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
 
-                               Mutex mx;
-                               CndVar cv;
-                               mx.lock();
-                               cv.timedwait(mx.pMutex(), 2);
-                               mx.unlock();
+                       Mutex mx;
+                       CndVar cv;
+                       mx.lock();
+                       cv.timedwait(mx.pMutex(), 2);
+                       mx.unlock();
 
-                               MSG_END();
+                       MSG_END();
+               }
+               break;
+       case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+       case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
+               {
+                       connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
                        }
-                       break;
-               case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
-               case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
-                       {
-                               connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
 
-                               dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_NONE, NULL,
-                                                                                       "org.tizen.omadsagent", "/org/tizen/omadsagent",
-                                                                                       "org.tizen.omadsagent", NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
+                       dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                                                                               "org.tizen.omadsagent", "/org/tizen/omadsagent",
+                                                                               "org.tizen.omadsagent", NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
+                               goto _DBUS_ERROR;
+                       }
 
-                               result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL,
-                                                                               G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-                               if (error) {
-                                       MSG_DEBUG("invoking service error: %s\n", error->message);
-                                       goto _DBUS_ERROR;
-                               }
+                       result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL,
+                                                                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+                       if (error) {
+                               MSG_DEBUG("invoking service error: %s\n", error->message);
+                               goto _DBUS_ERROR;
                        }
-                       break;
-               default:
-                       break;
+               }
+               break;
+       default:
+               break;
        }
 
 _DBUS_ERROR:
@@ -1231,7 +1215,7 @@ _DBUS_ERROR:
 }
 
 
-void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen, int simIndex)
+void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen, int simIndex, time_t sent_time)
 {
        MSG_BEGIN();
 
@@ -1253,22 +1237,21 @@ void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPu
                return;
        }
 
-       for(int i = 0; i < pushEvt_cnt; ++i)    {
-
-               /**  check Push message receive setting */
+       for (int i = 0; i < pushEvt_cnt; ++i) {
+               /* check Push message receive setting */
                bool bPushRecv = false;
                int appcode = 0;
                MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv);
 
                storageHandler->getnthPushEvent(i, &appcode);
                MSG_DEBUG("pushEvt_cnt: %d, appcode: %d", pushEvt_cnt, appcode);
-               if ((bPushRecv == false) && (appcode != SMS_WAP_APPLICATION_MMS_UA)) {
+               if ((bPushRecv == false) && (IsWapPushMsgInWhiteList(appcode) == false)) {
                        MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
                        return;
                }
 
 #ifdef FEATURE_MMS_DISABLE
-               if (appcode == SMS_WAP_APPLICATION_MMS_UA){
+               if (appcode == SMS_WAP_APPLICATION_MMS_UA) {
                        MSG_DEBUG("Drop MMS Notification for DOCOMO");
                        return;
                }
@@ -1279,7 +1262,7 @@ void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPu
                switch (appcode) {
                case SMS_WAP_APPLICATION_MMS_UA:
                        MSG_DEBUG("Received MMS Notification");
-                       handleMMSNotification(pPushBody, PushBodyLen, simIndex);
+                       handleMMSNotification(pPushBody, PushBodyLen, simIndex, sent_time);
                        break;
 
                case SMS_WAP_APPLICATION_PUSH_SI:
@@ -1367,31 +1350,31 @@ void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPu
                case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
                case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
                        MSG_DEBUG("Received DRM V2");
-                       // TODO: DRM V2
+                       /* TODO: DRM V2 */
                        break;
 
                case SMS_WAP_APPLICATION_PUSH_EMAIL:
                case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
                case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
                        MSG_DEBUG("Received Email");
-                       // TODO: Email
+                       /* TODO: Email */
                        break;
 
 
                case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
                        MSG_DEBUG("Received IMPS CIR");
-                       // TODO: IMPS CIR
+                       /* TODO: IMPS CIR */
                        break;
 
-               case SMS_WAP_APPLICATION_LBS :
+               case SMS_WAP_APPLICATION_LBS:
                        MSG_DEBUG("Received LBS related message");
                        SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
-                       // TODO: LBS
+                       /* TODO: LBS */
                        break;
 
-               case SMS_WAP_APPLICATION_PUSH_SIA :
+               case SMS_WAP_APPLICATION_PUSH_SIA:
                        MSG_DEBUG("Received SIA");
-                       // TODO: SIA
+                       /* TODO: SIA */
                        break;
 
                default:
@@ -1405,15 +1388,42 @@ void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPu
 }
 #endif
 
-void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int PushBodyLen, int simIndex)
+bool SmsPluginWapPushHandler::IsWapPushMsgInWhiteList(int appCode)
+{
+       MSG_BEGIN();
+
+       bool isAllowed = false;
+
+       switch (appCode) {
+       case SMS_WAP_APPLICATION_MMS_UA:
+       case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
+       case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
+       case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
+       case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
+       case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
+       case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
+       case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
+       case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+       case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
+               MSG_INFO("appcode[%d] is allowed even if push receive option is disabled.", appCode);
+               isAllowed = true;
+               break;
+       default:
+               MSG_DEBUG("appcode[%d] is not allowed when push receive option is disabled.", appCode);
+               break;
+       }
+
+       return isAllowed;
+}
+
+void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int PushBodyLen, int simIndex, time_t sent_time)
 {
        MSG_BEGIN();
 
 #ifdef MSG_FW_FOR_DEBUG
        printf("\n\n[handleMMSNotification] Push Body.\n");
 
-       for (int i = 0; i < PushBodyLen; i++)
-       {
+       for (int i = 0; i < PushBodyLen; i++) {
                printf(" [%02x]", pPushBody[i]);
        }
        printf("\n\n");
@@ -1436,6 +1446,9 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P
        msgInfo.dataSize = PushBodyLen;
        msgInfo.sim_idx = simIndex;
 
+       if (sent_time > 0)
+               msgInfo.displayTime = sent_time;
+
        if (msgInfo.dataSize > MAX_MSG_TEXT_LEN) {
                msgInfo.bTextSms = false;
 
@@ -1486,7 +1499,7 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen,
        xmlNodePtr      topNode = NULL;
        xmlNodePtr      indNode = NULL;
 
-       xmlChar*                tmpXmlChar = NULL;
+       xmlChar* tmpXmlChar = NULL;
 
        if (pPushBody == NULL) {
                MSG_DEBUG("pPushBody is NULL");
@@ -1528,8 +1541,8 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen,
        pushMsg.expires = 0xFFFFFFFF;
 
        /** setting received time */
-       time_t  t               =       time(NULL);
-       time_t  utfTime =       time(&t);
+       time_t t = time(NULL);
+       time_t utfTime = time(&t);
 
        pushMsg.received = (unsigned long)utfTime;
 
@@ -1621,9 +1634,8 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen,
                /** Callback */
                err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
 
-               if (err != MSG_SUCCESS){
+               if (err != MSG_SUCCESS)
                        MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
-               }
        } else {
                MSG_DEBUG("checkMessage() Error !! [%d]", err);
        }
@@ -1649,31 +1661,31 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen,
        msg_error_t err = MSG_SUCCESS;
 
        if (pPushBody == NULL) {
-               MSG_DEBUG("pPushBody is NULL \n" );
+               MSG_DEBUG("pPushBody is NULL \n");
                return;
        }
 
        getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
 
        if (xmlDoc == NULL) {
-               MSG_DEBUG("xmlDoc is NULL \n" );
+               MSG_DEBUG("xmlDoc is NULL \n");
                return;
        }
 
        topNode = xmlDocGetRootElement(xmlDoc);
 
        if (topNode == NULL) {
-               MSG_DEBUG("Empty Document." );
+               MSG_DEBUG("Empty Document.");
                xmlFreeDoc(xmlDoc);
                return;
        } else {
-               MSG_SEC_DEBUG("Not an empty Document and topNode->name = %s \n",topNode->name );
+               MSG_SEC_DEBUG("Not an empty Document and topNode->name = %s \n",topNode->name);
        }
 
        indNode = topNode;
 
        while (indNode != NULL) {
-               if (!xmlStrcmp(indNode->name, (const xmlChar*) "sl")) {
+               if (!xmlStrcmp(indNode->name, (const xmlChar*)"sl")) {
                        MSG_SEC_DEBUG("indNode->name = %s\n",indNode->name);
                        break;
                }
@@ -1682,8 +1694,8 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen,
        }
 
        /**  setting received time setting */
-       time_t  t               =       time(NULL);
-       time_t  utfTime =       time(&t);
+       time_t t = time(NULL);
+       time_t utfTime = time(&t);
 
        pushMsg.received = (unsigned long)utfTime;
 
@@ -1781,20 +1793,20 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen,
        MSG_DEBUG("Enter handleCOMessage");
 
        if (pPushBody == NULL) {
-               MSG_DEBUG("pPushBody is NULL \n" );
+               MSG_DEBUG("pPushBody is NULL \n");
                return;
        }
 
        getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
 
        if (xmlDoc == NULL) {
-               MSG_DEBUG("xmlDoc is NULL \n" );
+               MSG_DEBUG("xmlDoc is NULL \n");
                return;
        }
 
        topNode = xmlDocGetRootElement(xmlDoc);
        if (topNode == NULL) {
-               MSG_DEBUG("Warning:Empty Document\n" );
+               MSG_DEBUG("Warning:Empty Document\n");
                xmlFreeDoc(xmlDoc);
                return;
        }
@@ -1802,13 +1814,13 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen,
        indNode = topNode->xmlChildrenNode;
 
 
-       while(indNode != NULL) {
+       while (indNode != NULL) {
 
                xmlChar* tmpUrl = NULL;
-               if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_OBJ)) {
+               if (!xmlStrcmp(indNode->name, (const xmlChar*)SMS_PUSH_XML_INVAL_OBJ)) {
                        MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
 
-                       tmpUrl = xmlGetProp(indNode, (xmlChar*) SMS_PUSH_XML_CO_URI);
+                       tmpUrl = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CO_URI);
 
                        if (tmpUrl != NULL) {
                                strncpy(cacheOp.invalObjectUrl[cacheOp.invalObjectCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
@@ -1817,7 +1829,7 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen,
                        } else {
                                MSG_DEBUG("NO href value from the xmlDoc\n");
                        }
-               } else if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_SVC)) {
+               } else if (!xmlStrcmp(indNode->name, (const xmlChar*)SMS_PUSH_XML_INVAL_SVC)) {
                        MSG_SEC_DEBUG("indNode->name = %s\n",indNode->name);
                        tmpUrl = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CO_URI);
 
@@ -1876,9 +1888,8 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen,
                /** Callback */
                err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
 
-               if (err != MSG_SUCCESS) {
+               if (err != MSG_SUCCESS)
                        MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
-               }
        } else {
                MSG_DEBUG("checkMessage() Error !! [%d]", err);
        }
@@ -2065,7 +2076,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        }
        tmpBuf[i] = '\0';
        index++;
-       timeStruct.tm_year = (atoi( tmpBuf)-1900);
+       timeStruct.tm_year = (atoi(tmpBuf)-1900);
 
        /**  Month */
        for (i = 0; i < 2; i++) {
@@ -2073,7 +2084,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        }
        tmpBuf[i] = '\0';
        index++;
-       timeStruct.tm_mon = (atoi( tmpBuf) - 1);
+       timeStruct.tm_mon = (atoi(tmpBuf) - 1);
 
        /** Date */
        for (i = 0; i < 2; i++) {
@@ -2081,7 +2092,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        }
        tmpBuf[i] = '\0';
        index++;
-       timeStruct.tm_mday = atoi( tmpBuf);
+       timeStruct.tm_mday = atoi(tmpBuf);
 
        /** Hours */
        for (i = 0; i < 2; i++) {
@@ -2089,7 +2100,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        }
        tmpBuf[i] = '\0';
        index++;
-       timeStruct.tm_hour = atoi( tmpBuf);
+       timeStruct.tm_hour = atoi(tmpBuf);
 
        /** Minites */
        for (i = 0; i < 2; i++) {
@@ -2097,7 +2108,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        }
        tmpBuf[i] = '\0';
        index++;
-       timeStruct.tm_min = atoi( tmpBuf);
+       timeStruct.tm_min = atoi(tmpBuf);
 
        /** Seconds */
        for (i = 0; i < 2; i++) {
@@ -2105,7 +2116,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        }
        tmpBuf[i] = '\0';
        index++;
-       timeStruct.tm_sec = atoi( tmpBuf);
+       timeStruct.tm_sec = atoi(tmpBuf);
 
        nTimeInSec = mktime(&timeStruct);
 
@@ -2122,27 +2133,27 @@ msg_push_action_t SmsPluginWapPushHandler::convertSIActionStrToEnum(char* pActio
        }
 
        /** compare  with signal-none. */
-       comp = g_strcmp0( "signal-none", pAction );
+       comp = g_strcmp0("signal-none", pAction);
        if (comp == 0)
                return MSG_PUSH_SI_ACTION_SIGNAL_NONE;
 
        /** compare  with signal-low. */
-       comp = g_strcmp0( "signal-low", pAction );
+       comp = g_strcmp0("signal-low", pAction);
        if (comp == 0)
                return MSG_PUSH_SI_ACTION_SIGNAL_LOW;
 
        /**  compare  with signal-medium. */
-       comp = g_strcmp0( "signal-medium", pAction );
+       comp = g_strcmp0("signal-medium", pAction);
        if (comp == 0)
                return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
 
        /**  compare  with signal-high. */
-       comp = g_strcmp0( "signal-high", pAction );
+       comp = g_strcmp0("signal-high", pAction);
        if (comp == 0)
                return MSG_PUSH_SI_ACTION_SIGNAL_HIGH;
 
        /**  compare  with delete. */
-       comp = g_strcmp0( "delete", pAction );
+       comp = g_strcmp0("delete", pAction);
        if (comp == 0)
                return MSG_PUSH_SI_ACTION_DELETE;
 
@@ -2156,22 +2167,22 @@ msg_push_action_t SmsPluginWapPushHandler::convertSLActionStrToEnum(char* pActio
        int comp = 0;
 
        if (pAction == NULL) {
-               MSG_DEBUG( "MSG_DEBUG is NULL. Setting to default action type.\n" );
+               MSG_DEBUG("MSG_DEBUG is NULL. Setting to default action type.\n");
                return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
        }
 
        /**  compare pSrcStr with execute-low. */
-       comp = g_strcmp0( "execute-low", pAction );
+       comp = g_strcmp0("execute-low", pAction);
        if (comp == 0)
                return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
 
        /**  compare pSrcStr with execute-high. */
-       comp = g_strcmp0( "execute-high", pAction );
+       comp = g_strcmp0("execute-high", pAction);
        if (comp == 0)
                return MSG_PUSH_SL_ACTION_EXECUTE_HIGH;
 
        /** compare pSrcStr with cache. */
-       comp = g_strcmp0( "cache", pAction );
+       comp = g_strcmp0("cache", pAction);
        if (comp == 0)
                return MSG_PUSH_SL_ACTION_CACHE;
 
@@ -2181,37 +2192,38 @@ msg_push_action_t SmsPluginWapPushHandler::convertSLActionStrToEnum(char* pActio
 }
 
 
-unsigned long SmsPluginWapPushHandler::wspRetriveUintvarDecode( unsigned char* sourceData, unsigned long* currentPointer )
+unsigned long SmsPluginWapPushHandler::wspRetriveUintvarDecode(unsigned char* sourceData, unsigned long* currentPointer)
 {
        unsigned long i = 0;
        unsigned long decodedValue;
 
-       while (sourceData[*currentPointer +i] >= 0x80) i++;
+       while (sourceData[*currentPointer + i] >= 0x80)
+               i++;
 
-       decodedValue = wspDecodeUintvar( i+1, sourceData + *currentPointer );
+       decodedValue = wspDecodeUintvar(i + 1, sourceData + *currentPointer);
        *currentPointer = *currentPointer + i + 1;
-       MSG_DEBUG("wspRetriveUintvarDecode: decodedValue=%d .\n",decodedValue );
+       MSG_DEBUG("wspRetriveUintvarDecode: decodedValue=%d .\n",decodedValue);
        return decodedValue;
 }
 
 
-unsigned long SmsPluginWapPushHandler::wspDecodeUintvar(unsigned long length, unsigned char* userVar )
+unsigned long SmsPluginWapPushHandler::wspDecodeUintvar(unsigned long length, unsigned char* userVar)
 {
        unsigned long i;
        unsigned long decodedUintvar = 0;
 
 
        for (i = 0 ; i < length; i++) {
-               decodedUintvar = decodedUintvar +  ( wspUintvarDecodeTable[i] * (userVar[length-(i+1)] & 0x7f ));
+               decodedUintvar = decodedUintvar +  (wspUintvarDecodeTable[i] * (userVar[length-(i+1)] & 0x7f));
        }
 
        return decodedUintvar;
 }
 
 
-void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader)
+void SmsPluginWapPushHandler::wspDecodeHeader(unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader)
 {
-       unsigned long iField;
+       unsigned long iField = 0;
        bool   continueField = FALSE;
        unsigned long currentLength;
 
@@ -2230,57 +2242,57 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un
        /* outTemper is Decoded Headers.
            temper is Single Decoded Header.
        */
-       if (NULL == ( outTemper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ])) {
-               MSG_DEBUG("outTemper Memory allocation is failed.\n" );
+       if (NULL == (outTemper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ])) {
+               MSG_DEBUG("outTemper Memory allocation is failed.\n");
                return;
        }
        memset(outTemper, 0, (WSP_STANDARD_STR_LEN_MAX * 5));
        currentLength = WSP_STANDARD_STR_LEN_MAX;
 
-       MSG_DEBUG("wspDecodeHeader: Message header decoding started.\n" );
+       MSG_DEBUG("wspDecodeHeader: Message header decoding started.\n");
 
        int loop;
        char szBuf[64];
 
        szBuf[0] = 0x00;
-       MSG_DEBUG("wspDecodeHeader: RAW data \n" );
+       MSG_DEBUG("wspDecodeHeader: RAW data \n");
        for (loop = 0 ; loop<(int)encodedHeaderLen; loop++) {
                char szTempBuf[5];
                szTempBuf[0] = 0x00;
-               snprintf( szTempBuf, sizeof(szTempBuf), "%2X ", sEncodedHeader[loop] );
+               snprintf(szTempBuf, sizeof(szTempBuf), "%2X ", sEncodedHeader[loop]);
 
-               if (AcStrlen( szBuf ) + 7 < 64) {
-                       strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 );
+               if (AcStrlen(szBuf) + 7 < 64) {
+                       strncat(szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1);
                } else {
-                       strncat( szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1 );
+                       strncat(szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1);
                        MSG_DEBUG("[%s]", szBuf);
                        szBuf[0] = 0x00;
-                       strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 );
+                       strncat(szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1);
                }
        }
-       strncat( szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1 );
+       strncat(szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1);
        MSG_DEBUG("[%s]", szBuf);
-       MSG_DEBUG("fContentType=%d  \n",fContentType );
+       MSG_DEBUG("fContentType=%d  \n",fContentType);
        /* operation for content-type */
        /* makes psuedo- content-type fieldcode */
        /* content - type is processed with header. But it's come without field code. So existence of fContentType can decide adding content type header field code whether ContentType + general header is or not. */
 
        if (fContentType) {
                encodedHeader = new char[ encodedHeaderLen + 1 ];
-               if (encodedHeader == NULL)      {
-                       MSG_DEBUG("encodedHeader Memory allocation is failed.\n" );
+               if (encodedHeader == NULL) {
+                       MSG_DEBUG("encodedHeader Memory allocation is failed.\n");
                        return;
                }
                encodedHeader[0] = 0x91;
-               memcpy( encodedHeader + 1, sEncodedHeader, (size_t)encodedHeaderLen );
+               memcpy(encodedHeader + 1, sEncodedHeader, (size_t)encodedHeaderLen);
        } else {
                encodedHeader = new char[ encodedHeaderLen ];
-               if (encodedHeader == NULL)      {
-                       MSG_DEBUG("encodedHeader Memory allocation is failed.\n" );
+               if (encodedHeader == NULL) {
+                       MSG_DEBUG("encodedHeader Memory allocation is failed.\n");
                        return;
                }
 
-               memcpy( encodedHeader, sEncodedHeader, (size_t)encodedHeaderLen );
+               memcpy(encodedHeader, sEncodedHeader, (size_t)encodedHeaderLen);
        }
 
        /* Is it reacehd end of header? */
@@ -2290,7 +2302,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un
                        temper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ];
 
                        if (temper == NULL) {
-                               MSG_DEBUG("temper Memory allocation is failed.\n" );
+                               MSG_DEBUG("temper Memory allocation is failed.\n");
                                return;
                        }
                        memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
@@ -2300,712 +2312,715 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un
 
                /* this section presents header code page shifting procedure
                   This part can be implemented by future request.
-               if (track == 0x 7f )
+               if (track == 0x 7f)
                */
                track = encodedHeader[iEncodedHeader];
 
                if (track == 0x00) {
-                       MSG_DEBUG("WspLDecodeHeader: fieldcode  is 0 \n" );
+                       MSG_DEBUG("WspLDecodeHeader: fieldcode  is 0 \n");
                        strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
                        fieldCode = 0xff;
                        iEncodedHeader++;
-               } else if (( track > 0 ) && ( track < 0x20 )) {
+               } else if ((track > 0) && (track < 0x20)) {
                        iEncodedHeader++;
-               } else if (( track < 0x7f ) && ( track > 0x1f )) { /* In this case, first byte is normal string. So it's considered to unknown header. */
+               } else if ((track < 0x7f) && (track > 0x1f)) { /* In this case, first byte is normal string. So it's considered to unknown header. */
                        unsigned char* fieldName = (unsigned char*)gWapCodeBufferLeft;
                        unsigned char* fieldValue = (unsigned char*)gWapCodeBufferRight;
 
-                       strncpy( (char*)fieldName, (char*)(encodedHeader + iEncodedHeader ),WSP_CODE_BUFFER_LEFT_LEN_MAX-1);
+                       strncpy((char*)fieldName, (char*)(encodedHeader + iEncodedHeader),WSP_CODE_BUFFER_LEFT_LEN_MAX-1);
                        fieldName[WSP_CODE_BUFFER_LEFT_LEN_MAX-1] = '\0';
-                       iEncodedHeader = iEncodedHeader + AcStrlen( (char*)fieldName ) + 1;
-                       strncpy( (char*)fieldValue, (char*)(encodedHeader + iEncodedHeader ), WSP_CODE_BUFFER_RIGHT_LEN_MAX-1);
+                       iEncodedHeader = iEncodedHeader + AcStrlen((char*)fieldName) + 1;
+                       strncpy((char*)fieldValue, (char*)(encodedHeader + iEncodedHeader), WSP_CODE_BUFFER_RIGHT_LEN_MAX-1);
                        fieldValue[WSP_CODE_BUFFER_RIGHT_LEN_MAX-1] = '\0';
-                       iEncodedHeader = iEncodedHeader + AcStrlen( (char*)fieldValue ) + 1;
+                       iEncodedHeader = iEncodedHeader + AcStrlen((char*)fieldValue) + 1;
 
-                       strncat((char*)temper, (char*)fieldName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                       strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                       strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                       strncat((char*)temper, (char*)fieldName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                       strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                       strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                        /* this means 'don't process anymore.' */
                        fieldCode = 0xff;
 
                } else if (track > 0x7f) {
                        /* In case of first byte is field code, else case is error. */
 
-                       /*if (( track & 0x7f ) <= wspHeaderFieldCount ) */
+                       /*if ((track & 0x7f) <= wspHeaderFieldCount) */
                        {
 
                                unsigned long  fieldValueLen = encodedHeader[iEncodedHeader + 1];
                                unsigned char fieldValue[1275];
                                fieldCode = track & 0x7f;
                                /*
-                               if (( fieldValueLen == 0 ) || ( fieldValueLen == 0x80 ))
+                               if ((fieldValueLen == 0) || (fieldValueLen == 0x80))
                                {
-                                       dprint( DNET_WAP,DNET_DBG_HIGH, "%X %X %X %X %X %X\n" , fieldCode, encodedHeader[iEncodedHeader + 1], encodedHeader[iEncodedHeader + 2],encodedHeader[iEncodedHeader + 3],encodedHeader[iEncodedHeader + 4], encodedHeader[iEncodedHeader + 5] );
+                                       dprint(DNET_WAP,DNET_DBG_HIGH, "%X %X %X %X %X %X\n" , fieldCode, encodedHeader[iEncodedHeader + 1], encodedHeader[iEncodedHeader + 2],encodedHeader[iEncodedHeader + 3],encodedHeader[iEncodedHeader + 4], encodedHeader[iEncodedHeader + 5]);
                                }
                                */
                                memset(fieldValue, 0, 1275);
-                               {
-                                       /* add field name */
-                                       /* This continueField flag show whether previous field code and current field code are same or not. If it's same, there are some sequential display effect by omitting field name addition process. The reason why it should be do that can be found in encoding example of spec. */
-                                       if (!continueField) {
-                                               strncat( (char*)temper, (char*)wspHeaderFieldName[fieldCode], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                               strncat( (char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                               continueField = FALSE;
-                                       }
+                               /* add field name */
+                               /* This continueField flag show whether previous field code and current field code are same or not. If it's same, there are some sequential display effect by omitting field name addition process. The reason why it should be do that can be found in encoding example of spec. */
+                               if (!continueField) {
+                                       strncat((char*)temper, (char*)wspHeaderFieldName[fieldCode], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                       strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                       continueField = FALSE;
+                               }
 
-                                       /* field value is string */
-                                       /* In this case, it just copy field value. */
-                                       if (( fieldValueLen > LENGTH_QUOTE ) && ( fieldValueLen < 0x80 )) {
+                               /* field value is string */
+                               /* In this case, it just copy field value. */
+                               if ((fieldValueLen > LENGTH_QUOTE) && (fieldValueLen < 0x80)) {
 
-                                               /* string field value should be NULL terminated */
-                                               strncat( (char*)temper, (char*)(encodedHeader + iEncodedHeader + 1 ), (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-                                               strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                       /* string field value should be NULL terminated */
+                                       strncat((char*)temper, (char*)(encodedHeader + iEncodedHeader + 1), (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                       strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
 
-                                               iEncodedHeader = iEncodedHeader + AcStrlen( (char*)encodedHeader + iEncodedHeader + 1 ) + 2;
-                                               fieldCode = 0xff;
-                                       }
-                                       /* first field value is length */
-                                       /* If first byte of field value is length value, allocate field value by the length.
-                                       In field value, data is
-                                       1D 03 8F 24 24  - Then 8F 24 24 is field value.
-                                       1D 1F 33.... - Then  allocate 33H for FieldValue.
-                                       1D 8F - Then 8F
-                                       1D 'Hi man!' Like 00, if string is come, then process without calculating field value.
-                                       1D 8F 24 24 - In this case, original data is wrong.
-                                       If  accept-charset: ISO-10646-ucs-2;Q=0.7 is
-                                       01 03 03 E8 47
-                                       01 - field code
-                                       03 - field value length
-                                       03 E8 47 - field value
-                                       it's decoded by above value.
-                                       */
-                                       if (fieldValueLen < 0x20) {
-
-                                               if (fieldValueLen  == LENGTH_QUOTE) {
-
-                                                       /* field length is encoded in UINTVAR */
-                                                       unsigned long  uintvarLen = 0;
-                                                       fieldValueLen = wspRetriveUintvarDecode((unsigned char*) encodedHeader + iEncodedHeader + 2, &uintvarLen );
-                                                       memcpy( fieldValue, encodedHeader + iEncodedHeader + 2 + uintvarLen, (size_t)fieldValueLen );
-                                                       iEncodedHeader = iEncodedHeader + fieldValueLen + uintvarLen + 2;
+                                       iEncodedHeader = iEncodedHeader + AcStrlen((char*)encodedHeader + iEncodedHeader + 1) + 2;
+                                       fieldCode = 0xff;
+                               }
+                               /* first field value is length */
+                               /* If first byte of field value is length value, allocate field value by the length.
+                               In field value, data is
+                               1D 03 8F 24 24  - Then 8F 24 24 is field value.
+                               1D 1F 33.... - Then  allocate 33H for FieldValue.
+                               1D 8F - Then 8F
+                               1D 'Hi man!' Like 00, if string is come, then process without calculating field value.
+                               1D 8F 24 24 - In this case, original data is wrong.
+                               If  accept-charset: ISO-10646-ucs-2;Q=0.7 is
+                               01 03 03 E8 47
+                               01 - field code
+                               03 - field value length
+                               03 E8 47 - field value
+                               it's decoded by above value.
+                               */
+                               if (fieldValueLen < 0x20) {
 
-                                               } else {
+                                       if (fieldValueLen  == LENGTH_QUOTE) {
 
-                                                       if (fieldValueLen == 1) {
-                                                               /* field value is one byte integer over 0x80 */
-                                                               /** make it two byte integer */
-                                                               fieldValue[0] = 0x00;
-                                                               memcpy( fieldValue + 1, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
-                                                               fieldValueLen = 2;
-                                                               iEncodedHeader = iEncodedHeader + 1 + 2;
-                                                       } else {
-                                                               memcpy( fieldValue, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen );
-                                                               fieldValue[fieldValueLen] = 0;
-                                                               iEncodedHeader = iEncodedHeader + fieldValueLen + 2;
-                                                               if (( fieldValueLen == 0 ) || ( fieldValueLen == 0x80 )) {
-                                                                       MSG_DEBUG("%X \n",  encodedHeader[iEncodedHeader] );
-                                                               }
+                                               /* field length is encoded in UINTVAR */
+                                               unsigned long  uintvarLen = 0;
+                                               fieldValueLen = wspRetriveUintvarDecode((unsigned char*) encodedHeader + iEncodedHeader + 2, &uintvarLen);
+                                               memcpy(fieldValue, encodedHeader + iEncodedHeader + 2 + uintvarLen, (size_t)fieldValueLen);
+                                               iEncodedHeader = iEncodedHeader + fieldValueLen + uintvarLen + 2;
+
+                                       } else {
+
+                                               if (fieldValueLen == 1) {
+                                                       /* field value is one byte integer over 0x80 */
+                                                       /** make it two byte integer */
+                                                       fieldValue[0] = 0x00;
+                                                       memcpy(fieldValue + 1, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
+                                                       fieldValueLen = 2;
+                                                       iEncodedHeader = iEncodedHeader + 1 + 2;
+                                               } else {
+                                                       memcpy(fieldValue, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
+                                                       fieldValue[fieldValueLen] = 0;
+                                                       iEncodedHeader = iEncodedHeader + fieldValueLen + 2;
+                                                       if ((fieldValueLen == 0) || (fieldValueLen == 0x80)) {
+                                                               MSG_DEBUG("%X \n",  encodedHeader[iEncodedHeader]);
                                                        }
                                                }
                                        }
-                                       /* field value is single encoded */
-                                       if (fieldValueLen > 0x7f) {
-                                               fieldValue[0] = encodedHeader[iEncodedHeader + 1];
-                                               fieldValueLen = 1;
-                                               iEncodedHeader = iEncodedHeader + 2;
-                                       }
-                                       /* processing normal pre-defined field decoding */
+                               }
+                               /* field value is single encoded */
+                               if (fieldValueLen > 0x7f) {
+                                       fieldValue[0] = encodedHeader[iEncodedHeader + 1];
+                                       fieldValueLen = 1;
+                                       iEncodedHeader = iEncodedHeader + 2;
+                               }
+                               /* processing normal pre-defined field decoding */
 
-                                       MSG_DEBUG("WspLDecodeHeader: FieldCode %X\n", fieldCode );
-                                       MSG_DEBUG("WspLDecodeHeader: fieldSize %d\n", fieldValueLen );
+                               MSG_DEBUG("WspLDecodeHeader: FieldCode %X\n", fieldCode);
+                               MSG_DEBUG("WspLDecodeHeader: fieldSize %d\n", fieldValueLen);
 
-                                       if (( fieldCode  > wspHeaderFieldCount ) && ( fieldCode != 0xff )) {
-                                               MSG_DEBUG("WspLDecodeHeader: unknown fieldcode %X \n", track );
-                                               strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
-                                               fieldCode = 0xff;
-                                       }
+                               if ((fieldCode  > wspHeaderFieldCount) && (fieldCode != 0xff)) {
+                                       MSG_DEBUG("WspLDecodeHeader: unknown fieldcode %X \n", track);
+                                       strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
+                                       fieldCode = 0xff;
+                               }
 
 
-                                       switch ( fieldCode )
-                                       {
-                                               /* accept charset */
-                                               /* It's normal way of field process. */
-                                               case 0x01 :
-                                                       {
-                                                               unsigned long  i = 0;
-                                                               unsigned long  code;
-
-                                                               /* Case of length of charset greater than 1 are two thigins.
-                                                               1. code length of charset is greater than 1.
-                                                               2. It include parameter.
-                                                               3. Or both of two
-                                                               */
-                                                               if (1 != fieldValueLen) {
-                                                                       code = wspHeaderDecodeInteger( fieldValue );
-                                                                       /* Calculate iField. */
-                                                                       if (fieldValue[0] < 0x80 )
-                                                                               iField = fieldValue[0];
-                                                                       else
-                                                                               iField = 1;
-
-                                                                       while ( wspCharset[i].charsetCode != code )
-                                                                               i++;
-                                                                       strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       /* If parameter exist */
-                                                                       if (iField < fieldValueLen) {
-                                                                               char* param = NULL;
-                                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                               wspHeaderDecodeQValue( fieldValueLen - iField, fieldValue + iField, &param);
-                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       }
-                                                               } else {
-                                                                       code = fieldValue[0] & 0x7f;
+                               switch (fieldCode) {
+                                       /* accept charset */
+                                       /* It's normal way of field process. */
+                                       case 0x01 :
+                                               {
+                                                       unsigned long  i = 0;
+                                                       unsigned long  code;
+
+                                                       /* Case of length of charset greater than 1 are two thigins.
+                                                       1. code length of charset is greater than 1.
+                                                       2. It include parameter.
+                                                       3. Or both of two
+                                                       */
+                                                       if (1 != fieldValueLen) {
+                                                               code = wspHeaderDecodeInteger(fieldValue);
+                                                               /* Calculate iField. */
+                                                               if (fieldValue[0] < 0x80)
+                                                                       iField = fieldValue[0];
+                                                               else
+                                                                       iField = 1;
 
-                                                                       while (( wspCharset[i].charsetCode != code ) && ( wspCharset[i].charsetCode != 0xffff  )) i++;
-                                                                       strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               while (wspCharset[i].charsetCode != code)
+                                                                       i++;
+                                                               strncat((char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                               /* If parameter exist */
+                                                               if (iField < fieldValueLen) {
+                                                                       char* param = NULL;
+                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                                       wspHeaderDecodeQValue(fieldValueLen - iField, fieldValue + iField, &param);
+                                                                       strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                                }
+                                                       } else {
+                                                               code = fieldValue[0] & 0x7f;
 
+                                                               while ((wspCharset[i].charsetCode != code) && (wspCharset[i].charsetCode != 0xffff )) i++;
+                                                               strncat((char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                        }
-                                                       break;
 
-                                               /* type encoding */
-                                               /* Like below routine, Same decoding routine process together. */
-                                               /* Accept-encoding */
-                                               case 0x02 :
-                                               /* content-encoding */
-                                               case 0x0b :
-                                                       {
-                                                               int integerValue;
-
-                                                               integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen );
-                                                               if (integerValue > 2) {
-                                                                       MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(2).\n");
-                                                                       break;
-                                                               }
-                                                               strncat( (char*)temper, (char*)wspEncodeMethod[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                               break;
+
+                                       /* type encoding */
+                                       /* Like below routine, Same decoding routine process together. */
+                                       /* Accept-encoding */
+                                       case 0x02 :
+                                       /* content-encoding */
+                                       case 0x0b :
+                                               {
+                                                       int integerValue;
+
+                                                       integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
+                                                       if (integerValue > 2) {
+                                                               MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(2).\n");
+                                                               break;
+                                                       }
+                                                       strncat((char*)temper, (char*)wspEncodeMethod[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                               break;
+                                       /* contents type decoder */
+                                       /* accept */
+                                       case 0x00 :
+                                       /* content-type */
+                                       case 0x11 :
+                                               {
+                                                       unsigned long  contentsTypeCode;
+                                                       unsigned long  i = 0;
+                                                       /* encoded content type length body */
+                                                       unsigned long  tempLen;
+                                                       MSG_DEBUG("fieldValueLen: %d", fieldValueLen);
+
+                                                       /* Like HTTP result state 304, it's for processing without Content type. This part doesn't defined. */
+                                                       if (0 == fieldValueLen) {
+                                                               strncat((char*)temper, (char*)"None" , (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                               break;
+                                                       }
+                                                       /* 01 AE --> 00 AE --> AE*/
+                                                       if (fieldValueLen == 2  &&  fieldValue[0] == 0) {
+                                                               memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1);
+                                                               MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n");
                                                        }
-                                                       break;
-                                               /* contents type decoder */
-                                               /* accept */
-                                               case 0x00 :
-                                               /* content-type */
-                                               case 0x11 :
-                                                       {
-                                                               unsigned long  contentsTypeCode;
-                                                               unsigned long  i = 0;
-                                                               /* encoded content type length body */
-                                                               unsigned long  tempLen;
-                                                               MSG_DEBUG("fieldValueLen: %d", fieldValueLen);
-
-                                                               /* Like HTTP result state 304, it's for processing without Content type. This part doesn't defined. */
-                                                               if (0 == fieldValueLen) {
-                                                                       strncat( (char*)temper, (char*)"None" , (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-                                                                       break;
-                                                               }
-                                                               /* 01 AE --> 00 AE --> AE*/
-                                                               if (fieldValueLen == 2  &&  fieldValue[0] == 0) {
-                                                                       memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
-                                                                       MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
-                                                               }
-
-                                                               if ((fieldValue[0] < 0x20 ) || (fieldValue[0] >= 0x80 )) {
-                                                                       if (fieldValue[0] >= 0x80) {
-                                                                               tempLen = 1;
-                                                                       } else if (fieldValueLen == 2 && fieldValue[0] == 0x03 && fieldValue[1] == 0x0A) { /** 06 05 02 03 0A AF 89 */
-                                                                               fieldValue[3] = fieldValue[2];
-                                                                               fieldValue[2] = fieldValue[1];
-                                                                               fieldValue[1] = fieldValue[0];
-                                                                               fieldValue[0] = 0x02;
-                                                                               tempLen = 2;
-                                                                               fieldValueLen = 3;
-                                                                               MSG_DEBUG("WspLDecodeHeader:For CPE problem\r\n" );
-                                                                       } else {
-                                                                               tempLen = fieldValue[0]; /** 06 06 03 02 03 16 AF 88 */
-                                                                       }
-
-                                                                       if (tempLen == 1) {
-
-                                                                               char* szExtendedContent;
 
-                                                                               contentsTypeCode = fieldValue[0] & 0x7f;
-                                                                               while (( wspContentsType[i].contentsTypeCode != contentsTypeCode ) && ( i < wspContentsTypeCount )) i++;
+                                                       if ((fieldValue[0] < 0x20) || (fieldValue[0] >= 0x80)) {
+                                                               if (fieldValue[0] >= 0x80) {
+                                                                       tempLen = 1;
+                                                               } else if (fieldValueLen == 2 && fieldValue[0] == 0x03 && fieldValue[1] == 0x0A) { /** 06 05 02 03 0A AF 89 */
+                                                                       fieldValue[3] = fieldValue[2];
+                                                                       fieldValue[2] = fieldValue[1];
+                                                                       fieldValue[1] = fieldValue[0];
+                                                                       fieldValue[0] = 0x02;
+                                                                       tempLen = 2;
+                                                                       fieldValueLen = 3;
+                                                                       MSG_DEBUG("WspLDecodeHeader:For CPE problem\r\n");
+                                                               } else {
+                                                                       tempLen = fieldValue[0]; /** 06 06 03 02 03 16 AF 88 */
+                                                               }
 
-                                                                               /* If specified content type doesn't exist */
-                                                                               if (i < wspContentsTypeCount)
-                                                                                       strncat( (char*)temper, (char*)wspContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               if (tempLen == 1) {
 
-                                                                               szExtendedContent =  wspExtendedDecodeType( (char)contentsTypeCode );
+                                                                       char* szExtendedContent;
 
-                                                                               if (szExtendedContent != NULL) {
-                                                                                       MSG_DEBUG("WspLDecodeHeader: Tele2 server problem \n " );
-                                                                                       strncat( (char*)temper, (char*)szExtendedContent, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                               }
-                                                                       } else {
-                                                                               contentsTypeCode = wspHeaderDecodeInteger(fieldValue);
+                                                                       contentsTypeCode = fieldValue[0] & 0x7f;
+                                                                       while ((wspContentsType[i].contentsTypeCode != contentsTypeCode) && (i < wspContentsTypeCount)) i++;
 
-                                                                               while ((i < wspUnregisteredContentsTypeCount) && (wspUnregisterContentsType[i].contentsTypeCode != contentsTypeCode)) i++;
+                                                                       /* If specified content type doesn't exist */
+                                                                       if (i < wspContentsTypeCount)
+                                                                               strncat((char*)temper, (char*)wspContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
 
-                                                                               /** If there is a Content-Type assigned, */
-                                                                               if (i < wspUnregisteredContentsTypeCount)
-                                                                                       strncat ((char*)temper, (char*)wspUnregisterContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                                       szExtendedContent =  wspExtendedDecodeType((char)contentsTypeCode);
 
-                                                                               tempLen +=1;
+                                                                       if (szExtendedContent != NULL) {
+                                                                               MSG_DEBUG("WspLDecodeHeader: Tele2 server problem \n ");
+                                                                               strncat((char*)temper, (char*)szExtendedContent, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                                        }
                                                                } else {
-                                                                       tempLen = AcStrlen( (char*)fieldValue ) + 1;
+                                                                       contentsTypeCode = wspHeaderDecodeInteger(fieldValue);
 
-                                                                       strncat ((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-                                                                       MSG_DEBUG("WspLDecodeHeader: Attention, Decoding Check of Content-Type\n ", tempLen);
-                                                               }
+                                                                       while ((i < wspUnregisteredContentsTypeCount) && (wspUnregisterContentsType[i].contentsTypeCode != contentsTypeCode)) i++;
 
-                                                               /* If there is a parameter */
-                                                               if (tempLen < fieldValueLen) {
-                                                                       char* param = NULL;
-                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                       wspHeaderDecodeParameter( fieldValue + tempLen, fieldValueLen - tempLen, &param);
-                                                                       if (param != NULL) {
-                                                                               strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       }
+                                                                       /** If there is a Content-Type assigned, */
+                                                                       if (i < wspUnregisteredContentsTypeCount)
+                                                                               strncat ((char*)temper, (char*)wspUnregisterContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+                                                                       tempLen +=1;
                                                                }
+                                                       } else {
+                                                               tempLen = AcStrlen((char*)fieldValue) + 1;
+
+                                                               strncat ((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                               MSG_DEBUG("WspLDecodeHeader: Attention, Decoding Check of Content-Type\n ", tempLen);
                                                        }
-                                                       break;
 
-                                               /* language */
-                                               /* content-language */
-                                               case 0x0c :
-                                               /* accept-language */
-                                               case 0x03 :
-                                                       {
-                                                               unsigned long i = 0;
-                                                               unsigned long code;
-                                                               unsigned long tempLen;
-                                                               if ((fieldValue[0] < 0x20 ) || (fieldValue[0] > 0x80 )) {
-                                                                       if (fieldValue[0] > 0x80 )
-                                                                               tempLen = 1;
-                                                                       else
-                                                                               tempLen = fieldValue[0];
-                                                               } else {
-                                                                       tempLen = AcStrlen( (char*)fieldValue ) + 1;
+                                                       /* If there is a parameter */
+                                                       if (tempLen < fieldValueLen) {
+                                                               char* param = NULL;
+                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                               wspHeaderDecodeParameter(fieldValue + tempLen, fieldValueLen - tempLen, &param);
+                                                               if (param != NULL) {
+                                                                       strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                                       strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                                }
+                                                       }
+                                               }
+                                               break;
+
+                                       /* language */
+                                       /* content-language */
+                                       case 0x0c :
+                                       /* accept-language */
+                                       case 0x03 :
+                                               {
+                                                       unsigned long i = 0;
+                                                       unsigned long code;
+                                                       unsigned long tempLen;
+                                                       if ((fieldValue[0] < 0x20) || (fieldValue[0] > 0x80)) {
+                                                               if (fieldValue[0] > 0x80)
+                                                                       tempLen = 1;
+                                                               else
+                                                                       tempLen = fieldValue[0];
+                                                       } else {
+                                                               tempLen = AcStrlen((char*)fieldValue) + 1;
+                                                       }
 
-                                                               if (tempLen == 1) {
-
-                                                                       code = wspHeaderDecodeInteger( fieldValue );
-                                                                       while ( wspLanguage[i].languageCode != code) {
-                                                                               i++;
-                                                                               if (i == wspLanguageCount)
-                                                                                       break;
-                                                                       }
+                                                       if (tempLen == 1) {
 
-                                                                       if (i < wspLanguageCount) {
-                                                                               strncat( (char*)temper, (char*)wspLanguage[i].languageName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       }
-                                                               } else {
-                                                                       strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                               code = wspHeaderDecodeInteger(fieldValue);
+                                                               while (wspLanguage[i].languageCode != code) {
+                                                                       i++;
+                                                                       if (i == wspLanguageCount)
+                                                                               break;
                                                                }
 
-                                                               if (tempLen < fieldValueLen) {
-                                                                       char* param = NULL;
-                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                       wspHeaderDecodeQValue(  fieldValueLen - tempLen, fieldValue + tempLen, &param );
-                                                                       strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                               if (i < wspLanguageCount) {
+                                                                       strncat((char*)temper, (char*)wspLanguage[i].languageName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                                }
+                                                       } else {
+                                                               strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                        }
-                                                       break;
 
-                                               /* integer */
-                                               /* Max-forwards */
-                                               case 0x1e :
-                                               /* content-length */
-                                               case 0x0d :
-                                               /* age */
-                                               case 0x05 :
-                                               /* Bearer-indication */
-                                               case 0x33 :
-                                               /* Push-Flag */
-                                               case 0x34 :
-                                                       {
-
-                                                               unsigned char temp[16];
-                                                               /*
-                                                               if (( fieldValueLen == 2 ) && ( fieldValue[0] > 0x7f ))
-                                                                       AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[1]);
-                                                               else
-                                                               */
-                                                               snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       if (tempLen < fieldValueLen) {
+                                                               char* param = NULL;
+                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                               wspHeaderDecodeQValue( fieldValueLen - tempLen, fieldValue + tempLen, &param);
+                                                               strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                        }
-                                                       break;
-                                               /* X-Wap-Application-Id */
-                                               case 0x2f :
-                                                       {
-                                                               unsigned char temp[64];
-                                                               int         integerValue;
-
+                                               }
+                                               break;
+
+                                       /* integer */
+                                       /* Max-forwards */
+                                       case 0x1e :
+                                       /* content-length */
+                                       case 0x0d :
+                                       /* age */
+                                       case 0x05 :
+                                       /* Bearer-indication */
+                                       case 0x33 :
+                                       /* Push-Flag */
+                                       case 0x34 :
+                                               {
+
+                                                       unsigned char temp[16];
+                                                       /*
+                                                       if ((fieldValueLen == 2) && (fieldValue[0] > 0x7f))
+                                                               AcSprintf((char*)temp, "%u", (unsigned int)fieldValue[1]);
+                                                       else
+                                                       */
+                                                       snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
+                                                       strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                               break;
+                                       /* X-Wap-Application-Id */
+                                       case 0x2f :
+                                               {
+                                                       unsigned char temp[64];
+                                                       int         integerValue;
+
+                                                       if (track == 0xaf) { /* WAP short-integer-encoded */
                                                                if (fieldValueLen == 2 &&  fieldValue[0] == 0) {
-                                                                       memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
-                                                                       MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
-                                                                       fieldValueLen = 1;
+                                                                       memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen);
                                                                }
-
                                                                integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
-
-                                                               int count = sizeof(wspHeaderApplId)/sizeof(SMS_WSP_HEADER_PARAMETER_S);
-                                                               for(int i = 0; i < count ; ++i)
-                                                               {
-                                                                       if ((unsigned int)integerValue == wspHeaderApplId[i].parameterCode)
-                                                                       {
-                                                                               snprintf((char*)temp, 64, "%s", wspHeaderApplId[i].parameterToken);
-                                                                               strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
-                                                                               break;
-                                                                       }
-                                                               }
-                                                       }
-                                                       break;
-                                               /* Accept-Application */
-                                               case 0x32 :
-                                                       if (0x80 == fieldValue[0]) {
-                                                               strncat( (char*)temper, "*", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
                                                        } else {
-
-                                                               unsigned char temp[16];
-                                                               /*
-                                if (( fieldValueLen == 2 ) && ( fieldValue[0] == 1 ))
-                                       AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[0]);
-                                else
-                                                               */
-                                                               snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+                                                               if (fieldValueLen == 2 &&  fieldValue[0] == 0) {
+                                                                       memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1);
+                                                                       MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n");
+                                                                       fieldValueLen = 1;
+                                                               }
+                                                               integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
                                                        }
-                                                       break;
 
+                                                       MSG_DEBUG("integerValue = [%02x]", integerValue);
 
-                                               /* date */
-                                               /* last-modified */
-                                               case 0x1d :
-                                               /* if-unmodified-since */
-                                               case 0x1b :
-                                               /* if-range */
-                                               case 0x1a :
-                                               /* if-modified-since */
-                                               case 0x17 :
-                                               /* expires */
-                                               case 0x14 :
-                                               /* date */
-                                               case 0x12 :
-                                                       {
-                                                               char* decodedString = NULL;
-                                                               unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
-                                                               wspHeaderDecodeDateValue( fieldValueLen, fieldValue, &decodedString);
-                                                               strncat( (char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
+                                                       int count = sizeof(wspHeaderApplId)/sizeof(SMS_WSP_HEADER_PARAMETER_S);
+                                                       for (int i = 0; i < count ; ++i) {
+                                                               if ((unsigned int)integerValue == wspHeaderApplId[i].parameterCode) {
+                                                                       snprintf((char*)temp, 64, "%s", wspHeaderApplId[i].parameterToken);
+                                                                       strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+                                                                       break;
+                                                               }
                                                        }
-                                                       break;
+                                               }
+                                               break;
+                                       /* Accept-Application */
+                                       case 0x32 :
+                                               if (0x80 == fieldValue[0]) {
+                                                       strncat((char*)temper, "*", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+                                               } else {
 
-                                               /* connection */
-                                               case 0x09 :
-                                                       if (fieldValue[0] == 0x80 )
-                                                               strncat( (char*)temper, "Close", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
-                                                       break;
-                                               /* accept-ranges */
-                                               case 0x04 :
-                                                       if (fieldValue[0] == 0x80 )
-                                                               strncat( (char*)temper, "None", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
-                                                       if (fieldValue[0] == 0x81 )
-                                                               strncat( (char*)temper, "Bytes", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 );
-                                                       break;
-                                               /* content-md5 */
-                                               case 0x0f :
-                                                       {
-                                                               unsigned char temp[1275];
-                                                               memcpy( temp, fieldValue, (size_t)fieldValueLen );
-                                                               temp[fieldValueLen] = 0;
-                                                               wspHeaderCopyDecodedString( temp, &currentLength, &temper );
-                                                       }
-                                                       break;
-                                               /* Credential */
-                                               /* authorization */
-                                               case 0x07 :
-                                               /* proxy - authorization */
-                                               case 0x21 :
-                                                       if (fieldValue[0] == 0x80) {
-                                                               char* addString = NULL;
-                                                               unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
-                                                               wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString );
-                                                               strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       } else {
-                                                               iField = AcStrlen( (char*)fieldValue) + 1;
+                                                       unsigned char temp[16];
+                                                       /*
+                                                       if ((fieldValueLen == 2) && (fieldValue[0] == 1))
+                                                               AcSprintf((char*)temp, "%u", (unsigned int)fieldValue[0]);
+                                                       else
+                                                       */
+                                                       snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
+                                                       strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+                                               }
+                                               break;
+
+
+                                       /* date */
+                                       /* last-modified */
+                                       case 0x1d :
+                                       /* if-unmodified-since */
+                                       case 0x1b :
+                                       /* if-range */
+                                       case 0x1a :
+                                       /* if-modified-since */
+                                       case 0x17 :
+                                       /* expires */
+                                       case 0x14 :
+                                       /* date */
+                                       case 0x12 :
+                                               {
+                                                       char* decodedString = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
+                                                       wspHeaderDecodeDateValue(fieldValueLen, fieldValue, &decodedString);
+                                                       strncat((char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+                                               }
+                                               break;
+
+                                       /* connection */
+                                       case 0x09 :
+                                               if (fieldValue[0] == 0x80)
+                                                       strncat((char*)temper, "Close", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+                                               break;
+                                       /* accept-ranges */
+                                       case 0x04 :
+                                               if (fieldValue[0] == 0x80)
+                                                       strncat((char*)temper, "None", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+                                               if (fieldValue[0] == 0x81)
+                                                       strncat((char*)temper, "Bytes", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+                                               break;
+                                       /* content-md5 */
+                                       case 0x0f :
+                                               {
+                                                       unsigned char temp[1275];
+                                                       memcpy(temp, fieldValue, (size_t)fieldValueLen);
+                                                       temp[fieldValueLen] = 0;
+                                                       wspHeaderCopyDecodedString(temp, &currentLength, &temper);
+                                               }
+                                               break;
+                                       /* Credential */
+                                       /* authorization */
+                                       case 0x07 :
+                                       /* proxy - authorization */
+                                       case 0x21 :
+                                               if (fieldValue[0] == 0x80) {
+                                                       char* addString = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
+                                                       wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString);
+                                                       strncat((char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               } else {
+                                                       iField = AcStrlen((char*)fieldValue) + 1;
 
-                                                               strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                               if (iField < fieldValueLen) {
-                                                                       char* param = NULL;
-                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                       wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, &param );
-                                                                       if (param != NULL) {
-                                                                               strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       }
+                                                       strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                       if (iField < fieldValueLen) {
+                                                               char* param = NULL;
+                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                               wspHeaderDecodeParameter(fieldValue + 1, fieldValueLen - 1, &param);
+                                                               if (param != NULL) {
+                                                                       strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                                       strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                                }
                                                        }
-                                                       break;
-
-
-                                               /* Challenge */
-                                               /* www - auth */
-                                               case 0x2d :
-                                               /* Proxy-authenticate */
-                                               case 0x20 :
-                                                       if (0 == fieldValueLen )
-                                                               break;
-                                                       if (fieldValue[0] == 0x80) {
-                                                               char* addString = NULL;
-                                                               unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
-                                                               wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString );
-                                                               strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       } else {
-                                                               unsigned char  authScheme[WSP_STANDARD_STR_LEN_MAX + 1];
-                                                               unsigned char  realmValue[WSP_STANDARD_STR_LEN_MAX];
-                                                               unsigned char  addedString[WSP_STANDARD_STR_LEN_MAX];
+                                               }
+                                               break;
 
-                                                               strncpy( (char*)authScheme, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX -1);
-                                                               iField = AcStrlen( (char*)authScheme ) + 1;
-                                                               strncpy( (char*)realmValue, (char*)(fieldValue + iField ), WSP_STANDARD_STR_LEN_MAX-1);
-                                                               iField = iField + AcStrlen( (char*)realmValue ) + 1;
-                                                               snprintf( (char*)addedString, sizeof(addedString), "%s %s", authScheme, realmValue );
-                                                               wspHeaderCopyDecodedString( addedString, &currentLength, &temper );
 
-                                                               if (iField < fieldValueLen) {
-                                                                       char* param = NULL;
-                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                       wspHeaderDecodeParameter( fieldValue + iField, fieldValueLen - iField, &param );
-                                                                       if (param != NULL) {
-                                                                               strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                               wspHeaderCopyDecodedString( (unsigned char*)param, &currentLength, &temper );
-                                                                       }
+                                       /* Challenge */
+                                       /* www - auth */
+                                       case 0x2d :
+                                       /* Proxy-authenticate */
+                                       case 0x20 :
+                                               if (0 == fieldValueLen)
+                                                       break;
+                                               if (fieldValue[0] == 0x80) {
+                                                       char* addString = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
+                                                       wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString);
+                                                       strncat((char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               } else {
+                                                       unsigned char  authScheme[WSP_STANDARD_STR_LEN_MAX + 1];
+                                                       unsigned char  realmValue[WSP_STANDARD_STR_LEN_MAX];
+                                                       unsigned char  addedString[WSP_STANDARD_STR_LEN_MAX];
+
+                                                       strncpy((char*)authScheme, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX -1);
+                                                       iField = AcStrlen((char*)authScheme) + 1;
+                                                       strncpy((char*)realmValue, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
+                                                       iField = iField + AcStrlen((char*)realmValue) + 1;
+                                                       snprintf((char*)addedString, sizeof(addedString), "%s %s", authScheme, realmValue);
+                                                       wspHeaderCopyDecodedString(addedString, &currentLength, &temper);
+
+                                                       if (iField < fieldValueLen) {
+                                                               char* param = NULL;
+                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                               wspHeaderDecodeParameter(fieldValue + iField, fieldValueLen - iField, &param);
+                                                               if (param != NULL) {
+                                                                       strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                                       wspHeaderCopyDecodedString((unsigned char*)param, &currentLength, &temper);
                                                                }
                                                        }
-                                                       break;
+                                               }
+                                               break;
 
-                                               /* content -range */
-                                               case 0x10 :
-                                                       {
-                                                               unsigned long  first, len, last;
+                                       /* content -range */
+                                       case 0x10 :
+                                               {
+                                                       unsigned long  first, len, last;
 
-                                                               unsigned char  temp[16];
-                                                               iField = 0;
+                                                       unsigned char  temp[16];
+                                                       iField = 0;
 
-                                                               strncat( (char*)temper," bytes ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       strncat((char*)temper," bytes ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
 
-                                                               first = wspRetriveUintvarDecode( fieldValue, &iField );
-                                                               len = wspRetriveUintvarDecode( fieldValue, &iField );
-                                                               /* Originally range of HTTP include entity length. But WSP omit it. Finally to calculate this, it should be get content length from export. If this field is included without content length, then it can get wrong result. This content length can be get by calculating PDU length.
-                                                               */
-                                                               last = first + contentsLength - 1;
+                                                       first = wspRetriveUintvarDecode(fieldValue, &iField);
+                                                       len = wspRetriveUintvarDecode(fieldValue, &iField);
+                                                       /* Originally range of HTTP include entity length. But WSP omit it. Finally to calculate this, it should be get content length from export. If this field is included without content length, then it can get wrong result. This content length can be get by calculating PDU length.
+                                                       */
+                                                       last = first + contentsLength - 1;
 
-                                                               snprintf( (char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len );
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       }
-                                                       break;
+                                                       snprintf((char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len);
+                                                       strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                               break;
 
-                                               /* cache-control */
-                                               case 0x08 :
-                                                       {
-                                                               char* cacheString = NULL;
-                                                               unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter);
+                                       /* cache-control */
+                                       case 0x08 :
+                                               {
+                                                       char* cacheString = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter);
 
-                                                               wspHeaderDecodeCacheControl( fieldValue, fieldValueLen, &cacheString );
-                                                               strncat( (char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       }
-                                                       break;
+                                                       wspHeaderDecodeCacheControl(fieldValue, fieldValueLen, &cacheString);
+                                                       strncat((char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                               break;
 
-                                               /* pragma */
-                                               case 0x1f :
-                                                       if (fieldValue[0] == 0x80) {
-                                                               strncat( (char*)temper, (char*)wspCacheControl[0], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       } else {
-                                                               if (1 < fieldValueLen) {
-                                                                       char* param = NULL;
-                                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                                       wspHeaderDecodeParameter( fieldValue, fieldValueLen, &param );
+                                       /* pragma */
+                                       case 0x1f :
+                                               if (fieldValue[0] == 0x80) {
+                                                       strncat((char*)temper, (char*)wspCacheControl[0], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               } else {
+                                                       if (1 < fieldValueLen) {
+                                                               char* param = NULL;
+                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                               wspHeaderDecodeParameter(fieldValue, fieldValueLen, &param);
 
-                                                                       if (param != NULL) {
-                                                                               strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                               strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       }
+                                                               if (param != NULL) {
+                                                                       strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                                       strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                                }
                                                        }
+                                               }
 
-                                                       break;
-                                               /* public */
-                                               case 0x22 :
-                                               /* allow */
-                                               case 0x06 :
-                                                       {
-                                                               unsigned long  i = 0;
-                                                               while ( wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ) != wspMethodType[i].methodCode ) i++;
-                                                               strncat( (char*)temper, (char*)wspMethodType[i].methodName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       }
-                                                       break;
-                                               /* range */
-                                               case 0x23 :
-                                                       strncat( (char*)temper, "bytes=", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       if (fieldValue[0] == 0x80) {
-                                                               unsigned char temp[16];
-                                                               unsigned long  first, last;
-                                                               iField = 0;
-
-                                                               first = wspRetriveUintvarDecode( fieldValue, &iField );
-                                                               last = wspRetriveUintvarDecode( fieldValue, &iField );
-
-                                                               snprintf( (char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last );
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       }
-                                                       if (fieldValue[0] == 0x81) {
-                                                               unsigned char temp[16];
-                                                               unsigned long  suffix;
+                                               break;
+                                       /* public */
+                                       case 0x22 :
+                                       /* allow */
+                                       case 0x06 :
+                                               {
+                                                       unsigned long  i = 0;
+                                                       while (wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen) != wspMethodType[i].methodCode) i++;
+                                                       strncat((char*)temper, (char*)wspMethodType[i].methodName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                               break;
+                                       /* range */
+                                       case 0x23 :
+                                               strncat((char*)temper, "bytes=", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               if (fieldValue[0] == 0x80) {
+                                                       unsigned char temp[16];
+                                                       unsigned long  first, last;
+                                                       iField = 0;
+
+                                                       first = wspRetriveUintvarDecode(fieldValue, &iField);
+                                                       last = wspRetriveUintvarDecode(fieldValue, &iField);
+
+                                                       snprintf((char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last);
+                                                       strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                               if (fieldValue[0] == 0x81) {
+                                                       unsigned char temp[16];
+                                                       unsigned long  suffix;
 
-                                                               suffix = wspRetriveUintvarDecode( fieldValue, &iField );
+                                                       suffix = wspRetriveUintvarDecode(fieldValue, &iField);
 
-                                                               snprintf( (char*)temp, sizeof(temp), "-%u", (unsigned int)suffix );
+                                                       snprintf((char*)temp, sizeof(temp), "-%u", (unsigned int)suffix);
 
-                                                       }
-                                                       break;
-                                               /* retry-after */
-                                               case 0x25 :
-                                                       if (fieldValue[0] == 0x80) {
-                                                               char* temp = NULL;
-                                                               unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter);
-
-                                                               wspHeaderDecodeDateValue( fieldValueLen - 1, fieldValue + 1, &temp );
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       }
+                                               }
+                                               break;
+                                       /* retry-after */
+                                       case 0x25 :
+                                               if (fieldValue[0] == 0x80) {
+                                                       char* temp = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter);
+
+                                                       wspHeaderDecodeDateValue(fieldValueLen - 1, fieldValue + 1, &temp);
+                                                       strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
 
-                                                       if (fieldValue[0] == 0x81) {
-                                                               unsigned char temp[16];
+                                               if (fieldValue[0] == 0x81) {
+                                                       unsigned char temp[16];
 
-                                                               snprintf( (char*)temp, 16, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen ));
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                       }
-                                                       break;
-                                               /* transfer-encoding */
-                                               case 0x27 :
-                                                       /* No other cases allowed */
-                                                       if (fieldValue[0] == 0x80 )
-                                                               strncat( (char*)temper, "chunked", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-
-                                                       break;
-                                               /* vary */
-                                               case 0x2a :
-                                                       {
-                                                               int integerValue = wspHeaderDecodeIntegerByLength(fieldValue,fieldValueLen );
-                                                               if (integerValue > wspHeaderFieldCount) {
-                                                                       MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x%x).\n",wspHeaderFieldCount);
-                                                                       break;
-                                                               }
-                                                               strncat( (char*)temper, (char*)wspHeaderFieldName[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                                                       snprintf((char*)temp, 16, "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue,fieldValueLen));
+                                                       strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                               break;
+                                       /* transfer-encoding */
+                                       case 0x27 :
+                                               /* No other cases allowed */
+                                               if (fieldValue[0] == 0x80)
+                                                       strncat((char*)temper, "chunked", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+                                               break;
+                                       /* vary */
+                                       case 0x2a :
+                                               {
+                                                       int integerValue = wspHeaderDecodeIntegerByLength(fieldValue,fieldValueLen);
+                                                       if (integerValue > wspHeaderFieldCount) {
+                                                               MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x%x).\n",wspHeaderFieldCount);
+                                                               break;
                                                        }
-                                                       break;
-                                               /* warning */
-                                               case 0x2c :
-                                                       {
-                                                               unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
-
-                                                               if (fieldValue[0] < 0x20 )
-                                                                       iField = fieldValue[0];
-                                                               else
-                                                                       iField = 1;
-
-                                                               snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, iField ));
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                               if (iField < fieldValueLen) {
-                                                                       unsigned char agent[WSP_STANDARD_STR_LEN_MAX];
-                                                                       unsigned char text[WSP_STANDARD_STR_LEN_MAX];
-                                                                       strncpy( (char*)agent, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
-                                                                       iField = iField + AcStrlen((char*)agent ) + 1;
-                                                                       strncpy((char*)text, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
-                                                                       snprintf( (char*)temp, sizeof(temp), " %s %s", agent, text );
-                                                                       wspHeaderCopyDecodedString( temp, &currentLength, &temper );
-                                                               }
+                                                       strncat((char*)temper, (char*)wspHeaderFieldName[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                               break;
+                                       /* warning */
+                                       case 0x2c :
+                                               {
+                                                       unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
+
+                                                       if (fieldValue[0] < 0x20)
+                                                               iField = fieldValue[0];
+                                                       else
+                                                               iField = 1;
+
+                                                       snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, iField));
+                                                       strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                       if (iField < fieldValueLen) {
+                                                               unsigned char agent[WSP_STANDARD_STR_LEN_MAX];
+                                                               unsigned char text[WSP_STANDARD_STR_LEN_MAX];
+                                                               strncpy((char*)agent, (char*)(fieldValue + iField),WSP_STANDARD_STR_LEN_MAX-1);
+                                                               iField = iField + AcStrlen((char*)agent) + 1;
+                                                               strncpy((char*)text, (char*)(fieldValue + iField),WSP_STANDARD_STR_LEN_MAX-1);
+                                                               snprintf((char*)temp, sizeof(temp), " %s %s", agent, text);
+                                                               wspHeaderCopyDecodedString(temp, &currentLength, &temper);
                                                        }
-                                                       break;
-                                               /* content-disposition */
-                                               case 0x2e :
-                                                       if (fieldValue[0] == 0x80 )
-                                                               strncat( (char*)temper, "form-data", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-
-                                                       if (fieldValue[0] == 0x81 )
-                                                               strncat( (char*)temper, "attachment", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-
-                                                       if (1 < fieldValueLen) {
-                                                               char* param = NULL;
-                                                               unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
-                                                               wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, &param );
-
-                                                               if (param != NULL) {
-                                                                       strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                                       strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
-                                                               }
+                                               }
+                                               break;
+                                       /* content-disposition */
+                                       case 0x2e :
+                                               if (fieldValue[0] == 0x80)
+                                                       strncat((char*)temper, "form-data", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+                                               if (fieldValue[0] == 0x81)
+                                                       strncat((char*)temper, "attachment", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+                                               if (1 < fieldValueLen) {
+                                                       char* param = NULL;
+                                                       unique_ptr<char*, void(*)(char**)> parambuf(&param, unique_ptr_deleter);
+                                                       wspHeaderDecodeParameter(fieldValue + 1, fieldValueLen - 1, &param);
+
+                                                       if (param != NULL) {
+                                                               strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                                               strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                                        }
-                                                       break;
-                                               /* Profile-diff */
-                                               case 0x36 :
-                                                       temper[AcStrlen((char*)temper) + fieldValueLen] = '\0';
-                                                       memcpy( temper, fieldValue, (size_t)fieldValueLen );
-                                                       break;
-                                               /* Profile-Warning */
-                                               case 0x37 :
-                                                       {
-                                                               unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
-
-                                                               snprintf( (char*)temp, sizeof(temp), "%lX", wspHeaderDecodeInteger(fieldValue ));
-                                                               temp[2] = temp[1];
-                                                               temp[1] = (unsigned char)0x30;
-                                                               temp[3] = '\0';
-                                                               if (fieldValueLen > 1) {
-                                                                       /* copy warn-target - URI */
-                                                                       strncat( (char*)temp, (char*)(fieldValue + 1), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
-                                                                       if (fieldValueLen > ( AcStrlen( (char*)(fieldValue + 1)) + 1 )) {
-                                                                               /* copy warn-date */
-                                                                               char* decodedString = NULL;
-                                                                               unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
-                                                                               wspHeaderDecodeDateValue( fieldValueLen - ( AcStrlen( (char*)(fieldValue + 1)) + 2 ), fieldValue + AcStrlen( (char*)(fieldValue + 1)) + 1, &decodedString );
-                                                                               strncat( (char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
-                                                                       }
+                                               }
+                                               break;
+                                       /* Profile-diff */
+                                       case 0x36 :
+                                               temper[AcStrlen((char*)temper) + fieldValueLen] = '\0';
+                                               memcpy(temper, fieldValue, (size_t)fieldValueLen);
+                                               break;
+                                       /* Profile-Warning */
+                                       case 0x37 :
+                                               {
+                                                       unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
+
+                                                       snprintf((char*)temp, sizeof(temp), "%lX", wspHeaderDecodeInteger(fieldValue));
+                                                       temp[2] = temp[1];
+                                                       temp[1] = (unsigned char)0x30;
+                                                       temp[3] = '\0';
+                                                       if (fieldValueLen > 1) {
+                                                               /* copy warn-target - URI */
+                                                               strncat((char*)temp, (char*)(fieldValue + 1), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1);
+                                                               if (fieldValueLen > (AcStrlen((char*)(fieldValue + 1)) + 1)) {
+                                                                       /* copy warn-date */
+                                                                       char* decodedString = NULL;
+                                                                       unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
+                                                                       wspHeaderDecodeDateValue(fieldValueLen - (AcStrlen((char*)(fieldValue + 1)) + 2), fieldValue + AcStrlen((char*)(fieldValue + 1)) + 1, &decodedString);
+                                                                       strncat((char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1);
                                                                }
-                                                               strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
                                                        }
-                                                       break;
-
-                                               default :
-                                                       break;
-                                       }
+                                                       strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+                                               }
+                                               break;
 
+                                       default :
+                                               break;
                                }
+
                        }
                }
                /* It deosn't finished decoding yet. */
-               if (( iEncodedHeader < encodedHeaderLen ) && ( fieldCode != 0xff )) {
+               if ((iEncodedHeader < encodedHeaderLen) && (fieldCode != 0xff)) {
                        /* In here, iEncodedHeader already point next field code to be decoded. */
                        /* If this code is same, then set continueField else add CRLF. */
-                       if (fieldCode == (encodedHeader[iEncodedHeader] & 0x7f )) {
-                               strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                       if (fieldCode == (encodedHeader[iEncodedHeader] & 0x7f)) {
+                               strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                continueField = TRUE;
                        } else {
-                               strncat( (char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                               strncat((char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                                continueField = FALSE;
                        }
                } else {
-                       strncat( (char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
+                       strncat((char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
                }
 
                /* add single header to total headers */
-               strncat( (char*)outTemper, (char*)temper, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)outTemper)-1 );
-               MSG_DEBUG("WspLDecodeHeader: Single Header : %s\r\n", temper );
+               strncat((char*)outTemper, (char*)temper, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)outTemper)-1);
+               MSG_DEBUG("WspLDecodeHeader: Single Header : %s\r\n", temper);
 
        }
 
 
-       MSG_DEBUG("WspLDecodeHeader: Header decoding ended.\n" );
+       MSG_DEBUG("WspLDecodeHeader: Header decoding ended.\n");
 
        *pHeader = outTemper;
 
@@ -3014,7 +3029,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un
 }
 
 
-unsigned long SmsPluginWapPushHandler::wspHeaderDecodeInteger( unsigned char* data )
+unsigned long SmsPluginWapPushHandler::wspHeaderDecodeInteger(unsigned char* data)
 {
        /* we only can handle max 32bit integer */
        unsigned long i;
@@ -3034,7 +3049,7 @@ unsigned long SmsPluginWapPushHandler::wspHeaderDecodeInteger( unsigned char* da
                MSG_DEBUG("WspLHeaderDecodeInteger: input %d , length %d\n", data[0], IntLen);
 
                for (i=0; i<IntLen; i++)
-                       returner.seg[IntLen-( i+1)] = data[i+1];
+                       returner.seg[IntLen-(i+1)] = data[i+1];
 
                return returner.integer;
        }
@@ -3043,7 +3058,7 @@ unsigned long SmsPluginWapPushHandler::wspHeaderDecodeInteger( unsigned char* da
 }
 
 
-void SmsPluginWapPushHandler::wspHeaderDecodeQValue( unsigned long length, unsigned char* data, char** pDecodedString)
+void SmsPluginWapPushHandler::wspHeaderDecodeQValue(unsigned long length, unsigned char* data, char** pDecodedString)
 {
        unsigned short qBase = 0;
        float  qValue;
@@ -3054,12 +3069,12 @@ void SmsPluginWapPushHandler::wspHeaderDecodeQValue( unsigned long length, unsig
                return;
        }
 
-       memcpy( &qBase, data, (size_t)length );
+       memcpy(&qBase, data, (size_t)length);
        qValue = (float)qBase;
        if (qValue > 100) {
                qValue = qValue - 100;
                qValue = qValue / 1000;
-               snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.3f", qValue );
+               snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.3f", qValue);
        } else {
                /* qValue variable is divided by 100. And it's multiplied by 100.
                   It's to resolve problem of changed 0.01 of qValue. */
@@ -3067,16 +3082,16 @@ void SmsPluginWapPushHandler::wspHeaderDecodeQValue( unsigned long length, unsig
                qValue = qValue - 1;
                qValue = qValue / 100;
                qValueTemp = (unsigned long)(qValue * 100);
-               if (0 == (qValueTemp % 10 ))
-                       snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.1f", qValue );
+               if (0 == (qValueTemp % 10))
+                       snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.1f", qValue);
                else
-                       snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.2f", qValue );
+                       snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.2f", qValue);
        }
        return;
 }
 
 
-unsigned long SmsPluginWapPushHandler::wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length )
+unsigned long SmsPluginWapPushHandler::wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length)
 {
        unsigned long i;
 
@@ -3087,25 +3102,25 @@ unsigned long SmsPluginWapPushHandler::wspHeaderDecodeIntegerByLength(unsigned c
 
        returner.integer = 0;
 
-       if (length == 1 )
+       if (length == 1)
                return data[0] & 0x7f;
 
        returner.integer = 0;
 
        for (i = 0 ; i < length; i++) {
-               returner.integer  =  returner.integer + ( data[i]  *  (0x1  << ( ( length - ( i + 1)) * 8 )));
-               MSG_DEBUG("WspLHeaderDecodeIntegerByLength: %d \n", returner.integer );
+               returner.integer  =  returner.integer + (data[i]  *  (0x1  << ((length - (i + 1)) * 8)));
+               MSG_DEBUG("WspLHeaderDecodeIntegerByLength: %d \n", returner.integer);
        }
 
        return returner.integer;
 }
 
 
-char* SmsPluginWapPushHandler::wspExtendedDecodeType(char contentType  )
+char* SmsPluginWapPushHandler::wspExtendedDecodeType(char contentType)
 {
        int i = 0;
 
-       while ( wspExtendedContentsType[i].contentsTypeCode != contentType) {
+       while (wspExtendedContentsType[i].contentsTypeCode != contentType) {
                if (wspExtendedContentsType[i].contentsTypeCode == 0xff)
                        return NULL;
                i++;
@@ -3115,7 +3130,7 @@ char* SmsPluginWapPushHandler::wspExtendedDecodeType(char contentType  )
 }
 
 
-void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, unsigned long length, char** pParam)
+void SmsPluginWapPushHandler::wspHeaderDecodeParameter(unsigned char* data, unsigned long length, char** pParam)
 {
        char* param = *pParam;
 
@@ -3127,111 +3142,110 @@ void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, uns
                param = new char[WSP_STANDARD_STR_LEN_MAX];
 
                if (param == NULL) {
-                       MSG_DEBUG("WspLHeaderDecodeParameter:MemAlloc failed\n" );
+                       MSG_DEBUG("WspLHeaderDecodeParameter:MemAlloc failed\n");
                        return;
                }
 
-               strncpy( (char*)param, (char*)data, WSP_STANDARD_STR_LEN_MAX - 1);
+               strncpy((char*)param, (char*)data, WSP_STANDARD_STR_LEN_MAX - 1);
 
-               if (NO_VALUE == data[AcStrlen( (char*)param ) + 1]) {
+               if (NO_VALUE == data[AcStrlen((char*)param) + 1]) {
                        *pParam = param;
                        return;
                }
 
-               strncat( (char*)param, "=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 );
-               strncat( (char*)param, (char*)(data + strlen( (char*)param )), WSP_STANDARD_STR_LEN_MAX-strlen((char*)param)-1);
+               strncat((char*)param, "=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+               strncat((char*)param, (char*)(data + strlen((char*)param)), WSP_STANDARD_STR_LEN_MAX-strlen((char*)param)-1);
 
                *pParam = param;
 
                return;
        }
 
-       switch ( data[0] & 0x7f )
-       {
-               case 0x00 :
-                       wspHeaderDecodeQValue(  length - 1, data + 1, &param);
-                       break;
-               case 0x01 :
-                       wspHeaderDecodeCharset( length - 1 , data + 1, &param);
-                       break;
-               case 0x02 :
-                       wspHeaderDecodeVersion( length - 1, data + 1, &param);
-                       break;
-                       /* integer */
-               case 0x03 :
-                       //param = (unsigned char *)malloc( (size_t)WSP_STANDARD_STR_LEN_MAX );
-                       param = new char[WSP_STANDARD_STR_LEN_MAX];
-                       if (param == NULL) {
-                               MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n");
-                               return;
-                       } else {
-                               snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Type=%i", (int)wspHeaderDecodeInteger( data + 1 ));
-                       }
-                       break;
-               case 0x08 :
-                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+       switch (data[0] & 0x7f) {
+       case 0x00 :
+               wspHeaderDecodeQValue( length - 1, data + 1, &param);
+               break;
+       case 0x01 :
+               wspHeaderDecodeCharset(length - 1 , data + 1, &param);
+               break;
+       case 0x02 :
+               wspHeaderDecodeVersion(length - 1, data + 1, &param);
+               break;
+               /* integer */
+       case 0x03 :
+               /* param = (unsigned char *)malloc((size_t)WSP_STANDARD_STR_LEN_MAX); */
+               param = new char[WSP_STANDARD_STR_LEN_MAX];
+               if (param == NULL) {
+                       MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n");
+                       return;
+               } else {
+                       snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Type=%i", (int)wspHeaderDecodeInteger(data + 1));
+               }
+               break;
+       case 0x08 :
+               param = new char[WSP_STANDARD_STR_LEN_MAX];
 
-                       if (param == NULL) {
-                               MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n");
-                               return;
-                       } else {
-                               snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Padding=%i", (int)wspHeaderDecodeInteger( data + 1 ));
-                       }
-                       break;
-               case 0x05 :
-                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+               if (param == NULL) {
+                       MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n");
+                       return;
+               } else {
+                       snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Padding=%i", (int)wspHeaderDecodeInteger(data + 1));
+               }
+               break;
+       case 0x05 :
+               param = new char[WSP_STANDARD_STR_LEN_MAX];
 
-                       if (param == NULL) {
-                               MSG_DEBUG("WspLHeaderDecodeParameter:0x05 MemAlloc failed\n");
-                               return;
-                       } else {
-                               strncpy( (char*)param, "Name=", WSP_STANDARD_STR_LEN_MAX-1);
-                               memcpy( param + 5, data + 1, length - 1 );
-                               param[5 + length - 1] = '\0';
-                       }
-                       break;
-               case 0x06 :
-                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+               if (param == NULL) {
+                       MSG_DEBUG("WspLHeaderDecodeParameter:0x05 MemAlloc failed\n");
+                       return;
+               } else {
+                       strncpy((char*)param, "Name=", WSP_STANDARD_STR_LEN_MAX-1);
+                       memcpy(param + 5, data + 1, length - 1);
+                       param[5 + length - 1] = '\0';
+               }
+               break;
+       case 0x06 :
+               param = new char[WSP_STANDARD_STR_LEN_MAX];
 
-                       if (param == NULL) {
-                               MSG_DEBUG("WspLHeaderDecodeParameter:0x06 MemAlloc failed\n");
-                               return;
-                       } else {
-                               strncpy( (char*)param, "Filename=", WSP_STANDARD_STR_LEN_MAX-1);
-                               memcpy( param + 9, (char*)(data + 1), (size_t)(length - 1) );
-                               param[9 + length - 1] = '\0';
-                       }
-                       break;
-               case 0x07 :
-                       param = NULL;
-                       /* TBI */
-                       break;
-                       /*OMA Provisioning*/
-               case 0x11 :
-                       param = new char[WSP_STANDARD_STR_LEN_MAX];
+               if (param == NULL) {
+                       MSG_DEBUG("WspLHeaderDecodeParameter:0x06 MemAlloc failed\n");
+                       return;
+               } else {
+                       strncpy((char*)param, "Filename=", WSP_STANDARD_STR_LEN_MAX-1);
+                       memcpy(param + 9, (char*)(data + 1), (size_t)(length - 1));
+                       param[9 + length - 1] = '\0';
+               }
+               break;
+       case 0x07 :
+               param = NULL;
+               /* TBI */
+               break;
+               /*OMA Provisioning*/
+       case 0x11 :
+               param = new char[WSP_STANDARD_STR_LEN_MAX];
 
-                       if (param == NULL) {
-                               MSG_DEBUG("WspLHeaderDecodeParameter:0x11 MemAlloc failed\n");
-                               return;
-                       } else {
-                               strncpy((char*)param, "SEC=", WSP_STANDARD_STR_LEN_MAX-1);
-                               SecurityTypeCode = data[1] & 0x7f;
-                               while (( i < wspSecurityTypeCount ) && ( wspSecurityType[i].SecurityTypeCode != SecurityTypeCode )) i++;
+               if (param == NULL) {
+                       MSG_DEBUG("WspLHeaderDecodeParameter:0x11 MemAlloc failed\n");
+                       return;
+               } else {
+                       strncpy((char*)param, "SEC=", WSP_STANDARD_STR_LEN_MAX-1);
+                       SecurityTypeCode = data[1] & 0x7f;
+                       while ((i < wspSecurityTypeCount) && (wspSecurityType[i].SecurityTypeCode != SecurityTypeCode)) i++;
 
-                               if (i < wspSecurityTypeCount) {
-                                       strncat( (char*)param, (char*)wspSecurityType[i].SecurityTypeName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
-                               }
+                       if (i < wspSecurityTypeCount) {
+                               strncat((char*)param, (char*)wspSecurityType[i].SecurityTypeName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+                       }
 
-                               if (0x12 == (data[2] & 0x7f)) {
-                                       strncat( (char*)param, "; MAC=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 );
-                                       memcpy(param+AcStrlen( (char*)param),(char*)(data+3),(size_t)length-3 );
-                               }
+                       if (0x12 == (data[2] & 0x7f)) {
+                               strncat((char*)param, "; MAC=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+                               memcpy(param+AcStrlen((char*)param),(char*)(data+3),(size_t)length-3);
                        }
-                       break;
+               }
+               break;
 
-               default :
-                       param = NULL;
-                       break;
+       default :
+               param = NULL;
+               break;
        }
 
        *pParam = param;
@@ -3239,7 +3253,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, uns
 }
 
 
-void SmsPluginWapPushHandler::wspHeaderDecodeCharset( unsigned long length, unsigned char* data, char**pDecodedString)
+void SmsPluginWapPushHandler::wspHeaderDecodeCharset(unsigned long length, unsigned char* data, char**pDecodedString)
 {
 
        char* param = NULL;
@@ -3252,10 +3266,10 @@ void SmsPluginWapPushHandler::wspHeaderDecodeCharset( unsigned long length, unsi
                return;
        }
 
-       strncpy( (char*)param, "charset=", WSP_STANDARD_STR_LEN_MAX-1);
+       strncpy((char*)param, "charset=", WSP_STANDARD_STR_LEN_MAX-1);
 
        if (data[0] > 0x80) {
-               unsigned long code = wspHeaderDecodeInteger(data );
+               unsigned long code = wspHeaderDecodeInteger(data);
                unsigned long i = 0;
                while (wspCharset[i].charsetCode !=  code) {
                        if (wspCharset[i].charsetCode == 0xffff) {
@@ -3264,14 +3278,14 @@ void SmsPluginWapPushHandler::wspHeaderDecodeCharset( unsigned long length, unsi
                        }
                        i++;
                }
-               strncat( (char*)param, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 );
+               strncat((char*)param, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
        } else {
                unsigned long lastLen = AcStrlen((char*)param);
                if (length + lastLen < WSP_STANDARD_STR_LEN_MAX - 1) {
-                       memcpy( (char*)(param + lastLen), data, (size_t)length );
+                       memcpy((char*)(param + lastLen), data, (size_t)length);
                        param[length + lastLen] = '\0';
                } else {
-                       memcpy( (char*)(param + lastLen), data, WSP_STANDARD_STR_LEN_MAX - lastLen - 1 );
+                       memcpy((char*)(param + lastLen), data, WSP_STANDARD_STR_LEN_MAX - lastLen - 1);
                        param[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
                }
        }
@@ -3282,7 +3296,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeCharset( unsigned long length, unsi
 
 
 
-void SmsPluginWapPushHandler::wspHeaderDecodeVersion( unsigned long length, unsigned char* data, char** pDecodedString )
+void SmsPluginWapPushHandler::wspHeaderDecodeVersion(unsigned long length, unsigned char* data, char** pDecodedString)
 {
        *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
 
@@ -3293,94 +3307,94 @@ void SmsPluginWapPushHandler::wspHeaderDecodeVersion( unsigned long length, unsi
 
        if (length > 1) {
                /* untyped version */
-               memcpy( *pDecodedString, data, (size_t)length );
+               memcpy(*pDecodedString, data, (size_t)length);
        } else {
                /* typed version */
-               unsigned char majorVer  = ((data[0] & 0x7f ) >> 4 );
+               unsigned char majorVer  = ((data[0] & 0x7f) >> 4);
                unsigned char minorVer = data[0] & 0x0f;
-               snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "level=%u.%u", majorVer, minorVer );
+               snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "level=%u.%u", majorVer, minorVer);
        }
 
        return;
 }
 
 
-void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, unsigned char* data, char** pDecodedString )
+void SmsPluginWapPushHandler::wspHeaderDecodeDateValue(unsigned long length, unsigned char* data, char** pDecodedString)
 {
        time_t  lTime;
        struct  tm pTMData;
 
-       MSG_DEBUG("WspLHeaderDecodeDateValue:   \n" );
+       MSG_DEBUG("WspLHeaderDecodeDateValue:   \n");
 
        *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
 
        if (*pDecodedString == NULL) {
-               MSG_DEBUG( "WspLHeaderDecodeDateValue:MemAlloc failed\n");
+               MSG_DEBUG("WspLHeaderDecodeDateValue:MemAlloc failed\n");
                return;
        }
 
        lTime = wspHeaderDecodeIntegerByLength(data, length);
 
-       (struct tm*)gmtime_r((const time_t* )&lTime, &pTMData);
+       (struct tm*)gmtime_r((const time_t*)&lTime, &pTMData);
 
        /* check date value validity */
        {
-               if (( pTMData.tm_wday > 6 ) || (pTMData.tm_mon > 11 ) || (pTMData.tm_mday >  31 ))
+               if ((pTMData.tm_wday > 6) || (pTMData.tm_mon > 11) || (pTMData.tm_mday >  31))
                {
-                       MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData.tm_wday, pTMData.tm_mon, pTMData.tm_mday );
-                       strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
+                       MSG_DEBUG("WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData.tm_wday, pTMData.tm_mon, pTMData.tm_mday);
+                       strncpy((char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
                        return;
                }
        }
 
 #ifdef MSG_FW_FOR_DEBUG
        /** Date type selection */
-       switch ( wspMachineStatus.dateType )
+       switch (wspMachineStatus.dateType)
        {
                        /* UNIX asciitime function */
                case UNIX_DATE_TYPE :
-                       snprintf( (char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon],
-                                          pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900 );
+                       snprintf((char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon],
+                                          pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900);
                        break;
                case RFC1123_DATE_TYPE :
-                       snprintf( (char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData.tm_wday], pTMData.tm_mday,
-                                          wspMonth[pTMData.tm_mon], pTMData.tm_year + 1900, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec );
+                       snprintf((char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData.tm_wday], pTMData.tm_mday,
+                                          wspMonth[pTMData.tm_mon], pTMData.tm_year + 1900, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec);
                        break;
                case RFC850_DATE_TYPE :
                        /* Have some Y2K Problems */
                        /* In RFC 850, date is represented like 11-May-99. So Y2K problem always can be occured. So remainer (year divided by 100) is used.                     */
-                       snprintf( (char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData.tm_wday], pTMData.tm_mday,
-                                          wspMonth[pTMData.tm_mon], pTMData.tm_year % CENTURY, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec );
+                       snprintf((char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData.tm_wday], pTMData.tm_mday,
+                                          wspMonth[pTMData.tm_mon], pTMData.tm_year % CENTURY, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec);
 
                        break;
        }
 #endif
        /**UNIX_DATE_TYPE : */
-       snprintf( (char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon],
-                                                                                       pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900 );
+       snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon],
+                                                                                       pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900);
 
        return;
 
 }
 
-void SmsPluginWapPushHandler::wspHeaderCopyDecodedString( unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper )
+void SmsPluginWapPushHandler::wspHeaderCopyDecodedString(unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper)
 {
-       unsigned long elementLen = AcStrlen( (char*)szDecodedString );
+       unsigned long elementLen = AcStrlen((char*)szDecodedString);
        char* temper2 = NULL;
 
-       /**  // CR+LF */
+       /** CR+LF */
        *currentLen = *currentLen + elementLen + 2;
 
-       if ( *currentLen > AcStrlen( (char*)* pTemper ) + 2) {
-               temper2 = new char[(*currentLen + 1 )];
+       if (*currentLen > AcStrlen((char*)* pTemper) + 2) {
+               temper2 = new char[(*currentLen + 1)];
 
                if (temper2 == NULL) {
-                       MSG_DEBUG( "WspLHeaderCopyDecodedString:MemAlloc failed\n");
+                       MSG_DEBUG("WspLHeaderCopyDecodedString:MemAlloc failed\n");
                        return;
                }
-               strncpy( (char*)temper2, (char*)* pTemper, *currentLen);
+               strncpy((char*)temper2, (char*)* pTemper, *currentLen);
                delete[] *pTemper;
-               strncpy( (char*)temper2, (char*)szDecodedString, *currentLen);
+               strncpy((char*)temper2, (char*)szDecodedString, *currentLen);
        }
 
        *pTemper = temper2;
@@ -3389,7 +3403,7 @@ void SmsPluginWapPushHandler::wspHeaderCopyDecodedString( unsigned char* szDecod
 }
 
 
-void SmsPluginWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString )
+void SmsPluginWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString)
 {
        unsigned char  userId[WSP_STANDARD_STR_LEN_MAX];
        unsigned char  passWd[WSP_STANDARD_STR_LEN_MAX];
@@ -3399,7 +3413,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, u
        *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX * 2];
 
        if (*pDecodedString == NULL) {
-               MSG_DEBUG("WspLHeaderDecodeAuth:MemAlloc failed\n" );
+               MSG_DEBUG("WspLHeaderDecodeAuth:MemAlloc failed\n");
                return;
        }
 
@@ -3407,19 +3421,19 @@ void SmsPluginWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, u
        iField++;
        memset(authStr, 0x00, sizeof(authStr));
        snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(userId));
-       sscanf((char*)(fieldValue + iField), authStr, userId );
-       iField = iField + AcStrlen( (char*)userId ) + 1;
+       sscanf((char*)(fieldValue + iField), authStr, userId);
+       iField = iField + AcStrlen((char*)userId) + 1;
        memset(authStr, 0x00, sizeof(authStr));
        snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(passWd));
-       sscanf( (char*)(fieldValue + iField), authStr, passWd );
-       iField = iField + AcStrlen( (char*)userId ) + 1;
-       snprintf( (char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX*2), "basic %s/%s", userId, passWd );
+       sscanf((char*)(fieldValue + iField), authStr, passWd);
+       iField = iField + AcStrlen((char*)userId) + 1;
+       snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX*2), "basic %s/%s", userId, passWd);
 
        return;
 }
 
 
-void SmsPluginWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString )
+void SmsPluginWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString)
 {
        unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
        unsigned long iField = 0;
@@ -3428,7 +3442,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueL
        *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
 
        if (*pDecodedString == NULL) {
-               MSG_DEBUG( "WspLHeaderDecodeChallenge:MemAlloc failed\n");
+               MSG_DEBUG("WspLHeaderDecodeChallenge:MemAlloc failed\n");
                return;
        }
 
@@ -3436,10 +3450,10 @@ void SmsPluginWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueL
        iField++;
        memset(authStr, 0x00, sizeof(authStr));
        snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(userId));
-       sscanf( (char*)(fieldValue + iField), authStr, userId );
-       iField = iField + AcStrlen( (char*)userId ) + 1;
+       sscanf((char*)(fieldValue + iField), authStr, userId);
+       iField = iField + AcStrlen((char*)userId) + 1;
 
-       snprintf( (char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "basic realm=\"%s\"", userId );
+       snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "basic realm=\"%s\"", userId);
 
        return;
 }
@@ -3452,7 +3466,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeCacheControl(unsigned char* fieldVa
 
        *pCacheString = new char[WSP_STANDARD_STR_LEN_MAX];
        if (*pCacheString == NULL) {
-               MSG_DEBUG( "WspLHeaderDecodeCacheControl:MemAlloc failed\n");
+               MSG_DEBUG("WspLHeaderDecodeCacheControl:MemAlloc failed\n");
                return;
        }
 
@@ -3461,65 +3475,64 @@ void SmsPluginWapPushHandler::wspHeaderDecodeCacheControl(unsigned char* fieldVa
                if (fieldValue[0] > 0x8b) {
                        return; /* It's error detection. can be omitted. */
                }
-               strncpy( (char*)*pCacheString, (char*)wspCacheControl[fieldValue[0] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
+               strncpy((char*)*pCacheString, (char*)wspCacheControl[fieldValue[0] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
                return;
        }
 
        if (fieldValue[0] > 0x7f) {
                /* directive that has parameter */
                cacheCode = fieldValue[0] & 0x7f;
-               switch ( cacheCode )
-               {
-                               /* field name */
-                               /* no-cache */
-                       case 0x00 :
-                               /* private */
-                       case 0x07 :
-                               if (fieldValue[1] > 0x7f) {
-                                       /* well known field name */
-                                       strncpy( (char*)paramString, (char*)wspHeaderFieldName[fieldValue[1] & 0x7f],WSP_STANDARD_STR_LEN_MAX-1 );
-                                       paramString[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
-                               } else {
-                                       /* unknown field name */
-                                       strncpy( (char*)paramString, (char*)fieldValue + 1 , WSP_STANDARD_STR_LEN_MAX-1);
-                               }
-                               break;
-                               /* secound */
-                               /* max-age */
-                       case 0x02 :
-                               /* max- stale */
-                       case 0x03 :
-                               /* min-fresh */
-                       case 0x04 :
-                               snprintf( (char*)paramString, sizeof(paramString), "%u", (unsigned int)wspHeaderDecodeInteger( fieldValue + 1));
-                               break;
-
-                       default :
-                               break;
+               switch (cacheCode) {
+                       /* field name */
+                       /* no-cache */
+               case 0x00 :
+                       /* private */
+               case 0x07 :
+                       if (fieldValue[1] > 0x7f) {
+                               /* well known field name */
+                               strncpy((char*)paramString, (char*)wspHeaderFieldName[fieldValue[1] & 0x7f],WSP_STANDARD_STR_LEN_MAX-1);
+                               paramString[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
+                       } else {
+                               /* unknown field name */
+                               strncpy((char*)paramString, (char*)fieldValue + 1 , WSP_STANDARD_STR_LEN_MAX-1);
+                       }
+                       break;
+                       /* secound */
+                       /* max-age */
+               case 0x02 :
+                       /* max- stale */
+               case 0x03 :
+                       /* min-fresh */
+               case 0x04 :
+                       snprintf((char*)paramString, sizeof(paramString), "%u", (unsigned int)wspHeaderDecodeInteger(fieldValue + 1));
+                       break;
+
+               default :
+                       break;
 
                }
-               snprintf((char*)*pCacheString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s=%s", (char*)wspCacheControl[cacheCode], (char*)paramString );
+               snprintf((char*)*pCacheString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s=%s", (char*)wspCacheControl[cacheCode], (char*)paramString);
        } else {
                /* cache extentions */
                /* In case of come directive of doesn't specified string style */
 
                unsigned long stringLen;
                char szString[32];
-               strncpy( (char*)*pCacheString, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX-1);
-               stringLen = AcStrlen((char*)*pCacheString );
+               strncpy((char*)*pCacheString, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX-1);
+               stringLen = AcStrlen((char*)*pCacheString);
 
                if (stringLen + 1 < fieldValueLen) {
 
                        if (fieldValue[stringLen+ 1] > 0x7f) {
-                               int untyped = (int)wspHeaderDecodeIntegerByLength( fieldValue + stringLen + 1, fieldValueLen - (stringLen + 1 ));
+                               int untyped = (int)wspHeaderDecodeIntegerByLength(fieldValue + stringLen + 1, fieldValueLen - (stringLen + 1));
 
-                               snprintf( szString, sizeof(szString), "%d", untyped );
-                               strncat( (char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
-                               strncat( (char*)*pCacheString, (char*)szString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
+                               snprintf(szString, sizeof(szString), "%d", untyped);
+                               strncat((char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+                               strncat((char*)*pCacheString, (char*)szString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
                        } else {
                                if (fieldValue[fieldValueLen] == 0) {
-                                       strncat( (char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
-                                       strncat( (char*)*pCacheString, (char*)fieldValue + stringLen + 1 , WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+                                       strncat((char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+                                       strncat((char*)*pCacheString, (char*)fieldValue + stringLen + 1 , WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
                                }
                        }
                }
@@ -3530,7 +3543,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeCacheControl(unsigned char* fieldVa
 
 void SmsPluginWapPushHandler::getDisplayName(MSG_SUB_TYPE_T subType,char* displayName)
 {
-       if(subType == MSG_WAP_SL_SMS || subType == MSG_WAP_SI_SMS)
+       if (subType == MSG_WAP_SL_SMS || subType == MSG_WAP_SI_SMS)
                snprintf(displayName, MAX_ADDRESS_VAL_LEN + 1, "Push message");
        return;
 }
index 1634292..a230c0a 100755 (executable)
@@ -109,5 +109,5 @@ private:
        static SmsPluginCallback* pInstance;
 };
 
-#endif //SMS_PLUGIN_CALLBACK_H
+#endif /* SMS_PLUGIN_CALLBACK_H */
 
index c351889..e9097a7 100755 (executable)
@@ -98,5 +98,5 @@ private:
 
 };
 
-#endif //SMS_PLUGIN_CBMSG_HANDLER_H
+#endif /* SMS_PLUGIN_CBMSG_HANDLER_H */
 
index fa3552a..b42ebc8 100755 (executable)
@@ -92,8 +92,8 @@ public:
        static SmsPluginConcatHandler* instance();
 
        bool IsConcatMsg(SMS_USERDATA_S *pUserData);
-       void handleConcatMsg(struct tapi_handle *handle, SMS_TPDU_S *pTpdu);
-       void handleSimConcatMsg(struct tapi_handle *handle, SMS_TPDU_S *pTpdu, int msgId, int bRead, int *simIdList);
+       void handleConcatMsg(TapiHandle *handle, SMS_TPDU_S *pTpdu);
+       void handleSimConcatMsg(TapiHandle *handle, SMS_TPDU_S *pTpdu, int msgId, int bRead, int *simIdList);
 //     void handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t SimMsgId, bool bRead);
 
 //     void handleBrokenMsg();
@@ -105,13 +105,13 @@ private:
        static SmsPluginConcatHandler* pInstance;
 
        unsigned char checkConcatMsg(SMS_CONCAT_MSG_S *pConcatMsg, SMS_USERDATA_S *pUserData);
-       int makeConcatUserData(unsigned short MsgRef, int simIndex, char **ppTotalData);
+       int makeConcatUserData(unsigned short MsgRef, int simIndex, char **ppTotalData, char *originAddress);
 
        void convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo);
        void convertConcatToMsginfo(const SMS_SUBMIT_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo);
 //     void convertSimMsgToMsginfo(const SMS_CONCAT_MSG_S *pConcatMsg, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo);
 
-       void removeFromConcatList(unsigned short MsgRef, int simIndex);
+       void removeFromConcatList(unsigned short MsgRef, int simIndex, char *originAddress);
 
 //     void addToSimIdList(unsigned short MsgRef, msg_sim_id_t SimMsgId);
 //     void removeFromSimIdList(unsigned short MsgRef);
@@ -121,4 +121,4 @@ private:
 
 };
 
-#endif //SMS_PLUGIN_CONCAT_HANDLER_H
+#endif /* SMS_PLUGIN_CONCAT_HANDLER_H */
index 48d095b..291b8e4 100755 (executable)
@@ -33,10 +33,10 @@ public:
        static SmsPluginDSHandler* instance();
        int initTelHandle();
        void deinitTelHandle();
-       struct tapi_handle *getTelHandle(int sim_idx);
+       TapiHandle *getTelHandle(int sim_idx);
        int getTelHandleCount();
        int getActiveSimCount();
-       int getSimIndex(struct tapi_handle *handle);
+       int getSimIndex(TapiHandle *handle);
        void getDefaultNetworkSimId(int *simId);
 
        int getSubscriberId(unsigned int simIndex, char **subscriber_id);
@@ -49,5 +49,5 @@ private:
        SMS_TELEPHONY_HANDLE_LIST_S handle_list;
 };
 
-#endif //SMS_PLUGIN_DS_HANDLER_H
+#endif /* SMS_PLUGIN_DS_HANDLER_H */
 
index 12a0cdb..4d9973a 100755 (executable)
@@ -37,7 +37,7 @@ public:
 
        void registerListener(MSG_PLUGIN_LISTENER_S *pListener);
        void handleSentStatus(msg_network_status_t NetStatus);
-       void handleMsgIncoming(struct tapi_handle *handle, SMS_TPDU_S *pTpdu);
+       void handleMsgIncoming(TapiHandle *handle, SMS_TPDU_S *pTpdu);
        void handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, int simIndex);
        void handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen);
        void handlePushMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen, char *app_id, char *content_type);
@@ -53,10 +53,11 @@ public:
 
        void SetSentInfo(SMS_SENT_INFO_S *pSentInfo);
 
-       void setDeviceStatus(struct tapi_handle *handle);
-       bool getDeviceStatus(struct tapi_handle *handle);
+       void setDeviceStatus(TapiHandle *handle);
+       bool getDeviceStatus(TapiHandle *handle);
 
-       void convertTpduToMsginfo(SMS_TPDU_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo); // temp
+       /* temp */
+       void convertTpduToMsginfo(SMS_TPDU_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
 
        MSG_SUB_TYPE_T convertMsgSubType(SMS_PID_T pid);
 
@@ -80,8 +81,8 @@ private:
 
        Mutex mx;
        CndVar cv;
-       struct tapi_handle *devHandle;
+       TapiHandle *devHandle;
 };
 
-#endif //SMS_PLUGIN_EVENT_HANDLER_H
+#endif /* SMS_PLUGIN_EVENT_HANDLER_H */
 
index bedffb8..ec9a89d 100755 (executable)
@@ -46,10 +46,6 @@ msg_error_t SmsPlgSaveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_
 
 msg_error_t SmsPlgDeleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
 
-msg_error_t SmsPlgGetSimMessage(msg_sim_id_t SimMsgId);
-
-msg_error_t SmsPlgGetSimMessageCount();
-
 msg_error_t SmsPlgSetReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
 
 msg_error_t SmsPlgSetMemoryStatus(msg_sim_slot_id_t simIndex, msg_error_t Error);
@@ -66,5 +62,5 @@ msg_error_t SmsPlgGetDefaultNetworkSimId(int *simId);
 }
 #endif
 
-#endif //SMS_PLUGIN_MAIN_H
+#endif /* SMS_PLUGIN_MAIN_H */
 
index 0795823..715a971 100755 (executable)
@@ -46,9 +46,11 @@ public:
 
        static bool checkCphsVmiMsg(const unsigned char *pTpdu, int *setType, int *indType);
 
+       static time_t convertTime(const SMS_TIMESTAMP_S *time_stamp);
+
 private:
        static int convertDigitToBcd(char *pDigit, int DigitLen, unsigned char *pBcd);
        static int convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit);
 };
 
-#endif //SMS_PLUGIN_PARAMCODEC_H
+#endif /* SMS_PLUGIN_PARAMCODEC_H */
index e6a640f..d703456 100755 (executable)
@@ -37,10 +37,10 @@ class SmsPluginSatHandler
 public:
        static SmsPluginSatHandler* instance();
 
-       void refreshSms(struct tapi_handle *handle, void *pData);
-       void sendSms(struct tapi_handle *handle, void *pData);
-       void ctrlSms(struct tapi_handle *handle, void *pData);
-       void ctrlSms(struct tapi_handle *handle, SMS_NETWORK_STATUS_T netStatus);
+       void refreshSms(TapiHandle *handle, void *pData);
+       void sendSms(TapiHandle *handle, void *pData);
+       void ctrlSms(TapiHandle *handle, void *pData);
+       void ctrlSms(TapiHandle *handle, SMS_NETWORK_STATUS_T netStatus);
 
        void finishSimMsgInit(msg_error_t Err);
 
@@ -55,7 +55,7 @@ private:
 
        int handleSatTpdu(unsigned char *pTpdu, unsigned char TpduLen, int bIsPackingRequired);
 
-       void sendResult(struct tapi_handle *handle, SMS_SAT_CMD_TYPE_T CmdType, int ResultType);
+       void sendResult(TapiHandle *handle, SMS_SAT_CMD_TYPE_T CmdType, int ResultType);
 
        static SmsPluginSatHandler* pInstance;
 
@@ -69,5 +69,5 @@ private:
        CndVar cv;
 };
 
-#endif //SMS_PLUGIN_SAT_HANDLER_H
+#endif /* SMS_PLUGIN_SAT_HANDLER_H */
 
index 05e39d1..f59ddab 100755 (executable)
 #include "MsgMutex.h"
 #include "MsgSettingTypes.h"
 #include <list>
+#include <map>
 
 extern "C"
 {
        #include <tapi_common.h>
 }
 
+typedef map <int, MSG_SMSC_LIST_S> smscListMap;
+typedef map <int, SMS_SIM_MAILBOX_LIST_S> smsSimMailboxListMap;
+typedef map <int, SMS_SIM_MWI_INFO_S> simMwiInfoMap;
+typedef map <int, MSG_CBMSG_OPT_S>     cbOptMap;
+
 /*==================================================================================================
                                      CLASS DEFINITIONS
 ==================================================================================================*/
@@ -43,27 +49,27 @@ public:
        void getMeImei(char *pImei);
 
        void setParamCntEvent(int ParamCnt);
-       void setParamEvent(struct tapi_handle *handle, const MSG_SMSC_DATA_S *pSmscData, int RecordIdx, bool bSuccess);
-       void setCbConfigEvent(struct tapi_handle *handle, const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess);
-       void setMailboxInfoEvent(struct tapi_handle *handle, SMS_SIM_MAILBOX_LIST_S *pVoiceOpt, bool bSuccess, bool bMbdn);
+       void setParamEvent(TapiHandle *handle, const MSG_SMSC_DATA_S *pSmscData, int RecordIdx, bool bSuccess);
+       void setCbConfigEvent(TapiHandle *handle, const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess);
+       void setMailboxInfoEvent(TapiHandle *handle, SMS_SIM_MAILBOX_LIST_S *pVoiceOpt, bool bSuccess, bool bMbdn);
        void setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count);
-       void setMwiInfoEvent(struct tapi_handle *handle, SMS_SIM_MWI_INFO_S *pMwiInfo, bool bSuccess);
+       void setMwiInfoEvent(TapiHandle *handle, SMS_SIM_MWI_INFO_S *pMwiInfo, bool bSuccess);
        void setResultFromSim(bool bResult);
        void setResultImei(bool bResult, char *pImei);
 
        void setSmscInfo(const MSG_SMSC_LIST_S *pSmscList);
 
-       void setSimChangeStatus(struct tapi_handle *handle, bool bInitializing);
+       void setSimChangeStatus(TapiHandle *handle, bool bInitializing);
        void getSmscListInfo(int simIndex, MSG_SMSC_LIST_S *pSmscList);
-       void SimRefreshCb(struct tapi_handle *handle);
+       void SimRefreshCb(TapiHandle *handle);
 
 private:
        SmsPluginSetting();
        ~SmsPluginSetting();
 
-       void updateSimStatus(struct tapi_handle *handle);
+       void updateSimStatus(TapiHandle *handle);
 
-       void initConfigData(struct tapi_handle *handle);
+       void initConfigData(TapiHandle *handle);
        static void* init_config_data(void *data);
        static void* initSimInfo(void *data);
        void* processInitSimInfo(void *data);
@@ -76,22 +82,22 @@ private:
        void setParamList(const MSG_SMSC_LIST_S *pSMSCList);
        void getParamList(MSG_SMSC_LIST_S *pSMSCList);
 
-       int getParamCount(struct tapi_handle *handle);
-       bool getParam(struct tapi_handle *handle, int Index, MSG_SMSC_DATA_S *pSmscData);
+       int getParamCount(TapiHandle *handle);
+       bool getParam(TapiHandle *handle, int Index, MSG_SMSC_DATA_S *pSmscData);
 
        bool setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt);
        bool getCbConfig(MSG_CBMSG_OPT_S *pCbOpt);
 
        void setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt);
-       bool getVoiceMailInfo(struct tapi_handle *handle);
+       bool getVoiceMailInfo(TapiHandle *handle);
 
-       bool getMwiInfo(struct tapi_handle *handle);
-       bool getMsisdnInfo(struct tapi_handle *handle);
-       bool getSimServiceTable(struct tapi_handle *handle);
+       bool getMwiInfo(TapiHandle *handle);
+       bool getMsisdnInfo(TapiHandle *handle);
+       bool getSimServiceTable(TapiHandle *handle);
        bool getResultImei(char *pImei);
 
        int getParamCntEvent();
-       bool getParamEvent(struct tapi_handle *handle, MSG_SMSC_DATA_S *pSmscData);
+       bool getParamEvent(TapiHandle *handle, MSG_SMSC_DATA_S *pSmscData);
        bool getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt);
 
        bool getMailboxInfoEvent();
@@ -105,12 +111,12 @@ private:
        std::list<TapiHandle *> tel_handle_list;
 
        /* Setting values for keeping in setting instance */
-       MSG_SMSC_LIST_S         smscList[MAX_TELEPHONY_HANDLE_CNT+1];
-       MSG_SIM_STATUS_T        simStatus[MAX_TELEPHONY_HANDLE_CNT+1];
-       MSG_SMSC_DATA_S         smscData[MAX_TELEPHONY_HANDLE_CNT+1];
-       SMS_SIM_MAILBOX_LIST_S  simMailboxList[MAX_TELEPHONY_HANDLE_CNT+1];
-       SMS_SIM_MWI_INFO_S      simMwiInfo[MAX_TELEPHONY_HANDLE_CNT+1];
-       MSG_CBMSG_OPT_S cbOpt[MAX_TELEPHONY_HANDLE_CNT+1];
+       smscListMap                     smscList;
+       MSG_SIM_STATUS_T                simStatus[MAX_TELEPHONY_HANDLE_CNT+1];
+       MSG_SMSC_DATA_S                 smscData[MAX_TELEPHONY_HANDLE_CNT+1];
+       smsSimMailboxListMap    simMailboxList;
+       simMwiInfoMap                   simMwiInfo;
+       cbOptMap                                cbOpt;
 
        /* Local values for getting from SIM(TAPI) */
        bool    bTapiResult;
@@ -125,5 +131,5 @@ private:
        CndVar cv;
 };
 
-#endif //SMS_PLUGIN_SETTING_H
+#endif /* SMS_PLUGIN_SETTING_H */
 
index 900ddcf..1e11050 100755 (executable)
@@ -100,5 +100,5 @@ private:
        CndVar cv;
 };
 
-#endif //SMS_PLUGIN_SIMMSG_H
+#endif /* SMS_PLUGIN_SIMMSG_H */
 
index 0506e8f..758a0b8 100755 (executable)
@@ -71,6 +71,7 @@ public:
        msg_error_t getRegisteredPushEvent(char* pPushHeader, int *count, char *app_id, int app_id_len, char *content_type, int content_type_len);
        msg_error_t getnthPushEvent(int index, int *appcode);
        msg_error_t releasePushEvent();
+       msg_error_t updateSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
 private:
        SmsPluginStorage();
        ~SmsPluginStorage();
@@ -87,5 +88,5 @@ private:
 //     unsigned char tmpMsgRef;
 };
 
-#endif //SMS_PLUGIN_STORAGE_H
+#endif /* SMS_PLUGIN_STORAGE_H */
 
index 597a91d..f206185 100755 (executable)
@@ -47,5 +47,5 @@ private:
        static int decodeStatusReport(const unsigned char *pTpdu, int TpduLen, SMS_STATUS_REPORT_S *pStatusRep);
 };
 
-#endif //SMS_PLUGIN_TPDU_CODEC_H
+#endif /* SMS_PLUGIN_TPDU_CODEC_H */
 
index 59f177c..bb9e1da 100755 (executable)
@@ -84,5 +84,5 @@ private:
        CndVar cv;
 };
 
-#endif //SMS_PLUGIN_TRANSPORT_H
+#endif /* SMS_PLUGIN_TRANSPORT_H */
 
index d705686..7969fff 100755 (executable)
 #include "MsgStorageTypes.h"
 #include "MsgSettingTypes.h"
 
+extern "C"
+{
+       #include <tapi_common.h>
+}
 
 /*==================================================================================================
                                     DEFINES
 ==================================================================================================*/
-#define MAX_ADDRESS_LEN                        21 // including '+'
+#define MAX_ADDRESS_LEN                        21 /* including '+' */
 #define MAX_USER_DATA_LEN                      160
 #define MAX_GSM_7BIT_DATA_LEN          160
 #define MAX_UCS2_DATA_LEN                      140
 //#define MAX_TPDU_DATA_LEN                    165
-//CID 321400: Making MAX_TPDU_DATA_LEN same as TAPI_NETTEXT_SMDATA_SIZE_MAX of TelSms.h to prevent any buffer overflow
+/* CID 321400: Making MAX_TPDU_DATA_LEN same as TAPI_NETTEXT_SMDATA_SIZE_MAX of TelSms.h to prevent any buffer overflow */
 #define MAX_TPDU_DATA_LEN                      255
 #define MAX_SMS_SEND_RETRY                     4
 #define MAX_SMSC_LEN                           20
@@ -50,7 +54,6 @@
 #define MAX_SIM_SMS_NUM                        255
 #define MAX_SIM_IMSI_NUM               20
 #define MAX_SIM_MSP_CNT                        2
-#define MAX_TELEPHONY_HANDLE_CNT       3
 
 #define SMS_PUSH_XML_HREF_TAG          "href"
 #define SMS_PUSH_XML_SI_ID_TAG         "si-id"
@@ -118,8 +121,7 @@ typedef unsigned char SMS_NETWORK_STATUS_T; /* _SMS_NETWORK_STATUS_E */
 /*==================================================================================================
                                     ENUMS
 ==================================================================================================*/
-enum _SMS_TPDU_TYPE_E
-{
+enum _SMS_TPDU_TYPE_E {
        SMS_TPDU_SUBMIT,
        SMS_TPDU_DELIVER,
        SMS_TPDU_DELIVER_REP,
@@ -127,8 +129,7 @@ enum _SMS_TPDU_TYPE_E
 };
 
 
-enum _SMS_VPF_E
-{
+enum _SMS_VPF_E {
        SMS_VPF_NOT_PRESENT = 0,
        SMS_VPF_ENHANCED,
        SMS_VPF_RELATIVE,
@@ -136,8 +137,7 @@ enum _SMS_VPF_E
 };
 
 
-enum _SMS_TON_E
-{
+enum _SMS_TON_E {
        SMS_TON_UNKNOWN = 0,            /* unknown */
        SMS_TON_INTERNATIONAL,  /* international */
        SMS_TON_NATIONAL,                       /* national */
@@ -149,8 +149,7 @@ enum _SMS_TON_E
 };
 
 
-enum _SMS_NPI_E
-{
+enum _SMS_NPI_E {
        SMS_NPI_UNKNOWN = 0,            /* unknown */
        SMS_NPI_ISDN = 1,                       /* idsn */
        SMS_NPI_DATA = 3,                       /* data */
@@ -162,8 +161,7 @@ enum _SMS_NPI_E
 };
 
 
-enum _SMS_PID_E
-{
+enum _SMS_PID_E {
        SMS_PID_NORMAL = 0x00,
 
        SMS_PID_TELEX = 0x21,
@@ -195,8 +193,7 @@ enum _SMS_PID_E
 };
 
 
-enum _SMS_MSG_CLASS_E
-{
+enum _SMS_MSG_CLASS_E {
        SMS_MSG_CLASS_0 = 0,
        SMS_MSG_CLASS_1,
        SMS_MSG_CLASS_2,
@@ -205,8 +202,7 @@ enum _SMS_MSG_CLASS_E
 };
 
 
-enum _SMS_CODING_SCHEME_E
-{
+enum _SMS_CODING_SCHEME_E {
        SMS_CHARSET_7BIT = 0,
        SMS_CHARSET_8BIT,
        SMS_CHARSET_UCS2,
@@ -215,8 +211,7 @@ enum _SMS_CODING_SCHEME_E
 };
 
 
-enum _SMS_CODING_GROUP_E
-{
+enum _SMS_CODING_GROUP_E {
        SMS_GROUP_GENERAL = 0,
        SMS_GROUP_CODING_CLASS,
        SMS_GROUP_DELETION,
@@ -226,25 +221,22 @@ enum _SMS_CODING_GROUP_E
 };
 
 
-enum _SMS_INDICATOR_TYPE_E
-{
+enum _SMS_INDICATOR_TYPE_E {
        SMS_VOICE_INDICATOR = 0,
-       SMS_VOICE2_INDICATOR, // Only for CPSH
+       SMS_VOICE2_INDICATOR, /* Only for CPSH */
        SMS_FAX_INDICATOR,
        SMS_EMAIL_INDICATOR,
        SMS_OTHER_INDICATOR,
 };
 
 
-enum _SMS_TIME_FORMAT_E
-{
+enum _SMS_TIME_FORMAT_E {
        SMS_TIME_RELATIVE = 0,
        SMS_TIME_ABSOLUTE
 };
 
 
-enum _SMS_FAIL_CAUSE_E
-{
+enum _SMS_FAIL_CAUSE_E {
        SMS_FC_MSG_TYPE0_NOT_SUPPORTED = 0x81,
        SMS_FC_SM_CANNOT_BE_REPLACED = 0x82,
        SMS_FC_UNSPEC_PID_ERROR = 0x8F,
@@ -261,8 +253,7 @@ enum _SMS_FAIL_CAUSE_E
 };
 
 
-enum _SMS_STATUS_E
-{
+enum _SMS_STATUS_E {
        SMS_STATUS_RECEIVE_SUCCESS = 0x00,
        SMS_STATUS_UNABLE_TO_CONFIRM_DELIVER = 0x01,
        SMS_STATUS_REPLACED = 0x02,
@@ -295,25 +286,22 @@ enum _SMS_STATUS_E
 };
 
 
-enum _SMS_REF_NUMBER_E
-{
+enum _SMS_REF_NUMBER_E {
        SMS_REF_NUM_8BIT = 0,
        SMS_REF_NUM_16BIT
 };
 
 
-enum _SMS_REPORT_TYPE_E
-{
+enum _SMS_REPORT_TYPE_E {
        SMS_REPORT_POSITIVE = 0,
        SMS_REPORT_NEGATIVE
 };
 
 
-enum _SMS_UDH_TYPE_E
-{
+enum _SMS_UDH_TYPE_E {
        SMS_UDH_CONCAT_8BIT = 0x00,
        SMS_UDH_SPECIAL_SMS = 0x01,
-       // 0x02, 0x03 - Reserved
+       /* 0x02, 0x03 - Reserved */
        SMS_UDH_APP_PORT_8BIT = 0x04,
        SMS_UDH_APP_PORT_16BIT = 0x05,
        SMS_UDH_SC_CONTROL = 0x06,
@@ -329,8 +317,7 @@ enum _SMS_UDH_TYPE_E
 };
 
 
-enum _SMS_WAP_APP_CODE_E
-{
+enum _SMS_WAP_APP_CODE_E {
        SMS_WAP_APPLICATION_DEFAULT = 0x00,
 
        SMS_WAP_APPLICATION_PUSH_SI,
@@ -396,15 +383,13 @@ enum _SMS_WAP_APP_CODE_E
 };
 
 
-enum _SMS_CB_NETWORK_TYPE_E
-{
+enum _SMS_CB_NETWORK_TYPE_E {
        SMS_CB_NETWORK_TYPE_2G_GSM = 1,
        SMS_CB_NETWORK_TYPE_3G_UMTS,
 };
 
 
-enum _SMS_CBMSG_TYPE_E
-{
+enum _SMS_CBMSG_TYPE_E {
        SMS_CBMSG_TYPE_CBS = 1,         /**< CBS */
        SMS_CBMSG_TYPE_SCHEDULE,                /**< Schedule */
        SMS_CBMSG_TYPE_CBS41,                   /**< CBS41 */
@@ -413,8 +398,7 @@ enum _SMS_CBMSG_TYPE_E
 };
 
 
-enum _SMS_CBMSG_LANG_TYPE_E
-{
+enum _SMS_CBMSG_LANG_TYPE_E {
        SMS_CBMSG_LANG_GERMAN                   = 0x00,
        SMS_CBMSG_LANG_ENGLISH                  = 0x01,
        SMS_CBMSG_LANG_ITALIAN                  = 0x02,
@@ -455,24 +439,21 @@ enum _SMS_CBMSG_LANG_TYPE_E
 };
 
 
-enum _SMS_CBMSG_CODING_GROUP_E
-{
+enum _SMS_CBMSG_CODING_GROUP_E {
        SMS_CBMSG_CODGRP_GENERAL_DCS,                   /**< Bits 7..4 00xx */
        SMS_CBMSG_CODGRP_WAP,                                   /**< 1110 Cell Broadcast */
        SMS_CBMSG_CODGRP_CLASS_CODING,                  /**< 1111 Cell Broadcast */
 };
 
 
-enum _SMS_SAT_CMD_TYPE_E
-{
+enum _SMS_SAT_CMD_TYPE_E {
        SMS_SAT_CMD_REFRESH,
        SMS_SAT_CMD_SEND_SMS,
        SMS_SAT_CMD_SMS_CTRL,
 };
 
 
-enum _SMS_SIM_EFILE_NAME_E
-{
+enum _SMS_SIM_EFILE_NAME_E {
        SMS_SIM_EFILE_USIM_SMS  = 0x6A3C,               /** < USIM Short Messages file */
        SMS_SIM_EFILE_USIM_SMSP = 0x6A42,               /** < USIM SMS parameter */
        SMS_SIM_EFILE_USIM_SMSS = 0x6A43,               /** < USIM SMS status */
@@ -514,16 +495,14 @@ enum _SMS_NETWORK_STATUS_E {
 /*==================================================================================================
                                          STRUCTURES
 ==================================================================================================*/
-typedef struct _SMS_ADDRESS_S
-{
+typedef struct _SMS_ADDRESS_S {
        SMS_TON_T               ton;
        SMS_NPI_T               npi;
        char                            address[MAX_ADDRESS_LEN+1];        /* < null terminated string */
 } SMS_ADDRESS_S;
 
 
-typedef struct _SMS_DCS_S
-{
+typedef struct _SMS_DCS_S {
        bool                                            bCompressed;
        bool                                            bMWI;
        bool                                            bIndActive;
@@ -534,14 +513,12 @@ typedef struct _SMS_DCS_S
 } SMS_DCS_S;
 
 
-typedef struct _SMS_TIME_REL_S
-{
+typedef struct _SMS_TIME_REL_S {
        unsigned char time;
 } SMS_TIME_REL_S;
 
 
-typedef struct _SMS_TIME_ABS_S
-{
+typedef struct _SMS_TIME_ABS_S {
        unsigned char year;
        unsigned char month;
        unsigned char day;
@@ -552,62 +529,53 @@ typedef struct _SMS_TIME_ABS_S
 } SMS_TIME_ABS_S;
 
 
-typedef struct _SMS_TIMESTAMP_S
-{
+typedef struct _SMS_TIMESTAMP_S {
        SMS_TIME_FORMAT_T format;
 
-       union
-       {
+       union {
                SMS_TIME_REL_S  relative;
                SMS_TIME_ABS_S  absolute;
        } time;
 } SMS_TIMESTAMP_S;
 
 
-typedef struct _SMS_CONCAT_8BIT_S
-{
+typedef struct _SMS_CONCAT_8BIT_S {
        unsigned char           msgRef;
        unsigned char           totalSeg;
        unsigned char           seqNum;
 } SMS_CONCAT_8BIT_S;
 
 
-typedef struct _SMS_CONCAT_16BIT_S
-{
+typedef struct _SMS_CONCAT_16BIT_S {
        unsigned short          msgRef;
        unsigned char           totalSeg;
        unsigned char           seqNum;
 } SMS_CONCAT_16BIT_S;
 
 
-typedef struct _SMS_APP_PORT_8BIT_S
-{
+typedef struct _SMS_APP_PORT_8BIT_S {
        unsigned char           destPort;
        unsigned char           originPort;
 } SMS_APP_PORT_8BIT_S;
 
 
-typedef struct _SMS_APP_PORT_16BIT_S
-{
+typedef struct _SMS_APP_PORT_16BIT_S {
        unsigned short          destPort;
        unsigned short          originPort;
 } SMS_APP_PORT_16BIT_S;
 
 
-typedef struct _SMS_SPECIAL_INDICATION_S
-{
+typedef struct _SMS_SPECIAL_INDICATION_S {
        bool                            bStore;
        unsigned short          msgInd;
        unsigned short          waitMsgNum;
 } SMS_SPECIAL_INDICATION_S;
 
 
-typedef struct _SMS_UDH_S
-{
+typedef struct _SMS_UDH_S {
        SMS_UDH_TYPE_T udhType;
 
-       union
-       {
+       union {
                SMS_CONCAT_8BIT_S                       concat8bit;
                SMS_CONCAT_16BIT_S                      concat16bit;
                SMS_APP_PORT_8BIT_S             appPort8bit;
@@ -620,8 +588,7 @@ typedef struct _SMS_UDH_S
 } SMS_UDH_S;
 
 
-typedef struct _SMS_USERDATA_S
-{
+typedef struct _SMS_USERDATA_S {
        int                     headerCnt;
        SMS_UDH_S       header[MAX_UD_HEADER_NUM];
        int                     length;
@@ -629,15 +596,13 @@ typedef struct _SMS_USERDATA_S
 } SMS_USERDATA_S;
 
 
-typedef struct _SMS_TPUD_S
-{
+typedef struct _SMS_TPUD_S {
        int             udl;
        char            ud[MAX_USER_DATA_LEN+1];
 } SMS_TPUD_S;
 
 
-typedef struct _SMS_SUBMIT_S
-{
+typedef struct _SMS_SUBMIT_S {
        bool                            bRejectDup;
        bool                            bStatusReport;
        bool                            bHeaderInd;
@@ -660,8 +625,7 @@ typedef struct _SMS_SUBMIT_DATA_S
 } SMS_SUBMIT_DATA_S;
 
 
-typedef struct _SMS_DELIVER_S
-{
+typedef struct _SMS_DELIVER_S {
        bool                            bMoreMsg;
        bool                            bStatusReport;
        bool                            bHeaderInd;
@@ -675,8 +639,7 @@ typedef struct _SMS_DELIVER_S
 } SMS_DELIVER_S;
 
 
-typedef struct _SMS_DELIVER_REPORT_S
-{
+typedef struct _SMS_DELIVER_REPORT_S {
        SMS_REPORT_TYPE_T       reportType;
        bool                                    bHeaderInd;
        SMS_FAIL_CAUSE_T                failCause;
@@ -687,8 +650,7 @@ typedef struct _SMS_DELIVER_REPORT_S
 } SMS_DELIVER_REPORT_S;
 
 
-typedef struct _SMS_STATUS_REPORT_S
-{
+typedef struct _SMS_STATUS_REPORT_S {
        bool                            bMoreMsg;
        bool                            bStatusReport;
        bool                            bHeaderInd;
@@ -704,12 +666,10 @@ typedef struct _SMS_STATUS_REPORT_S
 } SMS_STATUS_REPORT_S;
 
 
-typedef struct _SMS_TPDU_S
-{
+typedef struct _SMS_TPDU_S {
        SMS_TPDU_TYPE_T tpduType;
 
-       union
-       {
+       union {
                SMS_SUBMIT_S                    submit;
                SMS_DELIVER_S                   deliver;
                SMS_DELIVER_REPORT_S    deliverRep;
@@ -718,39 +678,34 @@ typedef struct _SMS_TPDU_S
 } SMS_TPDU_S;
 
 
-typedef struct
-{
+typedef struct {
        msg_request_id_t                                reqId;          /**< Indicates the request ID, which is unique. When applications submit a request to the framework, this value will be set by the framework. */
        MSG_MESSAGE_INFO_S                      msgInfo;        /**< Indicates the message structure to be sent by applications. */
        MSG_SENDINGOPT_INFO_S   sendOptInfo;
 } SMS_REQUEST_INFO_S;
 
 
-typedef struct _SMS_SENT_INFO_S
-{
+typedef struct _SMS_SENT_INFO_S {
        SMS_REQUEST_INFO_S              reqInfo;                /**< Indicates the corresponding request structure. */
        bool                                            bLast;
 } SMS_SENT_INFO_S;
 
 
-typedef struct _SMS_PUSH_APP_INFO_S
-{
+typedef struct _SMS_PUSH_APP_INFO_S {
        char*                           pContentType;
        char*                           pAppId;
        SMS_WAP_APP_CODE_T      appCode;
 } SMS_PUSH_APP_INFO_S;
 
 
-typedef struct _SMS_CBMSG_SERIAL_NUM_S
-{
+typedef struct _SMS_CBMSG_SERIAL_NUM_S {
        unsigned char           geoScope;
        unsigned char           updateNum;
        unsigned short          msgCode;
 } SMS_CBMSG_SERIAL_NUM_S;
 
 
-typedef struct _SMS_CBMSG_DCS_S
-{
+typedef struct _SMS_CBMSG_DCS_S {
        SMS_CBMSG_CODING_GROUP_T                codingGroup;            /**< Coding group, GSM 03.38 */
        SMS_MSG_CLASS_T                                 classType;              /**< The message class */
        bool                                                            bCompressed;            /**< if text is compressed this is TRUE */
@@ -762,8 +717,7 @@ typedef struct _SMS_CBMSG_DCS_S
 } SMS_CBMSG_DCS_S;
 
 
-typedef struct _SMS_CBMSG_HEADER_S
-{
+typedef struct _SMS_CBMSG_HEADER_S {
        SMS_CBMSG_SERIAL_NUM_S          serialNum;              /**< Cell Broadcast Serial number */
        unsigned short                                  msgId;                  /**< Message identifier code */
        MSG_CB_LANGUAGE_TYPE_T          langType;               /**< Languages in CB Messages */
@@ -774,8 +728,7 @@ typedef struct _SMS_CBMSG_HEADER_S
 } SMS_CBMSG_HEADER_S;
 
 
-typedef struct _SMS_CBMSG_PAGE_S
-{
+typedef struct _SMS_CBMSG_PAGE_S {
        SMS_CBMSG_TYPE_T                        cbMsgType;                                                      /*CBS Msg or SCHEDULE Msg or CBS41 Msg */
        SMS_CBMSG_HEADER_S                      pageHeader;                                                     /**< CB Message Header */
        int                                                     pageLength;                                                     /**< message string length */
@@ -783,8 +736,7 @@ typedef struct _SMS_CBMSG_PAGE_S
 } SMS_CBMSG_PAGE_S;
 
 
-typedef struct _SMS_CBMSG_S
-{
+typedef struct _SMS_CBMSG_S {
        SMS_CBMSG_TYPE_T                        cbMsgType;                                                      /*CBS Msg or SCHEDULE Msg or CBS41 Msg */
        unsigned short                                  msgId;                                                          /**< Message identifier code */
        SMS_MSG_CLASS_T                         classType;                                                      /**< The message class */
@@ -794,8 +746,7 @@ typedef struct _SMS_CBMSG_S
        char                                                    msgData[MAX_CBMSG_PAGE_SIZE*8/7*MAX_CBMSG_PAGE_NUM+1];          /**< user data */
 } SMS_CBMSG_S;
 
-typedef struct _SMS_ETWS_PRIMARY_S
-{
+typedef struct _SMS_ETWS_PRIMARY_S {
        time_t                                          recvTime;
        SMS_CBMSG_SERIAL_NUM_S          serialNum;
        unsigned short                          msgId;
@@ -804,50 +755,43 @@ typedef struct _SMS_ETWS_PRIMARY_S
 }SMS_ETWS_PRIMARY_S;
 
 
-typedef struct _SMS_WSP_CONTENTS_TYPE_S
-{
+typedef struct _SMS_WSP_CONTENTS_TYPE_S {
        char*         contentsTypeName;
        unsigned char contentsTypeCode;
 } SMS_WSP_CONTENTS_TYPE_S;
 
 
-typedef struct _SMS_WSP_CHARSET_S
-{
+typedef struct _SMS_WSP_CHARSET_S {
        char*  charsetName;
        unsigned short charsetCode;
 } SMS_WSP_CHARSET_S;
 
 
-typedef struct _SMS_WAP_UNREGISTER_CONTENTS_TYPE_S
-{
+typedef struct _SMS_WAP_UNREGISTER_CONTENTS_TYPE_S {
        char*         contentsTypeName;
        unsigned short contentsTypeCode;
 } SMS_WAP_UNREGISTER_CONTENTS_TYPE_S;
 
 
-typedef struct _SMS_WSP_LANGUAGE_S
-{
+typedef struct _SMS_WSP_LANGUAGE_S {
        char*         languageName;
        unsigned char languageCode;
 } SMS_WSP_LANGUAGE_S;
 
 
-typedef struct _SMS_WSP_HEADER_PARAMETER_S
-{
+typedef struct _SMS_WSP_HEADER_PARAMETER_S {
        char*         parameterToken;
        unsigned int parameterCode;
 } SMS_WSP_HEADER_PARAMETER_S;
 
 
-typedef struct _SMS_WSP_METHOD_TYPE_S
-{
+typedef struct _SMS_WSP_METHOD_TYPE_S {
        char*         methodName;
        unsigned char methodCode;
 } SMS_WSP_METHOD_TYPE_S;
 
 
-typedef struct _SMS_WSP_SECURITY_TYPE_S
-{
+typedef struct _SMS_WSP_SECURITY_TYPE_S {
        char*         SecurityTypeName;
        unsigned char SecurityTypeCode;
 }SMS_WSP_SECURITY_TYPE_S;
@@ -856,8 +800,7 @@ typedef struct _SMS_WSP_SECURITY_TYPE_S
 /**
  *     @brief  Represents SIM count information.
  */
-typedef struct
-{
+typedef struct {
        unsigned int    totalCount;                     /**< The total number of SIM */
        int                     usedCount;                      /**< The used number of SIM */
        int                     indexList[MAX_SIM_SMS_NUM];     /**< The SIM index list */
@@ -867,8 +810,7 @@ typedef struct
 /**
  *     @brief  Represents Concat SIM Msg information.
  */
-typedef struct
-{
+typedef struct {
        unsigned int            simIdCnt;                                                                                       /**< The total number of SIM Msg ID*/
        msg_sim_id_t            simIdList[MAX_SEGMENT_NUM];                                                     /**< The SIM Msg ID List */
        char                            msgData[(MAX_MSG_DATA_LEN*MAX_SEGMENT_NUM)+1];          /**< user data */
@@ -899,7 +841,7 @@ typedef struct {
  */
 typedef struct {
        int count;
-       SMS_SIM_MAILBOX_INFO_S list[MAX_SIM_MSP_CNT*5]; //max is 10
+       SMS_SIM_MAILBOX_INFO_S list[MAX_SIM_MSP_CNT*5]; /* max is 10 */
 } SMS_SIM_MAILBOX_LIST_S;
 
 
@@ -971,7 +913,7 @@ typedef struct {
  */
 typedef struct {
        int count;
-       struct tapi_handle *handle[MAX_TELEPHONY_HANDLE_CNT]; //max is 3
+       struct tapi_handle *handle[MAX_TELEPHONY_HANDLE_CNT]; /* max is 3 */
 } SMS_TELEPHONY_HANDLE_LIST_S;
 
-#endif //SMS_PLUGIN_TYPES_H
+#endif /* SMS_PLUGIN_TYPES_H */
index 8a50cab..03afcde 100755 (executable)
@@ -57,5 +57,5 @@ private:
        CndVar cv;
 };
 
-#endif //SMS_PLUGIN_UA_MANAGER_H
+#endif /* SMS_PLUGIN_UA_MANAGER_H */
 
index c109210..ade94f9 100755 (executable)
@@ -53,5 +53,5 @@ private:
        static int decodeHeader(const unsigned char *pTpdu, SMS_UDH_S *pHeader);
 };
 
-#endif
+#endif /* SMS_PLUGIN_UDCODEC_H */
 
index f47b46e..b1cd370 100755 (executable)
@@ -50,12 +50,11 @@ class SmsPluginWapPushHandler
 public:
        static SmsPluginWapPushHandler* instance();
 
-       //void registerPushCallback();
        bool IsWapPushMsg(SMS_USERDATA_S *pUserData);
 
        void copyDeliverData(SMS_DELIVER_S *pDeliver);
-       void handleWapPushMsg(const char *pUserData, int DataSize, int simIndex);
-       void handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen, int simIndex);
+       void handleWapPushMsg(const char *pUserData, int DataSize, int simIndex, time_t sent_time);
+       void handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen, int simIndex, time_t sent_time);
 
 private:
        SmsPluginWapPushHandler();
@@ -64,8 +63,9 @@ private:
        static SmsPluginWapPushHandler* pInstance;
 
        SMS_WAP_APP_CODE_T getAppCode(const char *pPushHeader);
+       bool IsWapPushMsgInWhiteList(int appCode);
 
-       void handleMMSNotification(const char *pPushBody, int PushBodyLen, int simIndex);
+       void handleMMSNotification(const char *pPushBody, int PushBodyLen, int simIndex, time_t sent_time);
        void handleSIMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex);
        void handleSLMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex);
        void handleCOMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex);
@@ -98,5 +98,5 @@ private:
        SMS_TIMESTAMP_S tmpTimeStamp;
 };
 
-#endif //SmsPluginWapPushHandler
+#endif /* SmsPluginWapPushHandler */
 
index 984fac0..69315d1 100755 (executable)
@@ -31,7 +31,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(trans_proxy_pkgs REQUIRED glib-2.0 dlog vconf db-util)
+pkg_check_modules(trans_proxy_pkgs REQUIRED glib-2.0 dlog vconf)
 
 FOREACH(flag ${trans_proxy_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 06a3823..611418c 100755 (executable)
@@ -47,7 +47,9 @@ void MsgHandle::openHandle()
 {
        bool bReady = false;
 
-       // server is currently booting and service is not available until the end of booting
+       MsgProxyListener::instance()->insertOpenHandleSet(this);
+
+       /* server is currently booting and service is not available until the end of booting */
        MsgSettingGetBool(VCONFKEY_MSG_SERVER_READY, &bReady);
 
        if (bReady == false) {
@@ -56,7 +58,7 @@ void MsgHandle::openHandle()
                MSG_INFO("Msg Server is ready !!!!!");
        }
 
-       // Open Socket IPC
+       /* Open Socket IPC */
        connectSocket();
 }
 
@@ -65,19 +67,19 @@ void MsgHandle::closeHandle(MsgHandle* pHandle)
 {
        MSG_BEGIN();
 
-       //Remove CB List of closing Handle
+       /* Remove CB List of closing Handle */
        MsgProxyListener* eventListener = MsgProxyListener::instance();
 
        eventListener->clearListOfClosedHandle(pHandle);
-       //eventListener->stop();
+       /* eventListener->stop(); */
 
-       // Close Socket IPC
+       /* Close Socket IPC */
        disconnectSocket();
 
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-       // Close Contact Service
+       /* Close Contact Service */
        if (MsgCloseContactSvc() != MSG_SUCCESS) {
-               MSG_DEBUG("Fail to close contact service.");
+               MSG_WARN("Fail to close contact service.");
        }
 #endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED
        removeDbHandle(); /* unregister db handler */
@@ -106,24 +108,24 @@ void MsgHandle::write(const char *pCmdData, int cmdSize, char **ppEvent)
 
        int ret = 0;
 
-       // Send Command to MSG FW
+       /* Send Command to MSG FW */
+       MutexLocker lock(mx);
        ret = mClientSock.write(pCmdData, cmdSize);
        if (ret < 0)
                THROW(MsgException::IPC_ERROR, "IPC write error");
 
        char *tmpEvent = NULL;
 
-       while(1)
-       {
-               // Receive Result from MSG FW
+       while (1) {
+               /* Receive Result from MSG FW */
                read(&tmpEvent);
 
-               if(tmpEvent == NULL) {
+               if (tmpEvent == NULL) {
                        MSG_DEBUG("Event Data is NULL!!");
                        break;
                }
 
-               if(!CheckEventData(tmpEvent)) {
+               if (!CheckEventData(tmpEvent)) {
                        delete [] tmpEvent;
                        tmpEvent = NULL;
                } else {
@@ -215,7 +217,7 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_I
        pDest->priority = pSrc->priority;
        pDest->direction = pSrc->direction;
 
-       // Set Port Info.
+       /* Set Port Info. */
        pDest->msgPort.valid = pSrc->bPortValid;
 
        if (pDest->msgPort.valid == true) {
@@ -224,8 +226,9 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_I
        }
 
        MSG_DEBUG("nSize = %d",  pSrc->dataSize);
+       MSG_DEBUG("mainType = %d",  pSrc->mainType);
 
-       if (pSrc->mainType == MSG_SMS_TYPE){
+       if (pSrc->mainType == MSG_SMS_TYPE) {
                if (pSrc->pData != NULL) {
                        pDest->bTextSms = true;
                        pDest->dataSize = pSrc->dataSize;
@@ -233,11 +236,11 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_I
                        memset(pDest->msgText, 0x00, sizeof(pDest->msgText));
 
                        if (pSrc->dataSize > MAX_MSG_TEXT_LEN) {
-                               // Save Message Data into File
+                               /* Save Message Data into File */
                                char fileName[MSG_FILENAME_LEN_MAX+1];
                                memset(fileName, 0x00, sizeof(fileName));
 
-                               if(MsgCreateFileName(fileName) == false)
+                               if (MsgCreateFileName(fileName) == false)
                                        THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
 
                                MSG_SEC_DEBUG("Save pSrc->pData into file : size[%d] name[%s]", pDest->dataSize, fileName);
@@ -270,7 +273,7 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_I
                pDest->bTextSms = false;
                pDest->dataSize = pSrc->dataSize;
 
-               if(pSrc->subType == MSG_READREPLY_MMS) {
+               if (pSrc->subType == MSG_READREPLY_MMS) {
                        memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
 
                        if (pSrc->mmsDataSize < MAX_MSG_DATA_LEN)
@@ -279,14 +282,14 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_I
                                memcpy(pDest->msgData, pSrc->pMmsData, MAX_MSG_DATA_LEN);
 
                } else {
-                       // Save Message Data into File
+                       /* Save Message Data into File */
                        char fileName[MSG_FILENAME_LEN_MAX+1];
                        memset(fileName, 0x00, sizeof(fileName));
 
-                       if(MsgCreateFileName(fileName) == false)
+                       if (MsgCreateFileName(fileName) == false)
                                THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
 
-                       // change file extension in case of java MMS msg
+                       /* change file extension in case of java MMS msg */
                        if (pSrc->subType == MSG_SENDREQ_JAVA_MMS) {
                                char* pFileNameExt = NULL;
                                pFileNameExt = strstr(fileName,"DATA");
@@ -341,7 +344,7 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_INFO_S *pSrc, MSG_MESSAGE_HID
        pDest->direction = pSrc->direction;
        pDest->simIndex = pSrc->sim_idx;
 
-       // Set Port Info.
+       /* Set Port Info. */
        pDest->bPortValid = pSrc->msgPort.valid;
 
        if (pDest->bPortValid == true) {
@@ -349,7 +352,7 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_INFO_S *pSrc, MSG_MESSAGE_HID
                pDest->srcPort = pSrc->msgPort.srcPort;
        }
 
-       if(pSrc->thumbPath[0] != '\0')
+       if (pSrc->thumbPath[0] != '\0')
                strncpy(pDest->thumbPath, pSrc->thumbPath, MSG_FILEPATH_LEN_MAX);
 
        int maxCnt = (pSrc->nAddressCnt > 10)? MAX_TO_ADDRESS_CNT: pSrc->nAddressCnt;
@@ -400,7 +403,7 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_INFO_S *pSrc, MSG_MESSAGE_HID
 
                pDest->dataSize = pSrc->dataSize;
 
-               // Get Message Data from File
+               /* Get Message Data from File */
                if (MsgOpenAndReadFile(pSrc->msgData, &pFileData, &fileSize) == false)
                        THROW(MsgException::FILE_ERROR, "MsgOpenAndReadFile error");
 
@@ -478,21 +481,17 @@ void MsgHandle::convertSendOptStruct(const MSG_SENDINGOPT_S* pSrc, MSG_SENDINGOP
 
        if (msgType.mainType == MSG_SMS_TYPE) {
                msg_struct_s *pStruct = (msg_struct_s *)pSrc->smsSendOpt;
-               if(pStruct)
-               {
+               if (pStruct) {
                        SMS_SENDINGOPT_S *pSms = (SMS_SENDINGOPT_S *)pStruct->data;
-                       if(pSms)
-                       {
+                       if (pSms) {
                                pDest->option.smsSendOptInfo.bReplyPath = pSms->bReplyPath;
                        }
                }
        } else if (msgType.mainType == MSG_MMS_TYPE) {
                msg_struct_s *pStruct = (msg_struct_s *)pSrc->mmsSendOpt;
-               if(pStruct)
-               {
+               if (pStruct) {
                        MMS_SENDINGOPT_S *pMms = (MMS_SENDINGOPT_S *)pStruct->data;
-                       if(pMms)
-                       {
+                       if (pMms) {
                                pDest->option.mmsSendOptInfo.priority = pMms->priority;
                                pDest->option.mmsSendOptInfo.bReadReq = pMms->bReadReq;
 
@@ -559,38 +558,37 @@ int MsgHandle::getSettingCmdSize(MSG_OPTION_TYPE_T optionType)
 {
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
 
-       switch (optionType)
-       {
-               case MSG_GENERAL_OPT :
-                       cmdSize += sizeof(MSG_GENERAL_OPT_S);
-               break;
-               case MSG_SMS_SENDOPT :
-                       cmdSize += sizeof(MSG_SMS_SENDOPT_S);
-               break;
-               case MSG_SMSC_LIST :
-                       cmdSize += sizeof(MSG_SMSC_LIST_S);
-               break;
-               case MSG_MMS_SENDOPT :
-                       cmdSize += sizeof(MSG_MMS_SENDOPT_S);
-               break;
-               case MSG_MMS_RECVOPT :
-                       cmdSize += sizeof(MSG_MMS_RECVOPT_S);
-               break;
-               case MSG_MMS_STYLEOPT :
-                       cmdSize += sizeof(MSG_MMS_STYLEOPT_S);
-               break;
-               case MSG_PUSHMSG_OPT :
-                       cmdSize += sizeof(MSG_PUSHMSG_OPT_S);
-               break;
-               case MSG_CBMSG_OPT :
-                       cmdSize += sizeof(MSG_CBMSG_OPT_S);
-               break;
-               case MSG_VOICEMAIL_OPT :
-                       cmdSize += sizeof(MSG_VOICEMAIL_OPT_S);
-               break;
-               case MSG_MSGSIZE_OPT :
-                       cmdSize += sizeof(MSG_MSGSIZE_OPT_S);
-               break;
+       switch (optionType) {
+       case MSG_GENERAL_OPT:
+               cmdSize += sizeof(MSG_GENERAL_OPT_S);
+       break;
+       case MSG_SMS_SENDOPT:
+               cmdSize += sizeof(MSG_SMS_SENDOPT_S);
+       break;
+       case MSG_SMSC_LIST:
+               cmdSize += sizeof(MSG_SMSC_LIST_S);
+       break;
+       case MSG_MMS_SENDOPT:
+               cmdSize += sizeof(MSG_MMS_SENDOPT_S);
+       break;
+       case MSG_MMS_RECVOPT:
+               cmdSize += sizeof(MSG_MMS_RECVOPT_S);
+       break;
+       case MSG_MMS_STYLEOPT:
+               cmdSize += sizeof(MSG_MMS_STYLEOPT_S);
+       break;
+       case MSG_PUSHMSG_OPT:
+               cmdSize += sizeof(MSG_PUSHMSG_OPT_S);
+       break;
+       case MSG_CBMSG_OPT:
+               cmdSize += sizeof(MSG_CBMSG_OPT_S);
+       break;
+       case MSG_VOICEMAIL_OPT:
+               cmdSize += sizeof(MSG_VOICEMAIL_OPT_S);
+       break;
+       case MSG_MSGSIZE_OPT:
+               cmdSize += sizeof(MSG_MSGSIZE_OPT_S);
+       break;
        }
 
        return cmdSize;
@@ -601,17 +599,16 @@ bool MsgHandle::CheckEventData(char *pEventData)
 {
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       switch (pEvent->eventType)
-       {
-       case MSG_EVENT_PLG_SENT_STATUS_CNF :
-       case MSG_EVENT_PLG_INCOMING_MSG_IND :
-       case MSG_EVENT_PLG_INCOMING_MMS_CONF :
-       case MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND :
-       case MSG_EVENT_PLG_INCOMING_LBS_MSG_IND :
-       case MSG_EVENT_PLG_STORAGE_CHANGE_IND :
-       case MSG_EVENT_PLG_INCOMING_CB_MSG_IND :
-       case MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND :
-       case MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND :
+       switch (pEvent->eventType) {
+       case MSG_EVENT_PLG_SENT_STATUS_CNF:
+       case MSG_EVENT_PLG_INCOMING_MSG_IND:
+       case MSG_EVENT_PLG_INCOMING_MMS_CONF:
+       case MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND:
+       case MSG_EVENT_PLG_INCOMING_LBS_MSG_IND:
+       case MSG_EVENT_PLG_STORAGE_CHANGE_IND:
+       case MSG_EVENT_PLG_INCOMING_CB_MSG_IND:
+       case MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND:
+       case MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND:
                return false;
                break;
        default :
index 04917b6..d959a40 100755 (executable)
 ==================================================================================================*/
 msg_error_t MsgHandle::addFilter(const MSG_FILTER_S *pFilter)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FILTER_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_ADD_FILTER;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data*/
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFilter, sizeof(MSG_FILTER_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_ADD_FILTER)
-       {
+       if (pEvent->eventType != MSG_EVENT_ADD_FILTER) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -62,33 +61,32 @@ msg_error_t MsgHandle::addFilter(const MSG_FILTER_S *pFilter)
 
 msg_error_t MsgHandle::updateFilter(const MSG_FILTER_S *pFilter)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FILTER_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_UPDATE_FILTER;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFilter, sizeof(MSG_FILTER_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_UPDATE_FILTER)
-       {
+       if (pEvent->eventType != MSG_EVENT_UPDATE_FILTER) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -98,33 +96,32 @@ msg_error_t MsgHandle::updateFilter(const MSG_FILTER_S *pFilter)
 
 msg_error_t MsgHandle::deleteFilter(msg_filter_id_t FilterId)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_filter_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_DELETE_FILTER;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy(pCmd->cmdData, &FilterId, sizeof(msg_filter_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_DELETE_FILTER)
-       {
+       if (pEvent->eventType != MSG_EVENT_DELETE_FILTER) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -134,36 +131,35 @@ msg_error_t MsgHandle::deleteFilter(msg_filter_id_t FilterId)
 
 msg_error_t MsgHandle::getFilterList(msg_struct_list_s *pFilterList)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_FILTERLIST;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_GET_FILTERLIST)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_FILTERLIST) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
-       if(pEvent->result != MSG_SUCCESS) return pEvent->result;
+       if (pEvent->result != MSG_SUCCESS) return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeFilterList(pEvent->data, pFilterList);
 
        return MSG_SUCCESS;
@@ -174,33 +170,32 @@ msg_error_t MsgHandle::setFilterOperation(bool bSetFlag)
 {
        msg_error_t ret = MSG_SUCCESS;
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(bool);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SET_FILTER_OPERATION;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy(pCmd->cmdData, &bSetFlag, sizeof(bool));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_FILTER_OPERATION)
-       {
+       if (pEvent->eventType != MSG_EVENT_SET_FILTER_OPERATION) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -214,38 +209,36 @@ msg_error_t MsgHandle::getFilterOperation(bool *pSetFlag)
 {
        msg_error_t ret = MSG_SUCCESS;
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_FILTER_OPERATION;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_GET_FILTER_OPERATION)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_FILTER_OPERATION) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        ret = pEvent->result;
 
-       // Decode Return Data
-       if (ret == MSG_SUCCESS)
-       {
+       /* Decode Return Data */
+       if (ret == MSG_SUCCESS) {
                MsgDecodeFilterFlag(pEvent->data, pSetFlag);
                MSG_DEBUG("Flag : %d", *pSetFlag);
        }
@@ -253,36 +246,36 @@ msg_error_t MsgHandle::getFilterOperation(bool *pSetFlag)
        return ret;
 }
 
+
 msg_error_t MsgHandle::setFilterActivation(msg_filter_id_t filter_id, bool active)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_filter_id_t) + sizeof(bool);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SET_FILTER_ACTIVATION;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy(pCmd->cmdData, &filter_id, sizeof(msg_filter_id_t));
        memcpy(pCmd->cmdData+sizeof(msg_filter_id_t), &active, sizeof(bool));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_FILTER_ACTIVATION)
-       {
+       if (pEvent->eventType != MSG_EVENT_SET_FILTER_ACTIVATION) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
index 151fbb4..3984edd 100755 (executable)
@@ -23,7 +23,7 @@
 
 #define MSG_NULL_CHECK(a) \
        do { \
-               if(a == NULL) { \
+               if (a == NULL) { \
                        return MSG_ERR_NULL_POINTER; \
                } \
        } while(0)
@@ -38,23 +38,23 @@ msg_error_t MsgHandle::getSMSCOption(msg_struct_t msg_struct)
        MSG_TYPE_CHECK(smsc_opt->type, MSG_STRUCT_SETTING_SMSC_OPT);
        MSG_NULL_CHECK(smsc_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T) + sizeof(msg_sim_slot_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_SMSC_OPT;
 
-       // Set option type
+       /* Set option type */
        MSG_OPTION_TYPE_T opt_type = MSG_SMSC_LIST;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &opt_type, sizeof(MSG_OPTION_TYPE_T));
 
        msg_sim_slot_id_t simIndex = ((MSG_SMSC_LIST_HIDDEN_S *)smsc_opt->data)->simIndex;
@@ -63,17 +63,16 @@ msg_error_t MsgHandle::getSMSCOption(msg_struct_t msg_struct)
        }
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_OPTION_TYPE_T)), &simIndex, sizeof(msg_sim_slot_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_GET_SMSC_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_SMSC_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -103,13 +102,14 @@ msg_error_t MsgHandle::getSMSCOption(msg_struct_t msg_struct)
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::setSMSCOption(msg_struct_t msg_struct)
 {
        msg_struct_s *smsc_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(smsc_opt->type, MSG_STRUCT_SETTING_SMSC_OPT);
        MSG_NULL_CHECK(smsc_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        MSG_OPTION_TYPE_T optionType = MSG_SMSC_LIST;
        int cmdSize = getSettingCmdSize(optionType);
 
@@ -143,76 +143,75 @@ msg_error_t MsgHandle::setSMSCOption(msg_struct_t msg_struct)
                memcpy(&(smsc_list_tmp.smscData[i]), pStructTmp->data, sizeof(MSG_SMSC_DATA_S));
        }
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SET_SMSC_OPT;
 
-    // Copy Cookie
-    memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+       /* Copy Cookie */
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
        MSG_SETTING_S pSetting = {0,};
 
        pSetting.type = optionType;
        memcpy(&(pSetting.option.smscList), &smsc_list_tmp, sizeof(MSG_SMSC_LIST_S));
 
-    // Copy Command Data
-    memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
+       /* Copy Command Data */
+       memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_SMSC_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_SET_SMSC_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::getCBOption(msg_struct_t msg_struct)
 {
        msg_struct_s *cb_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(cb_opt->type, MSG_STRUCT_SETTING_CB_OPT);
        MSG_NULL_CHECK(cb_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T) + sizeof(msg_sim_slot_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_CB_OPT;
 
-       // Set option type
+       /* Set option type */
        MSG_OPTION_TYPE_T opt_type = MSG_CBMSG_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &opt_type, sizeof(MSG_OPTION_TYPE_T));
 
        msg_sim_slot_id_t simIndex = ((MSG_CBMSG_OPT_HIDDEN_S*)cb_opt->data)->simIndex;
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_OPTION_TYPE_T)), &simIndex, sizeof(msg_sim_slot_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_GET_CB_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_CB_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -243,13 +242,14 @@ msg_error_t MsgHandle::getCBOption(msg_struct_t msg_struct)
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::setCBOption(msg_struct_t msg_struct)
 {
        msg_struct_s *cb_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(cb_opt->type, MSG_STRUCT_SETTING_CB_OPT);
        MSG_NULL_CHECK(cb_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        MSG_OPTION_TYPE_T optionType = MSG_CBMSG_OPT;
        int cmdSize = getSettingCmdSize(optionType);
 
@@ -258,13 +258,13 @@ msg_error_t MsgHandle::setCBOption(msg_struct_t msg_struct)
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
        int i = 0;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SET_CB_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        MSG_CBMSG_OPT_S cb_opt_tmp = {0,};
        MSG_CBMSG_OPT_HIDDEN_S *cb_msg_opt = (MSG_CBMSG_OPT_HIDDEN_S *)cb_opt->data;
 
@@ -289,62 +289,61 @@ msg_error_t MsgHandle::setCBOption(msg_struct_t msg_struct)
 
        memcpy(&(pSetting.option.cbMsgOpt), &cb_opt_tmp, sizeof(MSG_CBMSG_OPT_S));
 
-    // Copy Command Data
-    memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
+       /* Copy Command Data */
+       memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_CB_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_SET_CB_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::getSmsSendOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *sms_send_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(sms_send_opt->type, MSG_STRUCT_SETTING_SMS_SEND_OPT);
        MSG_NULL_CHECK(sms_send_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_SMS_SEND_OPT;
 
-       // Set option type
+       /* Set option type */
        MSG_OPTION_TYPE_T opt_type = MSG_SMS_SENDOPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &opt_type, sizeof(MSG_OPTION_TYPE_T));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_GET_SMS_SEND_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_SMS_SEND_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -355,13 +354,14 @@ msg_error_t MsgHandle::getSmsSendOpt(msg_struct_t msg_struct)
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::setSmsSendOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *sms_send_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(sms_send_opt->type, MSG_STRUCT_SETTING_SMS_SEND_OPT);
        MSG_NULL_CHECK(sms_send_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        MSG_OPTION_TYPE_T optionType = MSG_SMS_SENDOPT;
        int cmdSize = getSettingCmdSize(optionType);
 
@@ -369,74 +369,73 @@ msg_error_t MsgHandle::setSmsSendOpt(msg_struct_t msg_struct)
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SET_SMS_SEND_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        MSG_SETTING_S pSetting = {0,};
        pSetting.type = optionType;
 
        memcpy(&(pSetting.option.smsSendOpt), sms_send_opt->data, sizeof(MSG_SMS_SENDOPT_S));
 
-    // Copy Command Data
-    memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
+       /*py Command Data */
+       memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_SMS_SEND_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_SET_SMS_SEND_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::getMmsSendOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *mms_send_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(mms_send_opt->type, MSG_STRUCT_SETTING_MMS_SEND_OPT);
        MSG_NULL_CHECK(mms_send_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_MMS_SEND_OPT;
 
-       // Set option type
+       /* Set option type */
        MSG_OPTION_TYPE_T opt_type = MSG_MMS_SENDOPT;
 
-       // Copy Cookie
+       /* Copy Cookie*/
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &opt_type, sizeof(MSG_OPTION_TYPE_T));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_GET_MMS_SEND_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_MMS_SEND_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -447,13 +446,14 @@ msg_error_t MsgHandle::getMmsSendOpt(msg_struct_t msg_struct)
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::setMmsSendOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *mms_send_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(mms_send_opt->type, MSG_STRUCT_SETTING_MMS_SEND_OPT);
        MSG_NULL_CHECK(mms_send_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        MSG_OPTION_TYPE_T optionType = MSG_MMS_SENDOPT;
        int cmdSize = getSettingCmdSize(optionType);
 
@@ -461,74 +461,73 @@ msg_error_t MsgHandle::setMmsSendOpt(msg_struct_t msg_struct)
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SET_MMS_SEND_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        MSG_SETTING_S pSetting = {0,};
        pSetting.type = optionType;
 
        memcpy(&(pSetting.option.mmsSendOpt), mms_send_opt->data, sizeof(MSG_MMS_SENDOPT_S));
 
-    // Copy Command Data
-    memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
+       /* Copy Command Data */
+       memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_MMS_SEND_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_SET_MMS_SEND_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::getMmsRecvOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *mms_recv_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(mms_recv_opt->type, MSG_STRUCT_SETTING_MMS_RECV_OPT);
        MSG_NULL_CHECK(mms_recv_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_MMS_RECV_OPT;
 
-       // Set option type
+       /* Set option type */
        MSG_OPTION_TYPE_T opt_type = MSG_MMS_RECVOPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &opt_type, sizeof(MSG_OPTION_TYPE_T));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_GET_MMS_RECV_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_MMS_RECV_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -539,13 +538,14 @@ msg_error_t MsgHandle::getMmsRecvOpt(msg_struct_t msg_struct)
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::setMmsRecvOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *mms_recv_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(mms_recv_opt->type, MSG_STRUCT_SETTING_MMS_RECV_OPT);
        MSG_NULL_CHECK(mms_recv_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        MSG_OPTION_TYPE_T optionType = MSG_MMS_RECVOPT;
        int cmdSize = getSettingCmdSize(optionType);
 
@@ -553,74 +553,73 @@ msg_error_t MsgHandle::setMmsRecvOpt(msg_struct_t msg_struct)
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SET_MMS_RECV_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        MSG_SETTING_S pSetting = {0,};
        pSetting.type = optionType;
 
        memcpy(&(pSetting.option.mmsRecvOpt), mms_recv_opt->data, sizeof(MSG_MMS_RECVOPT_S));
 
-    // Copy Command Data
-    memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
+       /* Copy Command Data */
+       memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_MMS_RECV_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_SET_MMS_RECV_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::getPushMsgOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *push_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(push_opt->type, MSG_STRUCT_SETTING_PUSH_MSG_OPT);
        MSG_NULL_CHECK(push_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_PUSH_MSG_OPT;
 
-       // Set option type
+       /* Set option type */
        MSG_OPTION_TYPE_T opt_type = MSG_PUSHMSG_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &opt_type, sizeof(MSG_OPTION_TYPE_T));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_GET_PUSH_MSG_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_PUSH_MSG_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -631,13 +630,14 @@ msg_error_t MsgHandle::getPushMsgOpt(msg_struct_t msg_struct)
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::setPushMsgOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *push_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(push_opt->type, MSG_STRUCT_SETTING_PUSH_MSG_OPT);
        MSG_NULL_CHECK(push_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        MSG_OPTION_TYPE_T optionType = MSG_PUSHMSG_OPT;
        int cmdSize = getSettingCmdSize(optionType);
 
@@ -645,61 +645,61 @@ msg_error_t MsgHandle::setPushMsgOpt(msg_struct_t msg_struct)
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SET_PUSH_MSG_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        MSG_SETTING_S pSetting = {0,};
        pSetting.type = optionType;
 
        memcpy(&(pSetting.option.pushMsgOpt), push_opt->data, sizeof(MSG_PUSHMSG_OPT_S));
 
-    // Copy Command Data
-    memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
+       /* Copy Command Data */
+       memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_PUSH_MSG_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_SET_PUSH_MSG_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::getVoiceMsgOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *voice_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(voice_opt->type, MSG_STRUCT_SETTING_VOICE_MSG_OPT);
        MSG_NULL_CHECK(voice_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T) + sizeof(msg_sim_slot_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_VOICE_MSG_OPT;
 
-       // Set option type
+       /* Set option type */
        MSG_OPTION_TYPE_T opt_type = MSG_VOICEMAIL_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &opt_type, sizeof(MSG_OPTION_TYPE_T));
 
        msg_sim_slot_id_t simIndex = ((MSG_VOICEMAIL_OPT_S *)voice_opt->data)->simIndex;
@@ -708,17 +708,16 @@ msg_error_t MsgHandle::getVoiceMsgOpt(msg_struct_t msg_struct)
        }
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_OPTION_TYPE_T)), &simIndex, sizeof(msg_sim_slot_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_GET_VOICE_MSG_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_VOICE_MSG_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -729,13 +728,14 @@ msg_error_t MsgHandle::getVoiceMsgOpt(msg_struct_t msg_struct)
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::setVoiceMsgOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *voice_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(voice_opt->type, MSG_STRUCT_SETTING_VOICE_MSG_OPT);
        MSG_NULL_CHECK(voice_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        MSG_OPTION_TYPE_T optionType = MSG_VOICEMAIL_OPT;
        int cmdSize = getSettingCmdSize(optionType);
 
@@ -743,74 +743,73 @@ msg_error_t MsgHandle::setVoiceMsgOpt(msg_struct_t msg_struct)
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SET_VOICE_MSG_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        MSG_SETTING_S pSetting = {0,};
        pSetting.type = optionType;
 
        memcpy(&(pSetting.option.voiceMailOpt), voice_opt->data, sizeof(MSG_VOICEMAIL_OPT_S));
 
-    // Copy Command Data
-    memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
+       /* Copy Command Data */
+       memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_VOICE_MSG_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_SET_VOICE_MSG_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::getGeneralOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *general_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(general_opt->type, MSG_STRUCT_SETTING_GENERAL_OPT);
        MSG_NULL_CHECK(general_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_GENERAL_MSG_OPT;
 
-       // Set option type
+       /* Set option type */
        MSG_OPTION_TYPE_T opt_type = MSG_GENERAL_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &opt_type, sizeof(MSG_OPTION_TYPE_T));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_GET_GENERAL_MSG_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_GENERAL_MSG_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -821,13 +820,14 @@ msg_error_t MsgHandle::getGeneralOpt(msg_struct_t msg_struct)
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::setGeneralOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *general_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(general_opt->type, MSG_STRUCT_SETTING_GENERAL_OPT);
        MSG_NULL_CHECK(general_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        MSG_OPTION_TYPE_T optionType = MSG_GENERAL_OPT;
        int cmdSize = getSettingCmdSize(optionType);
 
@@ -835,74 +835,73 @@ msg_error_t MsgHandle::setGeneralOpt(msg_struct_t msg_struct)
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SET_GENERAL_MSG_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        MSG_SETTING_S pSetting = {0,};
        pSetting.type = optionType;
 
        memcpy(&(pSetting.option.generalOpt), general_opt->data, sizeof(MSG_GENERAL_OPT_S));
 
-    // Copy Command Data
-    memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
+       /* Copy Command Data */
+       memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_GENERAL_MSG_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_SET_GENERAL_MSG_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::getMsgSizeOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *msg_size_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(msg_size_opt->type, MSG_STRUCT_SETTING_MSGSIZE_OPT);
        MSG_NULL_CHECK(msg_size_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_MSG_SIZE_OPT;
 
-       // Set option type
+       /* Set option type */
        MSG_OPTION_TYPE_T opt_type = MSG_MSGSIZE_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &opt_type, sizeof(MSG_OPTION_TYPE_T));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_GET_MSG_SIZE_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_MSG_SIZE_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -913,13 +912,14 @@ msg_error_t MsgHandle::getMsgSizeOpt(msg_struct_t msg_struct)
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::setMsgSizeOpt(msg_struct_t msg_struct)
 {
        msg_struct_s *msg_size_opt = (msg_struct_s *)msg_struct;
        MSG_TYPE_CHECK(msg_size_opt->type, MSG_STRUCT_SETTING_MSGSIZE_OPT);
        MSG_NULL_CHECK(msg_size_opt->data);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        MSG_OPTION_TYPE_T optionType = MSG_MSGSIZE_OPT;
        int cmdSize = getSettingCmdSize(optionType);
 
@@ -927,32 +927,31 @@ msg_error_t MsgHandle::setMsgSizeOpt(msg_struct_t msg_struct)
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SET_MSG_SIZE_OPT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        MSG_SETTING_S pSetting = {0,};
        pSetting.type = optionType;
 
        memcpy(&(pSetting.option.msgSizeOpt), msg_size_opt->data, sizeof(MSG_MSGSIZE_OPT_S));
 
-    // Copy Command Data
-    memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
+       /* Copy Command Data */
+       memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_MSG_SIZE_OPT)
-       {
+       if (pEvent->eventType != MSG_EVENT_SET_MSG_SIZE_OPT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
index 8fa5659..29b6c5d 100755 (executable)
@@ -34,10 +34,10 @@ int MsgHandle::addMessage(MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pS
        msgInfo.addressList = NULL;
        unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
 
-       // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
+       /* Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S */
        convertMsgStruct(pMsg, &msgInfo);
 
-       // Covert MSG_SENDINGOPT_S to MSG_SENDINGOPT_INFO_S
+       /* Covert MSG_SENDINGOPT_S to MSG_SENDINGOPT_INFO_S */
        MSG_MESSAGE_TYPE_S msgType = {0,};
 
        msgType.mainType = pMsg->mainType;
@@ -46,7 +46,7 @@ int MsgHandle::addMessage(MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pS
 
        convertSendOptStruct(pSendOpt, &sendOptInfo, msgType);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        char* encodedData = NULL;
        unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
        int dataSize = MsgEncodeMsgInfo(&msgInfo, &sendOptInfo, &encodedData);
@@ -57,29 +57,28 @@ int MsgHandle::addMessage(MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pS
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_ADD_MSG;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), encodedData, dataSize);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_ADD_MSG)
-       {
+       if (pEvent->eventType != MSG_EVENT_ADD_MSG) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -88,7 +87,7 @@ int MsgHandle::addMessage(MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pS
 
        msg_message_id_t msgId = 0;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeMsgId(pEvent->data, &msgId);
 
        return (int)msgId;
@@ -103,11 +102,11 @@ msg_error_t MsgHandle::addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg)
        msgInfo.addressList = NULL;
        unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
 
-       // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
+       /* Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S */
        msg_struct_s *msg = (msg_struct_s *)pSyncMLMsg->msg;
        convertMsgStruct((MSG_MESSAGE_HIDDEN_S *)msg->data, &msgInfo);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        char* encodedData = NULL;
        unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
        int dataSize = MsgEncodeMsgInfo(&msgInfo, &encodedData);
@@ -118,38 +117,37 @@ msg_error_t MsgHandle::addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg)
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_ADD_SYNCML_MSG;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &pSyncMLMsg->extId, sizeof(int));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), &pSyncMLMsg->pinCode, sizeof(int));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+sizeof(int)), encodedData, dataSize);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_ADD_SYNCML_MSG)
-       {
+       if (pEvent->eventType != MSG_EVENT_ADD_SYNCML_MSG) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        msg_message_id_t msgId = 0;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeMsgId(pEvent->data, &msgId);
 
        ((MSG_MESSAGE_HIDDEN_S *)msg->data)->msgId = msgId;
@@ -166,7 +164,7 @@ msg_error_t MsgHandle::updateMessage(const MSG_MESSAGE_HIDDEN_S *pMsg, const MSG
        msgInfo.addressList = NULL;
        unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
 
-       // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
+       /* Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S */
        convertMsgStruct(pMsg, &msgInfo);
 
        if (pSendOpt != NULL) {
@@ -179,7 +177,7 @@ msg_error_t MsgHandle::updateMessage(const MSG_MESSAGE_HIDDEN_S *pMsg, const MSG
                convertSendOptStruct(pSendOpt, &sendOptInfo, msgType);
        }
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        char* encodedData = NULL;
        unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
        int dataSize = MsgEncodeMsgInfo(&msgInfo, &sendOptInfo, &encodedData);
@@ -190,29 +188,28 @@ msg_error_t MsgHandle::updateMessage(const MSG_MESSAGE_HIDDEN_S *pMsg, const MSG
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_UPDATE_MSG;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), encodedData, dataSize);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_UPDATE_MSG)
-       {
+       if (pEvent->eventType != MSG_EVENT_UPDATE_MSG) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -222,37 +219,36 @@ msg_error_t MsgHandle::updateMessage(const MSG_MESSAGE_HIDDEN_S *pMsg, const MSG
 
 msg_error_t MsgHandle::updateReadStatus(msg_message_id_t MsgId, bool bRead)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t) + sizeof(bool);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_UPDATE_READ;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), &bRead, sizeof(bool));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_UPDATE_READ)
-       {
+       if (pEvent->eventType != MSG_EVENT_UPDATE_READ) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -262,36 +258,35 @@ msg_error_t MsgHandle::updateReadStatus(msg_message_id_t MsgId, bool bRead)
 
 msg_error_t MsgHandle::setConversationToRead(msg_thread_id_t ThreadId)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_thread_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_UPDATE_THREAD_READ;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &ThreadId, sizeof(msg_thread_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_UPDATE_THREAD_READ)
-       {
+       if (pEvent->eventType != MSG_EVENT_UPDATE_THREAD_READ) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -301,37 +296,36 @@ msg_error_t MsgHandle::setConversationToRead(msg_thread_id_t ThreadId)
 
 msg_error_t MsgHandle::updateProtectedStatus(msg_message_id_t MsgId, bool bProtected)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t) + sizeof(bool);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_UPDATE_PROTECTED;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), &bProtected, sizeof(bool));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_UPDATE_PROTECTED)
-       {
+       if (pEvent->eventType != MSG_EVENT_UPDATE_PROTECTED) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -341,36 +335,35 @@ msg_error_t MsgHandle::updateProtectedStatus(msg_message_id_t MsgId, bool bProte
 
 msg_error_t MsgHandle::deleteMessage(msg_message_id_t MsgId)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_DELETE_MSG;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy((void*)pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_DELETE_MSG)
-       {
+       if (pEvent->eventType != MSG_EVENT_DELETE_MSG) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -380,37 +373,36 @@ msg_error_t MsgHandle::deleteMessage(msg_message_id_t MsgId)
 
 msg_error_t MsgHandle::deleteAllMessagesInFolder(msg_folder_id_t FolderId, bool bOnlyDB)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_folder_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_DELALL_MSGINFOLDER;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(msg_folder_id_t));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_folder_id_t)), &bOnlyDB, sizeof(bool));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_DELALL_MSGINFOLDER)
-       {
+       if (pEvent->eventType != MSG_EVENT_DELALL_MSGINFOLDER) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -420,32 +412,32 @@ msg_error_t MsgHandle::deleteAllMessagesInFolder(msg_folder_id_t FolderId, bool
 
 msg_error_t MsgHandle::deleteMessagesByList(msg_id_list_s *pMsgIdList)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + (sizeof(int)*pMsgIdList->nCount);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_DELETE_MESSAGE_BY_LIST;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &(pMsgIdList->nCount), sizeof(int));
        for (int i=0; i<pMsgIdList->nCount; i++) {
                memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)+(sizeof(int)*i)), &(pMsgIdList->msgIdList[i]), sizeof(int));
        }
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
@@ -461,37 +453,36 @@ msg_error_t MsgHandle::deleteMessagesByList(msg_id_list_s *pMsgIdList)
 
 msg_error_t MsgHandle::moveMessageToFolder(msg_message_id_t MsgId, msg_folder_id_t DestFolderId)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t) + sizeof(msg_folder_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_MOVE_MSGTOFOLDER;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+sizeof(msg_message_id_t)+MAX_COOKIE_LEN), &DestFolderId, sizeof(msg_folder_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOFOLDER)
-       {
+       if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOFOLDER) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -501,37 +492,36 @@ msg_error_t MsgHandle::moveMessageToFolder(msg_message_id_t MsgId, msg_folder_id
 
 msg_error_t MsgHandle::moveMessageToStorage(msg_message_id_t MsgId, msg_storage_id_t DestStorageId)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t) + sizeof(msg_storage_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_MOVE_MSGTOSTORAGE;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_id_t)), &DestStorageId, sizeof(msg_storage_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOSTORAGE)
-       {
+       if (pEvent->eventType != MSG_EVENT_MOVE_MSGTOSTORAGE) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -541,43 +531,42 @@ msg_error_t MsgHandle::moveMessageToStorage(msg_message_id_t MsgId, msg_storage_
 
 msg_error_t MsgHandle::countMessage(msg_folder_id_t FolderId, MSG_COUNT_INFO_S *pCountInfo)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_folder_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_COUNT_MSG;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(msg_folder_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_COUNT_MSG)
-       {
+       if (pEvent->eventType != MSG_EVENT_COUNT_MSG) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeCountInfo(pEvent->data, pCountInfo);
 
        return MSG_SUCCESS;
@@ -586,43 +575,42 @@ msg_error_t MsgHandle::countMessage(msg_folder_id_t FolderId, MSG_COUNT_INFO_S *
 
 msg_error_t MsgHandle::countMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *pMsgCount)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_TYPE_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_COUNT_BY_MSGTYPE;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsgType, sizeof(MSG_MESSAGE_TYPE_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_COUNT_BY_MSGTYPE)
-       {
+       if (pEvent->eventType != MSG_EVENT_COUNT_BY_MSGTYPE) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        memcpy(pMsgCount, (void*)((char*)pEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(int));
 
        return MSG_SUCCESS;
@@ -631,45 +619,44 @@ msg_error_t MsgHandle::countMsgByType(const MSG_MESSAGE_TYPE_S *pMsgType, int *p
 
 msg_error_t MsgHandle::countMsgByContact(const MSG_THREAD_LIST_INDEX_INFO_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) +  sizeof(MSG_THREAD_LIST_INDEX_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_CONTACT_COUNT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pAddrInfo, sizeof(msg_contact_id_t));
        msg_struct_s *pAddr = (msg_struct_s *)pAddrInfo->msgAddrInfo;
 
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN + sizeof(msg_contact_id_t)), pAddr->data, sizeof(MSG_ADDRESS_INFO_S));
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_GET_CONTACT_COUNT)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_CONTACT_COUNT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeContactCount(pEvent->data, pMsgThreadCountList);
 
        return MSG_SUCCESS;
@@ -678,30 +665,30 @@ msg_error_t MsgHandle::countMsgByContact(const MSG_THREAD_LIST_INDEX_INFO_S *pAd
 
 msg_error_t MsgHandle::getMessage(msg_message_id_t MsgId, MSG_MESSAGE_HIDDEN_S *pMsg, MSG_SENDINGOPT_S *pSendOpt)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_MSG;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
@@ -714,7 +701,7 @@ msg_error_t MsgHandle::getMessage(msg_message_id_t MsgId, MSG_MESSAGE_HIDDEN_S *
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MSG_MESSAGE_INFO_S msgInfo;
        MSG_SENDINGOPT_INFO_S sendOptInfo;
 
@@ -723,7 +710,7 @@ msg_error_t MsgHandle::getMessage(msg_message_id_t MsgId, MSG_MESSAGE_HIDDEN_S *
 
        MsgDecodeMsgInfo(pEvent->data, &msgInfo, &sendOptInfo);
 
-       // Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_HIDDEN_S
+       /* Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_HIDDEN_S */
        convertMsgStruct(&msgInfo, pMsg);
 
        if (pSendOpt != NULL) {
@@ -736,11 +723,10 @@ msg_error_t MsgHandle::getMessage(msg_message_id_t MsgId, MSG_MESSAGE_HIDDEN_S *
                convertSendOptStruct(&sendOptInfo, pSendOpt, msgType);
        }
 
-       // Delete Temp File
-       if (msgInfo.bTextSms == false)
-       {
-               // Delete Temp File
-               MsgDeleteFile(msgInfo.msgData); //ipc
+       /* Delete Temp File */
+       if (msgInfo.bTextSms == false) {
+               /* Delete Temp File */
+               MsgDeleteFile(msgInfo.msgData); /* ipc */
        }
 
        return MSG_SUCCESS;
@@ -749,36 +735,35 @@ msg_error_t MsgHandle::getMessage(msg_message_id_t MsgId, MSG_MESSAGE_HIDDEN_S *
 
 msg_error_t MsgHandle::addFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_INFO_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_ADD_FOLDER;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFolderInfo, sizeof(MSG_FOLDER_INFO_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_ADD_FOLDER)
-       {
+       if (pEvent->eventType != MSG_EVENT_ADD_FOLDER) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -788,36 +773,35 @@ msg_error_t MsgHandle::addFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
 
 msg_error_t MsgHandle::updateFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_FOLDER_INFO_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_UPDATE_FOLDER;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pFolderInfo, sizeof(MSG_FOLDER_INFO_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_UPDATE_FOLDER)
-       {
+       if (pEvent->eventType != MSG_EVENT_UPDATE_FOLDER) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -827,36 +811,35 @@ msg_error_t MsgHandle::updateFolder(const MSG_FOLDER_INFO_S *pFolderInfo)
 
 msg_error_t MsgHandle::deleteFolder(msg_folder_id_t FolderId)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_folder_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_DELETE_FOLDER;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &FolderId, sizeof(msg_folder_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_DELETE_FOLDER)
-       {
+       if (pEvent->eventType != MSG_EVENT_DELETE_FOLDER) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -866,40 +849,39 @@ msg_error_t MsgHandle::deleteFolder(msg_folder_id_t FolderId)
 
 msg_error_t MsgHandle::getFolderList(msg_struct_list_s *pFolderList)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_FOLDERLIST;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_GET_FOLDERLIST)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_FOLDERLIST) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeFolderList(pEvent->data, pFolderList);
 
        return MSG_SUCCESS;
@@ -909,60 +891,58 @@ msg_error_t MsgHandle::getFolderList(msg_struct_list_s *pFolderList)
 msg_error_t MsgHandle::getThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList)
 {
        msg_error_t err = MSG_SUCCESS;
+       /*
+       err = MsgStoConnectDB();
 
-//     err = MsgStoConnectDB();
-//
-//     if (err != MSG_SUCCESS)
-//     {
-//             MSG_DEBUG("MsgStoConnectDB() Error!!");
-//             return err;
-//     }
+       if (err != MSG_SUCCESS) {
+               MSG_DEBUG("MsgStoConnectDB() Error!!");
+               return err;
+       }
+       */
 
        err = MsgStoGetThreadViewList(pSortRule, pThreadViewList);
 
-       if (err != MSG_SUCCESS)
-       {
+       if (err != MSG_SUCCESS) {
                MSG_DEBUG("MsgStoGetThreadViewList() Error!!");
                return err;
        }
 
-//     MsgStoDisconnectDB();
+       /* MsgStoDisconnectDB(); */
 
 #if 0
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_SORT_RULE_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_THREADVIEWLIST;
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)), pSortRule, sizeof(MSG_SORT_RULE_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_GET_THREADVIEWLIST)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_THREADVIEWLIST) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeThreadViewList(pEvent->data, pMsgThreadViewList);
 #endif
 
@@ -975,9 +955,9 @@ msg_error_t MsgHandle::getConversationViewItem(msg_message_id_t MsgId, MSG_CONVE
 
        msg_error_t err = MSG_SUCCESS;
 
-//     MsgStoConnectDB();
+       /* MsgStoConnectDB(); */
        err = MsgStoGetConversationViewItem(MsgId, pConv);
-//     MsgStoDisconnectDB();
+       /* MsgStoDisconnectDB(); */
 
        return err;
 }
@@ -988,9 +968,9 @@ msg_error_t MsgHandle::getConversationViewList(msg_thread_id_t ThreadId, msg_str
 
        msg_error_t err = MSG_SUCCESS;
 
-//     MsgStoConnectDB();
+       /* MsgStoConnectDB(); */
        err = MsgStoGetConversationViewList(ThreadId, pConvViewList);
-//     MsgStoDisconnectDB();
+       /* MsgStoDisconnectDB(); */
 
        if (err != MSG_SUCCESS)
                return err;
@@ -1003,37 +983,36 @@ msg_error_t MsgHandle::getConversationViewList(msg_thread_id_t ThreadId, msg_str
 
 msg_error_t MsgHandle::deleteThreadMessageList(msg_thread_id_t ThreadId, bool include_protected_msg)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_thread_id_t) + sizeof(bool);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_DELETE_THREADMESSAGELIST;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &ThreadId, sizeof(msg_thread_id_t));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_thread_id_t)), &include_protected_msg, sizeof(bool));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_DELETE_THREADMESSAGELIST)
-       {
+       if (pEvent->eventType != MSG_EVENT_DELETE_THREADMESSAGELIST) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -1046,43 +1025,42 @@ msg_error_t MsgHandle::deleteThreadMessageList(msg_thread_id_t ThreadId, bool in
 
 msg_error_t MsgHandle::getQuickPanelData(msg_quickpanel_type_t Type, MSG_MESSAGE_HIDDEN_S *pMsg)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_quickpanel_type_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_QUICKPANEL_DATA;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &Type, sizeof(msg_quickpanel_type_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_GET_QUICKPANEL_DATA)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_QUICKPANEL_DATA) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MSG_MESSAGE_INFO_S msgInfo;
 
        memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
@@ -1092,14 +1070,13 @@ msg_error_t MsgHandle::getQuickPanelData(msg_quickpanel_type_t Type, MSG_MESSAGE
 
        MsgDecodeMsgInfo((char *)pEvent->data, &msgInfo);
 
-       // Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_S
+       /* Covert MSG_MESSAGE_INFO_S to MSG_MESSAGE_S */
        convertMsgStruct(&msgInfo, pMsg);
 
-       // Delete Temp File
-       if (msgInfo.bTextSms == false)
-       {
-               // Delete Temp File
-               MsgDeleteFile(msgInfo.msgData); //ipc
+       /* Delete Temp File */
+       if (msgInfo.bTextSms == false) {
+               /* Delete Temp File */
+               MsgDeleteFile(msgInfo.msgData); /* ipc */
        }
 
        return MSG_SUCCESS;
@@ -1108,33 +1085,32 @@ msg_error_t MsgHandle::getQuickPanelData(msg_quickpanel_type_t Type, MSG_MESSAGE
 
 msg_error_t MsgHandle::resetDatabase()
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_RESET_DB;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_RESET_DB)
-       {
+       if (pEvent->eventType != MSG_EVENT_RESET_DB) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -1144,53 +1120,53 @@ msg_error_t MsgHandle::resetDatabase()
 
 msg_error_t MsgHandle::getMemSize(unsigned int* memsize)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_MEMSIZE;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_GET_MEMSIZE)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_MEMSIZE) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeMemSize(pEvent->data, memsize);
 
        return MSG_SUCCESS;
 }
 
+
 msg_error_t MsgHandle::backupMessage(msg_message_backup_type_t type, const char *backup_filepath)
 {
        if (backup_filepath == NULL)
                return MSG_ERR_NULL_POINTER;
 
-       //Create an empty file for writing.
-       //If a file with the same name already exists its content is erased
-       //and the file is treated as a new empty file.
+       /* Create an empty file for writing. */
+       /* If a file with the same name already exists its content is erased */
+       /* and the file is treated as a new empty file. */
 
        FILE *pFile = MsgOpenFile(backup_filepath, "w");
        if (pFile == NULL) {
@@ -1202,41 +1178,41 @@ msg_error_t MsgHandle::backupMessage(msg_message_backup_type_t type, const char
        char path[MSG_FILEPATH_LEN_MAX+1] = {0,};
        strncpy(path, backup_filepath, MSG_FILEPATH_LEN_MAX);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_backup_type_t) + sizeof(path);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_BACKUP_MESSAGE;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &type, sizeof(msg_message_backup_type_t));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_message_backup_type_t)), (char *)path, sizeof(path));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_BACKUP_MESSAGE)
-       {
+       if (pEvent->eventType != MSG_EVENT_BACKUP_MESSAGE) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::restoreMessage(const char *backup_filepath)
 {
        if (backup_filepath == NULL)
@@ -1250,34 +1226,33 @@ msg_error_t MsgHandle::restoreMessage(const char *backup_filepath)
        char path[MSG_FILEPATH_LEN_MAX+1] = {0,};
        strncpy(path, backup_filepath, MSG_FILEPATH_LEN_MAX);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(path);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_RESTORE_MESSAGE;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), (char *)path, sizeof(path));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_RESTORE_MESSAGE)
-       {
+       if (pEvent->eventType != MSG_EVENT_RESTORE_MESSAGE) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -1289,23 +1264,53 @@ msg_error_t MsgHandle::searchMessage(const char *pSearchString, msg_struct_list_
 {
        msg_error_t err = MSG_SUCCESS;
 
-//     err = MsgStoConnectDB();
-//
-//     if (err != MSG_SUCCESS)
-//     {
-//             MSG_DEBUG("MsgStoConnectDB() Error!!");
-//             return err;
-//     }
+       int count = 0;
 
-       err = MsgStoSearchMessage(pSearchString, pThreadViewList);
+       int search_len = strlen(pSearchString);
 
-       if (err != MSG_SUCCESS)
-       {
+       /* Allocate Memory to Command Data */
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + sizeof(char) * search_len;
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+       /* Set Command Parameters */
+       pCmd->cmdType = MSG_CMD_SET_TEMP_ADDRESS_TABLE;
+
+       /* Copy Cookie */
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       /* Copy Command Data */
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &search_len, sizeof(int));
+       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), pSearchString, sizeof(char) * search_len);
+
+       /* Send Command to Messaging FW */
+       char* pEventData = NULL;
+       unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       /* Get Return Data */
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       if (pEvent == NULL)
+               THROW(MsgException::INVALID_RESULT, "Event is NULL");
+
+       if (pEvent->eventType != MSG_EVENT_SET_TEMP_ADDRESS_TABLE) {
+               THROW(MsgException::INVALID_RESULT, "Event Data Error");
+       }
+
+       memcpy(&count, pEvent->data, sizeof(int));
+
+       err = MsgStoSearchMessage(pSearchString, pThreadViewList, count);
+
+       if (err != MSG_SUCCESS) {
                MSG_DEBUG("MsgStoSearchMessage() Error!!");
                return err;
        }
 
-//     MsgStoDisconnectDB();
+/*     MsgStoDisconnectDB(); */
 
        return err;
 }
@@ -1314,24 +1319,22 @@ msg_error_t MsgHandle::searchMessage(const char *pSearchString, msg_struct_list_
 msg_error_t MsgHandle::getRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList)
 {
        msg_error_t err = MSG_SUCCESS;
+       /*
+       err = MsgStoConnectDB();
 
-//     err = MsgStoConnectDB();
-//
-//     if (err != MSG_SUCCESS)
-//     {
-//             MSG_DEBUG("MsgStoConnectDB() Error!!");
-//             return err;
-//     }
-
+       if (err != MSG_SUCCESS) {
+               MSG_DEBUG("MsgStoConnectDB() Error!!");
+               return err;
+       }
+       */
        err = MsgStoGetRejectMsgList(pNumber, pRejectMsgList);
 
-       if (err != MSG_SUCCESS)
-       {
+       if (err != MSG_SUCCESS) {
                MSG_DEBUG("MsgStoGetRejectMsgList() Error!!");
                return err;
        }
 
-//     MsgStoDisconnectDB();
+       /* MsgStoDisconnectDB(); */
 
        return err;
 }
@@ -1346,24 +1349,24 @@ msg_error_t MsgHandle::regStorageChangeCallback(msg_storage_change_cb onStorageC
 
        eventListener->start(this);
 
-       int remoteFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       int remoteFd = eventListener->getRemoteFd(); /* fd that is reserved to the "listener thread" by msgfw daemon */
 
        if (remoteFd == -1 )
                return MSG_ERR_INVALID_MSGHANDLE;
 
-       if (eventListener->regStorageChangeEventCB(this, onStorageChange, pUserParam) == false)
+       if (eventListener->regStorageChangeEventCB(this, remoteFd, onStorageChange, pUserParam) == false)
                return MSG_ERR_INVALID_PARAMETER;
 
-       // Allocate Memory to Command Data
-       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); // cmd type, listenerFd
+       /* Allocate Memory to Command Data */
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); /* cmd type, listenerFd */
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_REG_STORAGE_CHANGE_CB;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
        MSG_DEBUG("remote fd %d", remoteFd);
@@ -1372,29 +1375,29 @@ msg_error_t MsgHandle::regStorageChangeCallback(msg_storage_change_cb onStorageC
 
        MSG_DEBUG("reg status [%d : %s], %d", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType), remoteFd);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_REG_STORAGE_CHANGE_CB)
-       {
+       if (pEvent->eventType != MSG_EVENT_REG_STORAGE_CHANGE_CB) {
                THROW(MsgException::INVALID_PARAM, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::getReportStatus(msg_message_id_t msg_id, msg_struct_list_s *report_list)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
 
        char cmdBuf[cmdSize];
@@ -1404,36 +1407,35 @@ msg_error_t MsgHandle::getReportStatus(msg_message_id_t msg_id, msg_struct_list_
        report_list->nCount = 0;
        report_list->msg_struct_info = NULL;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_REPORT_STATUS;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msg_id, sizeof(msg_message_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_GET_REPORT_STATUS)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_REPORT_STATUS) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeReportStatus(pEvent->data, report_list);
 
        return MSG_SUCCESS;
@@ -1443,24 +1445,22 @@ msg_error_t MsgHandle::getReportStatus(msg_message_id_t msg_id, msg_struct_list_
 msg_error_t MsgHandle::getAddressList(const msg_thread_id_t threadId, msg_struct_list_s *pAddrList)
 {
        msg_error_t err = MSG_SUCCESS;
+       /*
+       err = MsgStoConnectDB();
 
-//     err = MsgStoConnectDB();
-//
-//     if (err != MSG_SUCCESS)
-//     {
-//             MSG_DEBUG("MsgStoConnectDB() Error!!");
-//             return err;
-//     }
-
+       if (err != MSG_SUCCESS) {
+               MSG_DEBUG("MsgStoConnectDB() Error!!");
+               return err;
+       }
+       */
        err = MsgStoGetAddressList(threadId, (msg_struct_list_s *)pAddrList);
 
-       if (err != MSG_SUCCESS)
-       {
+       if (err != MSG_SUCCESS) {
                MSG_DEBUG("MsgStoGetThreadViewList() Error!!");
                return err;
        }
 
-//     MsgStoDisconnectDB();
+       /* MsgStoDisconnectDB(); */
 
        return err;
 }
@@ -1468,47 +1468,46 @@ msg_error_t MsgHandle::getAddressList(const msg_thread_id_t threadId, msg_struct
 
 msg_error_t MsgHandle::getThreadIdByAddress(msg_struct_list_s *pAddrList, msg_thread_id_t *pThreadId)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(pAddrList->nCount) + (sizeof(MSG_ADDRESS_INFO_S)*pAddrList->nCount);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_THREAD_ID_BY_ADDRESS;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &pAddrList->nCount, sizeof(pAddrList->nCount));
        int addSize = sizeof(MSG_ADDRESS_INFO_S);
-       for(int i=0; i<pAddrList->nCount; i++) {
+       for (int i = 0; i < pAddrList->nCount; i++) {
                memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+sizeof(pAddrList->nCount)+(addSize*i)+MAX_COOKIE_LEN), ((msg_struct_s *)(pAddrList->msg_struct_info[i]))->data, sizeof(MSG_ADDRESS_INFO_S));
        }
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_GET_THREAD_ID_BY_ADDRESS)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_THREAD_ID_BY_ADDRESS) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeThreadId(pEvent->data, pThreadId);
 
        return MSG_SUCCESS;
@@ -1519,47 +1518,46 @@ msg_error_t MsgHandle::getThreadIdByAddress(msg_list_handle_t msg_address_list,
 {
        int addrCnt = (int)g_list_length((GList *)msg_address_list);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + (sizeof(MSG_ADDRESS_INFO_S)*addrCnt);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_THREAD_ID_BY_ADDRESS;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &addrCnt, sizeof(int));
        int addSize = sizeof(MSG_ADDRESS_INFO_S);
-       for(int i=0; i<addrCnt; i++) {
+       for (int i = 0; i < addrCnt; i++) {
                memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+sizeof(addrCnt)+(addSize*i)+MAX_COOKIE_LEN), ((msg_struct_s *)(g_list_nth_data((GList *)msg_address_list,(guint)i)))->data, sizeof(MSG_ADDRESS_INFO_S));
        }
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_GET_THREAD_ID_BY_ADDRESS)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_THREAD_ID_BY_ADDRESS) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeThreadId(pEvent->data, pThreadId);
 
        return MSG_SUCCESS;
@@ -1568,40 +1566,39 @@ msg_error_t MsgHandle::getThreadIdByAddress(msg_list_handle_t msg_address_list,
 
 msg_error_t MsgHandle::getThread(msg_thread_id_t threadId, MSG_THREAD_VIEW_S* pThreadInfo)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_thread_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_THREAD_INFO;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &threadId, sizeof(msg_thread_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_GET_THREAD_INFO)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_THREAD_INFO) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
-       // Decode Return Data
+       /* Decode Return Data */
        MsgDecodeThreadInfo(pEvent->data, pThreadInfo);
 
        return MSG_SUCCESS;
@@ -1611,22 +1608,63 @@ msg_error_t MsgHandle::getThread(msg_thread_id_t threadId, MSG_THREAD_VIEW_S* pT
 msg_error_t MsgHandle::getMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_struct_list_s *pMsgList)
 {
        msg_error_t err = MSG_SUCCESS;
+       /*
+       err = MsgStoConnectDB();
+
+       if (err != MSG_SUCCESS) {
+               MSG_DEBUG("MsgStoConnectDB() Error!!");
+               return err;
+       }
+       */
+       int count = 0;
+
+       if (pListCond->pAddressVal) {
+               int address_len = strlen(pListCond->pAddressVal);
+
+               /* Allocate Memory to Command Data */
+               int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + sizeof(char) * address_len;
+
+               char cmdBuf[cmdSize];
+               bzero(cmdBuf, cmdSize);
+               MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+
+               /* Set Command Parameters */
+               pCmd->cmdType = MSG_CMD_SET_TEMP_ADDRESS_TABLE;
+
+               /* Copy Cookie */
+               memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+               /* Copy Command Data */
+               memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &address_len, sizeof(int));
+               memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), pListCond->pAddressVal, sizeof(char) * address_len);
+
+               /* Send Command to Messaging FW */
+               char* pEventData = NULL;
+               unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
-//     err = MsgStoConnectDB();
-//
-//     if (err != MSG_SUCCESS) {
-//             MSG_DEBUG("MsgStoConnectDB() Error!!");
-//             return err;
-//     }
+               write((char*)pCmd, cmdSize, &pEventData);
 
-       err = MsgStoGetMessageList(pListCond, pMsgList);
+               /* Get Return Data */
+               MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+               if (pEvent == NULL)
+                       THROW(MsgException::INVALID_RESULT, "Event is NULL");
+
+               if (pEvent->eventType != MSG_EVENT_SET_TEMP_ADDRESS_TABLE) {
+                       THROW(MsgException::INVALID_RESULT, "Event Data Error");
+               }
+
+               memcpy(&count, pEvent->data, sizeof(int));
+       }
+
+       err = MsgStoGetMessageList(pListCond, pMsgList, count);
 
        if (err != MSG_SUCCESS) {
                MSG_DEBUG("MsgStoGetMessageList() Error!!");
                return err;
        }
 
-//     MsgStoDisconnectDB();
+       /* MsgStoDisconnectDB(); */
 
        return err;
 }
@@ -1649,36 +1687,35 @@ msg_error_t MsgHandle::getMediaList(const msg_thread_id_t thread_id, msg_list_ha
 
 int MsgHandle::addPushEvent(MSG_PUSH_EVENT_INFO_S *pPushEvent)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_PUSH_EVENT_INFO_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_ADD_PUSH_EVENT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pPushEvent, sizeof(MSG_PUSH_EVENT_INFO_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_ADD_PUSH_EVENT)
-       {
+       if (pEvent->eventType != MSG_EVENT_ADD_PUSH_EVENT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -1688,121 +1725,120 @@ int MsgHandle::addPushEvent(MSG_PUSH_EVENT_INFO_S *pPushEvent)
 
 int MsgHandle::deletePushEvent(MSG_PUSH_EVENT_INFO_S *pPushEvent)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_PUSH_EVENT_INFO_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_DELETE_PUSH_EVENT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pPushEvent, sizeof(MSG_PUSH_EVENT_INFO_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_DELETE_PUSH_EVENT)
-       {
+       if (pEvent->eventType != MSG_EVENT_DELETE_PUSH_EVENT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 int MsgHandle::updatePushEvent(MSG_PUSH_EVENT_INFO_S *pSrc, MSG_PUSH_EVENT_INFO_S *pDst)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) +  2 * sizeof(MSG_PUSH_EVENT_INFO_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_UPDATE_PUSH_EVENT;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pSrc, sizeof(MSG_PUSH_EVENT_INFO_S));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_PUSH_EVENT_INFO_S)), pDst, sizeof(MSG_PUSH_EVENT_INFO_S));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_UPDATE_PUSH_EVENT)
-       {
+       if (pEvent->eventType != MSG_EVENT_UPDATE_PUSH_EVENT) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::getVobject(msg_message_id_t MsgId, void** encodedData)
 {
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
        char *encode_data = NULL;
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_GET_MSG;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &MsgId, sizeof(msg_message_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
        if (pEvent == NULL)
                THROW(MsgException::INVALID_RESULT, "Event is NULL");
 
-       if (pEvent->eventType != MSG_EVENT_GET_MSG)
-       {
+       if (pEvent->eventType != MSG_EVENT_GET_MSG) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        if (pEvent->result != MSG_SUCCESS)
                return pEvent->result;
 
-       // Decode Return Data
+       /* Decode Return Data */
        MSG_MESSAGE_INFO_S msgInfo = {0,};
        MSG_SENDINGOPT_INFO_S sendOptInfo = {0,};
 
@@ -1811,7 +1847,7 @@ msg_error_t MsgHandle::getVobject(msg_message_id_t MsgId, void** encodedData)
 
        MsgDecodeMsgInfo(pEvent->data, &msgInfo, &sendOptInfo);
 
-       //Convert MSG_MESSAGE_INFO_S to
+       /*Convert MSG_MESSAGE_INFO_S to */
        encode_data = MsgVMessageEncode(&msgInfo);
        if (encode_data) {
                *encodedData = (void*)encode_data;
@@ -1820,11 +1856,10 @@ msg_error_t MsgHandle::getVobject(msg_message_id_t MsgId, void** encodedData)
                *encodedData = NULL;
        }
 
-       // Delete Temp File
-       if (msgInfo.bTextSms == false)
-       {
-               // Delete Temp File
-               MsgDeleteFile(msgInfo.msgData); //ipc
+       /* Delete Temp File */
+       if (msgInfo.bTextSms == false) {
+               /* Delete Temp File */
+               MsgDeleteFile(msgInfo.msgData); /* ipc */
        }
 
        return MSG_SUCCESS;
index 32c8722..b075528 100755 (executable)
@@ -20,6 +20,7 @@
 #include "MsgDebug.h"
 #include "MsgCppTypes.h"
 #include "MsgException.h"
+#include "MsgUtilFile.h"
 #include "MsgUtilFunction.h"
 #include "MsgProxyListener.h"
 #include "MsgHandle.h"
@@ -56,8 +57,8 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq)
        }
 
        if (reqmsg->subType != MSG_SENDREQ_JAVA_MMS) {
-               // In case MMS read report, get address value later.
-               if(reqmsg->subType != MSG_READREPLY_MMS) {
+               /* In case MMS read report, get address value later. */
+               if (reqmsg->subType != MSG_READREPLY_MMS) {
                        if (reqmsg->addr_list && (reqmsg->addr_list->nCount > 0) && (reqmsg->addr_list->nCount <= MAX_TO_ADDRESS_CNT)) {
                                MSG_DEBUG("Recipient address count [%d]", reqmsg->addr_list->nCount );
                        } else if (g_list_length(reqmsg->addressList) > 0) {
@@ -69,8 +70,10 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq)
                }
 
                /* Begin: Setting default values for submit request */
-       //      pReq->msg.msgId = 0;    // Set Request ID: internal use
-       //      pReq->msg.folderId = MSG_OUTBOX_ID;     // Set Folder ID
+               /* Set Request ID: internal use */
+               /* pReq->msg.msgId = 0; */
+               /* Set Folder ID */
+               /* pReq->msg.folderId = MSG_OUTBOX_ID; */
                if (reqmsg->subType == MSG_RETRIEVE_MMS) {
                        reqmsg->networkStatus = MSG_NETWORK_RETRIEVING;
                } else {
@@ -78,7 +81,7 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq)
                }
 
                reqmsg->bRead = false;
-               //reqmsg->bProtected = false;
+               /* reqmsg->bProtected = false; */
                reqmsg->priority = MSG_MESSAGE_PRIORITY_NORMAL;
                reqmsg->direction = MSG_DIRECTION_TYPE_MO;
                reqmsg->storageId = MSG_STORAGE_PHONE;
@@ -91,13 +94,13 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq)
                reqmsg->displayTime = curTime;
                /* End : Setting default values for submit request */
        } else {
-               //in case of JAVA MMS msg, parse mms transaction id from pMmsData
+               /* in case of JAVA MMS msg, parse mms transaction id from pMmsData */
                reqmsg->networkStatus = MSG_NETWORK_SENDING;
                strncpy(trId, (char*)reqmsg->pMmsData+3,MMS_TR_ID_LEN);
                MSG_SEC_DEBUG("JavaMMS transaction Id:%s ",trId);
        }
 
-       // Convert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
+       /* Convert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S */
        convertMsgStruct(reqmsg, &(reqInfo.msgInfo));
 
        MSG_MESSAGE_TYPE_S msgType = {0,};
@@ -127,7 +130,7 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq)
 
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_request_id_t) + dataSize + sizeof(MSG_PROXY_INFO_S);
 
-       // In case of JAVA MMS msg, add trId
+       /* In case of JAVA MMS msg, add trId */
        if (reqmsg->subType == MSG_SENDREQ_JAVA_MMS)
                cmdSize += sizeof(trId);
 
@@ -136,36 +139,47 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq)
 
        MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SUBMIT_REQ;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &reqInfo.reqId, sizeof(msg_request_id_t));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_request_id_t)), &chInfo, sizeof(MSG_PROXY_INFO_S));
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_request_id_t)+sizeof(MSG_PROXY_INFO_S)), encodedData, dataSize);
 
-       // In case of JAVA MMS msg, add trId
+       /* In case of JAVA MMS msg, add trId */
        if (reqmsg->subType == MSG_SENDREQ_JAVA_MMS)
                memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(msg_request_id_t)+sizeof(MSG_PROXY_INFO_S)+dataSize), &trId, sizeof(trId));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Delete Temp File */
+       if (reqInfo.msgInfo.bTextSms == false) {
+               MsgDeleteFile(reqInfo.msgInfo.msgData); /* ipc */
+       }
+
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*) pEventData;
 
-       int* pReqId = (int*) pEvent->data;
-       pReq->reqId = *pReqId;
+       int ret[3] = {0,};
+
+       memcpy(&ret, (void*)pEvent->data, sizeof(ret));
+
+       pReq->reqId = ret[0];
+       reqmsg->msgId = (msg_message_id_t)ret[1];
+       reqmsg->threadId = (msg_thread_id_t)ret[2];
        MSG_DEBUG("SENT_REQ_ID: %d", pReq->reqId);
+       MSG_DEBUG("MSG_ID: %d", reqmsg->msgId);
+       MSG_DEBUG("THREAD_ID: %d", reqmsg->threadId);
 
-       if (pEvent->eventType != MSG_EVENT_SUBMIT_REQ)
-       {
+       if (pEvent->eventType != MSG_EVENT_SUBMIT_REQ) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error:%d", pEvent->eventType);
        }
 
@@ -184,24 +198,28 @@ msg_error_t MsgHandle::regSentStatusCallback(msg_sent_status_cb onStatusChanged,
 
        eventListener->start(this);
 
-       int remoteFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       int remoteFd = eventListener->getRemoteFd(); /* fd that is reserved to the "listener thread" by msgfw daemon */
 
-       if(remoteFd == -1 )
+       if (remoteFd == -1) {
+               eventListener->stop();
                return MSG_ERR_INVALID_MSGHANDLE;
+       }
 
-       if (eventListener->regSentStatusEventCB(this, onStatusChanged, pUserParam) == false)
+       if (eventListener->regSentStatusEventCB(this, remoteFd, onStatusChanged, pUserParam) == false) {
+               eventListener->stop();
                return MSG_ERR_INVALID_PARAMETER;
+       }
 
-       // Allocate Memory to Command Data
-       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); // cmd type, listenerFd
+       /* Allocate Memory to Command Data */
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); /* cmd type, listenerFd */
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_REG_SENT_STATUS_CB;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
        MSG_DEBUG("remote fd %d", remoteFd);
@@ -210,17 +228,16 @@ msg_error_t MsgHandle::regSentStatusCallback(msg_sent_status_cb onStatusChanged,
 
        MSG_DEBUG("reg status [%d : %s], %d", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType), remoteFd);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_REG_SENT_STATUS_CB)
-       {
+       if (pEvent->eventType != MSG_EVENT_REG_SENT_STATUS_CB) {
                THROW(MsgException::INVALID_PARAM, "Event Data Error");
        }
 
@@ -230,33 +247,39 @@ msg_error_t MsgHandle::regSentStatusCallback(msg_sent_status_cb onStatusChanged,
 
 msg_error_t MsgHandle::regSmsMessageCallback(msg_sms_incoming_cb onMsgIncoming, unsigned short port, void *pUserParam)
 {
-       if( (!onMsgIncoming) )
+       if (!onMsgIncoming)
                THROW(MsgException::INVALID_PARAM, "Param %p", onMsgIncoming);
 
        MsgProxyListener* eventListener = MsgProxyListener::instance();
 
        eventListener->start(this);
 
-       int remoteFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       int remoteFd = eventListener->getRemoteFd(); /* fd that is reserved to the "listener thread" by msgfw daemon */
 
-       if(remoteFd == -1 )
+       if (remoteFd == -1) {
+               eventListener->stop();
                return MSG_ERR_INVALID_MSGHANDLE;
+       }
 
-       if (eventListener->regMessageIncomingEventCB(this, onMsgIncoming, port, pUserParam) == false)
+       if (eventListener->regMessageIncomingEventCB(this, remoteFd, onMsgIncoming, port, pUserParam) == false) {
+               eventListener->stop();
                return MSG_ERR_INVALID_PARAMETER;
+       }
 
-       // Allocate Memory to Command Data
-       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_MSG_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
+       /* Allocate Memory to Command Data */
+       /* sizeof(int) + sizeof; */
+       /* cmd type, listener fd */
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_MSG_CB_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
 
        MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_REG_INCOMING_MSG_CB;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
        MSG_CMD_REG_INCOMING_MSG_CB_S cmdParam = {0};
@@ -269,18 +292,17 @@ msg_error_t MsgHandle::regSmsMessageCallback(msg_sms_incoming_cb onMsgIncoming,
 
        MSG_DEBUG("reg new msg [%s], fd %d, port %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd, cmdParam.port);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_MSG_CB)
-       {
+       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_MSG_CB) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -290,22 +312,26 @@ msg_error_t MsgHandle::regSmsMessageCallback(msg_sms_incoming_cb onMsgIncoming,
 
 msg_error_t MsgHandle::regMmsConfMessageCallback(msg_mms_conf_msg_incoming_cb onMMSConfMsgIncoming, const char *pAppId, void *pUserParam)
 {
-       if( (!onMMSConfMsgIncoming) )
+       if (!onMMSConfMsgIncoming)
                THROW(MsgException::INVALID_PARAM, "Param %p", onMMSConfMsgIncoming);
 
        MsgProxyListener* eventListener = MsgProxyListener::instance();
 
        eventListener->start(this);
 
-       int remoteFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       int remoteFd = eventListener->getRemoteFd(); /* fd that is reserved to the "listener thread" by msgfw daemon */
 
-       if(remoteFd == -1 )
+       if (remoteFd == -1) {
+               eventListener->stop();
                return MSG_ERR_INVALID_MSGHANDLE;
+       }
 
-       if (eventListener->regMMSConfMessageIncomingEventCB(this, onMMSConfMsgIncoming, pAppId, pUserParam) == false)
+       if (eventListener->regMMSConfMessageIncomingEventCB(this, remoteFd, onMMSConfMsgIncoming, pAppId, pUserParam) == false) {
+               eventListener->stop();
                return MSG_ERR_INVALID_PARAMETER;
+       }
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S);
 
        char cmdBuf[cmdSize];
@@ -313,10 +339,10 @@ msg_error_t MsgHandle::regMmsConfMessageCallback(msg_mms_conf_msg_incoming_cb on
 
        MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
        MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S cmdParam = {0};
@@ -331,18 +357,17 @@ msg_error_t MsgHandle::regMmsConfMessageCallback(msg_mms_conf_msg_incoming_cb on
 
        MSG_DEBUG("reg new msg [%s], fd:%d, appId:%s", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd,  (pAppId)? cmdParam.appId:"NULL" );
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB)
-       {
+       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -352,33 +377,39 @@ msg_error_t MsgHandle::regMmsConfMessageCallback(msg_mms_conf_msg_incoming_cb on
 
 msg_error_t MsgHandle::regSyncMLMessageCallback(msg_syncml_msg_incoming_cb onSyncMLMsgIncoming, void *pUserParam)
 {
-       if( (!onSyncMLMsgIncoming) )
+       if (!onSyncMLMsgIncoming)
                THROW(MsgException::INVALID_PARAM, "Param %p", onSyncMLMsgIncoming);
 
        MsgProxyListener* eventListener = MsgProxyListener::instance();
 
        eventListener->start(this);
 
-       int remoteFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       int remoteFd = eventListener->getRemoteFd(); /* fd that is reserved to the "listener thread" by msgfw daemon */
 
-       if(remoteFd == -1 )
+       if (remoteFd == -1) {
+               eventListener->stop();
                return MSG_ERR_INVALID_MSGHANDLE;
+       }
 
-       if (eventListener->regSyncMLMessageIncomingEventCB(this, onSyncMLMsgIncoming, pUserParam) == false)
+       if (eventListener->regSyncMLMessageIncomingEventCB(this, remoteFd, onSyncMLMsgIncoming, pUserParam) == false) {
+               eventListener->stop();
                return MSG_ERR_INVALID_PARAMETER;
+       }
 
-       // Allocate Memory to Command Data
-       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
+       /* Allocate Memory to Command Data */
+       /* sizeof(int) + sizeof; */
+       /* cmd type, listener fd */
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
 
        MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_REG_INCOMING_SYNCML_MSG_CB;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
        MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S cmdParam = {0};
@@ -390,17 +421,16 @@ msg_error_t MsgHandle::regSyncMLMessageCallback(msg_syncml_msg_incoming_cb onSyn
 
        MSG_DEBUG("reg new msg [%s], fd %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB)
-       {
+       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -410,31 +440,37 @@ msg_error_t MsgHandle::regSyncMLMessageCallback(msg_syncml_msg_incoming_cb onSyn
 
 msg_error_t MsgHandle::regLBSMessageCallback(msg_lbs_msg_incoming_cb onLBSMsgIncoming, void *pUserParam)
 {
-       if( (!onLBSMsgIncoming) )
+       if (!onLBSMsgIncoming)
                THROW(MsgException::INVALID_PARAM, "Param %p", onLBSMsgIncoming);
 
        MsgProxyListener* eventListener = MsgProxyListener::instance();
 
        eventListener->start(this);
 
-       int remoteFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       int remoteFd = eventListener->getRemoteFd(); /* fd that is reserved to the "listener thread" by msgfw daemon */
 
-       if(remoteFd == -1 )
+       if (remoteFd == -1) {
+               eventListener->stop();
                return MSG_ERR_INVALID_MSGHANDLE;
+       }
 
-       if (eventListener->regLBSMessageIncomingEventCB(this, onLBSMsgIncoming, pUserParam) == false)
+       if (eventListener->regLBSMessageIncomingEventCB(this, remoteFd, onLBSMsgIncoming, pUserParam) == false) {
+               eventListener->stop();
                return MSG_ERR_INVALID_PARAMETER;
+       }
 
-       // Allocate Memory to Command Data
-       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
+       /* Allocate Memory to Command Data */
+       /* sizeof(int) + sizeof; */
+       /* cmd type, listener fd */
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S);
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_REG_INCOMING_LBS_MSG_CB;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
        MSG_CMD_REG_INCOMING_LBS_MSG_CB_S cmdParam = {0};
@@ -446,18 +482,17 @@ msg_error_t MsgHandle::regLBSMessageCallback(msg_lbs_msg_incoming_cb onLBSMsgInc
 
        MSG_DEBUG("reg new msg [%s], fd %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_LBS_MSG_CB)
-       {
+       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_LBS_MSG_CB) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -467,33 +502,39 @@ msg_error_t MsgHandle::regLBSMessageCallback(msg_lbs_msg_incoming_cb onLBSMsgInc
 
 msg_error_t MsgHandle::regSyncMLMessageOperationCallback(msg_syncml_msg_operation_cb onSyncMLMsgOperation, void *pUserParam)
 {
-       if( (!onSyncMLMsgOperation) )
+       if (!onSyncMLMsgOperation)
                THROW(MsgException::INVALID_PARAM, "Param %p", onSyncMLMsgOperation);
 
        MsgProxyListener* eventListener = MsgProxyListener::instance();
 
        eventListener->start(this);
 
-       int remoteFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       int remoteFd = eventListener->getRemoteFd(); /* fd that is reserved to the "listener thread" by msgfw daemon */
 
-       if(remoteFd == -1 )
+       if (remoteFd == -1) {
+               eventListener->stop();
                return MSG_ERR_INVALID_MSGHANDLE;
+       }
 
-       if (eventListener->regSyncMLMessageOperationEventCB(this, onSyncMLMsgOperation, pUserParam) == false)
+       if (eventListener->regSyncMLMessageOperationEventCB(this, remoteFd, onSyncMLMsgOperation, pUserParam) == false) {
+               eventListener->stop();
                return MSG_ERR_INVALID_PARAMETER;
+       }
 
-       // Allocate Memory to Command Data
-       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
+       /* Allocate Memory to Command Data */
+       /* sizeof(int) + sizeof; */
+       /* cmd type, listener fd */
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
 
        MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_REG_SYNCML_MSG_OPERATION_CB;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
        MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S cmdParam = {0};
@@ -505,42 +546,46 @@ msg_error_t MsgHandle::regSyncMLMessageOperationCallback(msg_syncml_msg_operatio
 
        MSG_DEBUG("register syncML msg operation callback [%s], fd %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB)
-       {
+       if (pEvent->eventType != MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::regPushMessageCallback(msg_push_msg_incoming_cb onPushMsgIncoming, const char *pAppId, void *pUserParam)
 {
-       if( (!onPushMsgIncoming) )
+       if (!onPushMsgIncoming)
                THROW(MsgException::INVALID_PARAM, "Param %p", onPushMsgIncoming);
 
        MsgProxyListener* eventListener = MsgProxyListener::instance();
 
        eventListener->start(this);
 
-       int remoteFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       int remoteFd = eventListener->getRemoteFd(); /* fd that is reserved to the "listener thread" by msgfw daemon */
 
-       if(remoteFd == -1 )
+       if (remoteFd == -1) {
+               eventListener->stop();
                return MSG_ERR_INVALID_MSGHANDLE;
+       }
 
-       if (eventListener->regPushMessageIncomingEventCB(this, onPushMsgIncoming, pAppId, pUserParam) == false)
+       if (eventListener->regPushMessageIncomingEventCB(this, remoteFd, onPushMsgIncoming, pAppId, pUserParam) == false) {
+               eventListener->stop();
                return MSG_ERR_INVALID_PARAMETER;
+       }
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S);
 
        char cmdBuf[cmdSize];
@@ -548,10 +593,10 @@ msg_error_t MsgHandle::regPushMessageCallback(msg_push_msg_incoming_cb onPushMsg
 
        MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_REG_INCOMING_PUSH_MSG_CB;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
        MSG_CMD_REG_INCOMING_PUSH_MSG_CB_S cmdParam = {0};
@@ -566,53 +611,60 @@ msg_error_t MsgHandle::regPushMessageCallback(msg_push_msg_incoming_cb onPushMsg
 
        MSG_DEBUG("reg new msg [%s], fd:%d, appId:%s", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd,  (pAppId)? cmdParam.appId:"NULL" );
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_PUSH_MSG_CB)
-       {
+       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_PUSH_MSG_CB) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
        return pEvent->result;
 }
 
+
 msg_error_t MsgHandle::regCBMessageCallback(msg_cb_incoming_cb onCBIncoming, bool bSave, void *pUserParam)
 {
-       if( (!onCBIncoming) )
+       if (!onCBIncoming)
                THROW(MsgException::INVALID_PARAM, "Param %p", onCBIncoming);
 
        MsgProxyListener* eventListener = MsgProxyListener::instance();
 
        eventListener->start(this);
 
-       int remoteFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       int remoteFd = eventListener->getRemoteFd(); /* fd that is reserved to the "listener thread" by msgfw daemon */
 
-       if(remoteFd == -1 )
+       if (remoteFd == -1) {
+               eventListener->stop();
                return MSG_ERR_INVALID_MSGHANDLE;
+       }
 
-       if (eventListener->regCBMessageIncomingEventCB(this, onCBIncoming, bSave, pUserParam) == false)
-               return MSG_SUCCESS;
+       if (eventListener->regCBMessageIncomingEventCB(this, remoteFd, onCBIncoming, bSave, pUserParam) == false) {
+               eventListener->stop();
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+
+       /* Allocate Memory to Command Data */
+       /* sizeof(int) + sizeof; */
+       /* cmd type, listener fd */
 
-       // Allocate Memory to Command Data
-       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_CB_MSG_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_CB_MSG_CB_S);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
 
        MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_REG_INCOMING_CB_MSG_CB;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
        MSG_CMD_REG_CB_INCOMING_MSG_CB_S cmdParam = {0};
@@ -625,18 +677,17 @@ msg_error_t MsgHandle::regCBMessageCallback(msg_cb_incoming_cb onCBIncoming, boo
 
        MSG_DEBUG("reg new msg [%s], fd: %d, bSave: %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd, cmdParam.bsave);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_CB_MSG_CB)
-       {
+       if (pEvent->eventType != MSG_EVENT_REG_INCOMING_CB_MSG_CB) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
@@ -653,24 +704,28 @@ msg_error_t MsgHandle::regReportMessageCallback(msg_report_msg_incoming_cb onRep
 
        eventListener->start(this);
 
-       int remoteFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
+       int remoteFd = eventListener->getRemoteFd(); /* fd that is reserved to the "listener thread" by msgfw daemon */
 
-       if(remoteFd == -1 )
+       if (remoteFd == -1) {
+               eventListener->stop();
                return MSG_ERR_INVALID_MSGHANDLE;
+       }
 
-       if (eventListener->regReportMsgIncomingCB(this, onReportMsgCB, pUserParam) == false)
+       if (eventListener->regReportMsgIncomingCB(this, remoteFd, onReportMsgCB, pUserParam) == false) {
+               eventListener->stop();
                return MSG_ERR_INVALID_PARAMETER;
+       }
 
-       // Allocate Memory to Command Data
-       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); // cmd type, listenerFd
+       /* Allocate Memory to Command Data */
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); /* cmd type, listenerFd */
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_REG_REPORT_MSG_INCOMING_CB;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
        MSG_DEBUG("remote fd %d", remoteFd);
@@ -679,17 +734,16 @@ msg_error_t MsgHandle::regReportMessageCallback(msg_report_msg_incoming_cb onRep
 
        MSG_DEBUG("reg status [%d : %s], %d", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType), remoteFd);
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_REG_REPORT_MSG_INCOMING_CB)
-       {
+       if (pEvent->eventType != MSG_EVENT_REG_REPORT_MSG_INCOMING_CB) {
                THROW(MsgException::INVALID_PARAM, "Event Data Error");
        }
 
@@ -699,37 +753,36 @@ msg_error_t MsgHandle::regReportMessageCallback(msg_report_msg_incoming_cb onRep
 
 msg_error_t MsgHandle::operateSyncMLMessage(msg_message_id_t msgId)
 {
-       ifmsgId < 1)
+       if (msgId < 1)
                THROW(MsgException::INVALID_PARAM, "Param msgId %d", msgId);
 
-       // Allocate Memory to Command Data
+       /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_id_t);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
        MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       // Set Command Parameters
+       /* Set Command Parameters */
        pCmd->cmdType = MSG_CMD_SYNCML_OPERATION;
 
-       // Copy Cookie
+       /* Copy Cookie */
        memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       // Copy Command Data
+       /* Copy Command Data */
        memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msgId, sizeof(msg_message_id_t));
 
-       // Send Command to Messaging FW
+       /* Send Command to Messaging FW */
        char* pEventData = NULL;
        unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
 
        write((char*)pCmd, cmdSize, &pEventData);
 
-       // Get Return Data
+       /* Get Return Data */
        MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SYNCML_OPERATION)
-       {
+       if (pEvent->eventType != MSG_EVENT_SYNCML_OPERATION) {
                THROW(MsgException::INVALID_RESULT, "Event Data Error");
        }
 
index 44195ef..04e3a98 100755 (executable)
@@ -28,14 +28,17 @@ void MsgServerRestartCb(keynode_t *key, void* data)
 {
        bool bReady = false;
        MSG_DEBUG("Message Service Running State Changed");
-       // server is currently booting and service is not available until the end of booting
+       /* server is currently booting and service is not available until the end of booting */
        MsgSettingGetBool(VCONFKEY_MSG_SERVER_READY, &bReady);
        MSG_INFO("Message Service Running State Changed bReady:(%d)", bReady);
 
-       //bReady false indicates that server has restarted. Hence the proxylistener needs to be reset
+       /* bReady false indicates that server has restarted. Hence the proxylistener needs to be reset */
        if (bReady == false) {
-               MSG_DEBUG("Message Service Is Restarted. Resetting ProxyListener");
+               MSG_DEBUG("Message Service Is Restarted");
                MsgProxyListener::instance()->resetProxyListener();
+       } else {
+               MSG_DEBUG("Message Service Is ready again. Refreshing ProxyListener");
+               MsgProxyListener::instance()->refreshProxyListener();
        }
 }
 
@@ -43,35 +46,30 @@ gboolean readSocket(GIOChannel *source, GIOCondition condition, gpointer data)
 {
        MSG_BEGIN();
 #if 0
-       if ((G_IO_ERR & condition) || (G_IO_HUP & condition) || (G_IO_NVAL & condition))
-       {
+       if ((G_IO_ERR & condition) || (G_IO_HUP & condition) || (G_IO_NVAL & condition)) {
                MSG_DEBUG("IO condition Error!!! [%d]", condition);
 
                MsgProxyListener::instance()->stop();
                return FALSE;
        }
 #endif
-       if (G_IO_ERR & condition)
-       {
+       if (G_IO_ERR & condition) {
                MSG_ERR("IO Error!!! [%d]", condition);
-
-               MsgProxyListener::instance()->stop();
+               MsgProxyListener::instance()->clearProxyCBLists();
+               MsgProxyListener::instance()->clearOpenHandleSet();
                return FALSE;
        }
 
-       if (G_IO_HUP & condition)
-       {
+       if (G_IO_HUP & condition) {
                MSG_ERR("socket fd Error!!! [%d]", condition);
-
-               MsgProxyListener::instance()->stop();
+               MsgProxyListener::instance()->resetProxyListener();
                return FALSE;
        }
 
-       if (G_IO_NVAL & condition)
-       {
+       if (G_IO_NVAL & condition) {
                MSG_ERR("Invaild socket Error!!! [%d]", condition);
-
-               MsgProxyListener::instance()->stop();
+               MsgProxyListener::instance()->clearProxyCBLists();
+               MsgProxyListener::instance()->clearOpenHandleSet();
                return FALSE;
        }
 
@@ -81,19 +79,13 @@ gboolean readSocket(GIOChannel *source, GIOCondition condition, gpointer data)
 
        int n = MsgProxyListener::instance()->readFromSocket(&buf, &len);
 
-       if (n > 0)
-       {
+       if (n > 0) {
                MSG_DEBUG(">>Receiving %d bytes", n);
                MsgProxyListener::instance()->handleEvent((MSG_EVENT_S*)buf);
-       }
-       else if (n == 0)
-       {
+       } else if (n == 0) {
                MSG_WARN("Server closed connection");
-               MsgProxyListener::instance()->stop();
                return FALSE;
-       }
-       else // dataSize < 0
-       {
+       } else /* dataSize < 0 */ {
                MSG_DEBUG("Data is not for Listener");
        }
 
@@ -111,12 +103,8 @@ MsgProxyListener* MsgProxyListener::pInstance = NULL;
 
 MsgProxyListener::MsgProxyListener() : running(0)
 {
-       sentStatusCBList.clear();
-       newMessageCBList.clear();
-       newMMSConfMessageCBList.clear();
-       newSyncMLMessageCBList.clear();
-       newLBSMessageCBList.clear();
-       openHandleSet.clear();
+       clearProxyCBLists();
+       clearOpenHandleSet();
        MsgSettingRegVconfCBCommon(VCONFKEY_MSG_SERVER_READY, MsgServerRestartCb);
 
        channel = NULL;
@@ -126,12 +114,8 @@ MsgProxyListener::MsgProxyListener() : running(0)
 
 MsgProxyListener::~MsgProxyListener()
 {
-       sentStatusCBList.clear();
-       newMessageCBList.clear();
-       newMMSConfMessageCBList.clear();
-       newSyncMLMessageCBList.clear();
-       newLBSMessageCBList.clear();
-       openHandleSet.clear();
+       clearProxyCBLists();
+       clearOpenHandleSet();
        MsgSettingRemoveVconfCBCommon(VCONFKEY_MSG_SERVER_READY, MsgServerRestartCb);
 }
 
@@ -153,21 +137,22 @@ void MsgProxyListener::start(MsgHandle* pMsgHandle)
 {
        MutexLocker lock(mx);
 
-       handle_set::iterator it = openHandleSet.find(pMsgHandle);
-       if (it == openHandleSet.end())
-               openHandleSet.insert(pMsgHandle);
-       if (running == 0)
-       {
+       this->insertOpenHandleSet(pMsgHandle);
+
+       if (running == 0) {
                cliSock.connect(MSG_SOCKET_PATH);
-               cv.signal(); // wake up the waiting thread
+               /* wake up the waiting thread */
+               cv.signal();
 
                int fd = cliSock.fd();
 
                MSG_DEBUG("Socket Fd : %d", fd);
 
-               channel = g_io_channel_unix_new(fd); // initializes ref_count = 1
+               /* initializes ref_count = 1 */
+               channel = g_io_channel_unix_new(fd);
 
-               eventSourceId = g_io_add_watch(channel, (GIOCondition)(G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL), &readSocket, NULL); // increments ref_count =2
+               /* increments ref_count = 2 */
+               eventSourceId = g_io_add_watch(channel, (GIOCondition)(G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL), &readSocket, NULL);
 
                MSG_DEBUG("Call g_io_add_watch() : %d", eventSourceId);
        }
@@ -181,21 +166,25 @@ void MsgProxyListener::stop()
 {
        MSG_BEGIN();
 
-       if (running > 1)
-       {
+       MutexLocker lock(mx);
+
+       if (running > 1) {
                running--;
                MSG_DEBUG("There are still running Listener. [%d] left.", running);
-       }
-       else if (running == 1)
-       {
-               running--;
+       } else if (running == 1) {
+               if (channel) {
+                       g_io_channel_unref(channel);
+                       channel = NULL;
+               }
 
-               g_io_channel_unref(channel); // decrements ref_count = 1
+               if (eventSourceId > 0) {
+                       g_source_remove(eventSourceId);
+                       eventSourceId = 0;
+               }
 
-               g_source_remove(eventSourceId);
+               running = 0;
 
                cliSock.close();
-
                MSG_DEBUG("client Listener is terminated.");
        }
 
@@ -203,21 +192,26 @@ void MsgProxyListener::stop()
 }
 
 
-bool MsgProxyListener::regSentStatusEventCB(MsgHandle* pMsgHandle, msg_sent_status_cb pfSentStatus, void *pUserParam)
+bool MsgProxyListener::regSentStatusEventCB(MsgHandle* pMsgHandle, int fd, msg_sent_status_cb pfSentStatus, void *pUserParam)
 {
        MutexLocker lock(mx);
 
        std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
 
-       for (; it != sentStatusCBList.end(); it++)
-       {
+       for (; it != sentStatusCBList.end(); it++) {
                if (it->hAddr == pMsgHandle && it->pfSentStatusCB == pfSentStatus) {
-                       MSG_DEBUG("msg_sent_status_cb() callback : [%p] is already registered!!!", pfSentStatus);
-                       return false;
+                       if (it->fd == fd) {
+                               MSG_DEBUG("msg_sent_status_cb() callback : [%p] is already registered!!!", pfSentStatus);
+                               return false;
+                       } else {
+                               MSG_DEBUG("callback is registered by restarting server");
+                               it->fd = fd;
+                               return true;
+                       }
                }
        }
 
-       MSG_SENT_STATUS_CB_ITEM_S sentStatusCB = {pMsgHandle, pfSentStatus, pUserParam};
+       MSG_SENT_STATUS_CB_ITEM_S sentStatusCB = {pMsgHandle, fd, pfSentStatus, pUserParam};
 
        sentStatusCBList.push_back(sentStatusCB);
 
@@ -225,21 +219,26 @@ bool MsgProxyListener::regSentStatusEventCB(MsgHandle* pMsgHandle, msg_sent_stat
 }
 
 
-bool MsgProxyListener::regMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam)
+bool MsgProxyListener::regMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam)
 {
        MutexLocker lock(mx);
 
        std::list<MSG_INCOMING_CB_ITEM_S>::iterator it = newMessageCBList.begin();
 
-       for (; it != newMessageCBList.end(); it++)
-       {
+       for (; it != newMessageCBList.end(); it++) {
                if (it->hAddr == pMsgHandle && it->port == port && it->pfIncomingCB == pfNewMessage) {
-                       MSG_DEBUG("msg_sms_incoming_cb() callback : Port Number [%d] is already registered!!!", port);
-                       return false;
+                       if (it->fd == fd) {
+                               MSG_DEBUG("msg_sms_incoming_cb() callback : Port Number [%d] is already registered!!!", port);
+                               return false;
+                       } else {
+                               MSG_DEBUG("callback is registered by restarting server");
+                               it->fd = fd;
+                               return true;
+                       }
                }
        }
 
-       MSG_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewMessage, port, pUserParam};
+       MSG_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, fd, pfNewMessage, port, pUserParam};
 
        newMessageCBList.push_back(incomingCB);
 
@@ -247,27 +246,31 @@ bool MsgProxyListener::regMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_sms_
 }
 
 
-bool MsgProxyListener::regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam)
+bool MsgProxyListener::regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam)
 {
        MutexLocker lock(mx);
 
        std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it = newMMSConfMessageCBList.begin();
 
-       for (; it != newMMSConfMessageCBList.end(); it++)
-       {
+       for (; it != newMMSConfMessageCBList.end(); it++) {
                if (it->hAddr == pMsgHandle && it->pfMMSConfIncomingCB == pfNewMMSConfMessage) {
-
-                       if(pAppId == NULL) {
-                               MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback is already registered!!!");
-                               return false;
-                       } else if(!strncmp(it->appId, pAppId, MAX_MMS_JAVA_APPID_LEN)) {
-                               MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
-                               return false;
+                       if (it->fd == fd) {
+                               if (pAppId == NULL) {
+                                       MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback is already registered!!!");
+                                       return false;
+                               } else if (!strncmp(it->appId, pAppId, MAX_MMS_JAVA_APPID_LEN)) {
+                                       MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
+                                       return false;
+                               }
+                       } else {
+                               MSG_DEBUG("callback is registered by restarting server");
+                               it->fd = fd;
+                               return true;
                        }
                }
        }
 
-       MSG_MMS_CONF_INCOMING_CB_ITEM_S incomingConfCB = {pMsgHandle, pfNewMMSConfMessage, {0}, pUserParam};
+       MSG_MMS_CONF_INCOMING_CB_ITEM_S incomingConfCB = {pMsgHandle, fd, pfNewMMSConfMessage, {0}, pUserParam};
 
        if (pAppId != NULL)
                strncpy(incomingConfCB.appId, pAppId, MAX_MMS_JAVA_APPID_LEN);
@@ -278,27 +281,31 @@ bool MsgProxyListener::regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, m
 }
 
 
-bool MsgProxyListener::regPushMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_push_msg_incoming_cb pfNewPushMessage, const char *pAppId, void *pUserParam)
+bool MsgProxyListener::regPushMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_push_msg_incoming_cb pfNewPushMessage, const char *pAppId, void *pUserParam)
 {
        MutexLocker lock(mx);
 
        std::list<MSG_PUSH_INCOMING_CB_ITEM_S>::iterator it = newPushMessageCBList.begin();
 
-       for (; it != newPushMessageCBList.end(); it++)
-       {
+       for (; it != newPushMessageCBList.end(); it++) {
                if (it->hAddr == pMsgHandle && it->pfPushIncomingCB == pfNewPushMessage) {
-
-                       if(pAppId == NULL) {
-                               MSG_DEBUG("msg_push_msg_incoming_cb() callback is already registered!!!");
-                               return false;
-                       } else if(!strncmp(it->appId, pAppId, MAX_WAPPUSH_ID_LEN)) {
-                               MSG_DEBUG("msg_push_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
-                               return false;
+                       if (it->fd == fd) {
+                               if (pAppId == NULL) {
+                                       MSG_DEBUG("msg_push_msg_incoming_cb() callback is already registered!!!");
+                                       return false;
+                               } else if (!strncmp(it->appId, pAppId, MAX_WAPPUSH_ID_LEN)) {
+                                       MSG_DEBUG("msg_push_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
+                                       return false;
+                               }
+                       } else {
+                               MSG_DEBUG("callback is registered by restarting server");
+                               it->fd = fd;
+                               return true;
                        }
                }
        }
 
-       MSG_PUSH_INCOMING_CB_ITEM_S incomingPushCB = {pMsgHandle, pfNewPushMessage, {0}, pUserParam};
+       MSG_PUSH_INCOMING_CB_ITEM_S incomingPushCB = {pMsgHandle, fd, pfNewPushMessage, {0}, pUserParam};
 
        if (pAppId != NULL)
                strncpy(incomingPushCB.appId, pAppId, MAX_WAPPUSH_ID_LEN);
@@ -308,23 +315,30 @@ bool MsgProxyListener::regPushMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_
        return true;
 }
 
-bool MsgProxyListener::regCBMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_cb_incoming_cb pfNewCBMessage, bool bSave, void *pUserParam)
+
+bool MsgProxyListener::regCBMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_cb_incoming_cb pfNewCBMessage, bool bSave, void *pUserParam)
 {
        MutexLocker lock(mx);
 
        std::list<MSG_CB_INCOMING_CB_ITEM_S>::iterator it = newCBMessageCBList.begin();
 
-       for (; it != newCBMessageCBList.end(); it++)
-       {
+       for (; it != newCBMessageCBList.end(); it++) {
                if (it->hAddr == pMsgHandle && it->pfCBIncomingCB == pfNewCBMessage) {
-                       MSG_DEBUG("msg_CB_incoming_cb() callback : [%p] is already registered!!!", pfNewCBMessage);
-                        it->bsave = bSave;
-                        it->userParam = pUserParam;
-                       return false;
+                       if (it->fd == fd) {
+                               MSG_DEBUG("msg_CB_incoming_cb() callback : [%p] is already registered!!!", pfNewCBMessage);
+                                it->bsave = bSave;
+                                it->userParam = pUserParam;
+                               return false;
+                       } else {
+                               MSG_DEBUG("callback is registered by restarting server");
+                               it->fd = fd;
+                               return true;
+                       }
+
                }
        }
 
-       MSG_CB_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewCBMessage, bSave, pUserParam};
+       MSG_CB_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, fd, pfNewCBMessage, bSave, pUserParam};
 
        newCBMessageCBList.push_back(incomingCB);
 
@@ -332,22 +346,27 @@ bool MsgProxyListener::regCBMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_cb
 }
 
 
-bool MsgProxyListener::regReportMsgIncomingCB(MsgHandle* pMsgHandle, msg_report_msg_incoming_cb pfReportMessage, void *pUserParam)
+bool MsgProxyListener::regReportMsgIncomingCB(MsgHandle* pMsgHandle, int fd, msg_report_msg_incoming_cb pfReportMessage, void *pUserParam)
 {
        MutexLocker lock(mx);
 
        std::list<MSG_REPORT_INCOMING_CB_ITEM_S>::iterator it = reportMessageCBList.begin();
 
-       for (; it != reportMessageCBList.end(); it++)
-       {
+       for (; it != reportMessageCBList.end(); it++) {
                if (it->hAddr == pMsgHandle && it->pfReportMsgIncomingCB == pfReportMessage) {
-                       MSG_DEBUG("msg_report_msg_incoming_cb() callback : [%p] is already registered!!!", pfReportMessage);
-                        it->userParam = pUserParam;
-                       return false;
+                       if (it->fd == fd) {
+                               MSG_DEBUG("msg_report_msg_incoming_cb() callback : [%p] is already registered!!!", pfReportMessage);
+                                it->userParam = pUserParam;
+                               return false;
+                       } else {
+                               MSG_DEBUG("callback is registered by restarting server");
+                               it->fd = fd;
+                               return true;
+                       }
                }
        }
 
-       MSG_REPORT_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfReportMessage, pUserParam};
+       MSG_REPORT_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, fd, pfReportMessage, pUserParam};
 
        reportMessageCBList.push_back(incomingCB);
 
@@ -355,21 +374,26 @@ bool MsgProxyListener::regReportMsgIncomingCB(MsgHandle* pMsgHandle, msg_report_
 }
 
 
-bool MsgProxyListener::regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam)
+bool MsgProxyListener::regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam)
 {
        MutexLocker lock(mx);
 
        std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it = newSyncMLMessageCBList.begin();
 
-       for (; it != newSyncMLMessageCBList.end(); it++)
-       {
+       for (; it != newSyncMLMessageCBList.end(); it++) {
                if (it->hAddr == pMsgHandle && it->pfSyncMLIncomingCB == pfNewSyncMLMessage) {
-                       MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewSyncMLMessage);
-                       return false;
+                       if (it->fd == fd) {
+                               MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewSyncMLMessage);
+                               return false;
+                       } else {
+                               MSG_DEBUG("callback is registered by restarting server");
+                               it->fd = fd;
+                               return true;
+                       }
                }
        }
 
-       MSG_SYNCML_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewSyncMLMessage, pUserParam};
+       MSG_SYNCML_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, fd, pfNewSyncMLMessage, pUserParam};
 
        newSyncMLMessageCBList.push_back(incomingCB);
 
@@ -377,21 +401,26 @@ bool MsgProxyListener::regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, ms
 }
 
 
-bool MsgProxyListener::regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam)
+bool MsgProxyListener::regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam)
 {
        MutexLocker lock(mx);
 
        std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it = newLBSMessageCBList.begin();
 
-       for (; it != newLBSMessageCBList.end(); it++)
-       {
+       for (; it != newLBSMessageCBList.end(); it++) {
                if (it->hAddr == pMsgHandle && it->pfLBSMsgIncoming == pfNewLBSMsgIncoming) {
-                       MSG_DEBUG("msg_lbs_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewLBSMsgIncoming);
-                       return false;
+                       if (it->fd == fd) {
+                               MSG_DEBUG("msg_lbs_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewLBSMsgIncoming);
+                               return false;
+                       } else {
+                               MSG_DEBUG("callback is registered by restarting server");
+                               it->fd = fd;
+                               return true;
+                       }
                }
        }
 
-       MSG_LBS_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewLBSMsgIncoming, pUserParam};
+       MSG_LBS_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, fd, pfNewLBSMsgIncoming, pUserParam};
 
        newLBSMessageCBList.push_back(incomingCB);
 
@@ -399,21 +428,26 @@ bool MsgProxyListener::regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_l
 }
 
 
-bool MsgProxyListener::regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam)
+bool MsgProxyListener::regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, int fd, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam)
 {
        MutexLocker lock(mx);
 
        std::list<MSG_SYNCML_OPERATION_CB_ITEM_S>::iterator it = operationSyncMLMessageCBList.begin();
 
-       for (; it != operationSyncMLMessageCBList.end(); it++)
-       {
+       for (; it != operationSyncMLMessageCBList.end(); it++) {
                if (it->hAddr == pMsgHandle && it->pfSyncMLOperationCB == pfSyncMLMessageOperation) {
-                       MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfSyncMLMessageOperation);
-                       return false;
+                       if (it->fd == fd) {
+                               MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfSyncMLMessageOperation);
+                               return false;
+                       } else {
+                               MSG_DEBUG("callback is registered by restarting server");
+                               it->fd = fd;
+                               return true;
+                       }
                }
        }
 
-       MSG_SYNCML_OPERATION_CB_ITEM_S incomingCB = {pMsgHandle, pfSyncMLMessageOperation, pUserParam};
+       MSG_SYNCML_OPERATION_CB_ITEM_S incomingCB = {pMsgHandle, fd, pfSyncMLMessageOperation, pUserParam};
 
        operationSyncMLMessageCBList.push_back(incomingCB);
 
@@ -421,21 +455,26 @@ bool MsgProxyListener::regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, m
 }
 
 
-bool MsgProxyListener::regStorageChangeEventCB(MsgHandle* pMsgHandle, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam)
+bool MsgProxyListener::regStorageChangeEventCB(MsgHandle* pMsgHandle, int fd, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam)
 {
        MutexLocker lock(mx);
 
        std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it = storageChangeCBList.begin();
 
-       for (; it != storageChangeCBList.end(); it++)
-       {
+       for (; it != storageChangeCBList.end(); it++) {
                if (it->hAddr == pMsgHandle && it->pfStorageChangeCB == pfStorageChangeOperation) {
-                       MSG_DEBUG("msg_storage_change_cb() callback : [%p] is already registered!!!", pfStorageChangeOperation);
-                       return false;
+                       if (it->fd == fd) {
+                               MSG_DEBUG("msg_storage_change_cb() callback : [%p] is already registered!!!", pfStorageChangeOperation);
+                               return false;
+                       } else {
+                               MSG_DEBUG("callback is registered by restarting server");
+                               it->fd = fd;
+                               return true;
+                       }
                }
        }
 
-       MSG_STORAGE_CHANGE_CB_ITEM_S changeCB = {pMsgHandle, pfStorageChangeOperation, pUserParam};
+       MSG_STORAGE_CHANGE_CB_ITEM_S changeCB = {pMsgHandle, fd, pfStorageChangeOperation, pUserParam};
 
        storageChangeCBList.push_back(changeCB);
 
@@ -449,159 +488,273 @@ void MsgProxyListener::clearListOfClosedHandle(MsgHandle* pMsgHandle)
 
        MutexLocker lock(mx);
 
-       // sent status CB list
+       /* sent status CB list */
        std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
 
-       for (; it != sentStatusCBList.end(); )
-       {
-               if (it->hAddr == pMsgHandle)
-               {
+       for (; it != sentStatusCBList.end(); ) {
+               if (it->hAddr == pMsgHandle) {
                        sentStatusCBList.erase(it++);
-
-                       //Stop client Listener
                        stop();
-               }
-               else
+               } else {
                        ++it;
+               }
        }
 
-       // new message CB list
+       /* new message CB list */
        std::list<MSG_INCOMING_CB_ITEM_S>::iterator it2 = newMessageCBList.begin();
 
-       for (; it2 != newMessageCBList.end(); )
-       {
-               if (it2->hAddr == pMsgHandle)
-               {
+       for (; it2 != newMessageCBList.end(); ) {
+               if (it2->hAddr == pMsgHandle) {
                        newMessageCBList.erase(it2++);
-
-                       //Stop client Listener
                        stop();
-               }
-               else
+               } else {
                        ++it2;
+               }
        }
 
-       // MMS conf Message CB list
+       /* MMS conf Message CB list */
        std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it3 = newMMSConfMessageCBList.begin();
 
-       for (; it3 != newMMSConfMessageCBList.end(); )
-       {
-               if (it3->hAddr == pMsgHandle)
-               {
+       for (; it3 != newMMSConfMessageCBList.end(); ) {
+               if (it3->hAddr == pMsgHandle) {
                        newMMSConfMessageCBList.erase(it3++);
-
-                       //Stop client Listener
                        stop();
-               }
-               else
+               } else {
                        ++it3;
+               }
        }
 
-       // SyncML Message CB list
+       /* SyncML Message CB list */
        std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it4 = newSyncMLMessageCBList.begin();
 
-       for (; it4 != newSyncMLMessageCBList.end(); )
-       {
-               if (it4->hAddr == pMsgHandle)
-               {
+       for (; it4 != newSyncMLMessageCBList.end(); ) {
+               if (it4->hAddr == pMsgHandle) {
                        newSyncMLMessageCBList.erase(it4++);
-
-                       //Stop client Listener
                        stop();
-               }
-               else
+               } else {
                        ++it4;
+               }
        }
 
-       // LBS Message CB list
+       /* LBS Message CB list */
        std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it5 = newLBSMessageCBList.begin();
 
-       for (; it5 != newLBSMessageCBList.end(); )
-       {
-               if (it5->hAddr == pMsgHandle)
-               {
+       for (; it5 != newLBSMessageCBList.end(); ) {
+               if (it5->hAddr == pMsgHandle) {
                        newLBSMessageCBList.erase(it5++);
-
-                       //Stop client Listener
                        stop();
-               }
-               else
+               } else {
                        ++it5;
+               }
        }
 
-       // Push Message CB list
+       /* Push Message CB list */
        std::list<MSG_PUSH_INCOMING_CB_ITEM_S>::iterator it6 = newPushMessageCBList.begin();
 
-       for (; it6 != newPushMessageCBList.end(); )
-       {
-               if (it6->hAddr == pMsgHandle)
-               {
+       for (; it6 != newPushMessageCBList.end(); ) {
+               if (it6->hAddr == pMsgHandle) {
                        newPushMessageCBList.erase(it6++);
-
-                       //Stop client Listener
                        stop();
-               }
-               else
+               } else {
                        ++it6;
-
+               }
        }
 
-       // CB Message CB list
+       /* CB Message CB list */
        std::list<MSG_CB_INCOMING_CB_ITEM_S>::iterator it7 = newCBMessageCBList.begin();
 
-       for (; it7 != newCBMessageCBList.end(); )
-       {
-
-               if (it7->hAddr == pMsgHandle)
-               {
-
+       for (; it7 != newCBMessageCBList.end(); ) {
+               if (it7->hAddr == pMsgHandle) {
                        newCBMessageCBList.erase(it7++);
-
-                       //Stop client Listener
                        stop();
-               }
-               else
-               {
+               } else {
                        ++it7;
                }
        }
 
-       // Storage change Message CB list
+       /* Storage change Message CB list */
        std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it8 = storageChangeCBList.begin();
 
-       for (; it8 != storageChangeCBList.end(); )
-       {
-               if (it8->hAddr == pMsgHandle)
-               {
+       for (; it8 != storageChangeCBList.end(); ) {
+               if (it8->hAddr == pMsgHandle) {
                        storageChangeCBList.erase(it8++);
-
-                       //Stop client Listener
                        stop();
-               }
-               else
+               } else {
                        ++it8;
+               }
        }
 
 
-       // Report message incoming CB list
+       /* Report message incoming CB list */
        std::list<MSG_REPORT_INCOMING_CB_ITEM_S>::iterator it9 = reportMessageCBList.begin();
-       for (; it9 != reportMessageCBList.end(); )
-       {
-               if (it9->hAddr == pMsgHandle)
-               {
+       for (; it9 != reportMessageCBList.end(); ) {
+               if (it9->hAddr == pMsgHandle) {
                        reportMessageCBList.erase(it9++);
+                       stop();
+               } else {
+                       ++it9;
+               }
+       }
+
 
-                       //Stop client Listener
+       /* SyncML Message Operation CB list */
+       std::list<MSG_SYNCML_OPERATION_CB_ITEM_S>::iterator it10 = operationSyncMLMessageCBList.begin();
+       for (; it10 != operationSyncMLMessageCBList.end(); ) {
+               if (it10->hAddr == pMsgHandle) {
+                       operationSyncMLMessageCBList.erase(it10++);
                        stop();
+               } else {
+                       ++it10;
                }
-               else
-                       ++it9;
        }
 
+       /* Open Handle Set */
+       openHandleSet.erase(pMsgHandle);
 
        MSG_END();
 }
 
+
+void MsgProxyListener::refreshListOfOpenedHandle(MsgHandle* pMsgHandle)
+{
+       MSG_BEGIN();
+
+       MutexLocker lock(mx);
+
+       /* sent status CB list */
+       std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
+       for (; it != sentStatusCBList.end(); ++it) {
+               if (it->hAddr == pMsgHandle) {
+                       it->fd = CUSTOM_SOCKET_ERROR;
+                       try {
+                               pMsgHandle->regSentStatusCallback(it->pfSentStatusCB, it->userParam);
+                       } catch (MsgException& e) {
+                               MSG_FATAL("%s", e.what());
+                       }
+               }
+       }
+
+       /* new message CB list */
+       std::list<MSG_INCOMING_CB_ITEM_S>::iterator it2 = newMessageCBList.begin();
+       for (; it2 != newMessageCBList.end(); ++it2) {
+               if (it2->hAddr == pMsgHandle) {
+                       it2->fd = CUSTOM_SOCKET_ERROR;
+                       try {
+                               pMsgHandle->regSmsMessageCallback(it2->pfIncomingCB, it2->port, it2->userParam);
+                       } catch (MsgException& e) {
+                               MSG_FATAL("%s", e.what());
+                       }
+               }
+       }
+
+       /* MMS conf Message CB list */
+       std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it3 = newMMSConfMessageCBList.begin();
+       for (; it3 != newMMSConfMessageCBList.end(); ++it3) {
+               if (it3->hAddr == pMsgHandle) {
+                       it3->fd = CUSTOM_SOCKET_ERROR;
+                       try {
+                               pMsgHandle->regMmsConfMessageCallback(it3->pfMMSConfIncomingCB, it3->appId, it3->userParam);
+                       } catch (MsgException& e) {
+                               MSG_FATAL("%s", e.what());
+                       }
+               }
+       }
+
+       /* SyncML Message CB list */
+       std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it4 = newSyncMLMessageCBList.begin();
+       for (; it4 != newSyncMLMessageCBList.end(); ++it4) {
+               if (it4->hAddr == pMsgHandle) {
+                       it4->fd = CUSTOM_SOCKET_ERROR;
+                       try {
+                               pMsgHandle->regSyncMLMessageCallback(it4->pfSyncMLIncomingCB, it4->userParam);
+                       } catch (MsgException& e) {
+                               MSG_FATAL("%s", e.what());
+                       }
+               }
+       }
+
+       /* LBS Message CB list */
+       std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it5 = newLBSMessageCBList.begin();
+       for (; it5 != newLBSMessageCBList.end(); ++it5) {
+               if (it5->hAddr == pMsgHandle) {
+                       it5->fd = CUSTOM_SOCKET_ERROR;
+                       try {
+                               pMsgHandle->regLBSMessageCallback(it5->pfLBSMsgIncoming, it5->userParam);
+                       } catch (MsgException& e) {
+                               MSG_FATAL("%s", e.what());
+                       }
+               }
+       }
+
+       /* Push Message CB list */
+       std::list<MSG_PUSH_INCOMING_CB_ITEM_S>::iterator it6 = newPushMessageCBList.begin();
+       for (; it6 != newPushMessageCBList.end(); ++it6) {
+               if (it6->hAddr == pMsgHandle) {
+                       it6->fd = CUSTOM_SOCKET_ERROR;
+                       try {
+                               pMsgHandle->regPushMessageCallback(it6->pfPushIncomingCB, it6->appId, it6->userParam);
+                       } catch (MsgException& e) {
+                               MSG_FATAL("%s", e.what());
+                       }
+               }
+       }
+
+       /* CB Message CB list */
+       std::list<MSG_CB_INCOMING_CB_ITEM_S>::iterator it7 = newCBMessageCBList.begin();
+       for (; it7 != newCBMessageCBList.end(); ++it7) {
+               if (it7->hAddr == pMsgHandle) {
+                       it7->fd = CUSTOM_SOCKET_ERROR;
+                       try {
+                               pMsgHandle->regCBMessageCallback(it7->pfCBIncomingCB, it7->bsave, it7->userParam);
+                       } catch (MsgException& e) {
+                               MSG_FATAL("%s", e.what());
+                       }
+               }
+       }
+
+       /* Storage change Message CB list */
+       std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it8 = storageChangeCBList.begin();
+       for (; it8 != storageChangeCBList.end(); ++it8) {
+               if (it8->hAddr == pMsgHandle) {
+                       it8->fd = CUSTOM_SOCKET_ERROR;
+                       try {
+                               pMsgHandle->regStorageChangeCallback(it8->pfStorageChangeCB, it8->userParam);
+                       } catch (MsgException& e) {
+                               MSG_FATAL("%s", e.what());
+                       }
+               }
+       }
+
+       /* Report message incoming CB list */
+       std::list<MSG_REPORT_INCOMING_CB_ITEM_S>::iterator it9 = reportMessageCBList.begin();
+       for (; it9 != reportMessageCBList.end(); ++it9) {
+               if (it9->hAddr == pMsgHandle) {
+                       it9->fd = CUSTOM_SOCKET_ERROR;
+                       try {
+                               pMsgHandle->regReportMessageCallback(it9->pfReportMsgIncomingCB, it9->userParam);
+                       } catch (MsgException& e) {
+                               MSG_FATAL("%s", e.what());
+                       }
+               }
+       }
+
+       /* SyncML Message Operation CB list */
+       std::list<MSG_SYNCML_OPERATION_CB_ITEM_S>::iterator it10 = operationSyncMLMessageCBList.begin();
+       for (; it10 != operationSyncMLMessageCBList.end(); ++it10) {
+               if (it10->hAddr == pMsgHandle) {
+                       it10->fd = CUSTOM_SOCKET_ERROR;
+                       try {
+                               pMsgHandle->regSyncMLMessageOperationCallback(it10->pfSyncMLOperationCB, it10->userParam);
+                       } catch (MsgException& e) {
+                               MSG_FATAL("%s", e.what());
+                       }
+               }
+       }
+
+       MSG_END();
+}
+
+
 void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
 {
        MSG_BEGIN();
@@ -609,9 +762,8 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
        if (!pMsgEvent)
                THROW(MsgException::INVALID_PARAM, "pMsgEvent is NULL");
 
-       if (pMsgEvent->eventType == MSG_EVENT_PLG_SENT_STATUS_CNF)
-       {
-               unsigned int chInfo[3] = {0}; //3// reqid, status, object
+       if (pMsgEvent->eventType == MSG_EVENT_PLG_SENT_STATUS_CNF) {
+               unsigned int chInfo[3] = {0}; /*3 reqid, status, object */
 
                memcpy(&chInfo, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(chInfo));
 
@@ -625,8 +777,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
 
                MsgSentStatusCBList::iterator it = sentStatusCBList.begin();
 
-               for( ; it != sentStatusCBList.end() ; it++)
-               {
+               for ( ; it != sentStatusCBList.end() ; it++) {
                        MsgHandle* pHandle = it->hAddr;
 
                        msg_sent_status_cb pfunc = it->pfSentStatusCB;
@@ -637,9 +788,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
                }
 
                mx.unlock();
-       }
-       else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MSG_IND )
-       {
+       } else if (pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MSG_IND) {
                MSG_MESSAGE_INFO_S msgInfo;
                memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
 
@@ -655,10 +804,8 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
                MsgNewMessageCBList::iterator it = newMessageCBList.begin();
                MsgNewMessageCBList matchList;
 
-               for( ; it != newMessageCBList.end() ; it++)
-               {
-                       if( portKey == it->port)
-                       {
+               for ( ; it != newMessageCBList.end() ; it++) {
+                       if ( portKey == it->port) {
                                matchList.push_back(*it);
                        }
                }
@@ -667,8 +814,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
 
                it = matchList.begin();
 
-               for( ; it != matchList.end(); it++ )
-               {
+               for ( ; it != matchList.end(); it++ ) {
                        MsgHandle* pHandle = it->hAddr;
 
                        MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
@@ -719,10 +865,9 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
                        if (msgHidden.pMmsData != NULL)
                                delete [] (char*)msgHidden.pMmsData;
 
-                       // address Memory Free
-                       if (msgHidden.addr_list!= NULL)
-                       {
-                               for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
+                       /* address Memory Free */
+                       if (msgHidden.addr_list!= NULL) {
+                               for (int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
                                        msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
                                        delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
                                        addrInfo->data = NULL;
@@ -738,9 +883,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
 
                }
 
-       }
-       else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MMS_CONF )
-       {
+       } else if (pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MMS_CONF) {
                MSG_MESSAGE_INFO_S msgInfo;
                memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
 
@@ -759,25 +902,22 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
                MsgNewMMSConfMessageCBList::iterator it = newMMSConfMessageCBList.begin();
                MsgNewMMSConfMessageCBList matchList;
 
-               for( ; it != newMMSConfMessageCBList.end() ; it++)
-               {
-                       if(appIdKey)
-                       {
-                               if(!strcmp(appIdKey, it->appId))
+               for ( ; it != newMMSConfMessageCBList.end(); it++) {
+                       if (appIdKey) {
+                               if (!strcmp(appIdKey, it->appId))
                                        matchList.push_back(*it);
-                       }
-                       else//(appIdKey == NULL && it->appId[0] == 0)
-                       {
-                               if(it->appId[0] == 0)
+                       } else {
+                               /* (appIdKey == NULL && it->appId[0] == 0) */
+                               if (it->appId[0] == 0)
                                        matchList.push_back(*it);
                        }
                }
 
                mx.unlock();
 
-               // Contents of msgData removed and replaced to retrievedFilePath for convertMsgStruct
-               // it is moved from UpdateMessage in MmsPluginStorage.cpp
-               char tempFileName[MSG_FILENAME_LEN_MAX+1] = {0};  // check MSG_FILENAME_LEN_MAX
+               /* Contents of msgData removed and replaced to retrievedFilePath for convertMsgStruct */
+               /* it is moved from UpdateMessage in MmsPluginStorage.cpp */
+               char tempFileName[MSG_FILENAME_LEN_MAX+1] = {0}; /* check MSG_FILENAME_LEN_MAX */
 
                strncpy(tempFileName, pMmsRecvData->retrievedFilePath, MSG_FILENAME_LEN_MAX);
 
@@ -786,8 +926,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
 
                it = matchList.begin();
 
-               for( ; it != matchList.end() ; it++)
-               {
+               for ( ; it != matchList.end(); it++) {
                        MsgHandle* pHandle = it->hAddr;
 
                        MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
@@ -837,10 +976,9 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
                        if (msgHidden.pMmsData != NULL)
                                delete [] (char*)msgHidden.pMmsData;
 
-                       // address Memory Free
-                       if (msgHidden.addr_list != NULL)
-                       {
-                               for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
+                       /* address Memory Free */
+                       if (msgHidden.addr_list != NULL) {
+                               for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
                                        msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
                                        delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
                                        addrInfo->data = NULL;
@@ -854,17 +992,14 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
                                msgHidden.addr_list = NULL;
                        }
 
-                       // Here the retrieved message will be deleted from native storage.
-                       // as of now, msg which have appId is considered as JAVA MMS message and it will be sent and handled in JAVA app.
-                       if(appIdKey)
-                       {
+                       /* Here the retrieved message will be deleted from native storage. */
+                       /* as of now, msg which have appId is considered as JAVA MMS message and it will be sent and handled in JAVA app. */
+                       if (appIdKey) {
                                MSG_DEBUG("delete received JAVA MMS message:%s from native storage",tempFileName);
                                pHandle->deleteMessage(msgInfo.msgId);
                        }
                }
-       }
-       else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND )
-       {
+       } else if (pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND) {
                MSG_SYNCML_MESSAGE_DATA_S* pSyncMLData = (MSG_SYNCML_MESSAGE_DATA_S *)pMsgEvent->data;
 
                MSG_DEBUG("msgType [%d]", pSyncMLData->syncmlType);
@@ -873,8 +1008,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
 
                MsgNewSyncMLMessageCBList::iterator it = newSyncMLMessageCBList.begin();
 
-               for( ; it != newSyncMLMessageCBList.end() ; it++)
-               {
+               for ( ; it != newSyncMLMessageCBList.end(); it++) {
                        MsgHandle* pHandle = it->hAddr;
 
                        msg_syncml_msg_incoming_cb pfunc = it->pfSyncMLIncomingCB;
@@ -885,17 +1019,14 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
                }
 
                mx.unlock();
-       }
-       else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_LBS_MSG_IND )
-       {
+       } else if (pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_LBS_MSG_IND) {
                MSG_LBS_MESSAGE_DATA_S* pLBSData = (MSG_LBS_MESSAGE_DATA_S *)pMsgEvent->data;
 
                mx.lock();
 
                MsgNewLBSMessageCBList::iterator it = newLBSMessageCBList.begin();
 
-               for( ; it != newLBSMessageCBList.end() ; it++)
-               {
+               for ( ; it != newLBSMessageCBList.end(); it++) {
                        MsgHandle* pHandle = it->hAddr;
 
                        msg_lbs_msg_incoming_cb pfunc = it->pfLBSMsgIncoming;
@@ -906,9 +1037,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
                }
 
                mx.unlock();
-       }
-       else if ( pMsgEvent->eventType == MSG_EVENT_SYNCML_OPERATION )
-       {
+       } else if (pMsgEvent->eventType == MSG_EVENT_SYNCML_OPERATION) {
                int msgId;
                int extId;
 
@@ -922,8 +1051,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
 
                MsgOperationSyncMLMessageCBList::iterator it = operationSyncMLMessageCBList.begin();
 
-               for( ; it != operationSyncMLMessageCBList.end() ; it++)
-               {
+               for ( ; it != operationSyncMLMessageCBList.end(); it++) {
                        MsgHandle* pHandle = it->hAddr;
 
                        msg_syncml_msg_operation_cb pfunc = it->pfSyncMLOperationCB;
@@ -934,18 +1062,16 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
                }
 
                mx.unlock();
-       }
-       else if (pMsgEvent->eventType == MSG_EVENT_PLG_STORAGE_CHANGE_IND)
-       {
+       } else if (pMsgEvent->eventType == MSG_EVENT_PLG_STORAGE_CHANGE_IND) {
                msg_storage_change_type_t storageChangeType;
                msg_id_list_s msgIdList;
                memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
 
-               // Decode event data
+               /* Decode event data */
                memcpy(&storageChangeType, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(msg_storage_change_type_t));
                memcpy(&msgIdList.nCount, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(msg_storage_change_type_t)), sizeof(int));
 
-               if(msgIdList.nCount > 0)
+               if (msgIdList.nCount > 0)
                        msgIdList.msgIdList = (msg_message_id_t*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(msg_storage_change_type_t)+sizeof(int));
                else
                        msgIdList.msgIdList = NULL;
@@ -956,8 +1082,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
 
                MsgStorageChangeCBList::iterator it = storageChangeCBList.begin();
 
-               for( ; it != storageChangeCBList.end() ; it++)
-               {
+               for ( ; it != storageChangeCBList.end(); it++) {
                        MsgHandle* pHandle = it->hAddr;
 
                        msg_storage_change_cb pfunc = it->pfStorageChangeCB;
@@ -968,18 +1093,14 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
                }
 
                mx.unlock();
-       }
-
-       else if (pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_CB_MSG_IND)
-       {
+       } else if (pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_CB_MSG_IND) {
                MSG_CB_MSG_S *pCbMsg = (MSG_CB_MSG_S *)pMsgEvent->data;
 
                mx.lock();
 
                MsgNewCBMessageCBList::iterator it = newCBMessageCBList.begin();
 
-               for( ; it != newCBMessageCBList.end() ; it++)
-               {
+               for ( ; it != newCBMessageCBList.end(); it++) {
                        MsgHandle* pHandle = it->hAddr;
                        msg_struct_s msg = {0,};
 
@@ -994,39 +1115,32 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
                }
 
                mx.unlock();
-       }
-
-       else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND )
-       {
+       } else if (pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND) {
                MSG_PUSH_MESSAGE_DATA_S* pPushData = (MSG_PUSH_MESSAGE_DATA_S *)pMsgEvent->data;
 
                mx.lock();
 
                MsgNewPushMessageCBList::iterator it = newPushMessageCBList.begin();
 
-               for( ; it != newPushMessageCBList.end() ; it++)
-               {
+               for ( ; it != newPushMessageCBList.end(); it++) {
                        MsgHandle* pHandle = it->hAddr;
 
                        msg_push_msg_incoming_cb pfunc = it->pfPushIncomingCB;
 
                        void* param = it->userParam;
 
-                       if(!strncmp(it->appId, pPushData->pushAppId, MAX_WAPPUSH_ID_LEN))
+                       if (!strncmp(it->appId, pPushData->pushAppId, MAX_WAPPUSH_ID_LEN))
                                pfunc((msg_handle_t)pHandle, pPushData->pushHeader, pPushData->pushBody, pPushData->pushBodyLen, param);
                }
 
                mx.unlock();
-       }
-
-       else if (pMsgEvent->eventType == MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND)
-       {
+       } else if (pMsgEvent->eventType == MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND) {
                msg_report_type_t reportType;
                msg_message_id_t msgId;
                int addr_len;
                char *addr_val;
 
-               // Decode event data
+               /* Decode event data */
                memcpy(&reportType, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(msg_report_type_t));
                memcpy(&msgId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(msg_report_type_t)), sizeof(msg_message_id_t));
                memcpy(&addr_len, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(msg_report_type_t)+sizeof(msg_message_id_t)), sizeof(int));
@@ -1039,8 +1153,7 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
 
                MsgReportMessageCBList::iterator it = reportMessageCBList.begin();
 
-               for( ; it != reportMessageCBList.end() ; it++)
-               {
+               for ( ; it != reportMessageCBList.end(); it++) {
                        MsgHandle* pHandle = it->hAddr;
 
                        msg_report_msg_incoming_cb pfunc = it->pfReportMsgIncomingCB;
@@ -1057,58 +1170,95 @@ void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
 }
 
 
-int  MsgProxyListener::getRemoteFd()
+int MsgProxyListener::getRemoteFd()
 {
-       MSG_BEGIN();
-       //MutexLocker lock(mx);
+       return cliSock.getRemoteFd();
+}
 
-       int tmpFd = -1;
-       int ret = mx.timedlock();
 
-       if (ret != 0) {
-               MSG_DEBUG("mx.timedlock fail [%d]", ret);
-               return tmpFd;
-       }
+int MsgProxyListener::readFromSocket(char** buf, unsigned int* len)
+{
+       return cliSock.read(buf, len);
+}
 
-       tmpFd = cliSock.getRemoteFd();
 
-       MSG_DEBUG("listener fd [%d]", tmpFd);
+void MsgProxyListener::resetProxyListener()
+{
+       MSG_DEBUG("client Listener reset");
+       MutexLocker lock(mx);
 
-       if( tmpFd == -1 ) {
-               ret = cv.timedwait(mx.pMutex(),1);
+       if (channel) {
+               g_io_channel_unref(channel);
+               channel = NULL;
        }
 
-       if (ret == ETIMEDOUT) {
-               MSG_DEBUG("get listener fd TIME-OUT");
-               mx.unlock();
-               return tmpFd;
+       if (eventSourceId > 0) {
+               g_source_remove(eventSourceId);
+               eventSourceId = 0;
        }
 
-       tmpFd = cliSock.getRemoteFd();
-       mx.unlock();
+       running = 0;
 
-       MSG_END();
+       cliSock.close();
 
-       return tmpFd;
+       handle_set::iterator it = openHandleSet.begin();
+       for (; it != openHandleSet.end(); it++) {
+               MSG_DEBUG("disconnect socket for opened handle [%p]", it);
+               MsgHandle *handle = (MsgHandle *)*it;
+               handle->disconnectSocket();
+       }
 }
 
 
-int MsgProxyListener::readFromSocket(char** buf, unsigned int* len)
-{
-       return cliSock.read(buf, len);
-}
-
-void MsgProxyListener::resetProxyListener()
+void MsgProxyListener::refreshProxyListener()
 {
-       MSG_BEGIN();
+       MSG_DEBUG("refresh proxy listener");
        MutexLocker lock(mx);
+
        handle_set::iterator it = openHandleSet.begin();
        for (; it != openHandleSet.end(); it++) {
                MsgHandle *handle = (MsgHandle *)*it;
-               clearListOfClosedHandle(handle);
+               handle->openHandle();
+               refreshListOfOpenedHandle(handle);
+       }
+}
+
+
+void MsgProxyListener::clearProxyCBLists()
+{
+       MSG_DEBUG("clear proxy callback list");
+
+       sentStatusCBList.clear();
+       newMessageCBList.clear();
+       newMMSConfMessageCBList.clear();
+       newSyncMLMessageCBList.clear();
+       newLBSMessageCBList.clear();
+       newPushMessageCBList.clear();
+       newCBMessageCBList.clear();
+       newSyncMLMessageCBList.clear();
+       storageChangeCBList.clear();
+       reportMessageCBList.clear();
+}
+
+
+void MsgProxyListener::insertOpenHandleSet(MsgHandle* pMsgHandle)
+{
+       MSG_DEBUG("try to insert opened handle. handle=[%p]", pMsgHandle);
+
+       MutexLocker lock(mx);
+
+       handle_set::iterator it = openHandleSet.find(pMsgHandle);
+       if (it == openHandleSet.end()) {
+               openHandleSet.insert(pMsgHandle);
+               MSG_DEBUG("New handle is added. current count = [%d]", openHandleSet.size());
        }
+}
+
+
+void MsgProxyListener::clearOpenHandleSet()
+{
+       MSG_DEBUG("clear opened handle set");
        openHandleSet.clear();
-       MSG_END();
 }
 
 #ifdef CHECK_SENT_STATUS_CALLBACK
index 447a641..5e6b222 100755 (executable)
@@ -15,6 +15,7 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -O2 -g -Wall")
 ##########################################################
 
 SET(UTILS-SRCS
+       ${CMAKE_SOURCE_DIR}/utils/MsgCallStatusManager.cpp
        ${CMAKE_SOURCE_DIR}/utils/MsgDebug.cpp
        ${CMAKE_SOURCE_DIR}/utils/MsgException.cpp
        ${CMAKE_SOURCE_DIR}/utils/MsgUtilFunction.cpp
@@ -32,6 +33,7 @@ SET(UTILS-SRCS
        ${CMAKE_SOURCE_DIR}/utils/MsgJsonParser.cpp
        ${CMAKE_SOURCE_DIR}/utils/MsgSerialize.cpp
        ${CMAKE_SOURCE_DIR}/utils/MsgSmil.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgUtilMime.cpp
 )
 
 INCLUDE_DIRECTORIES(
@@ -44,7 +46,7 @@ INCLUDE_DIRECTORIES(
 
 INCLUDE(FindPkgConfig)
 
-SET(PKG_MODULES glib-2.0 vconf db-util contacts-service2 dlog libxml-2.0 storage json-glib-1.0 capi-system-info libsmack)
+SET(PKG_MODULES glib-2.0 vconf contacts-service2 dlog libxml-2.0 storage json-glib-1.0 capi-system-info capi-media-thumbnail-util capi-media-image-util capi-content-media-content aul sqlite3 capi-media-metadata-extractor icu-uc)
 pkg_check_modules(utils_pkgs REQUIRED ${PKG_MODULES})
 
 FOREACH(flag ${utils_pkgs_CFLAGS})
diff --git a/utils/MsgCallStatusManager.cpp b/utils/MsgCallStatusManager.cpp
new file mode 100644 (file)
index 0000000..27f3475
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include "MsgCallStatusManager.h"
+#include "MsgDebug.h"
+#include "MsgInternalTypes.h"
+#include "MsgGconfWrapper.h"
+
+GDBusConnection *call_status_gdbus_conn = NULL;
+GDBusProxy *call_status_gdbus_proxy = NULL;
+gint call_status_subs_id = 0;
+gint call_status = 0;
+
+static void call_status_change_received(GDBusConnection *connection, const gchar *sender_name,
+               const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
+               GVariant *parameters, gpointer user_data)
+{
+       MSG_DEBUG("signal_name = [%s]", signal_name);
+
+       if (g_strcmp0(signal_name, CALL_MGR_MEMBER_NAME) == 0) {
+               g_variant_get(parameters, "(iis)", &call_status, NULL, NULL);
+               MSG_INFO("callStatus = [%d]", call_status);
+               if (call_status == 0)
+                       MsgSettingSetInt(MSG_MESSAGE_DURING_CALL, 0); //call not active
+               else
+                       MsgSettingSetInt(MSG_MESSAGE_DURING_CALL, 1); //call active ( call_status: 2 [Ringing], call_status: 1 [In call])
+       }
+}
+
+void MsgInitCallStatusManager()
+{
+       MSG_BEGIN();
+
+       GError *error = NULL;
+
+       if (call_status_gdbus_conn) {
+               g_object_unref(call_status_gdbus_conn);
+               call_status_gdbus_conn = NULL;
+       }
+
+       call_status_gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (error) {
+               MSG_FATAL("g_bus_get_sync() failed : %s", error->message);
+               g_error_free(error);
+               error = NULL;
+               goto _DBUS_ERROR;
+       }
+
+       if (call_status_gdbus_proxy) {
+               g_object_unref(call_status_gdbus_proxy);
+               call_status_gdbus_proxy = NULL;
+       }
+
+       call_status_gdbus_proxy = g_dbus_proxy_new_sync(call_status_gdbus_conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                       NULL, CALL_MGR_BUS_NAME, CALL_MGR_PATH_NAME, CALL_MGR_INTERFACE_NAME, NULL, &error);
+       if (error) {
+               MSG_FATAL("g_dbus_proxy_new_sync() failed : %s", error->message);
+               g_error_free(error);
+               error = NULL;
+               goto _DBUS_ERROR;
+       }
+
+       call_status_subs_id = g_dbus_connection_signal_subscribe(call_status_gdbus_conn, NULL,
+                                                       CALL_MGR_INTERFACE_NAME, CALL_MGR_MEMBER_NAME, CALL_MGR_PATH_NAME,
+                                                       NULL, G_DBUS_SIGNAL_FLAGS_NONE,
+                                                       call_status_change_received, NULL, NULL);
+       MSG_END();
+       return;
+
+_DBUS_ERROR:
+       if (call_status_gdbus_conn) {
+               g_object_unref(call_status_gdbus_conn);
+               call_status_gdbus_conn = NULL;
+       }
+
+       if (call_status_gdbus_proxy) {
+               g_object_unref(call_status_gdbus_proxy);
+               call_status_gdbus_proxy = NULL;
+       }
+
+       MSG_END();
+       return;
+}
+
+void MsgDeInitCallStatusManager()
+{
+       if (call_status_subs_id) {
+               g_dbus_connection_signal_unsubscribe(call_status_gdbus_conn, call_status_subs_id);
+               call_status_subs_id = 0;
+       }
+
+       if (call_status_gdbus_conn) {
+               g_object_unref(call_status_gdbus_conn);
+               call_status_gdbus_conn = NULL;
+       }
+
+       if (call_status_gdbus_proxy) {
+               g_object_unref(call_status_gdbus_proxy);
+               call_status_gdbus_proxy = NULL;
+       }
+}
+
+int MsgGetCallStatus()
+{
+       /* call_status is defined in <call-manager.h> in callmgr_client package.
+        * typedef enum {
+        *  CM_CALL_STATUS_IDLE,
+        *  CM_CALL_STATUS_RINGING,
+        *  CM_CALL_STATUS_OFFHOOK,
+        *  CM_CALL_STATUS_MAX
+        * } cm_call_status_e;
+        */
+       return (int)call_status;
+}
index c038b9f..44a3820 100755 (executable)
@@ -717,7 +717,17 @@ void MsgAddPhoneLog(const MSG_MESSAGE_INFO_S *pMsgInfo)
                                strncpy(strText, pMsgInfo->subject, 100);
                                MSG_SEC_DEBUG("subject : %s", strText);
                        } else {
-                               strncpy(strText, pMsgInfo->msgText, 100);
+                               char *pFileData = NULL;
+                               gsize fileSize = 0;
+
+                               if (pMsgInfo->msgText[0] != '\0' && g_file_get_contents(pMsgInfo->msgText, &pFileData, &fileSize, NULL) == true) {
+                                       if (pFileData)
+                                               strncpy(strText, pFileData, 100);
+                               }
+
+                               if (pFileData)
+                                       g_free(pFileData);
+
                                MSG_SEC_DEBUG("msgText : %s", strText);
                        }
                }
index 1e436f1..f582248 100755 (executable)
@@ -210,6 +210,8 @@ const char * MsgDbgCmdStr(MSG_CMD_TYPE_T cmdType)
                return "MSG_CMD_REG_REPORT_MSG_INCOMING_CB";
        case MSG_CMD_UPDATE_IMSI:
                return "MSG_CMD_UPDATE_IMSI";
+       case MSG_CMD_SET_TEMP_ADDRESS_TABLE:
+               return "MSG_CMD_SET_TEMP_ADDRESS_TABLE";
 
 #ifdef FEATURE_SMS_CDMA
        case MSG_CMD_PLG_CHECK_UNIQUENESS:
@@ -412,6 +414,8 @@ const char * MsgDbgEvtStr(MSG_EVENT_TYPE_T evtType)
                return "MSG_EVENT_REG_REPORT_MSG_INCOMING_CB";
        case MSG_EVENT_UPDATE_IMSI:
                return "MSG_EVENT_UPDATE_IMSI";
+       case MSG_EVENT_SET_TEMP_ADDRESS_TABLE:
+               return "MSG_EVENT_SET_TEMP_ADDRESS_TABLE";
 
 #ifdef FEATURE_SMS_CDMA
        case MSG_EVENT_PLG_CHECK_UNIQUENESS:
index ca6cde2..564220f 100755 (executable)
@@ -98,8 +98,8 @@ msg_error_t MsgIpcClientSocket::connect(const char* path)
 msg_error_t MsgIpcClientSocket::close()
 {
        if (sockfd < 0) {
-               MSG_FATAL("Client socket is not opened (check if you call close twice by accident) [%d]", sockfd);
-               return MSG_ERR_UNKNOWN;
+               MSG_DEBUG("Client socket is not opened or already closed");
+               return MSG_SUCCESS;
        }
 
        /* it means that client is going to close the connection.*/
@@ -110,6 +110,7 @@ msg_error_t MsgIpcClientSocket::close()
        bzero(cmdbuf, len);
        memcpy(cmdbuf, &cmd, len);
 
+       MSG_DEBUG("client socket [%d] will be closed", sockfd);
        ::close(sockfd);
        sockfd = CUSTOM_SOCKET_ERROR;
 
@@ -178,10 +179,12 @@ int MsgIpcClientSocket::readn( char *buf, unsigned int len )
 {
        unsigned int nleft;
        int nread;
+       char t_buf[len];
 
        nleft = len;
        while (nleft > 0) {
-               nread = ::read(sockfd, (void*) buf, nleft);
+               memset(t_buf, 0x00, len);
+               nread = ::read(sockfd, t_buf, nleft);
                if (nread < 0) {
                        MSG_FATAL("WARNING read value %d: %s", nread, g_strerror(errno));
                        return nread;
@@ -190,6 +193,7 @@ int MsgIpcClientSocket::readn( char *buf, unsigned int len )
                }
 
                nleft -= nread;
+               memcpy(buf, t_buf, nread);
                buf += nread;
        }
 
index 2c1a8cb..49fea89 100755 (executable)
 
 static char root_key[5] = "root";
 
+msg_json_gen_object* msg_json_gen_new_obj(msg_json_gen_type type)
+{
+       void *json_value = NULL;
+       switch(type) {
+       case MSG_JSON_GEN_OBJECT:
+               json_value = (void *)json_object_new();
+               break;
+       case MSG_JSON_GEN_ARRAY:
+               json_value = (void *)json_array_new();
+               break;
+       default:
+               break;
+       }
+       if (json_value != NULL) {
+               msg_json_gen_object *new_obj = NULL;
+               new_obj = (msg_json_gen_object *)g_try_malloc0(sizeof(msg_json_gen_object));
+
+               if (new_obj == NULL) {
+                       g_object_unref(json_value);
+                       return NULL;
+               }
+
+               new_obj->type = type;
+               new_obj->value = json_value;
+               return new_obj;
+       }
+       return NULL;
+}
+
+void msg_json_gen_free_obj(msg_json_gen_object *obj)
+{
+       if (obj == NULL) {
+               return;
+       }
+       if (obj->value != NULL) {
+               g_object_unref(obj->value);
+               obj->value = NULL;
+       }
+       g_free(obj);
+       obj = NULL;
+}
+
+void msg_json_gen_set_child(msg_json_gen_object *parent, const char *key, msg_json_gen_object *child) {
+       if (parent == NULL || child == NULL)
+       {
+               return;
+       }
+       switch(parent->type) {
+       case MSG_JSON_GEN_OBJECT:
+               if (key == NULL) {
+                       return;
+               }
+               switch(child->type) {
+               case MSG_JSON_GEN_OBJECT:
+                       json_object_set_object_member((JsonObject *)parent->value, key, (JsonObject *)child->value);
+                       break;
+               case MSG_JSON_GEN_ARRAY:
+                       json_object_set_array_member((JsonObject *)parent->value, key, (JsonArray *)child->value);
+                       break;
+               }
+               break;
+       case MSG_JSON_GEN_ARRAY:
+               switch(child->type) {
+               case MSG_JSON_GEN_OBJECT:
+                       json_array_add_object_element((JsonArray *)parent->value, (JsonObject *)child->value);
+                       break;
+               case MSG_JSON_GEN_ARRAY:
+                       json_array_add_array_element((JsonArray *)parent->value, (JsonArray *)child->value);
+                       break;
+               }
+               break;
+       }
+}
+
+void msg_json_gen_set_value(msg_json_gen_object *parent, const char *key, long long int value) {
+       if (parent == NULL)
+       {
+               return;
+       }
+       switch(parent->type) {
+       case MSG_JSON_GEN_OBJECT:
+               if (key == NULL) {
+                       return;
+               }
+               json_object_set_int_member((JsonObject *)parent->value, key, value);
+               break;
+       case MSG_JSON_GEN_ARRAY:
+               json_array_add_int_element((JsonArray *)parent->value, value);
+               break;
+       }
+}
+
+void msg_json_gen_set_value(msg_json_gen_object *parent, const char *key, const char *value) {
+       if (parent == NULL)
+       {
+               return;
+       }
+       switch(parent->type) {
+       case MSG_JSON_GEN_OBJECT:
+               if (key == NULL) {
+                       return;
+               }
+               json_object_set_string_member((JsonObject *)parent->value, key, value);
+               break;
+       case MSG_JSON_GEN_ARRAY:
+               json_array_add_string_element((JsonArray *)parent->value, value);
+               break;
+       }
+}
+
+char* msg_json_gen_make_json_msg(msg_json_gen_object *root_obj, unsigned long *len) {
+       if (root_obj == NULL)
+       {
+               return NULL;
+       }
+       JsonGenerator *generator = json_generator_new();
+       JsonNode *root = json_node_new(JSON_NODE_OBJECT);
+
+       json_node_take_object(root, (JsonObject *)root_obj->value);
+       json_generator_set_root(generator, root);
+
+       char *json_msg = json_generator_to_data(generator, (gsize *)len);
+       g_object_unref(generator);
+       json_node_free(root);
+
+       return json_msg;
+}
+
 int msg_json_parser_get_value(msg_json_parser_object *json_obj)
 {
        GValue value = { 0 };
@@ -36,6 +164,9 @@ int msg_json_parser_get_value(msg_json_parser_object *json_obj)
                return -1;
        }
 
+       json_obj->float_value = 0;
+       json_obj->number_value = 0;
+
        json_node_get_value((JsonNode *) json_obj->value, &value);
 
        switch (json_node_get_value_type((JsonNode *) json_obj->value)) {
@@ -43,7 +174,6 @@ int msg_json_parser_get_value(msg_json_parser_object *json_obj)
                {
                        json_obj->type = MSG_JSON_PARSER_STRING;
                        json_obj->value = (void *)g_value_get_string(&value);
-                       json_obj->number_value = 0;
                }
                break;
        case G_TYPE_INT:
@@ -85,7 +215,7 @@ int msg_json_parser_get_value(msg_json_parser_object *json_obj)
                {
                        json_obj->type = MSG_JSON_PARSER_REAL;
                        json_obj->value = NULL;
-                       json_obj->number_value = (double)g_value_get_double(&value);
+                       json_obj->float_value = (double)g_value_get_double(&value);
                }
                break;
        default:
@@ -110,6 +240,9 @@ int msg_json_parser_object_get_value(msg_json_parser_object *json_obj)
        }
        node = json_object_get_member((JsonObject *)json_obj->value, json_obj->key);
 
+       json_obj->float_value = 0;
+       json_obj->number_value = 0;
+
        json_node_get_value((JsonNode *) node, &value);
 
        switch (json_node_get_value_type((JsonNode *) node)) {
@@ -117,7 +250,6 @@ int msg_json_parser_object_get_value(msg_json_parser_object *json_obj)
                {
                        json_obj->type = MSG_JSON_PARSER_STRING;
                        json_obj->value = (void *)g_value_get_string(&value);
-                       json_obj->number_value = 0;
                }
                break;
        case G_TYPE_INT:
@@ -159,7 +291,7 @@ int msg_json_parser_object_get_value(msg_json_parser_object *json_obj)
                {
                        json_obj->type = MSG_JSON_PARSER_REAL;
                        json_obj->value = NULL;
-                       json_obj->number_value = (double)g_value_get_double(&value);
+                       json_obj->float_value = (double)g_value_get_double(&value);
                }
                break;
        default:
@@ -490,7 +622,7 @@ int msg_json_parser_get_child_by_name(const msg_json_parser_object *parent,
        return lReturn;
 }
 
-#if 0
+
 /**
  * @fn msg_json_parser_get_child_count
  * This function returns the count for a specified JSON object.
@@ -550,4 +682,4 @@ int msg_json_parser_get_child_count(msg_json_parser_object *object)
        MSG_DEBUG("COUNT :: %d ", count);
        return count;
 }
-#endif
+
index 248d263..33c5538 100755 (executable)
@@ -26,6 +26,7 @@
 #include "MsgUtilFile.h"
 #include "MsgMmsMessage.h"
 #include "MsgUtilFile.h"
+#include "MsgUtilFunction.h"
 #include "MsgSmil.h"
 #include "MsgDebug.h"
 #include "MsgSerialize.h"
@@ -1226,7 +1227,15 @@ static bool IsMatchedMedia(MMS_MEDIA_S *media, MMS_MULTIPART_DATA_S *pMultipart)
                removeLessGreaterMark(pMultipart->szContentID, szTempContentID, sizeof(szTempContentID));
 
                if (strcmp(media->szContentID, szTempContentID) == 0) {
-                       return true;
+                       if (strlen(media->szContentLocation) > 0 && strlen(pMultipart->szContentLocation) > 0) {
+                               if (strcmp(media->szContentLocation,  pMultipart->szContentLocation) == 0) {
+                                       return true;
+                               } else {
+                                       /* go through */
+                               }
+                       } else {
+                               return true;
+                       }
                }
 
                if (strcmp(media->szContentLocation,  szTempContentID) == 0) {
@@ -1512,6 +1521,9 @@ int MsgMmsSetMultipartFilePath(const char *dirPath, MMS_MULTIPART_DATA_S *pMulti
 
        snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), "%s/%s", dirPath, pMultipart->szFileName);
 
+       /* remove space character of original file name */
+       msg_replace_space_char(pMultipart->szFilePath);
+
        if (!MsgCreateFile (pMultipart->szFilePath, pMultipart->pMultipartData, pMultipart->nMultipartDataLen)) {
                MSG_SEC_DEBUG("Fail to set content to file [%s]", pMultipart->szFilePath);
                return -1;
@@ -1701,16 +1713,17 @@ int MsgMmsCheckFilepathSmack(int fd, const char* ipc_filename)
                return MSG_ERR_PERMISSION_DENIED;
        }
 
-       MSG_DEBUG("app_smack_label [%s]", app_smack_label);
+       MSG_SEC_DEBUG("app_smack_label [%s]", app_smack_label);
 
        char ipc_filepath[MSG_FILEPATH_LEN_MAX+1] = {0,};
        snprintf(ipc_filepath, MSG_FILEPATH_LEN_MAX, "%s%s", MSG_IPC_DATA_PATH, ipc_filename);
 
        gchar *serialized_data = NULL;
        gsize serialized_len = 0;
-       MSG_DEBUG("ipc_path [%s]", ipc_filepath);
+       MSG_SEC_DEBUG("ipc_path [%s]", ipc_filepath);
 
        if (!g_file_get_contents((gchar*)ipc_filepath, (gchar**)&serialized_data, (gsize*)&serialized_len, NULL)) {
+               MSG_FREE(app_smack_label);
                return MSG_ERR_PERMISSION_DENIED;
        }
 
@@ -1730,6 +1743,9 @@ int MsgMmsCheckFilepathSmack(int fd, const char* ipc_filename)
                                }
                        }
                }
+               if (err == MSG_SUCCESS && mms_data->smil) {
+                       err = MsgCheckFilepathSmack(app_smack_label, mms_data->smil->szFilePath);
+               }
                MsgMmsRelease(&mms_data);
        } else {
                err = MSG_ERR_INVALID_PARAMETER;
index ca84e03..b0ae5aa 100755 (executable)
@@ -720,7 +720,7 @@ int MsgSerializeMms(const MMS_DATA_S *pMsgData, char **pValue)
 
                if (pMsgData->smil->pMultipartData) {
                        memcpy(buf + offset, pMsgData->smil->pMultipartData, sizeof(char)*pMsgData->smil->nMultipartDataLen);
-                       MSG_DEBUG("[#%2d][%5d] smil data = %s", serial_index++, offset, pMsgData->smil->pMultipartData);
+                       MSG_SEC_DEBUG("[#%2d][%5d] smil data = %s", serial_index++, offset, pMsgData->smil->pMultipartData);
                        offset += sizeof(char)*pMsgData->smil->nMultipartDataLen;
                }
        }
@@ -741,7 +741,7 @@ int MsgSerializeMms(const MMS_DATA_S *pMsgData, char **pValue)
                                memcpy(buf + offset, multipart_data, sizeof(MMS_MULTIPART_DATA_S));
                                offset += sizeof(MMS_MULTIPART_DATA_S);
 
-                               MSG_DEBUG("Multipart file path = [%s]", multipart_data->szFilePath);
+                               MSG_SEC_DEBUG("Multipart file path = [%s]", multipart_data->szFilePath);
 
                                if (multipart_data->pMultipartData) {
                                        memcpy(buf + offset, multipart_data->pMultipartData, sizeof(char)*multipart_data->nMultipartDataLen);
@@ -880,7 +880,7 @@ int MsgDeserializeMmsData(char* value, int value_len, MMS_DATA_S **ppMmsData)
                memcpy(pMmsData->smil, value + offset, sizeof(MMS_MULTIPART_DATA_S));
                offset += sizeof(MMS_MULTIPART_DATA_S);
 
-               MSG_DEBUG("SMIL file path = [%s]", pMmsData->smil->szFilePath);
+               MSG_SEC_DEBUG("SMIL file path = [%s]", pMmsData->smil->szFilePath);
                MSG_DEBUG("SMIL nMultipartDataLen = [%d]", pMmsData->smil->nMultipartDataLen);
 
                if (pMmsData->smil->nMultipartDataLen > 0) {
@@ -916,7 +916,7 @@ int MsgDeserializeMmsData(char* value, int value_len, MMS_DATA_S **ppMmsData)
                        memcpy(multipart_data, value + offset, sizeof(MMS_MULTIPART_DATA_S));
                        offset += sizeof(MMS_MULTIPART_DATA_S);
 
-                       MSG_DEBUG("Multipart file path = [%s]", multipart_data->szFilePath);
+                       MSG_SEC_DEBUG("Multipart file path = [%s]", multipart_data->szFilePath);
 
                        if (multipart_data->nMultipartDataLen > 0) {
                                multipart_data->pMultipartData = (char *)calloc(1, sizeof(char)*multipart_data->nMultipartDataLen);
index 914bdee..635e62c 100755 (executable)
@@ -21,6 +21,7 @@
 #include "MsgMmsMessage.h"
 #include "MsgInternalTypes.h"
 #include "MsgSmil.h"
+#include "MsgUtilFunction.h"
 #include "MsgDebug.h"
 
 #define INVALID_HOBJ   -1
@@ -957,7 +958,7 @@ bool MsgSmilAddRegion(HMsgSmil hSmilDoc, MMS_SMIL_REGION *pstSmilRegion)
        }
 }
 
-bool MsgSmilAddMedia( HMsgSmil hSmilDoc, int nPageNo, int nMediaIdx, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
+bool MsgSmilAddMedia(HMsgSmil hSmilDoc, int nPageNo, int nMediaIdx, MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
 {
        int nSmilDocNo = hSmilDoc;
 
@@ -1000,7 +1001,20 @@ bool MsgSmilAddMedia( HMsgSmil hSmilDoc, int nPageNo, int nMediaIdx, MMS_MEDIA_S
                else
                        snprintf(pszContentID, MSG_MSG_ID_LEN+1, "%lu_%lu", (unsigned long)nPageNo, (unsigned long)nMediaIdx);
 
-               snprintf(pstSmilMedia->szContentLocation, sizeof(pstSmilMedia->szContentLocation), "%s", pstSmilMedia->szFileName);
+               /* remove space character in content location */
+               msg_replace_space_char(pstSmilMedia->szFileName);
+
+               memset(pstSmilMedia->szContentLocation, 0, sizeof(pstSmilMedia->szContentLocation));
+               gchar *tmpContentLoc = msg_replace_non_ascii_char(pstSmilMedia->szFileName, '_');
+               if (tmpContentLoc) {
+                       MSG_SEC_DEBUG("tmpContentLoc = [%s]", tmpContentLoc);
+                       snprintf(pstSmilMedia->szContentLocation, sizeof(pstSmilMedia->szContentLocation), "%s", tmpContentLoc);
+                       g_free(tmpContentLoc);
+                       tmpContentLoc = NULL;
+               } else {
+                       MSG_WARN("tmpContentLoc is NULL.");
+                       snprintf(pstSmilMedia->szContentLocation, sizeof(pstSmilMedia->szContentLocation), "%s", pstSmilMedia->szFileName);
+               }
 
                /* Create <media> node and insert set attribute */
                switch (pstSmilMedia->mediatype) {
@@ -1093,7 +1107,7 @@ xmlNode *MsgSmilCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
 
                        if (NULL == pstParam) {
                                MSG_DEBUG("Cannot create <param> node");
-                               return false;
+                               return NULL;
                        }
 
                        xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"foreground-color");
@@ -1109,7 +1123,7 @@ xmlNode *MsgSmilCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
 
                        if (NULL == pstParam) {
                                MSG_DEBUG("Cannot create <param> node");
-                               return false;
+                               return NULL;
                        }
 
                        xmlSetProp(pstParam, (const xmlChar *)"name", (const xmlChar *)"background-color");
@@ -1124,7 +1138,7 @@ xmlNode *MsgSmilCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
                        pstParam = xmlNewNode(NULL, (xmlChar *)"param");
                        if (NULL == pstParam) {
                                MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node");
-                               return false;
+                               return NULL;
                        }
 
                        if (pstSmilMedia->sMedia.sText.nSize  <= MMS_SMIL_FONT_SIZE_SMALL) {
@@ -1147,7 +1161,7 @@ xmlNode *MsgSmilCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
                        pstParam = xmlNewNode(NULL, (xmlChar *)"param");
                        if (NULL == pstParam) {
                                MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node");
-                               return false;
+                               return NULL;
                        }
 
                        snprintf(szSizeBuf, sizeof(szSizeBuf), "%s", "bold");
@@ -1164,7 +1178,7 @@ xmlNode *MsgSmilCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
                        pstParam = xmlNewNode(NULL, (xmlChar *)"param");
                        if (NULL == pstParam) {
                                MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node");
-                               return false;
+                               return NULL;
                        }
 
                        snprintf(szSizeBuf, sizeof(szSizeBuf), "%s", "italic");
@@ -1181,7 +1195,7 @@ xmlNode *MsgSmilCreateTextNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
                        pstParam = xmlNewNode(NULL, (xmlChar *)"param");
                        if (NULL == pstParam) {
                                MSG_DEBUG(" __MmsCreateTextNode: cannot create <param> node");
-                               return false;
+                               return NULL;
                        }
 
                        snprintf(szSizeBuf, sizeof(szSizeBuf), "%s", "underline");
@@ -1240,7 +1254,7 @@ xmlNode *MsgSmilCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
 #endif
                if (strlen(pstSmilMedia->szContentLocation) > 0) {
                        MsgSmilSetAttribute(pstMedia, (char *)"src", pstSmilMedia->szContentLocation); //using content Location in Smil
-                       MSG_DEBUG("[Set Attribute] src : [%s]", pstSmilMedia->szContentLocation);
+                       MSG_SEC_DEBUG("[Set Attribute] src : [%s]", pstSmilMedia->szContentLocation);
                }
 
                if (pstSmilMedia->sMedia.sAVI.nBegin > 0) {
index 374f842..bc2f43a 100755 (executable)
 #include <fcntl.h>
 #include <errno.h>
 #include <pthread.h>
+#include <sqlite3.h>
 
 #include "MsgDebug.h"
 #include "MsgSqliteWrapper.h"
 
-extern "C"
-{
-       #include <db-util.h>
-}
-
-Mutex MsgDbHandler::mx;
+int __msg_db_util_open(const char *pszFilePath, sqlite3 **ppDB, int flags, const char *zVfs);
+int __msg_db_util_close(sqlite3 *pDB);
+void __clear_db_handle(sqlite3 *pDB);
 
 /*==================================================================================================
                                      VARIABLES
@@ -51,6 +49,7 @@ MsgDbHandler::MsgDbHandler()
        stmt   = NULL;
        mmapMx = NULL;
        shm_fd = -1;
+       in_trans = false;
 }
 
 
@@ -72,7 +71,36 @@ msg_error_t MsgDbHandler::connect()
                memset(strDBName, 0x00, sizeof(strDBName));
                snprintf(strDBName, 64, "%s", MSGFW_DB_NAME);
 
-               ret = db_util_open(strDBName, &handle, DB_UTIL_REGISTER_HOOK_METHOD);
+               ret = __msg_db_util_open(strDBName, &handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
+
+               if (ret == SQLITE_OK) {
+                       MSG_DEBUG("DB Connect Success : [%p]", handle);
+                       return MSG_SUCCESS;
+               } else {
+                       MSG_DEBUG("DB Connect Fail [%d]", ret);
+                       return MSG_ERR_DB_CONNECT;
+               }
+       } else {
+               MSG_DEBUG("DB Connect exist : [%p]", handle);
+       }
+
+       return MSG_SUCCESS;
+}
+
+/* Use only in app side */
+msg_error_t MsgDbHandler::connectReadOnly()
+{
+
+       int ret = 0;
+
+       if (handle == NULL) {
+               char strDBName[64];
+
+               memset(strDBName, 0x00, sizeof(strDBName));
+               snprintf(strDBName, 64, "%s", MSGFW_DB_NAME);
+
+               MSG_DEBUG("db_util_open_with_options SQLITE_OPEN_READONLY");
+               ret = __msg_db_util_open(strDBName, &handle, SQLITE_OPEN_READONLY, NULL);
 
                if (ret == SQLITE_OK) {
                        MSG_DEBUG("DB Connect Success : [%p]", handle);
@@ -94,7 +122,7 @@ msg_error_t MsgDbHandler::disconnect()
        int ret = 0;
 
        if (handle != NULL) {
-               ret = db_util_close(handle);
+               ret = __msg_db_util_close(handle);
 
                if (ret == SQLITE_OK) {
                        handle = NULL;
@@ -138,13 +166,9 @@ bool MsgDbHandler::checkTableExist(const char *pTableName)
 
 msg_error_t MsgDbHandler::execQuery(const char *pQuery)
 {
-//     int ret = 0;
-
        if (!pQuery)
                return MSG_ERR_INVALID_PARAMETER;
 
-       MutexLocker lock(mx);
-
        if(connect() != MSG_SUCCESS)
                return MSG_ERR_DB_DISCONNECT;
 
@@ -249,8 +273,15 @@ msg_error_t MsgDbHandler::prepareQuery(const char *pQuery)
        if(connect() != MSG_SUCCESS)
                return MSG_ERR_DB_DISCONNECT;
 
-       if ((ret = sqlite3_prepare_v2(handle, pQuery, strlen(pQuery), &stmt, NULL)) == SQLITE_OK) {
-               MSG_DEBUG("Prepare Query Success");
+       ret = sqlite3_prepare_v2(handle, pQuery, strlen(pQuery), &stmt, NULL);
+
+       if (ret == SQLITE_BUSY) {
+               __clear_db_handle(handle);
+               ret = sqlite3_prepare_v2(handle, pQuery, strlen(pQuery), &stmt, NULL);
+       }
+
+       if (ret == SQLITE_OK) {
+               MSG_DEBUG("Prepare Query Success [%p]", stmt);
                return MSG_SUCCESS;
        } else {
                MSG_ERR("Prepare Query Fail [%d]", ret);
@@ -266,6 +297,7 @@ msg_error_t MsgDbHandler::stepQuery()
 {
        int ret = 0;
 
+       MSG_DEBUG("stepQuery for [%p]", stmt);
        ret = sqlite3_step(stmt);
 
        if (ret == SQLITE_ROW) {
@@ -286,16 +318,27 @@ msg_error_t MsgDbHandler::stepQuery()
 
 void MsgDbHandler::resetQuery()
 {
-       if (stmt)
+       if (stmt) {
+               sqlite3_clear_bindings(stmt);
                sqlite3_reset(stmt);
+       }
 }
 
 
 void MsgDbHandler::finalizeQuery()
 {
-       if(stmt != NULL)
-               sqlite3_finalize(stmt);
+       if(stmt != NULL) {
+               resetQuery();
+               int ret = sqlite3_finalize(stmt);
+               MSG_DEBUG("sqlite3_finalize = [%d]", ret);
+
+               __clear_db_handle(handle);
+       }
+
        stmt = NULL;
+
+       if (in_trans == false)
+               disconnect();
 }
 
 
@@ -387,15 +430,17 @@ msg_error_t MsgDbHandler::beginTrans()
        if(connect() != MSG_SUCCESS)
                return MSG_ERR_DB_DISCONNECT;
 
+#if 0
        if (!mmapMx) {
                getMmapMutex(SHM_FILE_FOR_DB_LOCK);
        }
        shm_mutex_timedlock(2);
-
-       ret = sqlite3_exec(handle, "BEGIN DEFERRED TRANSACTION;", 0, 0, NULL);
+#endif
+       ret = sqlite3_exec(handle, "BEGIN IMMEDIATE TRANSACTION;", 0, 0, NULL);
 
        if (ret == SQLITE_OK) {
                MSG_DEBUG("Begin Transaction Success");
+               in_trans = true;
                return MSG_SUCCESS;
        } else {
                MSG_DEBUG("Begin Transaction Fail [%d]", ret);
@@ -419,11 +464,13 @@ msg_error_t MsgDbHandler::endTrans(bool Success)
        } else {
                ret = sqlite3_exec(handle, "ROLLBACK TRANSACTION;", 0, 0, NULL);
        }
-
+#if 0
        shm_mutex_unlock();
-
+#endif
        if (ret == SQLITE_OK) {
                MSG_DEBUG("End Transaction Success");
+               in_trans = false;
+               disconnect();
                return MSG_SUCCESS;
        } else {
                MSG_DEBUG("End Transaction Fail [%d]", ret);
@@ -442,7 +489,6 @@ int MsgDbHandler::getColumnToInt(int RowIndex)
        int nTemp = 0;
 
        if (pTemp == NULL) {
-               MSG_DEBUG("NULL");
                return nTemp;
        }
 
@@ -457,7 +503,6 @@ char MsgDbHandler::getColumnToChar(int RowIndex)
        char* pTemp = result[RowIndex];
 
        if (pTemp == NULL) {
-               MSG_DEBUG("NULL");
                return '\0';
        }
 
@@ -470,7 +515,6 @@ char *MsgDbHandler::getColumnToString(int RowIndex)
        char* pTemp = result[RowIndex];
 
        if (pTemp == NULL) {
-               MSG_DEBUG("NULL");
                return NULL;
        }
 
@@ -483,7 +527,6 @@ void MsgDbHandler::getColumnToString(int RowIndex, int Length, char *pString)
        char* pTemp = result[RowIndex];
 
        if (pTemp == NULL) {
-               MSG_DEBUG("NULL");
                return;
        }
 
@@ -573,24 +616,23 @@ msg_error_t MsgConvertStrWithEscape(const char *input, char **output)
 
 typedef std::map<pthread_t, MsgDbHandler*> dbMap_t;
 dbMap_t gDbHandles;
-pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER;
+Mutex mu;
 
 MsgDbHandler *getDbHandle()
 {
        pthread_t self = pthread_self();
        MsgDbHandler *tmp = NULL;
 
-       pthread_mutex_lock(&mu);
        dbMap_t::iterator it = gDbHandles.find(self);
        if (it == gDbHandles.end()) {
                MSG_DEBUG("New DB handle added.");
+               MutexLocker locker(mu);
                tmp = new MsgDbHandler();
                gDbHandles.insert ( std::pair<pthread_t,MsgDbHandler*>(self,tmp));
 
        } else {
                tmp = it->second;
        }
-       pthread_mutex_unlock(&mu);
 
        return tmp;
 }
@@ -600,13 +642,101 @@ void removeDbHandle()
        pthread_t self = pthread_self();
        MsgDbHandler *tmp = NULL;
 
-       pthread_mutex_lock(&mu);
        dbMap_t::iterator it = gDbHandles.find(self);
        if (it != gDbHandles.end()) {
+               MutexLocker locker(mu);
                tmp = it->second;
                delete tmp;
                gDbHandles.erase (it);
        }
-       pthread_mutex_unlock(&mu);
 }
 
+
+static int __msg_db_util_busyhandler(void *pData, int count)
+{
+       if(20 - count > 0) {
+               struct timespec time = {0,};
+               time.tv_sec = 0;
+               time.tv_nsec = (count + 1) * 50 * 1000 * 1000;
+
+               MSG_DEBUG("Busy Handler Called! : PID(%d) / CNT(%d)\n", getpid(), count+1);
+               nanosleep(&time, NULL);
+               return 1;
+       } else {
+               MSG_WARN("Busy Handler will be returned SQLITE_BUSY error : PID(%d) \n", getpid());
+               return 0;
+       }
+}
+
+int __msg_db_util_open(const char *pszFilePath, sqlite3 **ppDB, int flags, const char *zVfs)
+{
+       if((pszFilePath == NULL) || (ppDB == NULL)) {
+               MSG_WARN("sqlite3 handle null error");
+               return SQLITE_ERROR;
+       }
+
+       if((geteuid() != 0) && (access(pszFilePath, R_OK))) {
+               if(errno == EACCES) {
+                       MSG_ERR("file access permission error");
+                       return SQLITE_PERM;
+               }
+       }
+
+       /* Open DB */
+       int rc = sqlite3_open_v2(pszFilePath, ppDB, flags, zVfs);
+       if (SQLITE_OK != rc) {
+               MSG_ERR("sqlite3_open_v2 error(%d)",rc);
+               return rc;
+       }
+
+       rc = sqlite3_busy_handler(*ppDB, __msg_db_util_busyhandler, NULL);
+       if (SQLITE_OK != rc) {
+               MSG_WARN("Fail to register busy handler\n");
+               sqlite3_close(*ppDB);
+       }
+
+       return rc;
+}
+
+
+int __msg_db_util_close(sqlite3 *pDB)
+{
+       if (pDB == NULL) {
+               MSG_WARN("sqlite3 handle null error");
+               return SQLITE_ERROR;
+       }
+
+       /* Close DB */
+       int rc = sqlite3_close(pDB);
+       MSG_INFO("sqlite3_close error [%d]", rc);
+
+       if (rc == SQLITE_BUSY) {
+               __clear_db_handle(pDB);
+               rc = sqlite3_close(pDB);
+       }
+
+       if (SQLITE_OK != rc) {
+               MSG_ERR("sqlite3_close error [%d]", rc);
+               return rc;
+       }
+
+       return 0;
+}
+
+
+void __clear_db_handle(sqlite3 *pDB)
+{
+       if (pDB == NULL) {
+               MSG_WARN("sqlite3 handle null error");
+               return;
+       }
+
+       int rc = 0;
+
+       sqlite3_stmt *pStmt;
+       while ((pStmt = sqlite3_next_stmt(pDB, NULL)) != NULL) {
+               MSG_INFO("sqlite3_next_stmt [%s]", sqlite3_sql(pStmt));
+               rc = sqlite3_finalize(pStmt);
+               MSG_INFO("sqlite3_finalize [%d]", rc);
+       }
+}
index 53e9769..fb617da 100755 (executable)
@@ -521,60 +521,6 @@ int MsgTextConvert::convertUTF8ToUCS2(OUT unsigned char *pDestText, IN int maxLe
        return ucs2Length;
 }
 
-#ifndef FEATURE_SMS_CDMA
-int MsgTextConvert::convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_LANGUAGE_ID_T *pLangId, OUT msg_encode_type_t *pCharType)
-{
-       int utf8Length = 0;
-       int gsm7bitLength = 0;
-       int ucs2Length = 0;
-
-       bool bUnknown = false;
-
-       utf8Length = srcTextLen;
-
-       int maxUCS2Length = utf8Length;         // max # of UCS2 chars, NOT bytes. when all utf8 chars are only one byte, UCS2Length is maxUCS2 Length. otherwise (ex: 2 bytes of UTF8 is one char) UCS2Length must be  less than utf8Length
-       WCHAR pUCS2Text[maxUCS2Length];
-       memset(pUCS2Text, 0x00, maxUCS2Length * sizeof(WCHAR));
-
-       MSG_DEBUG("srcTextLen = %d", srcTextLen);
-       MSG_DEBUG("temp buffer size = %d", maxUCS2Length * sizeof(WCHAR));
-       MSG_DEBUG("max dest Length = %d", maxLength);
-
-       ucs2Length = convertUTF8ToUCS2((unsigned char*)pUCS2Text, maxUCS2Length * sizeof(WCHAR), pSrcText, srcTextLen);
-
-       if(ucs2Length < 0) {
-               *pCharType = MSG_ENCODE_8BIT;
-
-               if (srcTextLen <= maxLength) {
-                       memcpy(pDestText, pSrcText, srcTextLen);
-                       return srcTextLen;
-               } else {
-                       memcpy(pDestText, pSrcText, maxLength);
-                       return maxLength;
-               }
-       } else {
-               gsm7bitLength = convertUCS2ToGSM7bit(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, pLangId, &bUnknown);
-
-               if (bUnknown == true) {
-                       *pCharType = MSG_ENCODE_UCS2;
-
-                       if (ucs2Length > 0) {
-                               if(ucs2Length <= maxLength) {
-                                       memcpy(pDestText, pUCS2Text, ucs2Length);
-                                       return ucs2Length;
-                               } else {
-                                       memcpy(pDestText, pUCS2Text, maxLength);
-                                       return maxLength;
-                               }
-                       }
-               } else {
-                       *pCharType = MSG_ENCODE_GSM7BIT;
-               }
-
-               return gsm7bitLength;
-       }
-}
-#else
 
 int MsgTextConvert::convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT msg_encode_type_t *pCharType)
 {
@@ -607,7 +553,11 @@ int MsgTextConvert::convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLe
                        return maxLength;
                }
        } else {
+#ifndef FEATURE_SMS_CDMA
+               gsm7bitLength = convertUCS2ToGSM7bitAuto(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, &bUnknown);
+#else
                gsm7bitLength = convertUCS2ToASCII(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, &bUnknown);
+#endif
 
                if (bUnknown == true) {
                        *pCharType = MSG_ENCODE_UCS2;
@@ -622,13 +572,17 @@ int MsgTextConvert::convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLe
                                }
                        }
                } else {
+#ifndef FEATURE_SMS_CDMA
+                       *pCharType = MSG_ENCODE_GSM7BIT;
+#else
                        *pCharType = MSG_ENCODE_ASCII7BIT;
+#endif
                }
 
                return gsm7bitLength;
        }
 }
-#endif
+
 
 /**
 return:
@@ -983,7 +937,72 @@ int MsgTextConvert::convertUCS2ToGSM7bit(OUT unsigned char *pDestText, IN int ma
        return outTextLen;
 }
 
+#ifndef FEATURE_SMS_CDMA
+int MsgTextConvert::convertUCS2ToGSM7bitAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown)
+{
+       // for UNICODE
+       int outTextLen = 0;
+       unsigned char lowerByte, upperByte;
+
+       if (srcTextLen == 0 || pSrcText == NULL || pDestText ==  NULL || maxLength == 0) {
+               MSG_DEBUG("UCS2 to GSM7bit Failed as text length is 0\n");
+               return -1;
+       }
+
+       std::map<unsigned short, unsigned char>::iterator itChar;
+       std::map<unsigned short, unsigned char>::iterator itExt;
+
+       unsigned short inText;
+
+       for (int index = 0; index < srcTextLen; index++)
+       {
+               upperByte = pSrcText[index++];
+               lowerByte = pSrcText[index];
+
+               inText = (upperByte << 8) & 0xFF00;
+               inText = inText | lowerByte;
+
+               // Check Default Char
+               itChar = ucs2toGSM7DefList.find(inText);
+
+               if (itChar != ucs2toGSM7DefList.end()) {
+                       pDestText[outTextLen++] = (unsigned char)itChar->second;
+               } else {
+                       itExt = ucs2toGSM7ExtList.find(inText);
+
+                       if (itExt != ucs2toGSM7ExtList.end()) {
+                               // prevent buffer overflow
+                               if (maxLength <= outTextLen + 1) {
+                                       MSG_DEBUG("Buffer Full.");
+                                       break;
+                               }
 
+                               pDestText[outTextLen++] = 0x1B;
+                               pDestText[outTextLen++] = (unsigned char)itExt->second;
+                       } else {
+                               MSG_DEBUG("Abnormal character is included. inText : [%04x]", inText);
+                               *pUnknown = true;
+                               return 0;
+                       }
+               }
+
+               // prevent buffer overflow
+               if (maxLength <= outTextLen) {
+                       MSG_DEBUG("Buffer full\n");
+                       break;
+               }
+       }
+
+#ifdef CONVERT_DUMP
+       MSG_DEBUG("\n########## Dump UCS2 -> GSM7bit\n");
+       convertDumpTextToHex((unsigned char*)pSrcText, srcTextLen);
+       convertDumpTextToHex((unsigned char*)pDestText, outTextLen);
+#endif
+
+       return outTextLen;
+}
+
+#else
 int MsgTextConvert::convertUCS2ToASCII(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown)
 {
        // for UNICODE
@@ -1033,7 +1052,7 @@ int MsgTextConvert::convertUCS2ToASCII(OUT unsigned char *pDestText, IN int maxL
 
        return outTextLen;
 }
-
+#endif
 
 /**
  args :
index 84714de..f181a20 100755 (executable)
 #include <fcntl.h>
 #include <libgen.h>
 
+#include <media_content.h>
+#include <thumbnail_util.h>
+#include <image_util.h>
+
 #include "MsgStorageTypes.h"
 #include "MsgDebug.h"
 #include "MsgException.h"
 #include "MsgMmsTypes.h"
 #include "MsgInternalTypes.h"
 #include "MsgDrmWrapper.h"
+#include "MsgMutex.h"
+
+extern "C" {
+       #include <aul.h>
+}
+
+Mutex g_mx;
+CndVar g_cv;
+
+void thumbnail_completed_cb(thumbnail_util_error_e error, const char *request_id,
+                                                                       int thumb_width, int thumb_height,
+                                                                       unsigned char *thumb_data, int thumb_size, void *user_data)
+{
+       if (!user_data) {
+               MSG_WARN("dstPath is NULL");
+               return;
+       }
+
+       MSG_BEGIN();
+
+       g_mx.lock();
+       MSG_DEBUG("=================[RESULT]");
+       MSG_DEBUG("error_code [%d]", error);
+       MSG_DEBUG("request id [%s]", request_id);
+       MSG_DEBUG("width [%d], height [%d]", thumb_width, thumb_height);
+       MSG_DEBUG("raw_data [0x%x], size [%d]", *thumb_data, thumb_size);
+
+       int ret = 0;
+       ret = image_util_encode_jpeg(thumb_data, thumb_width, thumb_height, IMAGE_UTIL_COLORSPACE_BGRA8888, 100, (char *)user_data);
+       if (ret != IMAGE_UTIL_ERROR_NONE)
+               MSG_WARN("image_util_encode_jpeg() is failed");
 
+       g_cv.signal();
+       g_mx.unlock();
+
+       MSG_END();
+}
 
 /*==================================================================================================
                                      FUNCTION IMPLEMENTATION
 ==================================================================================================*/
+bool MakeThumbnail(char *srcPath, char *dstPath)
+{
+       if (srcPath == NULL || dstPath == NULL) {
+               MSG_SEC_DEBUG("Invalid Param src = %p, dst = %p", srcPath, dstPath);
+               return false;
+       }
+
+       if (MsgAccessFile(srcPath, R_OK) == false) {
+               MSG_SEC_DEBUG("not exist source file [%s]", srcPath);
+               return false;
+       }
+
+       g_mx.lock();
+
+       int time_ret = 0;
+
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+       char *req_id = NULL;
+       thumbnail_h thumb_h;
+       thumbnail_util_create(&thumb_h);
+       thumbnail_util_set_path(thumb_h, srcPath);
+
+       ret = thumbnail_util_extract(thumb_h, thumbnail_completed_cb, dstPath, &req_id);
+       thumbnail_util_destroy(thumb_h);
+       if (req_id) {
+               g_free(req_id);
+               req_id = NULL;
+       }
+
+       if (ret != THUMBNAIL_UTIL_ERROR_NONE) {
+               MSG_ERR("thumbnail_util_extract is failed");
+               g_mx.unlock();
+               return false;
+       }
+
+       time_ret = g_cv.timedwait(g_mx.pMutex(), 5);
+
+       g_mx.unlock();
+
+       if (time_ret == ETIMEDOUT) {
+               MSG_ERR("@@ WAKE by timeout@@");
+               return false;
+       }
+
+       if (MsgAccessFile(dstPath, F_OK) == false) {
+               MSG_SEC_DEBUG("not exist result file [%s]", dstPath);
+               return false;
+       }
+
+       MSG_SEC_DEBUG("Make thumbnail: success [%s]", dstPath);
+       return true;
+}
+
 // File operation wrappers
 FILE *MsgOpenFile(const char *filepath, const char *opt)
 {
@@ -455,10 +548,10 @@ void MsgDeleteFile(const char *pFileName)
        try {
                snprintf(fullPath, MAX_FULL_PATH_SIZE, "%s%s", MSG_IPC_DATA_PATH, pFileName);
 
-               MSG_DEBUG("%s", fullPath);
+               MSG_SEC_DEBUG("%s", fullPath);
 
                if (remove(fullPath) != 0)
-                       MSG_FATAL("File Delete Error [%s]: %s", fullPath, g_strerror(errno));
+                       MSG_SEC_ERR("File Delete Error [%s]: %s", fullPath, g_strerror(errno));
        } catch (exception &e) {
                MSG_FATAL ("%s", e.what());
        }
@@ -479,7 +572,7 @@ void MsgDeleteSmilFile(const char *pFileName)
                snprintf(fullPath, MAX_FULL_PATH_SIZE, "%s%s", MSG_SMIL_FILE_PATH, pFileName);
 
                if (remove(fullPath) != 0)
-                       MSG_FATAL("File Delete Error [%s]: %s", fullPath, g_strerror(errno));
+                       MSG_SEC_ERR("File Delete Error [%s]: %s", fullPath, g_strerror(errno));
        } catch (exception &e) {
                MSG_FATAL("%s", e.what());
        }
@@ -535,7 +628,7 @@ FILE *MsgOpenMMSFile(char *pFileName)
                }
        }
 
-       MSG_DEBUG("pFileName = %s", pFileName);
+       MSG_SEC_DEBUG("pFileName = %s", pFileName);
 
        char fullPath[MAX_FULL_PATH_SIZE+1] = {0};
 
@@ -544,13 +637,13 @@ FILE *MsgOpenMMSFile(char *pFileName)
        FILE *pFile = MsgOpenFile(fullPath, "wb+");
 
        if (pFile == NULL) {
-               MSG_FATAL("File Open Error: %s", g_strerror(errno));
+               MSG_ERR("File Open Error: %s", g_strerror(errno));
                return NULL;
        }
 
        if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) {
                MsgCloseFile(pFile);
-               MSG_DEBUG("File Read Error: %s", g_strerror(errno));
+               MSG_ERR("File Read Error: %s", g_strerror(errno));
                return NULL;
        }
 
@@ -628,7 +721,7 @@ char *MsgOpenAndReadMmsFile( const char *szFilePath, int offset, int size, int *
        int     readSize = 0;
 
        if (szFilePath == NULL) {
-               MSG_DEBUG("MsgOpenAndReadMmsFile: [ERROR] szFilePath id NULL");
+               MSG_ERR("szFilePath id NULL");
                goto __CATCH;
        }
 
@@ -637,11 +730,11 @@ char *MsgOpenAndReadMmsFile( const char *szFilePath, int offset, int size, int *
        pFile = MsgOpenFile( szFilePath, "rb" );
 
        if (pFile == NULL) {
-               MSG_DEBUG("MsgOpenAndReadMmsFile: [ERROR] Can't open filepath", g_strerror(errno));
+               MSG_ERR("Can't open file: %s", g_strerror(errno));
                goto __CATCH;
        }
 
-       if( size == -1 ) {
+       if (size == -1) {
                if (MsgGetFileSize(szFilePath, & readSize) == false) {
                        MSG_DEBUG("MsgGetFileSize: failed");
                        goto __CATCH;
@@ -655,15 +748,14 @@ char *MsgOpenAndReadMmsFile( const char *szFilePath, int offset, int size, int *
 //             goto __CATCH;
 //     }
 
-       pData = (char *)malloc(readSize + 1);
+       pData = (char *)calloc(1, readSize + 1);
        if ( NULL == pData ) {
-               MSG_DEBUG( "MsgOpenAndReadMmsFile: [ERROR] pData MemAlloc Fail", g_strerror(errno) );
+               MSG_ERR("pData MemAlloc Fail : %s", g_strerror(errno) );
                goto __CATCH;
        }
-       memset( pData, 0, readSize + 1 );
 
        if (MsgFseek( pFile, offset, SEEK_SET) < 0) {
-               MSG_DEBUG( "MsgOpenAndReadMmsFile: [ERROR] FmSeekFile failed", g_strerror(errno) );
+               MSG_ERR("FmSeekFile failed : %s", g_strerror(errno) );
                goto __CATCH;
        }
 
@@ -1031,19 +1123,19 @@ bool MsgCreateFile(const char *pFilePath,char *pData, int DataSize)
        FILE *pFile = MsgOpenFile(pFilePath, "wb+");
 
        if (pFile == NULL) {
-               MSG_DEBUG("File Open Error: %s", g_strerror(errno));
+               MSG_ERR("File Open Error: %s", g_strerror(errno));
                return false;
        }
 
        if (MsgFseek(pFile, 0L, SEEK_SET) < 0) {
                MsgCloseFile(pFile);
-               MSG_DEBUG("File Seek Error: %s", g_strerror(errno));
+               MSG_ERR("File Seek Error: %s", g_strerror(errno));
                return false;
        }
 
        if (MsgWriteFile(pData, sizeof(char), DataSize, pFile) != (size_t)DataSize) {
                MsgCloseFile(pFile);
-               MSG_DEBUG("File Write Error: %s", g_strerror(errno));
+               MSG_ERR("File Write Error: %s", g_strerror(errno));
                return false;
        }
 
@@ -1074,45 +1166,49 @@ int MsgCheckFilepathSmack(const char *app_smack_label, char *file_path)
        char *dir_smack_label = NULL;
        char *dir_name = NULL;
 
+       if (!file_path || file_path[0] == '\0') {
+               return MSG_SUCCESS;
+       }
+
        struct stat st;
        if (stat(file_path, &st) != 0) {
-               MSG_DEBUG("stat(%s, &st) != 0", file_path);
+               MSG_SEC_ERR("stat(%s, &st) != 0", file_path);
                return MSG_ERR_PERMISSION_DENIED;
        }
        if (S_ISDIR(st.st_mode)) {
-               MSG_DEBUG("S_ISDIR(st.st_mode)");
+               MSG_ERR("S_ISDIR(st.st_mode)");
                return MSG_ERR_INVALID_PARAMETER;
        }
 
        dir_name = MsgGetDirName(file_path);
        if (!dir_name || !g_strcmp0(dir_name, file_path)) {
-               MSG_DEBUG("!dir_name || !g_strcmp0(dir_name, %s)", file_path);
+               MSG_SEC_ERR("!dir_name || !g_strcmp0(dir_name, %s)", file_path);
                err = MSG_ERR_INVALID_PARAMETER;
                goto __RETURN;
        }
 
        smack_getlabel(dir_name, &dir_smack_label, SMACK_LABEL_ACCESS);
        if (dir_smack_label == NULL) {
-               MSG_DEBUG("smack_getlabel failed (dir_smack_label)");
+               MSG_ERR("smack_getlabel failed (dir_smack_label)");
                err = MSG_ERR_PERMISSION_DENIED;
                goto __RETURN;
        }
 
        if (smack_have_access(app_smack_label, dir_smack_label, "RX") < 1) {
-               MSG_DEBUG("smack_have_access failed (dir_smack_label)");
+               MSG_ERR("smack_have_access failed (dir_smack_label)");
                err = MSG_ERR_PERMISSION_DENIED;
                goto __RETURN;
        }
 
        smack_getlabel(file_path, &path_smack_label, SMACK_LABEL_ACCESS);
        if (path_smack_label == NULL) {
-               MSG_DEBUG("smack_getlabel failed (path_smack_label)");
+               MSG_ERR("smack_getlabel failed (path_smack_label)");
                err = MSG_ERR_PERMISSION_DENIED;
                goto __RETURN;
        }
 
        if (smack_have_access(app_smack_label, path_smack_label, "R") < 1) {
-               MSG_DEBUG("smack_have_access failed (path_smack_label)");
+               MSG_ERR("smack_have_access failed (path_smack_label)");
                err = MSG_ERR_PERMISSION_DENIED;
                goto __RETURN;
        }
@@ -1125,3 +1221,40 @@ __RETURN:
        MSG_FREE(dir_name);
        return err;
 }
+
+
+bool MsgScanFile(char *filePath)
+{
+       if (filePath == NULL) {
+               MSG_DEBUG("Invalid Parameter src = %p", filePath);
+               return false;
+       }
+
+       msg_error_t ret = media_content_connect();
+
+       if (ret == MEDIA_CONTENT_ERROR_NONE) {
+               if (media_content_scan_file(filePath) != MEDIA_CONTENT_ERROR_NONE) {
+                       MSG_ERR("media_content_scan_file() is failed , %d", ret);
+                       media_content_disconnect();
+                       return false;
+               }
+
+               ret = media_content_disconnect();
+
+               if (ret != MEDIA_CONTENT_ERROR_NONE) {
+                       MSG_ERR("media_content_disconnect is failed , %d", ret);
+                       return false;
+               }
+       } else {
+               MSG_ERR("media_content_connect is failed , %d", ret);
+               return false;
+       }
+
+       return true;
+}
+
+
+void MsgGetMimeType(char *filePath, char *mimeType, int size)
+{
+       aul_get_mime_from_file(filePath, mimeType, size);
+}
index 1205e8b..72ca1b5 100755 (executable)
  * limitations under the License.
 */
 
+#include <gio/gio.h>
+
 #include "MsgDebug.h"
 #include "MsgContact.h"
+#include "MsgUtilFile.h"
 #include "MsgUtilFunction.h"
 
 #include <system_info.h>
+#include <libintl.h>
+#include <locale.h>
+#include <vconf.h>
+#include <ctype.h>
+
+
+enum _FEATURE_INDEX_E {
+       FEATURE_INDEX_SMS = 0,
+       FEATURE_INDEX_MMS = 1,
+};
+
+static bool b_feature_cache_flag = false;
+static bool b_feature_support[] = {
+               [FEATURE_INDEX_SMS] = false,
+               [FEATURE_INDEX_MMS] = false,
+};
 
-bool b_feature_check_flag = false;
-bool b_feature_telephony_sms = false;
-bool b_feature_telephony_mms = false;
+int _dbus_owner_id = 0;
 
- /*==================================================================================================
+/*==================================================================================================
                                      FUNCTION IMPLEMENTATION
 ==================================================================================================*/
 
@@ -32,24 +49,23 @@ bool MsgCheckFeatureSupport(const char *feature_name)
 {
        bool result = false;
 
-       if (b_feature_check_flag == false) {
-               if (system_info_get_platform_bool(MSG_TELEPHONY_SMS_FEATURE, &b_feature_telephony_sms) != SYSTEM_INFO_ERROR_NONE)
-                       MSG_INFO("fail to system_info_get_platform_bool [%s]", MSG_TELEPHONY_SMS_FEATURE);
-               if (system_info_get_platform_bool(MSG_TELEPHONY_MMS_FEATURE, &b_feature_telephony_mms) != SYSTEM_INFO_ERROR_NONE)
-                       MSG_INFO("fail to system_info_get_platform_bool [%s]", MSG_TELEPHONY_MMS_FEATURE);
+       if (b_feature_cache_flag == false) {
+               if (system_info_get_platform_bool(MSG_TELEPHONY_SMS_FEATURE, &b_feature_support[FEATURE_INDEX_SMS]) != SYSTEM_INFO_ERROR_NONE)
+                       MSG_WARN("fail to system_info_get_platform_bool [%s]", MSG_TELEPHONY_SMS_FEATURE);
 
-               MSG_INFO("[%s] feature is [%d]", MSG_TELEPHONY_SMS_FEATURE, b_feature_telephony_sms);
-               MSG_INFO("[%s] feature is [%d]", MSG_TELEPHONY_MMS_FEATURE, b_feature_telephony_mms);
+               if (system_info_get_platform_bool(MSG_TELEPHONY_MMS_FEATURE, &b_feature_support[FEATURE_INDEX_MMS]) != SYSTEM_INFO_ERROR_NONE)
+                       MSG_WARN("fail to system_info_get_platform_bool [%s]", MSG_TELEPHONY_MMS_FEATURE);
 
-               b_feature_check_flag = true;
+               MSG_INFO("[%s] feature is [%d]", MSG_TELEPHONY_SMS_FEATURE, b_feature_support[FEATURE_INDEX_SMS]);
+               MSG_INFO("[%s] feature is [%d]", MSG_TELEPHONY_MMS_FEATURE, b_feature_support[FEATURE_INDEX_MMS]);
+
+               b_feature_cache_flag = true;
        }
 
        if (!g_strcmp0(feature_name, MSG_TELEPHONY_SMS_FEATURE)) {
-               result = b_feature_telephony_sms;
+               result = b_feature_support[FEATURE_INDEX_SMS];
        } else if (!g_strcmp0(feature_name, MSG_TELEPHONY_MMS_FEATURE)) {
-               result = b_feature_telephony_mms;
-       } else {
-               result = false;
+               result = b_feature_support[FEATURE_INDEX_MMS];
        }
 
        return result;
@@ -1009,12 +1025,7 @@ msg_error_t MsgMakeSortRule(const MSG_SORT_RULE_S *pSortRule, char *pSqlSort)
        else
                strncpy(order, "DESC", 5);
 
-       //contacts-service is not used for gear
-#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
        int nameOrder = MsgGetContactNameOrder();
-#else // MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-       int nameOrder = 0;
-#endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED
 
        switch (pSortRule->sortType)
        {
@@ -1071,3 +1082,128 @@ bool msg_is_valid_email(char *pAddress)
                return false;
        return true;
 }
+
+msg_error_t msg_write_text_to_msg_info(MSG_MESSAGE_INFO_S *pMsgInfo, char *text)
+{
+       if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN) {
+               pMsgInfo->bTextSms = false;
+
+               // Save Message Data into File
+               char fileName[MSG_FILENAME_LEN_MAX+1];
+               memset(fileName, 0x00, sizeof(fileName));
+
+               if(MsgCreateFileName(fileName) == false) {
+                       MSG_DEBUG("MsgCreateFileName error");
+                       return MSG_ERR_STORAGE_ERROR;
+               }
+
+               MSG_SEC_DEBUG("Save text into file : size[%d] name[%s]", pMsgInfo->dataSize, fileName);
+
+               if (MsgWriteIpcFile(fileName, text, pMsgInfo->dataSize) == false) {
+                       MSG_DEBUG("MsgWriteIpcFile error");
+                       return MSG_ERR_STORAGE_ERROR;
+               }
+
+               memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData));
+               strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
+       } else {
+               pMsgInfo->bTextSms = true;
+
+               memset(pMsgInfo->msgText, 0x00, sizeof(pMsgInfo->msgText));
+               memcpy(pMsgInfo->msgText, text, pMsgInfo->dataSize);
+       }
+
+       return MSG_SUCCESS;
+}
+
+/* change illegal filename character to '_' */
+void msg_replace_available_file_name(char *fileName)
+{
+       int idx = 0;
+       int len = 0;
+       bool is_converted = false;
+
+       if (fileName) {
+               len = strlen(fileName);
+
+               while (fileName[idx] != 0) {
+                       if (idx >= len) {
+                               MSG_WARN("idx : %d, len : %d", idx, len);
+                               break;
+                       }
+
+                       if (fileName[idx] == '\\' || fileName[idx] == '/' || fileName[idx] == '?' || fileName[idx] == '%' || fileName[idx] == '*' ||
+                               fileName[idx] == ':' || fileName[idx] == '|' || fileName[idx] == '"' || fileName[idx] == '<' || fileName[idx] == '>') {
+                               fileName[idx++] = '_';
+                               is_converted = true;
+                       } else {
+                               idx++;
+                       }
+               }
+       }
+
+       if (is_converted)
+               MSG_SEC_DEBUG("converted filename : [%s]", fileName);
+}
+
+/* change character ' ' to '_' */
+void msg_replace_space_char(char *pszText)
+{
+       if (!pszText) {
+               MSG_ERR("pszText is NULL");
+               return;
+       }
+
+       char *spaceCharPtr = strchr(pszText, ' ');
+
+       while (spaceCharPtr) {
+               *spaceCharPtr = '_';
+               spaceCharPtr = strchr(pszText, ' ');
+       }
+}
+
+/* change non-ascii character to underscore */
+gchar * msg_replace_non_ascii_char(const gchar *pszText, gunichar replacementChar)
+{
+       if (!pszText) {
+               MSG_ERR(" msg_replace_non_ascii_char error : pszText is NULL");
+               return NULL;
+       }
+       gchar *res;
+       gsize result_len = 0;
+       const gchar *p;
+       result_len = g_utf8_strlen (pszText, -1) + 1; //+1 for malloc of non-terminating chracter
+       res = (gchar *)g_malloc (result_len * sizeof (gchar));
+       int i = 0;
+       for (p = pszText, i = 0; *p != '\0'; p = g_utf8_next_char (p), i++) {
+               res[i] = isascii(g_utf8_get_char (p)) ? *p : replacementChar;
+       }
+       res[i] = '\0';
+       return res;
+}
+
+void MsgDbusInit()
+{
+       MSG_DEBUG();
+
+       _dbus_owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+                                                                       "msg-service.dbus.service",
+                                                                       G_BUS_NAME_OWNER_FLAGS_NONE,
+                                                                       NULL, NULL, NULL,
+                                                                       NULL, NULL);
+
+       if (_dbus_owner_id == 0) {
+               MSG_ERR("g_bus_own_name() error");
+       }
+
+       MSG_DEBUG("owner_id = [%d]", _dbus_owner_id);
+}
+
+void MsgDbusDeinit()
+{
+       MSG_DEBUG();
+       if (_dbus_owner_id)
+               g_bus_unown_name(_dbus_owner_id);
+
+       _dbus_owner_id = 0;
+}
similarity index 93%
rename from plugin/mms_plugin/MmsPluginMIME.cpp
rename to utils/MsgUtilMime.cpp
index af59880..2c8e06c 100755 (executable)
@@ -16,8 +16,9 @@
 
 #include <string>
 #include <stdlib.h>
-#include "MmsPluginMIME.h"
-#include "MmsPluginDebug.h"
+#include <metadata_extractor.h>
+#include "MsgUtilMime.h"
+#include "MsgDebug.h"
 
 typedef enum _MimeAppType {
        MIME_APPLICATION_NONE,
@@ -56,10 +57,10 @@ typedef struct _MimeTable {
 
 /**************************************************     MIME definition     ***************************************************/
 static const MimeTable mimeTable[] = {
-       // 0
+       /* 0 */
        {"*/*",                                                                                                 "",                                     false,          MIME_ASTERISK,                                                                  MIME_ASTERISK,                                                  MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                              UNDEFINED_BINARY        },
 
-    // 1
+    /* 1 */
        {"application/xml",                                                                     "",                                     false,          MIME_APPLICATION_XML,                                                   MIME_APPLICATION_XML,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x27    },
        {"application/wml+xml",                                                         "",                                     false,          MIME_APPLICATION_WML_XML,                                               MIME_APPLICATION_WML_XML,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x3c    },
        {"application/xhtml+xml",                                                               "xhtml",                        false,          MIME_APPLICATION_XHTML_XML,                                             MIME_APPLICATION_XHTML_XML,                             MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x3b    },
@@ -76,7 +77,7 @@ static const MimeTable mimeTable[] = {
        {"application/ram",                                                                     "ram",                          true,           MIME_APPLICATION_RAM,                                                   MIME_APPLICATION_RAM,                                   MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
        {"application/*",                                                                               "",                                     false,          MIME_APPLICATION_ASTERIC,                                               MIME_APPLICATION_ASTERIC,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x10    },
 
-       //16
+       /* 16 */
        {"application/vnd.wap.xhtml+xml",                                               "",                                     false,          MIME_APPLICATION_VND_WAP_XHTMLXML,                              MIME_APPLICATION_VND_WAP_XHTMLXML,              MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x45    },
        {"application/vnd.wap.wmlc",                                                    "",                                     false,          MIME_APPLICATION_VND_WAP_WMLC,                                  MIME_APPLICATION_VND_WAP_WMLC,                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x14    },
        {"application/vnd.wap.wmlscriptc",                                              "",                                     false,          MIME_APPLICATION_VND_WAP_WMLSCRIPTC,                    MIME_APPLICATION_VND_WAP_WMLSCRIPTC,    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x15    },
@@ -111,7 +112,7 @@ static const MimeTable mimeTable[] = {
        {"application/vnd.ms-powerpoint",                                               "ppt",                          true,           MIME_APPLICATION_VND_POWERPOINT,                                MIME_APPLICATION_VND_POWERPOINT,                MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
        {"applcation/vnd.ms-word",                                                              "doc",                          true,           MIME_APPLICATION_VND_MSWORD,                                    MIME_APPLICATION_MSWORD,                                MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
 
-       //49
+       /* 49 */
        {"application/x-hdmlc",                                                         "",                                     false,          MIME_APPLICATION_X_HDMLC,                                               MIME_APPLICATION_X_HDMLC,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x13    },
        {"application/x-x968-user-cert",                                                "",                                     false,          MIME_APPLICATION_X_X968_USERCERT,                               MIME_APPLICATION_X_X968_USERCERT,               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x2c    },
        {"application/x-www-form-urlencoded",                                   "",                                     false,          MIME_APPLICATION_X_WWW_FORM_URLENCODED,                 MIME_APPLICATION_X_WWW_FORM_URLENCODED,         MIME_APPLICATION_NONE,                          MIME_MAINTYPE_APPLICATION,      0x12    },
@@ -121,7 +122,7 @@ static const MimeTable mimeTable[] = {
        {"application/x-mspowerpoint",                                                  "ppt",                          true,           MIME_APPLICATION_X_POWERPOINT,                                  MIME_APPLICATION_X_POWERPOINT,                  MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
 
 
-       //56
+       /* 56 */
        {"audio/basic",                                                                         "snd"/*,au"*/,          false,          MIME_AUDIO_BASIC,                                                               MIME_AUDIO_BASIC,                                               MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
        {"audio/mpeg",                                                                                  "mp3",                          true,           MIME_AUDIO_MPEG,                                                                MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
        {"audio/mp3",                                                                                   "mp3",                          true,           MIME_AUDIO_MP3,                                                                 MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
@@ -150,12 +151,13 @@ static const MimeTable mimeTable[] = {
        {"audio/wma",                                                                                   "wma",                          true,           MIME_AUDIO_WMA,                                                                 MIME_AUDIO_WMA,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
        {"audio/xmf",                                                                                   "xmf",                          true,           MIME_AUDIO_XMF,                                                                 MIME_AUDIO_XMF,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
        {"audio/imy",                                                                                   "imy",                          true,           MIME_AUDIO_IMY,                                                                 MIME_AUDIO_IMY,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
-       {"audio/mobile-xmf",                                                                    "mxmf",                         true,           MIME_AUDIO_MOBILE_XMF,                                                  MIME_AUDIO_XMF,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/mobile-xmf",                                                                    "mxmf",                         true,           MIME_AUDIO_MOBILE_XMF,                                                  MIME_AUDIO_MOBILE_XMF,                                          MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
+       {"audio/ogg",                                                                                   "ogg",                          true,           MIME_AUDIO_OGG,                                                         MIME_AUDIO_OGG,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
 
-       // 85
+       /* 86 */
        {"audio/vnd.rn-realaudio",                                                              "rm"/*,ram,ra"*/,       true,           MIME_AUDIO_VND_RN_REALAUDIO,                                    MIME_AUDIO_VND_RN_REALAUDIO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
 
-       //86
+       /* 87 */
        {"audio/x-mpeg",                                                                                "mp3",                          true,           MIME_AUDIO_X_MPEG,                                                              MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
        {"audio/x-mp3",                                                                         "mp3",                          true,           MIME_AUDIO_X_MP3,                                                               MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
        {"audio/x-mpeg3",                                                                               "mp3",                          true,           MIME_AUDIO_X_MPEG3,                                                             MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
@@ -176,7 +178,7 @@ static const MimeTable mimeTable[] = {
        {"audio/x-ms-asf",                                                                              "asf",                          true,           MIME_AUDIO_X_MS_ASF,                                                    MIME_AUDIO_X_MS_ASF,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
        {"audio/x-xmf",                                                                         "xmf",                          true,           MIME_AUDIO_X_XMF,                                                               MIME_AUDIO_XMF,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
 
-       //105
+       /* 106 */
        {"image/gif",                                                                                   "gif",                          false,          MIME_IMAGE_GIF,                                                                 MIME_IMAGE_GIF,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    0x1d    },
        {"image/jpeg",                                                                                  "jpg"/*,jpeg,jpe,jpz"*/,        false,  MIME_IMAGE_JPEG,                                                        MIME_IMAGE_JPG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            0x1e    },
        {"image/jpg",                                                                                   "jpg",                          false,          MIME_IMAGE_JPG,                                                                 MIME_IMAGE_JPG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
@@ -189,18 +191,18 @@ static const MimeTable mimeTable[] = {
        {"image/svg+xml",                                                                               "svg",                          false,          MIME_IMAGE_SVG,                                                                 MIME_IMAGE_SVG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
        {"image/svg-xml",                                                                               "svg",                          false,          MIME_IMAGE_SVG1,                                                                MIME_IMAGE_SVG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
 
-       //116
+       /* 117 */
        {"image/vnd.wap.wbmp",                                                                  "wbmp",                         false,          MIME_IMAGE_VND_WAP_WBMP,                                                MIME_IMAGE_WBMP,                                                MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            0x21    },
        {"image/vnd.tmo.my5-gif",                                                               "gif",                          false,          MIME_IMAGE_VND_TMO_GIF,                                                 MIME_IMAGE_GIF,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            UNDEFINED_BINARY        },
        {"image/vnd.tmo.my5-jpg",                                                               "jpg",                          false,          MIME_IMAGE_VND_TMO_JPG,                                                 MIME_IMAGE_JPG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            UNDEFINED_BINARY        },
 
-       // 119
+       /* 120 */
        {"image/x-bmp",                                                                         "bmp",                          false,          MIME_IMAGE_X_BMP,                                                               MIME_IMAGE_BMP,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            UNDEFINED_BINARY        },
 
-       // 120
+       /* 121 */
        {"message/rfc822",                                                                              "elm",                          false,          MIME_MESSAGE_RFC822,                                                    MIME_MESSAGE_RFC822,                                    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_MESSAGE,          UNDEFINED_BINARY        },
 
-       //121
+       /* 122 */
        {"multipart/mixed",                                                                     "",                                     false,          MIME_MULTIPART_MIXED,                                                   MIME_MULTIPART_MIXED,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x0c    },
        {"multipart/related",                                                                   "",                                     false,          MIME_MULTIPART_RELATED,                                                 MIME_MULTIPART_RELATED,                                 MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
        {"multipart/alternative",                                                               "",                                     false,          MIME_MULTIPART_ALTERNATIVE,                                             MIME_MULTIPART_ALTERNATIVE,                             MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x0f    },
@@ -209,16 +211,16 @@ static const MimeTable mimeTable[] = {
        {"multipart/report",                                                                    "",                                     false,          MIME_MULTIPART_REPORT,                                                  MIME_MULTIPART_REPORT,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
        {"multipart/voice-message",                                                     "",                                     false,          MIME_MULTIPART_VOICE_MESSAGE,                                   MIME_MULTIPART_VOICE_MESSAGE,                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
 
-       //128
+       /* 129 */
        {"text/txt",                                                                                    "",                             false,          MIME_TEXT_TXT,                                                                  MIME_TEXT_TXT,                                                  MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_TEXT,                     UNDEFINED_BINARY        },
        {"text/html",                                                                                   "html"/*,htm"*/,        false,          MIME_TEXT_HTML,                                                                 MIME_TEXT_HTML,                                                 MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x02    },
-       {"text/plain",                                                                                  "txt"/*,vbm,url"*/,                             false,          MIME_TEXT_PLAIN,                                                                MIME_TEXT_PLAIN,                                                MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_TEXT,                     0x03    },
+       {"text/plain",                                                                                  "txt" /*,vbm,url"*/,                            false,          MIME_TEXT_PLAIN,                                                                MIME_TEXT_PLAIN,                                                MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_TEXT,                     0x03    },
        {"text/css",                                                                                    "",                                     false,          MIME_TEXT_CSS,                                                                  MIME_TEXT_CSS,                                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x3d    },
        {"text/xml",                                                                                    "",                                     false,          MIME_TEXT_XML,                                                                  MIME_TEXT_XML,                                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x28    },
        {"text/iMelody",                                                                                "imy",                          true,           MIME_TEXT_IMELODY,                                                              MIME_TEXT_IMELODY,                                              MIME_APPLICATION_SOUNDPLAYER,                   MIME_MAINTYPE_AUDIO,            UNDEFINED_BINARY        },
        {"text/calendar",                                                                               "ics",                          true,   MIME_TEXT_CALENDAR,                                                             MIME_TEXT_CALENDAR,                                             MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,             UNDEFINED_BINARY },
 
-       //135
+       /* 136 */
        {"text/vnd.wap.wmlscript",                                                              "",                                     false,          MIME_TEXT_VND_WAP_WMLSCRIPT,                                    MIME_TEXT_VND_WAP_WMLSCRIPT,                    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x09    },
        {"text/vnd.wap.wml",                                                                    "wml",                          false,          MIME_TEXT_VND_WAP_WML,                                                  MIME_TEXT_VND_WAP_WML,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x08    },
        {"text/vnd.wap.wta-event",                                                              "",                                     false,          MIME_TEXT_VND_WAP_WTA_EVENT,                                    MIME_TEXT_VND_WAP_WTA_EVENT,                    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x0a    },
@@ -229,7 +231,7 @@ static const MimeTable mimeTable[] = {
        {"text/vnd.sun.j2me.app-descriptor",                                    "jad",                          true,           MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR,                  MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR,  MIME_APPLICATION_NONE,                                          MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
 
 
-       //143
+       /* 144 */
        {"text/x-hdml",                                                                         "",                                     false,          MIME_TEXT_X_HDML,                                                               MIME_TEXT_X_HDML,                                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x04    },
        {"text/x-vCalendar",                                                                    "vcs",                          true,           MIME_TEXT_X_VCALENDAR,                                                  MIME_TEXT_X_VCALENDAR,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      0x06    },
        {"text/x-vCard",                                                                                "vcf",                          true,           MIME_TEXT_X_VCARD,                                                              MIME_TEXT_X_VCARD,                                              MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      0x07    },
@@ -238,7 +240,7 @@ static const MimeTable mimeTable[] = {
        {"text/x-vnote",                                                                                "vnt",                          true,           MIME_TEXT_X_VNOTE,                                                              MIME_TEXT_X_VNOTE,                                              MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     UNDEFINED_BINARY        },
        {"text/x-vtodo",                                                                                "vts",                          true,           MIME_TEXT_X_VTODO,                                                              MIME_TEXT_X_VNOTE,                                              MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     UNDEFINED_BINARY        },
 
-       //150
+       /* 151 */
        {"video/mpeg4",                                                                         "mp4",                          true,           MIME_VIDEO_MPEG4,                                                               MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
        {"video/mp4",                                                                                   "mp4",                          true,           MIME_VIDEO_MP4,                                                                 MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
        {"video/h263",                                                                                  ""/*,3gpp,mp4"*/,true,          MIME_VIDEO_H263,                                                                MIME_VIDEO_H263,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
@@ -250,11 +252,11 @@ static const MimeTable mimeTable[] = {
        {"video/mpeg",                                                                                  "3gp",                          true,           MIME_VIDEO_MPEG,                                                                        MIME_VIDEO_3GP,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
        {"video/quicktime",                                                                             "mov",                          true,           MIME_VIDEO_MOV,                                                                 MIME_VIDEO_3GP,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
 
-       // 160
+       /* 161 */
        {"video/vnd.rn-realvideo",                                                              "rm",                           true,           MIME_VIDEO_VND_RN_REALVIDEO,                                    MIME_VIDEO_VND_RN_REALVIDEO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
        {"video/vnd.rn-realmedia",                                                              "rm",                           true,           MIME_VIDEO_VND_RN_REALMEDIA,                                    MIME_VIDEO_VND_RN_REALMEDIA,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
 
-       //162
+       /* 163 */
        {"video/x-mp4",                                                                         "mp4",                          true,           MIME_VIDEO_X_MP4,                                                               MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
        {"video/x-pv-mp4",                                                                              "mp4",                          true,           MIME_VIDEO_X_PV_MP4,                                                    MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
        {"video/x-pn-realvideo",                                                                "rv",                           true,           MIME_VIDEO_X_PN_REALVIDEO,                                              MIME_VIDEO_VND_RN_REALVIDEO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
@@ -268,12 +270,12 @@ static const MimeTable mimeTable[] = {
 /**********             MIME table information     ***********/
 static const int mimeTableIndex[] = {
        1,                      16,                     49,
-       56,                     85,                     86,
-       105,            116,            119,
-       120,            120,            120,
+       56,                     86,                     87,
+       106,            117,            120,
        121,            121,            121,
-       128,            135,            143,
-       150,            160,            162
+       122,            122,            122,
+       129,            136,            144,
+       151,            161,            163
 };
 
 static int mimeTableEnum[] =
@@ -370,6 +372,7 @@ static int mimeTableEnum[] =
        MIME_AUDIO_XMF,
        MIME_AUDIO_IMY,
        MIME_AUDIO_MOBILE_XMF,
+       MIME_AUDIO_OGG,
 
 
        MIME_AUDIO_VND_RN_REALAUDIO     ,
@@ -468,7 +471,7 @@ static int mimeTableEnum[] =
        MIME_VIDEO_X_MS_ASF,
        MIME_VIDEO_X_PV_PVX ,
 
-       MIME_UNKNOWN    // MIME_MAX
+       MIME_UNKNOWN    /* MIME_MAX */
 };
 
 
@@ -534,8 +537,8 @@ int __MimeGetTableIndexInt(MimeType mime)
        subtype = (mime & 0x0f00) >> 8;
        index = (mime & 0x003f);
 
-       //If 'type' is zero, mimeTableIndex's array value have a minus value
-       //If 'type' is zero, mime type is '*/*'
+       /* If 'type' is zero, mimeTableIndex's array value have a minus value */
+       // If 'type' is zero, mime type is '*\/*'
        if (type == 0)
                tableIndex = 0;
        else
@@ -572,7 +575,7 @@ int __MimeGetTableIndexString(const char *szMime)
 
        if (szMIMEType == NULL) {
                MSG_DEBUG("szMime is NULL");
-                return MIME_UNKNOWN;
+               return MIME_UNKNOWN;
        }
 
        memset(szMIMEType, 0, strlen(szMime) + 1);
@@ -685,8 +688,8 @@ MimeMainType __MimeGetMainTypeName(const char *szType)
 }
 
 
-//For Decode
-// MimeString -> MimeInt
+/* For Decode */
+/* MimeString -> MimeInt */
 MimeType MimeGetMimeIntFromMimeString(char *szMimeStr)
 {
        int index = __MimeGetTableIndexString(szMimeStr);
@@ -697,7 +700,7 @@ MimeType MimeGetMimeIntFromMimeString(char *szMimeStr)
        }
 }
 
-// MimeInt -> MimeString
+/* MimeInt -> MimeString */
 char *MimeGetMimeStringFromMimeInt(int mimeType)
 {
        int idx = __MimeGetTableIndexInt((MimeType)mimeType);
@@ -709,7 +712,7 @@ char *MimeGetMimeStringFromMimeInt(int mimeType)
 }
 
 
-// BinaryCode -> MimeInt
+/* BinaryCode -> MimeInt */
 MimeType MimeGetMimeIntFromBi(int binCode)
 {
        int index;
@@ -725,7 +728,7 @@ MimeType MimeGetMimeIntFromBi(int binCode)
        return MIME_UNKNOWN;
 }
 
-// Mimeint -> Binary Value
+/* Mimeint -> Binary Value */
 int MimeGetBinaryValueFromMimeInt(MimeType mime)
 {
        int index;
@@ -744,11 +747,11 @@ typedef struct {
        const char *szContentType;
 } ExtTableItem;
 
-#define EXT_TABLE_SIZE (56)
+#define EXT_TABLE_SIZE (58)
 
 const ExtTableItem extTable[EXT_TABLE_SIZE] = {
 
-       //text
+       /* text */
        {"txt",   MIME_MAINTYPE_TEXT, MIME_TEXT_PLAIN, "text/plain"},
        {"html",  MIME_MAINTYPE_TEXT, MIME_TEXT_HTML, "text/html"},
        {"xhtml", MIME_MAINTYPE_TEXT, MIME_APPLICATION_XHTML_XML, "application/xhtml+xml"},
@@ -758,9 +761,9 @@ const ExtTableItem extTable[EXT_TABLE_SIZE] = {
        {"vts",   MIME_MAINTYPE_TEXT, MIME_TEXT_X_VTODO, "text/x-vtodo"},
        {"ics",   MIME_MAINTYPE_TEXT, MIME_TEXT_CALENDAR, "text/calendar"},
 
-       //image
+       /* image */
        {"gif",   MIME_MAINTYPE_IMAGE, MIME_IMAGE_GIF, "image/gif"},
-       //{"jpg",   MIME_MAINTYPE_IMAGE, MIME_IMAGE_JPG, "image/jpg"},
+       /* {"jpg",   MIME_MAINTYPE_IMAGE, MIME_IMAGE_JPG, "image/jpg"}, */
        {"jpg",   MIME_MAINTYPE_IMAGE, MIME_IMAGE_JPEG, "image/jpeg"},
        {"jpeg",  MIME_MAINTYPE_IMAGE, MIME_IMAGE_JPEG, "image/jpeg"},
        {"tiff",  MIME_MAINTYPE_IMAGE, MIME_IMAGE_TIFF, "image/tiff"},
@@ -770,7 +773,7 @@ const ExtTableItem extTable[EXT_TABLE_SIZE] = {
        {"bmp",   MIME_MAINTYPE_IMAGE, MIME_IMAGE_BMP, "image/bmp"},
        {"svg",   MIME_MAINTYPE_IMAGE, MIME_IMAGE_SVG, "image/svg+xml"},
 
-       //audio
+       /* audio */
        {"snd",   MIME_MAINTYPE_AUDIO, MIME_AUDIO_BASIC, "audio/basic"},
        {"amr",   MIME_MAINTYPE_AUDIO, MIME_AUDIO_AMR, "audio/amr"},
        {"m4a",   MIME_MAINTYPE_AUDIO, MIME_AUDIO_M4A, "audio/m4a"},
@@ -787,8 +790,10 @@ const ExtTableItem extTable[EXT_TABLE_SIZE] = {
        {"wma",   MIME_MAINTYPE_AUDIO, MIME_AUDIO_X_MS_WMA, "audio/x-ms-wma"},
        {"rm",    MIME_MAINTYPE_AUDIO, MIME_AUDIO_VND_RN_REALAUDIO, "audio/vnd.rn-realaudio"},
        {"ra",    MIME_MAINTYPE_AUDIO, MIME_AUDIO_VND_RN_REALAUDIO, "audio/vnd.rn-realaudio"},
+       {"mxmf",    MIME_MAINTYPE_AUDIO, MIME_AUDIO_MOBILE_XMF, "audio/mobile-xmf"},
+       {"ogg",    MIME_MAINTYPE_AUDIO, MIME_AUDIO_OGG, "audio/ogg"},
 
-       //video
+       /* video */
        {"3gp",   MIME_MAINTYPE_VIDEO, MIME_VIDEO_3GPP, "video/3gpp"},
        {"3gpp",  MIME_MAINTYPE_VIDEO, MIME_VIDEO_3GPP, "video/3gpp"},
        {"mp4",   MIME_MAINTYPE_VIDEO, MIME_VIDEO_MP4, "video/mp4"},
@@ -798,7 +803,7 @@ const ExtTableItem extTable[EXT_TABLE_SIZE] = {
        {"asf",   MIME_MAINTYPE_VIDEO, MIME_VIDEO_X_MS_ASF, "video/x-ms-asf"},
        {"mov", MIME_MAINTYPE_VIDEO, MIME_VIDEO_MOV, "video/quicktime"},
 
-       //application
+       /* application */
        {"smil",  MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_SMIL, "application/smil"},
        {"rm",    MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_VND_RN_REALMEDIA, "application/vnd.rn-realmedia"},
        {"ram",   MIME_MAINTYPE_APPLICATION, MIME_APPLICATION_RAM, "application/ram"},
@@ -817,8 +822,8 @@ const ExtTableItem extTable[EXT_TABLE_SIZE] = {
 
 };
 
-//GetMimeType from File Extension
-bool MmsGetMimeTypeFromExt(MimeMainType mainType, const char *pExt, MimeType *pMimeType, const char **ppszMimeType)
+/* GetMimeType from File Extension */
+bool MsgGetMimeTypeFromExt(MimeMainType mainType, const char *pExt, MimeType *pMimeType, const char **ppszMimeType)
 {
        const ExtTableItem *matchedItem = NULL;
 
@@ -861,7 +866,7 @@ bool MmsGetMimeTypeFromExt(MimeMainType mainType, const char *pExt, MimeType *pM
        return false;
 }
 
-bool MmsGetMimeTypeFromFileName(MimeMainType mainType, const char *pFileName, MimeType *pMimeType, const char **ppszMimeType)
+bool MsgGetMimeTypeFromFileName(MimeMainType mainType, const char *pFileName, MimeType *pMimeType, const char **ppszMimeType)
 {
        const char *pExt = NULL;
 
@@ -878,5 +883,66 @@ bool MmsGetMimeTypeFromFileName(MimeMainType mainType, const char *pFileName, Mi
 
        pExt = pExt + 1;
 
-       return MmsGetMimeTypeFromExt(mainType, pExt, pMimeType, ppszMimeType);
+       return MsgGetMimeTypeFromExt(mainType, pExt, pMimeType, ppszMimeType);
 }
+
+bool MsgGetMainTypeFromMetaData(const char *pFileName, MimeMainType *mainType)
+{
+       char *video_track_cnt = NULL;
+       char *audio_track_cnt = NULL;
+
+       if (pFileName == NULL)
+               return false;
+
+       int ret = METADATA_EXTRACTOR_ERROR_NONE;
+       metadata_extractor_h metadata = NULL;
+
+       ret = metadata_extractor_create(&metadata);
+       if(ret != METADATA_EXTRACTOR_ERROR_NONE) {
+               MSG_ERR("Fail metadata_extractor_create [%d]", ret);
+               return false;
+       }
+
+       ret = metadata_extractor_set_path(metadata, pFileName);
+       if(ret != METADATA_EXTRACTOR_ERROR_NONE) {
+               MSG_ERR("Fail metadata_extractor_set_path [%d]", ret);
+               metadata_extractor_destroy(metadata);
+               return false;
+       }
+
+       metadata_extractor_get_metadata(metadata, METADATA_HAS_VIDEO, &video_track_cnt);
+       if (video_track_cnt) {
+               MSG_DEBUG("video_track_cnt = [%s]", video_track_cnt);
+               if (atoi(video_track_cnt) > 0) {
+                       metadata_extractor_destroy(metadata);
+                       free(video_track_cnt);
+                       video_track_cnt = NULL;
+
+                       *mainType = MIME_MAINTYPE_VIDEO;
+                       return true;
+               } else {
+                       free(video_track_cnt);
+                       video_track_cnt = NULL;
+               }
+       }
+
+       metadata_extractor_get_metadata(metadata, METADATA_HAS_AUDIO, &audio_track_cnt);
+       if (audio_track_cnt) {
+               MSG_DEBUG("audio_track_cnt = [%s]", audio_track_cnt);
+               if (atoi(audio_track_cnt) > 0) {
+                       metadata_extractor_destroy(metadata);
+                       free(audio_track_cnt);
+                       audio_track_cnt = NULL;
+
+                       *mainType = MIME_MAINTYPE_AUDIO;
+                       return true;
+               } else {
+                       free(audio_track_cnt);
+                       audio_track_cnt = NULL;
+               }
+       }
+
+       metadata_extractor_destroy(metadata);
+
+       return false;
+}
\ No newline at end of file
index fc19a42..37135e1 100755 (executable)
@@ -660,6 +660,40 @@ msg_error_t MsgStoUpdateConversation(MsgDbHandler *pDbHandle, msg_thread_id_t co
        }
 
        if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+               pDbHandle->finalizeQuery();
+
+               memset(sqlQuery, 0x00, MAX_QUERY_LEN);
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                               "SELECT MAIN_TYPE, SUB_TYPE, MSG_DIRECTION, DISPLAY_TIME, LENGTH(SUBJECT), SUBJECT, MSG_TEXT "
+                               "FROM %s "
+                               "WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND SCHEDULED_TIME = 0 ORDER BY DISPLAY_TIME DESC;",
+                               MSGFW_MESSAGE_TABLE_NAME,
+                               convId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE);
+
+               err = pDbHandle->prepareQuery(sqlQuery);
+               if (err != MSG_SUCCESS) {
+                       MSG_DEBUG("Fail to prepareQuery().");
+                       return err;
+               }
+
+               err = pDbHandle->stepQuery();
+               if (err != MSG_ERR_DB_ROW) {
+                       MSG_DEBUG("Fail to stepQuery().");
+                       pDbHandle->finalizeQuery();
+                       return err;
+               }
+
+               int main_type = pDbHandle->columnInt(0);
+               int sub_type = pDbHandle->columnInt(1);
+               int msg_direction = pDbHandle->columnInt(2);
+               time_t disp_time = (time_t)pDbHandle->columnInt(3);
+               int subject_length = pDbHandle->columnInt(4);
+               char subject[MAX_SUBJECT_LEN+1] = {0,};
+               snprintf(subject, sizeof(subject), "%s", pDbHandle->columnText(5));
+               char msg_text[MAX_MSG_TEXT_LEN+1] = {0,};
+               snprintf(msg_text, sizeof(msg_text), "%s", pDbHandle->columnText(6));
+
+               pDbHandle->finalizeQuery();
                memset(sqlQuery, 0x00, MAX_QUERY_LEN);
                snprintf(sqlQuery, sizeof(sqlQuery),
                                "UPDATE %s SET ",
@@ -692,6 +726,7 @@ msg_error_t MsgStoUpdateConversation(MsgDbHandler *pDbHandle, msg_thread_id_t co
                                "MMS_CNT = (SELECT COUNT(MSG_ID) FROM %s WHERE CONV_ID = %d AND MAIN_TYPE = %d AND SUB_TYPE NOT IN (%d, %d, %d) AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d), ",
                                MSGFW_MESSAGE_TABLE_NAME, convId, MSG_MMS_TYPE, MSG_DELIVERYIND_MMS, MSG_READRECIND_MMS, MSG_READORGIND_MMS, MSG_ALLBOX_ID, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE);
 
+#if 0
                tmpSize = strlen(sqlQuery);
                snprintf(sqlQuery+tmpSize, MAX_QUERY_LEN-tmpSize,
                                "MAIN_TYPE = (SELECT MAIN_TYPE FROM %s WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d ORDER BY DISPLAY_TIME DESC), ",
@@ -737,9 +772,16 @@ msg_error_t MsgStoUpdateConversation(MsgDbHandler *pDbHandle, msg_thread_id_t co
                                MSGFW_MESSAGE_TABLE_NAME, convId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE);
 #endif
 
+#endif
                tmpSize = strlen(sqlQuery);
                snprintf(sqlQuery+tmpSize, MAX_QUERY_LEN-tmpSize,
                                "MSG_TEXT = CASE "
+                               "WHEN %d > 0 THEN ? ELSE ? "
+                               "END, ",
+                               subject_length);
+#if 0
+               snprintf(sqlQuery+tmpSize, MAX_QUERY_LEN-tmpSize,
+                               "MSG_TEXT = CASE "
                                "WHEN (SELECT COUNT(MSG_ID) FROM %s WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND SCHEDULED_TIME = 0 ORDER BY DISPLAY_TIME DESC) > 0 "
                                "THEN CASE "
                                "WHEN (SELECT LENGTH(SUBJECT) FROM %s WHERE CONV_ID = %d AND FOLDER_ID > %d AND FOLDER_ID < %d AND STORAGE_ID = %d AND SCHEDULED_TIME = 0 ORDER BY DISPLAY_TIME DESC) > 0 "
@@ -751,29 +793,46 @@ msg_error_t MsgStoUpdateConversation(MsgDbHandler *pDbHandle, msg_thread_id_t co
                                MSGFW_MESSAGE_TABLE_NAME, convId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE,
                                MSGFW_MESSAGE_TABLE_NAME, convId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE,
                                MSGFW_MESSAGE_TABLE_NAME, convId, MSG_ALLBOX_ID, MSG_SPAMBOX_ID, MSG_STORAGE_PHONE);
+#endif
+               tmpSize = strlen(sqlQuery);
+               snprintf(sqlQuery+tmpSize, MAX_QUERY_LEN-tmpSize,
+                               "MAIN_TYPE = %d, SUB_TYPE = %d, MSG_DIRECTION = %d, DISPLAY_TIME = %lu ",
+                               main_type, sub_type, msg_direction, disp_time);
 
                tmpSize = strlen(sqlQuery);
                snprintf(sqlQuery+tmpSize, MAX_QUERY_LEN-tmpSize,
                                "WHERE CONV_ID = %d;",
                                convId);
+               if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
+                       MSG_DEBUG("Query Failed [%s]", sqlQuery);
+                       return MSG_ERR_DB_PREPARE;
+               }
+
+               pDbHandle->bindText(subject, 1);
+               pDbHandle->bindText(msg_text,2);
+
+               if (pDbHandle->stepQuery() != MSG_ERR_DB_DONE) {
+                       MSG_DEBUG("stepQuery() Failed");
+                       pDbHandle->finalizeQuery();
+                       return MSG_ERR_DB_STEP;
+               }
+
+               pDbHandle->finalizeQuery();
        } else {
+               pDbHandle->finalizeQuery();
+
                memset(sqlQuery, 0x00, MAX_QUERY_LEN);
                snprintf(sqlQuery, sizeof(sqlQuery),
                                "UPDATE %s SET UNREAD_CNT = 0, SMS_CNT = 0, MMS_CNT = 0, MAIN_TYPE = 0, SUB_TYPE = 0, MSG_DIRECTION = 0, DISPLAY_TIME = 0, MSG_TEXT = '' "
                                "WHERE CONV_ID = %d;",
                                MSGFW_CONVERSATION_TABLE_NAME, convId);
-       }
 
-       pDbHandle->finalizeQuery();
-
-       if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
-               MSG_DEBUG("Query Failed [%s]", sqlQuery);
-               pDbHandle->finalizeQuery();
-               return MSG_ERR_DB_EXEC;
+               if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+                       MSG_DEBUG("Query Failed [%s]", sqlQuery);
+                       return MSG_ERR_DB_EXEC;
+               }
        }
 
-       pDbHandle->finalizeQuery();
-
        MSG_END();
 
        return MSG_SUCCESS;
@@ -1370,9 +1429,9 @@ void MsgStoUpdateAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsg
        MSG_END();
 }
 
-#ifndef FEATURE_SMS_CDMA
 msg_error_t MsgStoAddCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel, msg_sim_slot_id_t simIndex)
 {
+#ifndef FEATURE_SMS_CDMA
        MSG_BEGIN();
 
        char sqlQuery[MAX_QUERY_LEN] = {0,};
@@ -1417,11 +1476,45 @@ msg_error_t MsgStoAddCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pC
        MSG_END();
 
        return MSG_SUCCESS;
+#else /* TODO: Add multisim for CDMA */
+       MSG_BEGIN();
+
+       char sqlQuery[MAX_QUERY_LEN] = {0,};
+
+       pDbHandle->beginTrans();
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s;", MSGFW_CDMA_CB_CHANNEL_INFO_TABLE_NAME);
+
+       if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+               pDbHandle->endTrans(false);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       for (int i = 0; i < pCBChannel->channelCnt; i++) {
+               memset(sqlQuery, 0x00, sizeof(sqlQuery));
+               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, '%s');", MSGFW_CDMA_CB_CHANNEL_INFO_TABLE_NAME,
+                               i, pCBChannel->channelInfo[i].bActivate, pCBChannel->channelInfo[i].ctg,
+                               pCBChannel->channelInfo[i].lang, pCBChannel->channelInfo[i].name);
+
+               if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+                       pDbHandle->endTrans(false);
+                       return MSG_ERR_DB_EXEC;
+               }
+       }
+
+       pDbHandle->endTrans(true);
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+#endif
 }
 
 
 msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel, msg_sim_slot_id_t simIndex)
 {
+#ifndef FEATURE_SMS_CDMA
        MSG_BEGIN();
 
        int rowCnt = 0, index = 0;
@@ -1461,48 +1554,7 @@ msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pC
        MSG_END();
 
        return MSG_SUCCESS;
-}
-#else
-
-msg_error_t MsgStoAddCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel)
-{
-       MSG_BEGIN();
-
-       char sqlQuery[MAX_QUERY_LEN] = {0,};
-
-       pDbHandle->beginTrans();
-
-       memset(sqlQuery, 0x00, sizeof(sqlQuery));
-       snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s;", MSGFW_CDMA_CB_CHANNEL_INFO_TABLE_NAME);
-
-       if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
-               pDbHandle->endTrans(false);
-               return MSG_ERR_DB_EXEC;
-       }
-
-       for (int i = 0; i < pCBChannel->channelCnt; i++) {
-               int index = 1;
-               memset(sqlQuery, 0x00, sizeof(sqlQuery));
-               snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, '%s');", MSGFW_CDMA_CB_CHANNEL_INFO_TABLE_NAME,
-                               i, pCBChannel->channelInfo[i].bActivate, pCBChannel->channelInfo[i].ctg,
-                               pCBChannel->channelInfo[i].lang, pCBChannel->channelInfo[i].name);
-
-               if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
-                       pDbHandle->endTrans(false);
-                       return MSG_ERR_DB_EXEC;
-               }
-       }
-
-       pDbHandle->endTrans(true);
-
-       MSG_END();
-
-       return MSG_SUCCESS;
-}
-
-
-msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel)
-{
+#else /* TODO: Add multisim for CDMA */
        MSG_BEGIN();
 
        int rowCnt = 0, index = 0;
@@ -1542,12 +1594,13 @@ msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pC
        MSG_END();
 
        return MSG_SUCCESS;
-}
 #endif
+}
 
 msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList)
 {
        MsgDbHandler *dbHandle = getDbHandle();
+       dbHandle->connectReadOnly();
 
        pThreadViewList->nCount = 0;
        pThreadViewList->msg_struct_info = NULL;
@@ -1648,10 +1701,8 @@ msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct
 }
 
 
-msg_error_t MsgStoGetConversationPreview(MSG_CONVERSATION_VIEW_S *pConv)
+msg_error_t MsgStoGetConversationPreview(MsgDbHandler *pDbHandle, MSG_CONVERSATION_VIEW_S *pConv)
 {
-       MsgDbHandler dbHandleForInner;
-
        char sqlQuery[MAX_QUERY_LEN + 1];
        int rowCnt = 0, index = 0;
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
@@ -1667,31 +1718,31 @@ msg_error_t MsgStoGetConversationPreview(MSG_CONVERSATION_VIEW_S *pConv)
                        "FROM %s WHERE MSG_ID=%d;",
                        MSGFW_MMS_PREVIEW_TABLE_NAME, pConv->msgId);
 
-       msg_error_t err = dbHandleForInner.getTable(sqlQuery, &rowCnt, &index);
+       msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt, &index);
        if (err == MSG_SUCCESS) {
                for (int i = 0; i < rowCnt; i++) {
-                       int type = dbHandleForInner.getColumnToInt(index++);
+                       int type = pDbHandle->getColumnToInt(index++);
                        if (type == MSG_MMS_ITEM_TYPE_IMG) {
-                               dbHandleForInner.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pConv->imageThumbPath);
-                               dbHandleForInner.getColumnToInt(index++);
+                               pDbHandle->getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pConv->imageThumbPath);
+                               pDbHandle->getColumnToInt(index++);
                        } else if (type == MSG_MMS_ITEM_TYPE_VIDEO) {
-                               dbHandleForInner.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pConv->videoThumbPath);
-                               dbHandleForInner.getColumnToInt(index++);
+                               pDbHandle->getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pConv->videoThumbPath);
+                               pDbHandle->getColumnToInt(index++);
                        } else if (type == MSG_MMS_ITEM_TYPE_AUDIO) {
-                               dbHandleForInner.getColumnToString(index++, MSG_FILENAME_LEN_MAX, pConv->audioFileName);
-                               dbHandleForInner.getColumnToInt(index++);
+                               pDbHandle->getColumnToString(index++, MSG_FILENAME_LEN_MAX, pConv->audioFileName);
+                               pDbHandle->getColumnToInt(index++);
                        } else if (type == MSG_MMS_ITEM_TYPE_ATTACH) {
-                               dbHandleForInner.getColumnToString(index++, MSG_FILENAME_LEN_MAX, pConv->attachFileName);
-                               pConv->attachCount = dbHandleForInner.getColumnToInt(index++);
+                               pDbHandle->getColumnToString(index++, MSG_FILENAME_LEN_MAX, pConv->attachFileName);
+                               pConv->attachCount = pDbHandle->getColumnToInt(index++);
                        } else if (type == MSG_MMS_ITEM_TYPE_PAGE) {
                                index++;
-                               pConv->pageCount = dbHandleForInner.getColumnToInt(index++);
+                               pConv->pageCount = pDbHandle->getColumnToInt(index++);
                        } else if (type == MSG_MMS_ITEM_TYPE_MALWARE) {
                                index++;
-                               pConv->tcs_bc_level = dbHandleForInner.getColumnToInt(index++);
+                               pConv->tcs_bc_level = pDbHandle->getColumnToInt(index++);
                        } else if (type == MSG_MMS_ITEM_TYPE_1ST_MEDIA) {
-                               dbHandleForInner.getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pConv->firstMediaPath);
-                               dbHandleForInner.getColumnToInt(index++);
+                               pDbHandle->getColumnToString(index++, MSG_FILEPATH_LEN_MAX, pConv->firstMediaPath);
+                               pDbHandle->getColumnToInt(index++);
                        } else {
                                MSG_DEBUG("Unknown item type [%d]", type);
                                index+=2;
@@ -1699,13 +1750,12 @@ msg_error_t MsgStoGetConversationPreview(MSG_CONVERSATION_VIEW_S *pConv)
                }
        }
 
-       dbHandleForInner.freeTable();
+       pDbHandle->freeTable();
        return MSG_SUCCESS;
 }
 
-msg_error_t MsgStoGetConversationMultipart(MSG_CONVERSATION_VIEW_S *pConv)
+msg_error_t MsgStoGetConversationMultipart(MsgDbHandler *pDbHandle, MSG_CONVERSATION_VIEW_S *pConv)
 {
-       MsgDbHandler dbHandleForInner;
        char sqlQuery[MAX_QUERY_LEN + 1];
        int rowCnt = 0, index = 0;
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
@@ -1718,7 +1768,7 @@ msg_error_t MsgStoGetConversationMultipart(MSG_CONVERSATION_VIEW_S *pConv)
                        "FROM %s WHERE MSG_ID=%d;",
                        MSGFW_MMS_MULTIPART_TABLE_NAME, pConv->msgId);
 
-       msg_error_t err = dbHandleForInner.getTable(sqlQuery, &rowCnt, &index);
+       msg_error_t err = pDbHandle->getTable(sqlQuery, &rowCnt, &index);
        if (err == MSG_SUCCESS) {
                GList *multipart_list = NULL;
                for (int i = 0; i < rowCnt; i++) {
@@ -1730,28 +1780,29 @@ msg_error_t MsgStoGetConversationMultipart(MSG_CONVERSATION_VIEW_S *pConv)
 
                        MMS_MULTIPART_DATA_S *multipart = (MMS_MULTIPART_DATA_S *)multipart_struct_s->data;
 
-                       dbHandleForInner.getColumnToString(index++, sizeof(multipart->szContentType), multipart->szContentType);
-                       dbHandleForInner.getColumnToString(index++, sizeof(multipart->szFileName), multipart->szFileName);
-                       dbHandleForInner.getColumnToString(index++, sizeof(multipart->szFilePath), multipart->szFilePath);
-                       dbHandleForInner.getColumnToString(index++, sizeof(multipart->szContentID), multipart->szContentID);
-                       dbHandleForInner.getColumnToString(index++, sizeof(multipart->szContentLocation), multipart->szContentLocation);
+                       pDbHandle->getColumnToString(index++, sizeof(multipart->szContentType), multipart->szContentType);
+                       pDbHandle->getColumnToString(index++, sizeof(multipart->szFileName), multipart->szFileName);
+                       pDbHandle->getColumnToString(index++, sizeof(multipart->szFilePath), multipart->szFilePath);
+                       pDbHandle->getColumnToString(index++, sizeof(multipart->szContentID), multipart->szContentID);
+                       pDbHandle->getColumnToString(index++, sizeof(multipart->szContentLocation), multipart->szContentLocation);
 
-                       multipart->tcs_bc_level = dbHandleForInner.getColumnToInt(index++);
-                       multipart->malware_allow = dbHandleForInner.getColumnToInt(index++);
-                       dbHandleForInner.getColumnToString(index++, sizeof(multipart->szThumbFilePath), multipart->szThumbFilePath);
+                       multipart->tcs_bc_level = pDbHandle->getColumnToInt(index++);
+                       multipart->malware_allow = pDbHandle->getColumnToInt(index++);
+                       pDbHandle->getColumnToString(index++, sizeof(multipart->szThumbFilePath), multipart->szThumbFilePath);
 
                        multipart_list = g_list_append(multipart_list, multipart_struct_s);
                }
                pConv->multipart_list = (msg_list_handle_t)multipart_list;
        }
 
-       dbHandleForInner.freeTable();
+       pDbHandle->freeTable();
        return MSG_SUCCESS;
 }
 
 msg_error_t MsgStoGetConversationViewItem(msg_message_id_t msgId, MSG_CONVERSATION_VIEW_S *pConv)
 {
        MsgDbHandler *dbHandle = getDbHandle();
+       dbHandle->connectReadOnly();
 
        int rowCnt = 0, index = 0;
 
@@ -1794,38 +1845,43 @@ msg_error_t MsgStoGetConversationViewItem(msg_message_id_t msgId, MSG_CONVERSATI
        pConv->scheduledTime = (time_t)dbHandle->getColumnToInt(index++);
 
        dbHandle->getColumnToString(index++, MAX_SUBJECT_LEN, pConv->subject);
+       char *tmpText = g_strdup(dbHandle->getColumnToString(index++));
+
+       //It does Not need to Get attach count in MSG_MESSAGE_TABLE. see MsgStoGetConversationPreview
+       //pConv->attachCount = dbHandle->getColumnToInt(index++);
+       index++;
+       pConv->simIndex = dbHandle->getColumnToInt(index++);
+
+       dbHandle->freeTable();
 
        if (pConv->mainType == MSG_MMS_TYPE &&
                (pConv->networkStatus == MSG_NETWORK_RETRIEVING || pConv->networkStatus == MSG_NETWORK_RETRIEVE_FAIL || pConv->subType == MSG_NOTIFICATIONIND_MMS)) {
                pConv->pText = NULL;
                pConv->textSize = 0;
-               index++;
        } else {
                if (pConv->mainType == MSG_SMS_TYPE) {
                        pConv->pText = new char[pConv->textSize+2];
                        memset(pConv->pText, 0x00, pConv->textSize+2);
-                       dbHandle->getColumnToString(index++, pConv->textSize+1, pConv->pText);
-               } else {
-                       char *tmpMmsText = dbHandle->getColumnToString(index++);
-
-                       pConv->textSize = strlen(tmpMmsText);
+                       snprintf(pConv->pText, pConv->textSize+1, "%s", tmpText);
+               } else if (pConv->mainType == MSG_MMS_TYPE) {
+                       if (tmpText) {
+                               pConv->textSize = strlen(tmpText);
 
-                       pConv->pText = new char[pConv->textSize+1];
-                       memset(pConv->pText, 0x00, pConv->textSize+1);
+                               pConv->pText = new char[pConv->textSize+1];
+                               memset(pConv->pText, 0x00, pConv->textSize+1);
 
-                       strncpy(pConv->pText, tmpMmsText, pConv->textSize);
+                               strncpy(pConv->pText, tmpText, pConv->textSize);
+                       }
 
-                       MsgStoGetConversationPreview(pConv);
-                       MsgStoGetConversationMultipart(pConv);
+                       MsgStoGetConversationPreview(dbHandle, pConv);
+                       MsgStoGetConversationMultipart(dbHandle, pConv);
                }
        }
 
-       //It does Not need to Get attach count in MSG_MESSAGE_TABLE. see MsgStoGetConversationPreview
-       //pConv->attachCount = dbHandle->getColumnToInt(index++);
-       index++;
-       pConv->simIndex = dbHandle->getColumnToInt(index++);
-
-       dbHandle->freeTable();
+       if (tmpText) {
+               g_free(tmpText);
+               tmpText = NULL;
+       }
 
        MSG_END();
 
@@ -1838,6 +1894,7 @@ msg_error_t MsgStoGetConversationViewList(msg_thread_id_t threadId, msg_struct_l
        MSG_BEGIN();
 
        MsgDbHandler *dbHandle = getDbHandle();
+       dbHandle->connectReadOnly();
 
        pConvViewList->nCount = 0;
        pConvViewList->msg_struct_info = NULL;
@@ -1874,6 +1931,7 @@ msg_error_t MsgStoGetConversationViewList(msg_thread_id_t threadId, msg_struct_l
        }
 
        pConvViewList->nCount = rowCnt;
+       char *tmpText[rowCnt] = {NULL};
 
        MSG_DEBUG("pConvViewList->nCount [%d]", pConvViewList->nCount);
 
@@ -1912,53 +1970,61 @@ msg_error_t MsgStoGetConversationViewList(msg_thread_id_t threadId, msg_struct_l
                index++; // This field is reserved.
 
                dbHandle->getColumnToString(index++, MAX_SUBJECT_LEN, pTmp->subject);
+               tmpText[i] = g_strdup(dbHandle->getColumnToString(index++));
+
+               //It does Not need to Get attach count in MSG_MESSAGE_TABLE. see MsgStoGetConversationPreview
+               //pTmp->attachCount = dbHandle->getColumnToInt(index++);
+               index++;
+               pTmp->simIndex = dbHandle->getColumnToInt(index++);
+       }
+       dbHandle->freeTable();
+
+       for (int i = 0; i < pConvViewList->nCount; i++) {
+               conv = (msg_struct_s *)pConvViewList->msg_struct_info[i];
+               pTmp = (MSG_CONVERSATION_VIEW_S *)conv->data;
 
                if (pTmp->mainType == MSG_MMS_TYPE &&
                        (pTmp->networkStatus == MSG_NETWORK_RETRIEVING || pTmp->networkStatus == MSG_NETWORK_RETRIEVE_FAIL || pTmp->subType == MSG_NOTIFICATIONIND_MMS)) {
                        pTmp->pText = NULL;
                        pTmp->textSize = 0;
-                       index++;
                } else {
                        if (pTmp->mainType == MSG_SMS_TYPE) {
                                pTmp->pText = new char[pTmp->textSize+2];
                                memset(pTmp->pText, 0x00, pTmp->textSize+2);
-                               dbHandle->getColumnToString(index++, pTmp->textSize+1, pTmp->pText);
-                       } else {
-                               char *tmpMmsText = dbHandle->getColumnToString(index++);
-
-                               if (tmpMmsText) {
-                                       pTmp->textSize = strlen(tmpMmsText);
+                               snprintf(pTmp->pText, pTmp->textSize+1, "%s", tmpText[i]);
+                       } else if (pTmp->mainType == MSG_MMS_TYPE) {
+                               if (tmpText[i]) {
+                                       pTmp->textSize = strlen(tmpText[i]);
 
                                        pTmp->pText = new char[pTmp->textSize+1];
                                        memset(pTmp->pText, 0x00, pTmp->textSize+1);
 
-                                       strncpy(pTmp->pText, tmpMmsText, pTmp->textSize);
+                                       strncpy(pTmp->pText, tmpText[i], pTmp->textSize);
                                }
 
-                               MsgStoGetConversationPreview(pTmp);
-                               MsgStoGetConversationMultipart(pTmp);
+                               MsgStoGetConversationPreview(dbHandle, pTmp);
+                               MsgStoGetConversationMultipart(dbHandle, pTmp);
                        }
                }
-               //It does Not need to Get attach count in MSG_MESSAGE_TABLE. see MsgStoGetConversationPreview
-               //pTmp->attachCount = dbHandle->getColumnToInt(index++);
-               index++;
-               pTmp->simIndex = dbHandle->getColumnToInt(index++);
+               if (tmpText[i]) {
+                       g_free(tmpText[i]);
+                       tmpText[i] = NULL;
+               }
        }
 
-       dbHandle->freeTable();
-
        MSG_END();
 
        return MSG_SUCCESS;
 }
 
 
-msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList)
+msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList, int contactCount)
 {
        if (!pSearchString)
                return MSG_ERR_NULL_POINTER;
 
        MsgDbHandler *dbHandle = getDbHandle();
+       dbHandle->connectReadOnly();
        char *escapeAddressStr = NULL;
 
        // Clear Out Parameter
@@ -1970,138 +2036,106 @@ msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pT
 
        MSG_THREAD_VIEW_S threadView;
 
-       MSG_ADDRESS_INFO_S *pAddrInfo = NULL;
-       unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> buf(&pAddrInfo, unique_ptr_deleter);
-       int count = 0;
-
-       //contacts-service is not used for gear
-#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-       // get contact search list
-       if (MsgGetContactSearchList(pSearchString, &pAddrInfo, &count) != MSG_SUCCESS) {
-               MSG_DEBUG("MsgGetContactSearchList fail.");
-               count = 0;
-       }
-#endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-       int iteration = (count / ITERATION_SIZE) + 1;
-       int remaining = count;
-
-       for (int itr = 0; itr < iteration ; ++ itr) {
-               int cnt = 0;
-               (remaining > ITERATION_SIZE) ? (cnt = ITERATION_SIZE) : (cnt = remaining);
-
-               unsigned int maxlength = MAX_QUERY_LEN + (MAX_ADDRESS_VAL_LEN * cnt) +1;
-               char sqlQuery[maxlength];
-
-               // Search - Address, Name
-               memset(sqlQuery, 0x00, maxlength);
-               snprintf(sqlQuery, maxlength, "SELECT A.CONV_ID, A.UNREAD_CNT, A.SMS_CNT, A.MMS_CNT, A.DISPLAY_NAME, "
-                               "A.MAIN_TYPE, A.SUB_TYPE, A.MSG_DIRECTION, A.DISPLAY_TIME, A.MSG_TEXT, "
-                               "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.PROTECTED = 1) AS PROTECTED, "
-                               "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.FOLDER_ID = %d) AS DRAFT, "
-                               "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.NETWORK_STATUS = %d) AS FAILED, "
-                               "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.NETWORK_STATUS = %d) AS SENDING "
-                               "FROM %s A WHERE (A.SMS_CNT > 0 OR A.MMS_CNT > 0) "
-                               "AND A.CONV_ID IN "
-                               "(SELECT DISTINCT(CONV_ID) FROM %s WHERE "
-                               "ADDRESS_VAL LIKE ? ESCAPE '%c' ",
-                               MSGFW_MESSAGE_TABLE_NAME,
-                               MSGFW_MESSAGE_TABLE_NAME, MSG_DRAFT_ID,
-                               MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SEND_FAIL,
-                               MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SENDING,
-                               MSGFW_CONVERSATION_TABLE_NAME,
-                               MSGFW_ADDRESS_TABLE_NAME,
-                               MSGFW_DB_ESCAPE_CHAR);
-
-               unsigned int tmpSize = 0;
-
-               for (int i = 0; i < cnt; i++) {
-                       int addrSize = strlen(pAddrInfo[itr * ITERATION_SIZE + i].addressVal);
-                       char newPhoneNum[addrSize+1];
-                       memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
-
-                       if (addrSize > MsgContactGetMinMatchDigit())
-                               MsgConvertNumber(pAddrInfo[itr * ITERATION_SIZE + i].addressVal, newPhoneNum, addrSize);
-                       else
-                               strncpy(newPhoneNum, pAddrInfo[itr * ITERATION_SIZE + i].addressVal, addrSize);
+       char sqlQuery[MAX_QUERY_LEN+1];
 
-                       tmpSize = strlen(sqlQuery);
-                       snprintf(sqlQuery+tmpSize, maxlength-tmpSize,
-                                       "OR ADDRESS_VAL LIKE '%%%s' ",
-                                       newPhoneNum);
+       // Search - Address, Name
+       memset(sqlQuery, 0x00, MAX_QUERY_LEN+1);
+       snprintf(sqlQuery, MAX_QUERY_LEN, "SELECT A.CONV_ID, A.UNREAD_CNT, A.SMS_CNT, A.MMS_CNT, A.DISPLAY_NAME, "
+                       "A.MAIN_TYPE, A.SUB_TYPE, A.MSG_DIRECTION, A.DISPLAY_TIME, A.MSG_TEXT, "
+                       "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.PROTECTED = 1) AS PROTECTED, "
+                       "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.FOLDER_ID = %d) AS DRAFT, "
+                       "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.NETWORK_STATUS = %d) AS FAILED, "
+                       "(SELECT COUNT(*) FROM %s B WHERE B.CONV_ID = A.CONV_ID AND B.NETWORK_STATUS = %d) AS SENDING "
+                       "FROM %s A WHERE (A.SMS_CNT > 0 OR A.MMS_CNT > 0) "
+                       "AND A.CONV_ID IN "
+                       "(SELECT DISTINCT(CONV_ID) FROM %s WHERE "
+                       "ADDRESS_VAL LIKE ? ESCAPE '%c' ",
+                       MSGFW_MESSAGE_TABLE_NAME,
+                       MSGFW_MESSAGE_TABLE_NAME, MSG_DRAFT_ID,
+                       MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SEND_FAIL,
+                       MSGFW_MESSAGE_TABLE_NAME, MSG_NETWORK_SENDING,
+                       MSGFW_CONVERSATION_TABLE_NAME,
+                       MSGFW_ADDRESS_TABLE_NAME,
+                       MSGFW_DB_ESCAPE_CHAR);
 
-               }
-               remaining -= cnt;
+       unsigned int tmpSize = 0;
+       if (contactCount > 0) {
                tmpSize = strlen(sqlQuery);
-               snprintf(sqlQuery+tmpSize, maxlength-tmpSize,
-                               ") ORDER BY A.DISPLAY_TIME DESC;");
-               MSG_DEBUG("maxlength: [%d], Query Length: [%d]", maxlength, strlen(sqlQuery));
-               MSG_DEBUG("[%s]", sqlQuery);
+               snprintf(sqlQuery+tmpSize, MAX_QUERY_LEN-tmpSize,
+                               "OR ADDRESS_VAL IN (SELECT C.ADDRESS_VAL FROM %s C JOIN %s D ON (C.ADDRESS_VAL LIKE D.ADDRESS_VAL))"
+                               , MSGFW_ADDRESS_TABLE_NAME, MSGFW_ADDRESS_TEMP_TABLE_NAME);
+       }
 
-               if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
-                       MSG_DEBUG("Prepare query fail.");
-                       return MSG_ERR_DB_PREPARE;
-               }
+       tmpSize = strlen(sqlQuery);
+       snprintf(sqlQuery+tmpSize, MAX_QUERY_LEN-tmpSize,
+                       ") ORDER BY A.DISPLAY_TIME DESC;");
 
-               MsgConvertStrWithEscape(pSearchString, &escapeAddressStr);
-               MSG_DEBUG("escapeAddressStr [%s]", escapeAddressStr);
-               dbHandle->bindText(escapeAddressStr, 1);
-               //dbHandle->bindText(escapeAddressStr, 2);
-               //dbHandle->bindText(escapeAddressStr, 3);
-               //dbHandle->bindText(escapeAddressStr, 4);
+       MSG_DEBUG("sqlQuery=[%s]", sqlQuery);
 
-               while (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
-                       memset(&threadView, 0x00, sizeof(threadView));
+       if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
+               MSG_DEBUG("Prepare query fail.");
+               return MSG_ERR_DB_PREPARE;
+       }
 
-                       threadView.threadId = dbHandle->columnInt(0);
-                       threadView.unreadCnt = dbHandle->columnInt(1);
-                       threadView.smsCnt = dbHandle->columnInt(2);
-                       threadView.mmsCnt = dbHandle->columnInt(3);
+       MsgConvertStrWithEscape(pSearchString, &escapeAddressStr);
+       MSG_DEBUG("escapeAddressStr [%s]", escapeAddressStr);
+       dbHandle->bindText(escapeAddressStr, 1);
+       //dbHandle->bindText(escapeAddressStr, 2);
+       //dbHandle->bindText(escapeAddressStr, 3);
+       //dbHandle->bindText(escapeAddressStr, 4);
 
-                       if (dbHandle->columnText(4))
-                               strncpy(threadView.threadName, (char *)dbHandle->columnText(4), MAX_THREAD_NAME_LEN);
+       while (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+               memset(&threadView, 0x00, sizeof(threadView));
 
-                       threadView.mainType = dbHandle->columnInt(5);
-                       threadView.subType = dbHandle->columnInt(6);
+               threadView.threadId = dbHandle->columnInt(0);
+               threadView.unreadCnt = dbHandle->columnInt(1);
+               threadView.smsCnt = dbHandle->columnInt(2);
+               threadView.mmsCnt = dbHandle->columnInt(3);
 
-                       threadView.direction = dbHandle->columnInt(7);
-                       threadView.threadTime = (time_t)dbHandle->columnInt(8);
+               if (dbHandle->columnText(4))
+                       strncpy(threadView.threadName, (char *)dbHandle->columnText(4), MAX_THREAD_NAME_LEN);
 
-                       if (dbHandle->columnText(9))
-                               strncpy(threadView.threadData, (char *)dbHandle->columnText(9), MAX_THREAD_DATA_LEN);
+               threadView.mainType = dbHandle->columnInt(5);
+               threadView.subType = dbHandle->columnInt(6);
 
-                       int protectedCnt = dbHandle->columnInt(10);
-                       if (protectedCnt > 0)
-                               threadView.bProtected = true;
+               threadView.direction = dbHandle->columnInt(7);
+               threadView.threadTime = (time_t)dbHandle->columnInt(8);
 
-                       int draftCnt = dbHandle->columnInt(11);
-                       if (draftCnt > 0)
-                               threadView.bDraft = true;
+               if (dbHandle->columnText(9))
+                       strncpy(threadView.threadData, (char *)dbHandle->columnText(9), MAX_THREAD_DATA_LEN);
 
-                       int failedCnt = dbHandle->columnInt(12);
-                       if (failedCnt > 0)
-                               threadView.bSendFailed = true;
+               int protectedCnt = dbHandle->columnInt(10);
+               if (protectedCnt > 0)
+                       threadView.bProtected = true;
 
-                       int sendingCnt = dbHandle->columnInt(13);
-                       if (sendingCnt > 0)
-                               threadView.bSending = true;
+               int draftCnt = dbHandle->columnInt(11);
+               if (draftCnt > 0)
+                       threadView.bDraft = true;
 
-                       tr1::unordered_set<msg_thread_id_t>::iterator it;
+               int failedCnt = dbHandle->columnInt(12);
+               if (failedCnt > 0)
+                       threadView.bSendFailed = true;
 
-                       it = IdList.find(threadView.threadId);
+               int sendingCnt = dbHandle->columnInt(13);
+               if (sendingCnt > 0)
+                       threadView.bSending = true;
 
-                       if (it == IdList.end()) {
-                               IdList.insert(threadView.threadId);
-                               searchList.push(threadView);
-                       }
+               tr1::unordered_set<msg_thread_id_t>::iterator it;
+
+               it = IdList.find(threadView.threadId);
 
+               if (it == IdList.end()) {
+                       IdList.insert(threadView.threadId);
+                       searchList.push(threadView);
                }
 
-               dbHandle->finalizeQuery();
+       }
 
-               if (escapeAddressStr) {
-                       free(escapeAddressStr);
-                       escapeAddressStr = NULL;
-               }
+       dbHandle->finalizeQuery();
+
+       if (escapeAddressStr) {
+               free(escapeAddressStr);
+               escapeAddressStr = NULL;
        }
 
 
@@ -2140,6 +2174,7 @@ msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pT
 msg_error_t MsgStoGetRejectMsgList(const char *pNumber, msg_struct_list_s *pRejectMsgList)
 {
        MsgDbHandler *dbHandle = getDbHandle();
+       dbHandle->connectReadOnly();
 
        // Clear Out Parameter
        pRejectMsgList->nCount = 0;
@@ -2232,6 +2267,7 @@ msg_error_t MsgStoGetRejectMsgList(const char *pNumber, msg_struct_list_s *pReje
 msg_error_t MsgStoGetAddressList(const msg_thread_id_t threadId, msg_struct_list_s *pAddrList)
 {
        MsgDbHandler *dbHandle = getDbHandle();
+       dbHandle->connectReadOnly();
 
        msg_error_t err = MSG_SUCCESS;
 
@@ -2249,9 +2285,10 @@ msg_error_t MsgStoGetAddressList(const msg_thread_id_t threadId, msg_struct_list
 }
 
 
-msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_struct_list_s *pMsgList)
+msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_struct_list_s *pMsgList, int contactCount)
 {
        MsgDbHandler *dbHandle = getDbHandle();
+       dbHandle->connectReadOnly();
 
        // Clear Out Parameter
        pMsgList->nCount = 0;
@@ -2262,7 +2299,6 @@ msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_stru
 
        char sqlQuery[MAX_QUERY_LEN+1];
        char sqlQuerySubset[(MAX_QUERY_LEN/5)+1];
-       char tmpsqlQuery[MAX_QUERY_LEN+1];
 
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "SELECT COUNT(*) FROM %s;", MSGFW_MMS_MULTIPART_TABLE_NAME);
@@ -2467,61 +2503,7 @@ msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_stru
                                        "(B.ADDRESS_VAL LIKE ? ESCAPE '%c' ", MSGFW_DB_ESCAPE_CHAR);
                        strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery));
 
-                       MSG_ADDRESS_INFO_S *pAddrInfo = NULL;
-                       unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> buf(&pAddrInfo, unique_ptr_deleter);
-                       int count = 0;
-
-                       //contacts-service is not used for gear
-#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                       // get contact search list
-                       if (MsgGetContactSearchList(pListCond->pAddressVal, &pAddrInfo, &count) != MSG_SUCCESS) {
-                               MSG_DEBUG("MsgGetContactSearchList fail.");
-                               count = 0;
-                       }
-#endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                       if (count > 0) {
-                               dbHandle->beginTrans();
-                               // reset address temp table
-                               memset(tmpsqlQuery, 0x00, sizeof(tmpsqlQuery));
-                               snprintf(tmpsqlQuery, sizeof(tmpsqlQuery), "DELETE FROM %s;", MSGFW_ADDRESS_TEMP_TABLE_NAME);
-                               MSG_DEBUG("[%s]", tmpsqlQuery);
-
-                               if (dbHandle->prepareQuery(tmpsqlQuery) != MSG_SUCCESS)
-                                       return MSG_ERR_DB_EXEC;
-
-                               if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
-                                       dbHandle->finalizeQuery();
-                                       dbHandle->endTrans(false);
-                                       return MSG_ERR_DB_EXEC;
-                               }
-
-                               dbHandle->finalizeQuery();
-
-                               memset(tmpsqlQuery, 0x00, sizeof(tmpsqlQuery));
-                               snprintf(tmpsqlQuery, sizeof(tmpsqlQuery), "INSERT INTO %s VALUES ('%%%%?');", MSGFW_ADDRESS_TEMP_TABLE_NAME);
-                               if (dbHandle->prepareQuery(tmpsqlQuery) != MSG_SUCCESS) {
-                                       dbHandle->endTrans(false);
-                                       return MSG_ERR_DB_PREPARE;
-                               }
-
-                               for (int i = 0; i < count; i++) {
-                                       int addrSize = strlen(pAddrInfo[i].addressVal);
-                                       char newPhoneNum[addrSize+1];
-                                       memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
-                                       MsgConvertNumber(pAddrInfo[i].addressVal, newPhoneNum, addrSize);
-
-                                       dbHandle->resetQuery();
-                                       dbHandle->bindText(newPhoneNum, 1);
-                                       if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
-                                               dbHandle->finalizeQuery();
-                                               dbHandle->endTrans(false);
-                                               return MSG_ERR_DB_EXEC;
-                                       }
-                               }
-
-                               dbHandle->finalizeQuery();
-                               dbHandle->endTrans(true);
-
+                       if (contactCount > 0) {
                                memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset));
                                snprintf(sqlQuerySubset, sizeof(sqlQuerySubset),
                                                "OR B.ADDRESS_VAL IN (SELECT D.ADDRESS_VAL FROM %s D JOIN %s E ON (D.ADDRESS_VAL LIKE E.ADDRESS_VAL)) "
@@ -2539,62 +2521,7 @@ msg_error_t MsgStoGetMessageList(const MSG_LIST_CONDITION_S *pListCond, msg_stru
                                        "AND (B.ADDRESS_VAL LIKE ? ESCAPE '%c' ", MSGFW_DB_ESCAPE_CHAR);
                        strncat(sqlQuery, sqlQuerySubset, MAX_QUERY_LEN-strlen(sqlQuery));
 
-                       MSG_ADDRESS_INFO_S *pAddrInfo = NULL;
-                       unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> buf(&pAddrInfo, unique_ptr_deleter);
-                       int count = 0;
-
-                       //contacts-service is not used for gear
-#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                       // get contact search list
-                       if (MsgGetContactSearchList(pListCond->pAddressVal, &pAddrInfo, &count) != MSG_SUCCESS) {
-                               MSG_DEBUG("MsgGetContactSearchList fail.");
-                               count = 0;
-                       }
-#endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED
-                       if (count > 0) {
-                               dbHandle->beginTrans();
-                               // reset address temp table
-                               memset(tmpsqlQuery, 0x00, sizeof(tmpsqlQuery));
-                               snprintf(tmpsqlQuery, sizeof(tmpsqlQuery), "DELETE FROM %s;", MSGFW_ADDRESS_TEMP_TABLE_NAME);
-                               MSG_DEBUG("[%s]", tmpsqlQuery);
-
-                               if (dbHandle->prepareQuery(tmpsqlQuery) != MSG_SUCCESS) {
-                                       dbHandle->endTrans(false);
-                                       return MSG_ERR_DB_EXEC;
-                               }
-
-                               if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
-                                       dbHandle->finalizeQuery();
-                                       return MSG_ERR_DB_EXEC;
-                               }
-
-                               dbHandle->finalizeQuery();
-
-                               memset(tmpsqlQuery, 0x00, sizeof(tmpsqlQuery));
-                               snprintf(tmpsqlQuery, sizeof(tmpsqlQuery), "INSERT INTO %s VALUES ('%%%%?');", MSGFW_ADDRESS_TEMP_TABLE_NAME);
-                               if (dbHandle->prepareQuery(tmpsqlQuery) != MSG_SUCCESS) {
-                                       dbHandle->endTrans(false);
-                                       return MSG_ERR_DB_PREPARE;
-                               }
-
-                               for (int i = 0; i < count; i++) {
-                                       int addrSize = strlen(pAddrInfo[i].addressVal);
-                                       char newPhoneNum[addrSize+1];
-                                       memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
-                                       MsgConvertNumber(pAddrInfo[i].addressVal, newPhoneNum, addrSize);
-
-                                       dbHandle->resetQuery();
-                                       dbHandle->bindText(newPhoneNum, 1);
-                                       if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
-                                               dbHandle->finalizeQuery();
-                                               dbHandle->endTrans(false);
-                                               return MSG_ERR_DB_EXEC;
-                                       }
-                               }
-
-                               dbHandle->finalizeQuery();
-                               dbHandle->endTrans(true);
-
+                       if (contactCount > 0) {
                                memset(sqlQuerySubset, 0x00, sizeof(sqlQuerySubset));
                                snprintf(sqlQuerySubset, sizeof(sqlQuerySubset),
                                                "OR B.ADDRESS_VAL IN (SELECT D.ADDRESS_VAL FROM %s D JOIN %s E ON (D.ADDRESS_VAL LIKE E.ADDRESS_VAL)) "
@@ -2872,6 +2799,7 @@ msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t
        MSG_BEGIN();
        msg_error_t err = MSG_SUCCESS;
        MsgDbHandler *dbHandle = getDbHandle();
+       dbHandle->connectReadOnly();
        char sqlQuery[MAX_QUERY_LEN+1];
        int msgIdCnt = 0;
 
@@ -2898,34 +2826,13 @@ msg_error_t MsgStoGetMediaList(const msg_thread_id_t threadId, msg_list_handle_t
 
        dbHandle->freeTable();
 
-       int main_type = 0;
        GList *media_list = NULL;
 
        for (int i = 0; i < msgIdCnt; i++) {
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
-               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MAIN_TYPE FROM %s WHERE MSG_ID = %d;",
-                               MSGFW_MESSAGE_TABLE_NAME, msgIds[i]);
-
-               err = dbHandle->prepareQuery(sqlQuery);
-               if (err != MSG_SUCCESS)
-                       return err;
-
-               err = dbHandle->stepQuery();
-               if (err != MSG_ERR_DB_ROW) {
-                       dbHandle->finalizeQuery();
-                       return err;
-               }
-
-               main_type = dbHandle->columnInt(0);
-
-               dbHandle->finalizeQuery();
-
-               if (main_type == MSG_MMS_TYPE) {
-                       memset(sqlQuery, 0x00, sizeof(sqlQuery));
-                       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, CONTENT_TYPE, FILE_PATH, THUMB_FILE_PATH "
-                                       "FROM %s WHERE MSG_ID = %d AND SEQ <> -1;",
-                                       MSGFW_MMS_MULTIPART_TABLE_NAME, msgIds[i]);
-               }
+               snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID, CONTENT_TYPE, FILE_PATH, THUMB_FILE_PATH "
+                               "FROM %s WHERE MSG_ID = %d AND SEQ <> -1 AND (TCS_LEVEL = -1 OR MALWARE_ALLOW = 1);",
+                               MSGFW_MMS_MULTIPART_TABLE_NAME, msgIds[i]);
 
                int rowCnt = 0, msg_id = 0, index = 0;
 
index e621568..141ed5e 100755 (executable)
  * limitations under the License.
 */
 
+#include <glib.h>
+#include <errno.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <unicode/ucnv.h>
+#include <unicode/ustring.h>
+
 #include <VMessage.h>
 #include <VCard.h>
 #include <time.h>
 
 #include "MsgMmsTypes.h"
-
+#include "MsgContact.h"
 #include "MsgDebug.h"
 #include "MsgUtilFile.h"
 #include "MsgCppTypes.h"
 #include "MsgMmsMessage.h"
 #include "MsgSerialize.h"
 
+#define VMSG_INIT_LENGTH 1024
+#define VMSG_ITEM_LENGTH 1024
+#define MSGSVC_VMSG_FOLDING_LIMIT 75
+
+#define SMART_STRDUP(src) (src && *src)?strdup(src):NULL
+#define SAFE_STR(src) (src)?src:""
+
+#define MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, str) do { \
+       if ((len = __msgsvc_vmsg_append_str(buf, buf_size, len, str, false)) < 0) { \
+               MSG_ERR("__msgsvc_vmsg_append_str() Failed"); \
+               return MSG_ERR_MEMORY_ERROR; \
+       } \
+} while (0)
+
+#define MSGSVC_VMSG_APPEND_STR_FREE(buf, buf_size, len, str) do { \
+       if ((len = __msgsvc_vmsg_append_str(buf, buf_size, len, str, false)) < 0) { \
+               MSG_ERR("__msgsvc_vmsg_append_str() Failed"); \
+               if (str) \
+                       free(str); \
+               return MSG_ERR_MEMORY_ERROR; \
+       } \
+} while (0)
+
+#define MSGSVC_VMSG_APPEND_CONTENT_STR(buf, buf_size, len, content) do { \
+       if ((len = __msgsvc_vmsg_append_str(buf, buf_size, len, content, true)) < 0) { \
+               MSG_ERR("__msgsvc_vmsg_append_str() Failed"); \
+               return MSG_ERR_MEMORY_ERROR; \
+       } \
+} while (0)
+
+
+#define MSGSVC_VMSG_APPEND_CONTENT(buf, buf_size, len, content) do { \
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, ";CHARSET=UTF-8"); \
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, ":"); \
+       MSGSVC_VMSG_APPEND_CONTENT_STR(buf, buf_size, len, content); \
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF); \
+} while (0)
+
+enum {
+       CTSVC_VCARD_VER_NONE,
+       CTSVC_VCARD_VER_2_1,
+       CTSVC_VCARD_VER_3_0,
+       CTSVC_VCARD_VER_4_0,
+};
+
+enum {
+       MSGSVC_VMSG_VER_NONE,
+       MSGSVC_VMSG_VER_1_1,
+       MSGSVC_VMSG_VER_3_0
+};
+
+
+enum {
+        // vMessage
+       VMSG_VALUE_NONE = 0,
+       BEGIN_VMSG = 1,
+       VERSION_VMSG =2,
+       BEGIN_VCARD = 3,
+       VERSION_VCARD = 4,
+       END_VCARD = 5,
+       BEGIN_VENV = 6,
+       BEGIN_VBODY = 7,
+       END_VBODY = 8,
+       END_VENV = 9,
+       END_VMSG = 10,
+
+       FNAME_VCARD = 11 ,
+       NAME_VCARD = 12,
+       TEL_VCARD = 13,
+       TEL_VCARD_CELL = 14,
+
+       DATE_VMSG = 15,
+       SUBJECT_VMSG =16 ,
+
+       FNAME_UTF8_VCARD = 17,
+       NAME_UTF8_VCARD = 18,
+
+       // Encodings
+       VMSG_ATTR_ENCODING_QP = 19,
+       VMSG_ATTR_ENCODING_BASE64_V21 = 20,
+       VMSG_ATTR_ENCODING_BASE64_V30 = 21,
+
+       // Message type indication
+       VMSG_INDICATION_MESSAGE_TYPE = 22,
+       VMSG_INDICATION_MESSAGE_TYPE_INET = 23,
+       VMSG_INDICATION_MESSAGE_TYPE_MSG = 24,
+
+       // Read status indication
+       VMSG_INDICATION_READ_STATUS = 25,
+       VMSG_INDICATION_READ_STATUS_READ = 26,
+       VMSG_INDICATION_READ_STATUS_UNREAD = 27,
+
+       // Mailbox status indication
+       VMSG_INDICATION_MSG_BOX = 28,
+       VMSG_INDICATION_MSG_BOX_SENT = 29,
+       VMSG_INDICATION_MSG_BOX_INBOX = 30,
+       VMSG_INDICATION_MSG_BOX_DRAFT = 31,
+
+       // Character set
+       VMSG_ATTR_CHARSET_PROPERTY = 32,
+
+       // Language
+       VMSG_ATTR_LANGUAGE_PROPERTY = 33,
+       VMSG_DATA_SEPARATOR = 34,
+
+       VMSG_BODY_PROPERTY_DATE = 35,
+       VMSG_BODY_PROPERTY_SUBJECT = 36,
+       VMSG_BODY_PROPERTY_FROM = 37,
+       VMSG_BODY_PROPERTY_TO = 38,
+
+       KEY_BODY = 39,
+       KEY_DATE = 40,
+
+        //DECODER
+       VMSG_VCARD_TEL = 41,
+       VMSG_MSG_BEGIN = 42,
+       VMSG_MSG_END = 43,
+       VMSG_MAXIMUM_VALUE = 44,
+};
+
+static const char *content_name[VMSG_MAXIMUM_VALUE+1] = {0};
+const char *MSGSVC_CRLF = "\r\n";
+bool needCharset = false;
+
+static void __msgsvc_vmsg_initial(void)
+{
+       if (NULL == *content_name) {
+
+               // vMessage
+               content_name[BEGIN_VMSG] = "BEGIN:VMSG";
+               content_name[VERSION_VMSG] = "VERSION:1.1";
+               content_name[BEGIN_VCARD] = "BEGIN:VCARD";
+               content_name[VERSION_VCARD] = "VERSION:2.1";
+               content_name[END_VCARD] = "END:VCARD";
+               content_name[BEGIN_VENV] = "BEGIN:VENV";
+               content_name[BEGIN_VBODY] = "BEGIN:VBODY";
+               content_name[END_VBODY] = "END:VBODY";
+               content_name[END_VENV] = "END:VENV";
+               content_name[END_VMSG] = "END:VMSG";
+
+               content_name[FNAME_VCARD] = "FN:";
+               content_name[NAME_VCARD] = "N:";
+               content_name[TEL_VCARD] = "TEL;";
+               content_name[TEL_VCARD_CELL] = "CELL:";
+
+               content_name[DATE_VMSG] = "Date:";
+               content_name[SUBJECT_VMSG] = "Subject:";
+
+               content_name[FNAME_UTF8_VCARD] = "FN;CHARSET=UTF-8:";
+               content_name[NAME_UTF8_VCARD] = "N;CHARSET=UTF-8:";
+
+               // Encodings
+               content_name[VMSG_ATTR_ENCODING_QP] = "ENCODING=QUOTED-PRINTABLE";
+               content_name[VMSG_ATTR_ENCODING_BASE64_V21] = "ENCODING=BASE64";
+               content_name[VMSG_ATTR_ENCODING_BASE64_V30] = "ENCODING=b";
+
+               // Message type indication
+               content_name[VMSG_INDICATION_MESSAGE_TYPE] = "X-IRMC-TYPE";
+               content_name[VMSG_INDICATION_MESSAGE_TYPE_INET] = "INET";
+               content_name[VMSG_INDICATION_MESSAGE_TYPE_MSG] = "MSG";
+
+               // Read status indication
+               content_name[VMSG_INDICATION_READ_STATUS] = "X-IRMC-STATUS";
+               content_name[VMSG_INDICATION_READ_STATUS_READ] = "READ";
+               content_name[VMSG_INDICATION_READ_STATUS_UNREAD] =  "UNREAD";
+
+               // Mailbox status indication
+               content_name[VMSG_INDICATION_MSG_BOX] = "X-IRMC-BOX";
+               content_name[VMSG_INDICATION_MSG_BOX_SENT] = "SENT";
+               content_name[VMSG_INDICATION_MSG_BOX_INBOX] = "INBOX";
+               content_name[VMSG_INDICATION_MSG_BOX_DRAFT] =  "DRAFT";
+
+               // Character set
+               content_name[VMSG_ATTR_CHARSET_PROPERTY] = "CHARSET";
+
+               // Language
+               content_name[VMSG_ATTR_LANGUAGE_PROPERTY] =  "LANGUAGE";
+               content_name[VMSG_DATA_SEPARATOR] = ":";
+
+               content_name[VMSG_BODY_PROPERTY_DATE] = "Date";
+               content_name[VMSG_BODY_PROPERTY_SUBJECT] = "Subject";
+               content_name[VMSG_BODY_PROPERTY_FROM] = "From";
+               content_name[VMSG_BODY_PROPERTY_TO] = "To";
+
+               content_name[KEY_BODY] = "body";
+               content_name[KEY_DATE] = "date";
+
+               content_name[VMSG_VCARD_TEL] = "TEL";
+               content_name[VMSG_MSG_BEGIN] = "BEGIN";
+               content_name[VMSG_MSG_END] = "END";
+               content_name[VMSG_MAXIMUM_VALUE] = "MAX";
+       }
+};
+
+static int __msgsvc_vmsg_append_str(char **buf, int *buf_size, int len, const char *str, bool need_conversion)
+{
+       int len_temp = 0;
+       char *tmp = NULL;
+       const char *safe_str = SAFE_STR(str);
+       int str_len = 0;
+       bool need_realloc = false;
+
+       str_len = strlen(safe_str);
+       while ((*buf_size-len) < (str_len+1)) {
+               *buf_size = *buf_size * 2;
+               need_realloc = true;
+       }
+
+       if (need_realloc) {
+               if (NULL == (tmp = (char *)realloc(*buf, *buf_size)))
+                       return -1;
+               else
+                       *buf = tmp;
+       }
+
+       if (need_conversion) {
+               const char *s = safe_str;
+               char *r = (char *)(*buf+len);
+
+               while (*s) {
+                       switch (*s) {
+                       case '\r':
+                               if (*(s+1) && '\n' == *(s+1)) {
+                                       s++;
+                                       *r = '\\';
+                                       r++;
+                                       *r = 'n';
+                               }
+                               else {
+                                       *r = *s;
+                               }
+                               break;
+                       case '\n':
+                               *r = '\\';
+                               r++;
+                               str_len++;
+                               if (*buf_size<str_len+len+1) {
+                                       *buf_size = *buf_size * 2;
+                                       if (NULL == (tmp = (char *)realloc(*buf, *buf_size)))
+                                               return -1;
+                                       else {
+                                               int pos_temp = r-(*buf+len);
+                                               *buf = tmp;
+                                               r = (char *)(*buf+len+pos_temp);
+                                       }
+                               }
+                               *r = 'n';
+                               break;
+                       case ';':
+                       case ':':
+                       case ',':
+                       case '<':
+                       case '>':
+                       case '\\':
+                               *r = '\\';
+                               r++;
+                               str_len++;
+                               if (*buf_size<str_len+len+1) {
+                                       *buf_size = *buf_size * 2;
+                                       if (NULL == (tmp = (char *)realloc(*buf, *buf_size)))
+                                               return -1;
+                                       else {
+                                               int pos_temp = r-(*buf+len);
+                                               *buf = tmp;
+                                               r = (char *)(*buf+len+pos_temp);
+                                       }
+                               }
+                               *r = *s;
+                               break;
+                       case 0xA1:
+                               if (*(s+1) && 0xAC == *(s+1)) { // en/em backslash
+                                       *r = '\\';
+                                       r++;
+                                       str_len++;
+                                       if (*buf_size<str_len+len+1) {
+                                               *buf_size = *buf_size * 2;
+                                               if (NULL == (tmp = (char *)realloc(*buf, *buf_size)))
+                                                       return -1;
+                                               else {
+                                                       int pos_temp = r-(*buf+len);
+                                                       *buf = tmp;
+                                                       r = (char *)(*buf+len+pos_temp);
+                                               }
+                                       }
+
+                                       *r = *s;
+                                       r++;
+                                       s++;
+                                       if (*buf_size<str_len+len+1) {
+                                               *buf_size = *buf_size * 2;
+                                               if (NULL == (tmp = (char *)realloc(*buf, *buf_size)))
+                                                       return -1;
+                                               else {
+                                                       int pos_temp = r-(*buf+len);
+                                                       *buf = tmp;
+                                                       r = (char *)(*buf+len+pos_temp);
+                                               }
+                                       }
+                                       *r = *s;
+                               }
+                               else {
+                                       *r = *s;
+                               }
+                               break;
+                       case 0x81:
+                               if (*(s+1) && 0x5F == *(s+1)) { // en/em backslash
+                                       *r = '\\';
+                                       r++;
+                                       str_len++;
+                                       if (*buf_size<str_len+len+1) {
+                                               *buf_size = *buf_size * 2;
+                                               if (NULL == (tmp = (char *)realloc(*buf, *buf_size)))
+                                                       return -1;
+                                               else {
+                                                       int pos_temp = r-(*buf+len);
+                                                       *buf = tmp;
+                                                       r = (char *)(*buf+len+pos_temp);
+                                               }
+                                       }
+
+                                       *r = *s;
+                                       r++;
+                                       s++;
+                                       if (*buf_size<str_len+len+1) {
+                                               *buf_size = *buf_size * 2;
+                                               if (NULL == (tmp = (char *)realloc(*buf, *buf_size)))
+                                                       return -1;
+                                               else {
+                                                       int pos_temp = r-(*buf+len);
+                                                       *buf = tmp;
+                                                       r = (char *)(*buf+len+pos_temp);
+                                               }
+                                       }
+                                       *r = *s;
+                               }
+                               else {
+                                       *r = *s;
+                               }
+                               break;
+                       default:
+                               *r = *s;
+                               break;
+                       }
+                       r++;
+                       s++;
+               }
+               len_temp = str_len;
+       }
+       else {
+               len_temp = snprintf(*buf+len, *buf_size-len+1, "%s", safe_str);
+       }
+       len += len_temp;
+       return len;
+}
+
+
 /*==================================================================================================
                                      DEFINES
 ==================================================================================================*/
@@ -97,128 +461,459 @@ pCard->pCur = pObject;
 /*==================================================================================================
                                      FUNCTION IMPLEMENTATION
 ==================================================================================================*/
-char* MsgVMessageAddRecord(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
+
+char* _convert_tm_to_vdata_str(const struct tm * tm)
 {
-       MSG_BEGIN();
+       char str[17] = {0, };
 
-       VObject*                pObject = NULL;
-       VParam*         param = NULL;
-       VTree *         pBody = NULL;
-       VTree *         pCard = NULL;
-       VTree *         pCurrent= NULL;
-       struct tm       display_time;
-       char*           encoded_data = NULL;
+       snprintf(str, 17, "%04d%02d%02dT%02d%02d%02dZ",
+               tm->tm_year + 1900,
+               tm->tm_mon +1,
+               tm->tm_mday,
+               tm->tm_hour,
+               tm->tm_min,
+               tm->tm_sec);
 
-       VTree* pMessage = NULL;
-       if (pMessage == NULL) {
-               pMessage = (VTree *)malloc(sizeof(VTree));
-               if (!pMessage) {
-                       return NULL;
-               }
-               pMessage->treeType = VMESSAGE;
-               pMessage->pTop = NULL;
-               pMessage->pCur = NULL;
-               pMessage->pNext = NULL;
+       return strdup(str);
+}
 
-       }
-               pCurrent = pMessage;
+bool _convert_vdata_str_to_tm(const char* szText, struct tm * tm)
+{
 
-       //Insert VObject (X-MESSAGE-TYPE) to VMessage tree
-       INSERT_VMSG_OBJ;
+   if (szText == NULL) return false;
+   if (strlen(szText) < 15) return false;
+   if (szText[8] != 'T') return false;
 
-       pObject->property = VMSG_TYPE_MSGTYPE;
+   char szBuff[8]={0};
+   memset(tm, 0, sizeof(struct tm));
 
-       if(pMsg->msgType.subType == MSG_NORMAL_SMS)
-               pObject->pszValue[0] = strdup("SMS");
-#if 0
-       else if(pMsg->msgType.mainType == MSG_MMS_TYPE && pMsg->msgType.subType == MSG_NOTIFICATIONIND_MMS)
-               pObject->pszValue[0] = strdup("MMS NOTIFICATION");
-#endif
+   // year, month, day
+   memcpy(szBuff, &(szText[0]), 4);
+   szBuff[4] = '\0';
+   tm->tm_year = atol(szBuff) - 1900;
+   if ((tm->tm_year > 137) || (tm->tm_year < 0))
+      tm->tm_year = 0;
 
-       else if(pMsg->msgType.mainType == MSG_MMS_TYPE && (pMsg->msgType.subType == MSG_SENDREQ_MMS || pMsg->msgType.subType == MSG_SENDCONF_MMS))
-               pObject->pszValue[0] = strdup("MMS SEND");
+   memcpy(szBuff, &(szText[4]), 2);
+   szBuff[2] = '\0';
+   tm->tm_mon = atol(szBuff)-1;
+   if ((tm->tm_mon > 11) || (tm->tm_mon < 0))
+      tm->tm_mon = 11;
 
-       else if(pMsg->msgType.mainType == MSG_MMS_TYPE && (pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS))
-               pObject->pszValue[0] = strdup("MMS RETRIEVED");
+   memcpy(szBuff, &(szText[6]), 2);
+   szBuff[2] = '\0';
+   tm->tm_mday = atol(szBuff);
+   if ((tm->tm_mday > 31) || (tm->tm_mday < 1))
+      tm->tm_mday = 31;
+
+   // hour, minute, second
+   memcpy(szBuff, &(szText[9]), 2);
+   szBuff[2] = '\0';
+   tm->tm_hour = atol(szBuff);
+   if ((tm->tm_hour > 23) || (tm->tm_hour < 0))
+      tm->tm_hour = 23;
+
+   memcpy(szBuff, &(szText[11]), 2);
+   szBuff[2] = '\0';
+   tm->tm_min = atol(szBuff);
+   if ((tm->tm_min > 59) || (tm->tm_min < 0))
+      tm->tm_min = 59;
+
+   memcpy(szBuff, &(szText[13]), 2);
+   szBuff[2] = '\0';
+   tm->tm_sec = atol(szBuff);
+   if ((tm->tm_sec > 59) || (tm->tm_sec < 0))
+      tm->tm_sec = 59;
+
+   return true;
+}
 
+int msgsvc_check_utf8(char c)
+{
+       if ((c & 0xff) < (128 & 0xff))
+               return 1;
+       else if ((c & (char)0xe0) == (char)0xc0)
+               return 2;
+       else if ((c & (char)0xf0) == (char)0xe0)
+               return 3;
+       else if ((c & (char)0xf8) == (char)0xf0)
+               return 4;
+       else if ((c & (char)0xfc) == (char)0xf8)
+               return 5;
+       else if ((c & (char)0xfe) == (char)0xfc)
+               return 6;
        else
-               goto __CATCH_FAIL__;
+               return MSG_ERR_INVALID_PARAMETER;
+}
 
-       pObject->valueCount = 1;
+char* __msgsvc_vmsg_convert_tm_to_vdata_str( struct tm * tm)
+{
+       char str[22] = {0, };
+       char APM[3] = {0, };
+       char month[15] = {0, };
+       int mon = 0;
+       int hour = 0;
+       mon = tm->tm_mon  +1;
+
+       if (tm->tm_hour >= 12)
+               strcpy(APM,"PM");
+       else
+               strcpy(APM,"AM");
 
+       if (tm->tm_hour > 12)
+               hour = tm->tm_hour - 12;
+       else
+               hour = tm->tm_hour;
 
-       //Insert VObject (X-IRMC-BOX) to VMessate tree
-       INSERT_VMSG_OBJ;
+       switch(mon)
+       {
+               case 1:
+                       strcpy(month,"Jan");
+                       break;
+               case 2:
+                       strcpy(month,"Feb");
+                       break;
+               case 3:
+                       strcpy(month,"Mar");
+                       break;
+               case 4:
+                       strcpy(month,"Apr");
+                       break;
+               case 5:
+                       strcpy(month,"May");
+                       break;
+               case 6:
+                       strcpy(month,"Jun");
+                       break;
+               case 7:
+                       strcpy(month,"Jul");
+                       break;
+               case 8:
+                       strcpy(month,"Aug");
+                       break;
+               case 9:
+                       strcpy(month,"Sep");
+                       break;
+               case 10:
+                       strcpy(month,"Oct");
+                       break;
+               case 11:
+                       strcpy(month,"Nov");
+                       break;
+               case 12:
+                       strcpy(month,"Dec");
+                       break;
+               default:
+                       MSG_DEBUG("invalid month number");
+               break;
+       }
 
-       pObject->property = VMSG_TYPE_MSGBOX;
+       snprintf(str, 22, "%d:%02d%s, %04d %s %d",
+               hour,
+               tm->tm_min,
+               APM,
+               tm->tm_year + 1900,
+               month,
+               tm->tm_mday);
+
+       return strdup(str);
+}
+static inline int __msgsvc_vmsg_add_folding(char **buf, int *buf_size, int buf_len)
+{
+       int char_len = 0;
+       char *buf_copy = NULL;
+       int len, result_len;
+       char *r;
+       const char *s;
+       bool content_start = false;
+       bool encode_64 = false;
+
+       buf_copy = (char *)calloc(1, *buf_size);
+
+       s = *buf;
+       r = buf_copy;
+       len = result_len = 0;
+
+       while (*s) {
+               if (*buf_size < result_len + 5) {
+                       char *tmp = NULL;
+                       *buf_size = *buf_size + 1000;
+                       if (NULL == (tmp = (char *)realloc(buf_copy, *buf_size))) {
+                               free(buf_copy);
+                               return -1;
+                       }
+                       else {
+                               buf_copy = tmp;
+                               r = (buf_copy + result_len);
+                       }
+               }
+
+               if (false == content_start) {
+                       if (':' == *s)
+                               content_start = true;
+                       else if (0 == strncmp(s, "ENCODING=BASE64", strlen("ENCODING=BASE64")))
+                               encode_64 = true;
+               }
+
+               if ('\r' == *s)
+                       len--;
+               else if ('\n' == *s) {
+                       len = -1;
+                       char_len = 0;
+                       content_start = false;
+                       encode_64 = false;
+               }
+
+               if (0 == char_len) {
+                       if (false == encode_64)
+                               char_len = msgsvc_check_utf8(*s);
+
+                       if (MSGSVC_VMSG_FOLDING_LIMIT <= len + char_len) {
+                               *r = '\r';
+                               r++;
+                               *r = '\n';
+                               r++;
+                               *r = ' ';
+                               r++;
+                               len = 1;
+                               result_len += 3;
+                       }
+               }
+
+               if (char_len)
+                       char_len--;
+
+               *r = *s;
+               r++;
+               s++;
+               len++;
+               result_len++;
+       }
+       *r = '\0';
+       free(*buf);
+       *buf = buf_copy;
+       return result_len;
+}
+
+static inline int __msgsvc_vmsg_append_start_vmsg_1_1(char **buf, int *buf_size, int len)
+{
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[BEGIN_VMSG]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VERSION_VMSG]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       return len;
+}
 
+static inline int __msgsvc_vmsg_append_end_vmsg(char **buf, int *buf_size, int len)
+{
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[END_VMSG]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       return len;
+}
+
+static inline int __msgsvc_vmsg_append_read_status(MSG_MESSAGE_INFO_S *pMsg, char **buf, int *buf_size, int len)
+{
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_INDICATION_READ_STATUS]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_DATA_SEPARATOR]);
+       if (pMsg->bRead) {
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_INDICATION_READ_STATUS_READ]);
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       } else {
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_INDICATION_READ_STATUS_UNREAD]);
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       }
+       return len;
+}
+static inline int __msgsvc_vmsg_append_box_type(MSG_MESSAGE_INFO_S *pMsg, char **buf, int *buf_size, int len)
+{
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_INDICATION_MSG_BOX]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_DATA_SEPARATOR]);
        switch(pMsg->folderId)
        {
                case MSG_INBOX_ID:
-                       pObject->pszValue[0] = strdup("INBOX");
-                       break;
-               case MSG_OUTBOX_ID:
-                       pObject->pszValue[0] = strdup("OUTBOX");
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_INDICATION_MSG_BOX_INBOX]);
+
                        break;
                case MSG_SENTBOX_ID:
-                       pObject->pszValue[0] = strdup("SENTBOX");
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_INDICATION_MSG_BOX_SENT]);
+
                        break;
                case MSG_DRAFT_ID:
-                       pObject->pszValue[0] = strdup("DRAFTBOX");
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_INDICATION_MSG_BOX_DRAFT]);
                        break;
                default:
-                       // Discard User Defined or Spam folder's messages.
-                       goto __CATCH_FAIL__;
+                       // Discard User Defined, outbox or Spam folder's messages.
+                       MSG_DEBUG("Invalid or unhandled msg box");
        }
-       pObject->valueCount = 1;
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       return len;
+}
 
+static inline int __msgsvc_vmsg_append_msg_type(MSG_MESSAGE_INFO_S *pMsg, char **buf, int *buf_size, int len)
+{
+       //TO DO check with msg text contains Only PrintableAscii if true then else handle INET_TYPE
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_INDICATION_MESSAGE_TYPE]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_DATA_SEPARATOR]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_INDICATION_MESSAGE_TYPE_MSG]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       return len;
+}
 
-       //Insert VObject (X-SS-DT) to VMessage tree
-       INSERT_VMSG_OBJ;
+static inline int __msgsvc_vmsg_append_origin_address_vcard(MSG_MESSAGE_INFO_S *pMsg, char **buf, int *buf_size, int len)
+{
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[BEGIN_VCARD]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VERSION_VCARD]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       char originAddress[MAX_ADDRESS_VAL_LEN + 1] = {0, };
+       bool isDisplayName = false;
+
+       if (pMsg->folderId == MSG_INBOX_ID) {
+               strcpy(originAddress, pMsg->addressList[0].addressVal);
+       }
 
-       pObject->property = VMSG_TYPE_DATE;
-       tzset();
-       localtime_r(&(pMsg->displayTime), &display_time);
-       pObject->pszValue[0] = _convert_tm_to_vdata_str(&display_time);
-       pObject->valueCount = 1;
+       needCharset = true; //as per android
 
+       if (strlen(originAddress) > 0) {
+               MSG_CONTACT_INFO_S contactInfo;
+               memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
 
-       //Insert Vobject read status to VMessage tree
-       INSERT_VMSG_OBJ;
+               if (MsgGetContactInfo(&(pMsg->addressList[0]), &contactInfo) != MSG_SUCCESS) {
+                       MSG_WARN("MsgGetContactInfo() fail.");
+               }
+               snprintf(pMsg->addressList[0].displayName, sizeof(pMsg->addressList[0].displayName), "%s", contactInfo.firstName);
+               if (pMsg->addressList[0].displayName[0] != '\0')
+                       isDisplayName = true;
+               if (needCharset && isDisplayName) {
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[FNAME_UTF8_VCARD]);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, pMsg->addressList->displayName);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[NAME_UTF8_VCARD]);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, pMsg->addressList->displayName);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+               } else {
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[FNAME_VCARD]);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, pMsg->addressList->displayName);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[NAME_VCARD]);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, pMsg->addressList->displayName);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+               }
+               if (MsgIsNumber(originAddress)) {
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[TEL_VCARD]);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[TEL_VCARD_CELL]);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, originAddress);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+               }
+       } else {
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[FNAME_VCARD]);
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[NAME_VCARD]);
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       }
 
-       pObject->property = VMSG_TYPE_STATUS;
 
-       if(pMsg->bRead)
-               pObject->pszValue[0] = strdup("READ");
-       else
-               pObject->pszValue[0] = strdup("UNREAD");
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[END_VCARD]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       return len;
+}
 
-       pObject->valueCount = 1;
+static inline int __msgsvc_vmsg_append_recipient_address_vcard(MSG_MESSAGE_INFO_S *pMsg, char **buf, int *buf_size, int len)
+{
+       //To do
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[BEGIN_VCARD]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VERSION_VCARD]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
 
+       needCharset = true; //as per android
 
-       //Insert VBody  tree for message body;
-       pBody = (VTree*)calloc(1, sizeof(VTree));
-       if ( !pBody )
-               goto __CATCH_FAIL__;
-       pBody->treeType = VBODY;
-       pBody->pTop = NULL;
-       pBody->pCur = NULL;
-       pBody->pNext = NULL;
-       pCurrent->pNext = pBody;
-       pCurrent = pBody;
+       for(int i = 0; i < pMsg->nAddressCnt; ++i)
+       {
+               char originAddress[MAX_ADDRESS_VAL_LEN + 1] = {0, };
+               bool isDisplayName = false;
 
-if(strlen(pMsg->subject) > 0)
-{
-       //Insert Subject object
-       INSERT_VBODY_OBJ;
-       pObject->property = VMSG_TYPE_SUBJECT;
-       pObject->pszValue[0] = strdup(pMsg->subject);
-       pObject->valueCount = 1;
+               if (pMsg->folderId == MSG_SENTBOX_ID) {
+                       strcpy(originAddress, pMsg->addressList[0].addressVal);
+               }
+
+               if (strlen(originAddress) > 0) {
+                       MSG_CONTACT_INFO_S contactInfo;
+                       memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
+
+                       if (MsgGetContactInfo(&(pMsg->addressList[i]), &contactInfo) != MSG_SUCCESS) {
+                               MSG_WARN("MsgGetContactInfo() fail.");
+                       }
+                       snprintf(pMsg->addressList[i].displayName, sizeof(pMsg->addressList[i].displayName), "%s", contactInfo.firstName);
+                       if (pMsg->addressList[i].displayName[0] != '\0')
+                               isDisplayName = true;
+                       if (needCharset && isDisplayName) {
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[FNAME_UTF8_VCARD]);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, pMsg->addressList[i].displayName);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[NAME_UTF8_VCARD]);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, pMsg->addressList[i].displayName);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+                       } else {
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[FNAME_VCARD]);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, pMsg->addressList[i].displayName);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[NAME_VCARD]);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, pMsg->addressList[i].displayName);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+                       }
+                       if (MsgIsNumber(originAddress)) {
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[TEL_VCARD]);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[TEL_VCARD_CELL]);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, originAddress);
+                               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+                       }
+               } else {
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[FNAME_VCARD]);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[NAME_VCARD]);
+                       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+               }
+       }
+
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[END_VCARD]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+
+       return len;
 }
-       //Insert VBody object
-       INSERT_VBODY_OBJ;
-       pObject->property = VMSG_TYPE_BODY;
 
+static inline int __msgsvc_vmsg_append_msg_body(MSG_MESSAGE_INFO_S *pMsg, char **buf, int *buf_size, int len)
+{
+       struct tm       display_time;
+
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[BEGIN_VENV]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[BEGIN_VBODY]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+
+       //Date:
+       tzset();
+       localtime_r(&(pMsg->displayTime), &display_time);
+       char *msgDate = __msgsvc_vmsg_convert_tm_to_vdata_str(&display_time);
+
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_BODY_PROPERTY_DATE]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_DATA_SEPARATOR]);
+       if (msgDate !=NULL) {
+               MSGSVC_VMSG_APPEND_STR_FREE(buf, buf_size, len, msgDate);
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+               g_free(msgDate);
+       }
+
+       //Subject:
+       if (pMsg->subject[0] != '\0') {
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_BODY_PROPERTY_SUBJECT]);
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[VMSG_DATA_SEPARATOR]);
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, pMsg->subject);
+               MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       }
+
+       //body:
        if(pMsg->msgType.mainType == MSG_SMS_TYPE)
        {
                if(pMsg->msgType.subType == MSG_NORMAL_SMS)
@@ -226,237 +921,93 @@ if(strlen(pMsg->subject) > 0)
                        if (pMsg->bTextSms == false)
                        {
                                char* pFileData = NULL;
-                               unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter);
+                               unique_ptr<char*, void(*)(char**)> buff(&pFileData, unique_ptr_deleter);
 
-                               int      fileSize = 0;
+                               int             fileSize = 0;
                                char*   msgText = NULL;
 
                                if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false)
-                                       goto __CATCH_FAIL__;
+                                       return len;
 
                                msgText = (char *)calloc(1, fileSize);
-                               if(pFileData && msgText)
-                                       memcpy(msgText, pFileData, fileSize);
-
-                               pObject->numOfBiData = fileSize;
-                               pObject->pszValue[0] = msgText;
+                               memcpy(msgText, pFileData, fileSize);
+                               MSGSVC_VMSG_APPEND_STR_FREE(buf,buf_size, len, msgText);
+                               g_free(msgText);
                        }
                        else
                        {
-                               pObject->numOfBiData = pMsg->dataSize;
-                               pObject->pszValue[0] = strdup(pMsg->msgText);
+                               MSGSVC_VMSG_APPEND_STR(buf,buf_size, len, pMsg->msgText);
                        }
-                       pObject->valueCount = 1;
                }
-               else
-                       goto __CATCH_FAIL__;
        }
 
-       else if(pMsg->msgType.mainType == MSG_MMS_TYPE)
-       {
-               //Insert VBody for mms raw data;
-               char* pFileData = NULL;
-               unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter);
-               MMS_DATA_S *pMmsData = NULL;
-               int fileSize = 0;
-               char* msgText = NULL;
-#if 0
-               char            filePath[MSG_FILEPATH_LEN_MAX] = {0, };
-               if(pMsg->msgType.subType == MSG_NOTIFICATIONIND_MMS)
-                       pFileData = MsgOpenAndReadMmsFile(pMsg->msgData, 0, -1, &fileSize);
-
-               else
-               {
-                       err = MsgStoGetMmsRawFilePath(pDbHandle, pMsg->msgId, filePath);
-
-                       if (err != MSG_SUCCESS)
-                               goto __CATCH_FAIL__;
-
-                       pFileData = MsgOpenAndReadMmsFile(filePath, 0, -1, &fileSize);
-               }
-#else
-
-               if (pMsg->bTextSms == false) {
-                       if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) {
-                               //CID 16205: Memory leak in case of failure
-                               if (pFileData) {
-                                       free(pFileData);
-                                       pFileData = NULL;
-                               }
-                               goto __CATCH_FAIL__;
-                       }
-               } else {
-                       fileSize = strlen(pMsg->msgData);
-                       pFileData = (char *)calloc(1, fileSize+1);
-                       if (!pFileData)
-                               goto __CATCH_FAIL__;
-                       snprintf(pFileData, fileSize, "%s", pMsg->msgData);
-               }
-
-               //CID 46178: Pulling up the null check
-               if (pFileData) {
-                       if (MsgDeserializeMmsData(pFileData, fileSize, &pMmsData) != 0) {
-                               MSG_DEBUG("Fail to Deserialize Message Data");
-                               MsgMmsRelease(&pMmsData);
-                               goto __CATCH_FAIL__;
-                       }
-
-                       free(pFileData);
-                       pFileData = NULL;
-               }
-
-               int serializedDataSize = 0;
-
-               if (pMmsData) {
-                       MsgMmsSetMultipartListData(pMmsData);//app file -> data
-                       serializedDataSize = MsgSerializeMms(pMmsData, &pFileData);
-               }
-
-               if (pFileData) {
-                       fileSize = serializedDataSize;
-               }
-
-               MsgMmsRelease(&pMmsData);
-
-#endif
-               MSG_DEBUG("FILE SIZE IS %d, %s", fileSize, pFileData);
-               msgText = (char *)calloc(1, fileSize);
-               if(pFileData && msgText)
-                       memcpy(msgText, pFileData, fileSize);
-
-               pObject->numOfBiData = fileSize;
-               pObject->pszValue[0] = msgText;
-               pObject->valueCount = 1;
-
-               if (pFileData) {
-                       free(pFileData);
-                       pFileData = NULL;
-               }
-       }
-
-       // Insert parameter for base64 encoding
-       MSG_DEBUG("before to start INSERT_PARAM");
-       INSERT_PARAM;
-       pObject->pParam = param;
-       param->parameter = VMSG_PARAM_ENCODING;
-       param->paramValue = VMSG_ENC_PARAM_BASE64;
-
-       // Add VCard tree for recipient address information.
-       for(int i = 0; i < pMsg->nAddressCnt; ++i)
-       {
-               pCard = (VTree*)calloc(1, sizeof(VTree));
-               if ( !pCard )
-                       goto __CATCH_FAIL__;
-
-               pCard->treeType = VCARD;
-               pCard->pTop = NULL;
-               pCard->pCur = NULL;
-               pCard->pNext = NULL;
-               pCurrent->pNext = pCard;
-               pCurrent = pCard;
-
-               INSERT_VCARD_OBJ;
-               pObject->property = VCARD_TYPE_TEL;
-               pObject->pszValue       [0] = strdup(pMsg->addressList[i].addressVal);
-               pObject->valueCount = 1;
-       }
-       MSG_DEBUG("before to start vmsg_encode");
-       encoded_data = vmsg_encode(pMessage);
-
-       vmsg_free_vtree_memory(pMessage);
-       MSG_END();
-       return encoded_data;
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
 
-__CATCH_FAIL__ :
-       vmsg_free_vtree_memory( pMessage );
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[END_VBODY]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
 
-       return NULL;
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[END_VENV]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       return len;
 }
 
-
-char* _convert_tm_to_vdata_str(const struct tm * tm)
+static inline int __msgsvc_vmsg_append_msg_envelope(MSG_MESSAGE_INFO_S *pMsg, char **buf, int *buf_size, int len)
 {
-       char str[17] = {0, };
-
-       snprintf(str, 17, "%04d%02d%02dT%02d%02d%02dZ",
-               tm->tm_year + 1900,
-               tm->tm_mon +1,
-               tm->tm_mday,
-               tm->tm_hour,
-               tm->tm_min,
-               tm->tm_sec);
 
-       return strdup(str);
-}
-
-
-bool _convert_vdata_str_to_tm(const char* szText, struct tm * tm)
-{
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[BEGIN_VENV]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
 
-   if (szText == NULL) return false;
-   if (strlen(szText) < 15) return false;
-   if (szText[8] != 'T') return false;
+       len = __msgsvc_vmsg_append_recipient_address_vcard(pMsg, buf, buf_size, len);
+       MSG_ERR_RET_VM(len < 0, len, "Invalid length : vcard");
 
-   char szBuff[8]={0};
-   memset(tm, 0, sizeof(struct tm));
+       len = __msgsvc_vmsg_append_msg_body(pMsg, buf, buf_size, len);
+       MSG_ERR_RET_VM(len < 0, len, "Invalid length : body");
 
-   // year, month, day
-   memcpy(szBuff, &(szText[0]), 4);
-   szBuff[4] = '\0';
-   tm->tm_year = atol(szBuff) - 1900;
-   if ((tm->tm_year > 137) || (tm->tm_year < 0))
-      tm->tm_year = 0;
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, content_name[END_VENV]);
+       MSGSVC_VMSG_APPEND_STR(buf, buf_size, len, MSGSVC_CRLF);
+       return len;
+}
 
-   memcpy(szBuff, &(szText[4]), 2);
-   szBuff[2] = '\0';
-   tm->tm_mon = atol(szBuff)-1;
-   if ((tm->tm_mon > 11) || (tm->tm_mon < 0))
-      tm->tm_mon = 11;
+static inline int __msgsvc_vmsg_append_msg(MSG_MESSAGE_INFO_S *pMsg, char **buf, int *buf_size, int len)
+{
+       len = __msgsvc_vmsg_append_read_status(pMsg, buf, buf_size, len);
+       MSG_ERR_RET_VM(len < 0, len, "Invalid length : read status");
 
-   memcpy(szBuff, &(szText[6]), 2);
-   szBuff[2] = '\0';
-   tm->tm_mday = atol(szBuff);
-   if ((tm->tm_mday > 31) || (tm->tm_mday < 1))
-      tm->tm_mday = 31;
+       len = __msgsvc_vmsg_append_box_type(pMsg, buf, buf_size, len);
+       MSG_ERR_RET_VM(len < 0, len, "Invalid length : box type");
 
-   // hour, minute, second
-   memcpy(szBuff, &(szText[9]), 2);
-   szBuff[2] = '\0';
-   tm->tm_hour = atol(szBuff);
-   if ((tm->tm_hour > 23) || (tm->tm_hour < 0))
-      tm->tm_hour = 23;
+       len = __msgsvc_vmsg_append_msg_type(pMsg, buf, buf_size, len);
+       MSG_ERR_RET_VM(len < 0, len, "Invalid length : msg type");
 
-   memcpy(szBuff, &(szText[11]), 2);
-   szBuff[2] = '\0';
-   tm->tm_min = atol(szBuff);
-   if ((tm->tm_min > 59) || (tm->tm_min < 0))
-      tm->tm_min = 59;
+       len = __msgsvc_vmsg_append_origin_address_vcard(pMsg, buf, buf_size, len);
+       MSG_ERR_RET_VM(len < 0, len, "Invalid length : origin address");
 
-   memcpy(szBuff, &(szText[13]), 2);
-   szBuff[2] = '\0';
-   tm->tm_sec = atol(szBuff);
-   if ((tm->tm_sec > 59) || (tm->tm_sec < 0))
-      tm->tm_sec = 59;
+       len = __msgsvc_vmsg_append_msg_envelope(pMsg, buf, buf_size, len);
+       MSG_ERR_RET_VM(len < 0, len, "Invalid length : envelop");
 
-   return true;
+       return len;
 }
 
 char *MsgVMessageEncode(MSG_MESSAGE_INFO_S *pMsg)
 {
        MSG_BEGIN();
 
-       MsgDbHandler dbHandle;
-       VObject *pObject = NULL;
-       VParam *param = NULL;
-       VTree *pBody = NULL;
-       VTree *pCard = NULL;
-       VTree *pCurrent= NULL;
-       VTree *pMessage = NULL;
-
+       VObject*                pObject = NULL;
+       VParam*         param = NULL;
+       VTree *         pBody = NULL;
+       VTree *         pCard = NULL;
+       VTree *         pCurrent= NULL;
        struct tm       display_time;
-       char *encoded_data = NULL;
-       int err = MSG_SUCCESS;
+       char*           encoded_data = NULL;
+
+       VTree* pMessage = NULL;
+
+       //to encode sms
+       if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.subType == MSG_NORMAL_SMS) {
+               return MsgVMessageEncodeSMS(pMsg);
+       }
 
+       //to encode mms
        if (pMessage == NULL) {
                pMessage = (VTree *)malloc(sizeof(VTree));
                if (!pMessage) {
@@ -475,17 +1026,14 @@ char *MsgVMessageEncode(MSG_MESSAGE_INFO_S *pMsg)
 
        pObject->property = VMSG_TYPE_MSGTYPE;
 
-       if(pMsg->msgType.subType == MSG_NORMAL_SMS)
-               pObject->pszValue[0] = strdup("SMS");
+       if (pMsg->msgType.mainType == MSG_MMS_TYPE && (pMsg->msgType.subType == MSG_SENDREQ_MMS || pMsg->msgType.subType == MSG_SENDCONF_MMS))
+               pObject->pszValue[0] = strdup("MMS SEND");
 #if 0
        else if(pMsg->msgType.mainType == MSG_MMS_TYPE && pMsg->msgType.subType == MSG_NOTIFICATIONIND_MMS)
                pObject->pszValue[0] = strdup("MMS NOTIFICATION");
 #endif
 
-       else if(pMsg->msgType.mainType == MSG_MMS_TYPE && (pMsg->msgType.subType == MSG_SENDREQ_MMS || pMsg->msgType.subType == MSG_SENDCONF_MMS))
-               pObject->pszValue[0] = strdup("MMS SEND");
-
-       else if(pMsg->msgType.mainType == MSG_MMS_TYPE && (pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS))
+       else if (pMsg->msgType.mainType == MSG_MMS_TYPE && (pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS))
                pObject->pszValue[0] = strdup("MMS RETRIEVED");
 
        else
@@ -535,7 +1083,7 @@ char *MsgVMessageEncode(MSG_MESSAGE_INFO_S *pMsg)
 
        pObject->property = VMSG_TYPE_STATUS;
 
-       if(pMsg->bRead)
+       if (pMsg->bRead)
                pObject->pszValue[0] = strdup("READ");
        else
                pObject->pszValue[0] = strdup("UNREAD");
@@ -554,73 +1102,74 @@ char *MsgVMessageEncode(MSG_MESSAGE_INFO_S *pMsg)
        pCurrent->pNext = pBody;
        pCurrent = pBody;
 
-if(strlen(pMsg->subject) > 0)
-{
-       //Insert Subject object
-       INSERT_VBODY_OBJ;
-       pObject->property = VMSG_TYPE_SUBJECT;
-       pObject->pszValue[0] = strdup(pMsg->subject);
-       pObject->valueCount = 1;
-}
+       if (strlen(pMsg->subject) > 0) {
+               //Insert Subject object
+               INSERT_VBODY_OBJ;
+               pObject->property = VMSG_TYPE_SUBJECT;
+               pObject->pszValue[0] = strdup(pMsg->subject);
+               pObject->valueCount = 1;
+       }
        //Insert VBody object
        INSERT_VBODY_OBJ;
        pObject->property = VMSG_TYPE_BODY;
 
-       if(pMsg->msgType.mainType == MSG_SMS_TYPE)
-       {
-               if(pMsg->msgType.subType == MSG_NORMAL_SMS)
-               {
-                       if (pMsg->bTextSms == false)
-                       {
-                               char* pFileData = NULL;
-                               unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter);
-
-                               int             fileSize = 0;
-                               char*   msgText = NULL;
-
-                               if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false)
-                                       goto __CATCH_FAIL__;
-
-                               msgText = (char *)calloc(1, fileSize);
-                               if (pFileData && msgText)
-                                       memcpy(msgText, pFileData, fileSize);
-
-                               pObject->numOfBiData = fileSize;
-                               pObject->pszValue[0] = msgText;
-                       }
-                       else
-                       {
-                               pObject->numOfBiData = pMsg->dataSize;
-                               pObject->pszValue[0] = strdup(pMsg->msgText);
-                       }
-                       pObject->valueCount = 1;
-               }
-               else
-                       goto __CATCH_FAIL__;
-       }
-
-       else if(pMsg->msgType.mainType == MSG_MMS_TYPE)
-       {
+       if (pMsg->msgType.mainType == MSG_MMS_TYPE) {
                //Insert VBody for mms raw data;
                char* pFileData = NULL;
-
-               int             fileSize = 0;
-               char*   msgText = NULL;
+               unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter);
+               MMS_DATA_S *pMmsData = NULL;
+               int fileSize = 0;
+               char* msgText = NULL;
+#if 0
                char            filePath[MSG_FILEPATH_LEN_MAX] = {0, };
-
                if(pMsg->msgType.subType == MSG_NOTIFICATIONIND_MMS)
                        pFileData = MsgOpenAndReadMmsFile(pMsg->msgData, 0, -1, &fileSize);
 
                else
                {
-                       err = MsgStoGetMmsRawFilePath(&dbHandle, pMsg->msgId, filePath);
+                       err = MsgStoGetMmsRawFilePath(pDbHandle, pMsg->msgId, filePath);
 
                        if (err != MSG_SUCCESS)
                                goto __CATCH_FAIL__;
 
                        pFileData = MsgOpenAndReadMmsFile(filePath, 0, -1, &fileSize);
                }
-               MSG_DEBUG("FILE SIZE IS %d", fileSize);
+#else
+
+               if (pMsg->bTextSms == false) {
+                       if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false) {
+                               //CID 16205: Memory leak in case of failure
+                               goto __CATCH_FAIL__;
+                       }
+               } else {
+                       fileSize = strlen(pMsg->msgData);
+                       pFileData = (char *)calloc(1, fileSize+1);
+                       if (!pFileData)
+                               goto __CATCH_FAIL__;
+                       snprintf(pFileData, fileSize, "%s", pMsg->msgData);
+               }
+
+               if (MsgDeserializeMmsData(pFileData, fileSize, &pMmsData) != 0) {
+                       MSG_DEBUG("Fail to Deserialize Message Data");
+                       MsgMmsRelease(&pMmsData);
+                       goto __CATCH_FAIL__;
+               }
+
+               int serializedDataSize = 0;
+
+               if (pMmsData) {
+                       MsgMmsSetMultipartListData(pMmsData);//app file -> data
+                       serializedDataSize = MsgSerializeMms(pMmsData, &pFileData);
+               }
+
+               if (pFileData) {
+                       fileSize = serializedDataSize;
+               }
+
+               MsgMmsRelease(&pMmsData);
+
+#endif
+               MSG_DEBUG("FILE SIZE IS %d, %s", fileSize, pFileData);
                msgText = (char *)calloc(1, fileSize);
                if(pFileData && msgText)
                        memcpy(msgText, pFileData, fileSize);
@@ -643,8 +1192,7 @@ if(strlen(pMsg->subject) > 0)
        param->paramValue = VMSG_ENC_PARAM_BASE64;
 
        // Add VCard tree for recipient address information.
-       for(int i = 0; i < pMsg->nAddressCnt; ++i)
-       {
+       for (int i = 0; i < pMsg->nAddressCnt; ++i) {
                pCard = (VTree*)calloc(1, sizeof(VTree));
                if ( !pCard )
                        goto __CATCH_FAIL__;
@@ -673,3 +1221,901 @@ __CATCH_FAIL__ :
 
        return NULL;
 }
+
+char *MsgVMessageEncodeSMS(MSG_MESSAGE_INFO_S *pMsg)
+{
+
+       MSG_BEGIN();
+
+       char *buf = NULL;
+       int buf_size = VMSG_INIT_LENGTH;
+       int len = 0;
+
+       __msgsvc_vmsg_initial();
+
+       buf = (char *)calloc(1, buf_size);
+
+       len = __msgsvc_vmsg_append_start_vmsg_1_1(&buf, &buf_size, len);
+       if (len < 0) {
+               free(buf);
+               return NULL;
+       }
+
+       len = __msgsvc_vmsg_append_msg(pMsg, &buf, &buf_size, len);
+       if (len < 0) {
+               free(buf);
+               return NULL;
+       }
+
+       len = __msgsvc_vmsg_append_end_vmsg(&buf, &buf_size, len);
+       if (len < 0) {
+               free(buf);
+               return NULL;
+       }
+
+       len = __msgsvc_vmsg_add_folding(&buf, &buf_size, len);
+       if (len < 0) {
+               free(buf);
+               return NULL;
+       }
+
+       MSG_END();
+       return buf;
+}
+bool __msgsvc_vmsg_convert_vdata_to_tm_str(const char* szText, struct tm * tm)
+{
+       if (szText == NULL)
+               return false;
+
+       char delims[] = ",";
+       gchar **token = NULL;
+       struct tm tmTemp;
+
+       token = g_strsplit_set(szText, delims, -1);
+       if (token && token[0]) {
+               g_strstrip(token[0]);
+               strptime(token[0], "%I:%M%p", tm);
+       }else {
+               g_strfreev(token);
+               return false;
+       }
+
+       if (token && token[1]) {
+               g_strstrip(token[1]);
+               strptime(token[1], "%Y %b %e", &tmTemp);
+       } else {
+               g_strfreev(token);
+               return false;
+       }
+
+       tm->tm_year = tmTemp.tm_year;
+       tm->tm_mon = tmTemp.tm_mon;
+       tm->tm_mday = tmTemp.tm_mday;
+       tm->tm_sec = 0;
+
+       g_strfreev(token);
+       return true;
+}
+
+
+static inline char* __msgsvc_vmsg_remove_empty_line(char *src)
+{
+       while (*src) {
+               if ('\n' != *src && '\r' != *src)
+                       break;
+               src++;
+       }
+       return src;
+}
+
+static char* __msgsvc_vmsg_check_word(char *src, const char *word)
+{
+       bool start = false;
+
+       MSG_ERR_RET_VM(NULL == src, NULL, "The src is NULL.");
+
+       src = __msgsvc_vmsg_remove_empty_line(src);
+
+       while (*src) {
+               switch (*src) {
+               case ' ':
+               case ':':
+               case ';':
+                       src++;
+                       break;
+               default:
+                       start = true;
+                       break;
+               }
+               if (start) break;
+       }
+
+       while (*src == *word) {
+               src++;
+               word++;
+
+               if ('\0' == *src || '\0' == *word)
+                       break;
+       }
+
+       if ('\0' == *word)
+               return src;
+       else
+               return NULL;
+}
+
+static inline int __msgsvc_vmsg_check_quoted(char *src, int max, int *quoted)
+{
+       int ret;
+       if (TRUE == *quoted)
+               return TRUE;
+
+       while (*src && max) {
+               if ('Q' == *src) {
+                       ret = strncmp(src, "QUOTED-PRINTABLE", sizeof("QUOTED-PRINTABLE") - 1);
+                       if (!ret) {
+                               *quoted = TRUE;
+                               return TRUE;
+                       }
+               }else if (':' == *src) {
+                       break;
+               }
+               src++;
+               max--;
+       }
+       return FALSE;
+}
+
+static inline int __msgsvc_vmsg_remove_folding(char *folded_src)
+{
+       char *result = folded_src;
+
+       MSG_ERR_RET_VM(NULL == folded_src, MSG_ERR_INVALID_PARAMETER, " Invalid Parameter : __msgsvc_vmsg_remove_folding");
+
+       while (*folded_src) {
+               if ('\r' == *folded_src && '\n' == *(folded_src+1) && ' ' == *(folded_src+2))
+                       folded_src += 3;
+               else if ('\n' == *folded_src && ' ' == *(folded_src+1))
+                       folded_src += 2;
+
+               if ('\0' == *folded_src)
+                       break;
+
+               *result = *folded_src;
+               result++;
+               folded_src++;
+       }
+       *result = '\0';
+       return MSG_SUCCESS;
+}
+
+static inline int __msgsvc_vmsg_hex_to_dec(char hex)
+{
+       switch (hex) {
+       case '0' ... '9':
+               return hex - '0';
+       case 'a' ... 'f':
+               return hex - 'a' + 10;
+       case 'A' ... 'F':
+               return hex - 'A' + 10;
+       default:
+               return -1;
+       }
+}
+static inline int __msgsvc_vmsg_decode_quoted_val(char *val)
+{
+       char *src, *dest;
+       int pre;
+
+       src = strchr(val, ':');
+       if (NULL == src)
+               src = val;
+
+       dest = src;
+       while (*src) {
+               if ('=' == *src) {
+                       pre = __msgsvc_vmsg_hex_to_dec(*(src+1));
+                       if (0 <= pre) {
+                               *dest = (char)((pre << 4) + __msgsvc_vmsg_hex_to_dec(*(src+2)));
+                               dest++;
+                               src += 2;
+                       } else {
+                               if ('\r' == *(src+1) && '\n' == *(src+2))
+                                       src += 2;
+                       }
+               } else {
+                       *dest = *src;
+                       dest++;
+               }
+               src++;
+       }
+
+       *dest = '\0';
+       return dest - val;
+}
+
+static inline char* __msgsvc_vmsg_translate_charset(char *src, int len)
+{
+       int ret;
+       char *val = src;
+
+       while (*val) {
+               if ('C' == *val) {
+                       ret = strncmp(val, "CHARSET", sizeof("CHARSET") - 1);
+                       if (!ret) {
+                               val += sizeof("CHARSET");
+                               break;
+                       }
+               }
+               else if (':' == *val) {
+                       return NULL;
+               }
+               val++;
+       }
+
+       if (*val) {
+               UChar *temp;
+               UConverter *conv;
+               UErrorCode err = U_ZERO_ERROR;
+               int dest_size = 0;
+               int temp_size = 0;
+               int src_len, i = 0;
+               char enc[32] = {0}, *dest;
+
+               while (';' != *val && ':' != *val  && ',' != *val) {
+                       enc[i++] = *val++;
+               }
+               enc[i] = '\0';
+               if (0 == strcasecmp("UTF-8", enc))
+                       return NULL;
+
+               while (':' != *val)
+                       val++;
+
+               src_len = len - (val - src);
+
+               temp_size = (src_len+1) * sizeof(UChar);
+               temp = (UChar *)malloc(temp_size);
+               conv = ucnv_open(enc, &err);
+               MSG_WARN_M(U_FAILURE(err), "ucnv_open() Failed(%d), enc=%s", err, enc);
+               ucnv_toUChars(conv, temp, temp_size, val, src_len, &err);
+               MSG_WARN_M(U_FAILURE(err), "ucnv_toUChars() Failed(%d), enc=%s", err, enc);
+               ucnv_close(conv);
+
+               dest_size = temp_size*2;
+               dest = (char *)malloc(dest_size);
+               conv = ucnv_open("UTF-8", &err);
+               MSG_WARN_M(U_FAILURE(err), "ucnv_open() Failed(%d), enc=%s", err, enc);
+               ucnv_fromUChars(conv, dest, dest_size, temp, u_strlen(temp), &err);
+               MSG_WARN_M(U_FAILURE(err), "ucnv_fromUChars() Failed(%d), enc=%s", err, enc);
+               ucnv_close(conv);
+               free(temp);
+
+               return dest;
+       }
+       return NULL;
+}
+
+static void __msgsvc_vmsg_get_prefix(char **prefix, char *src)
+{
+       char *temp = strchr(src, ':');
+       if (temp) {
+               long len = (long)temp - (long)src;
+               *prefix = (char *)calloc(len+1, sizeof(char));
+               snprintf(*prefix, len+1, "%s", src);
+       }
+       else {
+               *prefix = NULL;
+       }
+}
+
+static void __msgsvc_vmsg_remove_spec_out(char **prefix)
+{
+       if (NULL == prefix)
+               return;
+       char *p = *prefix;
+       while (p && *p) {
+               if (*p == '(') {
+                       *p = '\0';
+                       return;
+               }
+               p++;
+       }
+}
+
+static char* __msgsvc_vmsg_get_val(int ver, char *src, char **prefix, char **dest)
+{
+       int quoted;
+       bool start = false;
+       char *cursor;
+
+       MSG_ERR_RET_VM(NULL == src, NULL, "Invalid parameter : The src is NULL.");
+       MSG_ERR_RET_VM(NULL == dest, NULL, "sInvalid parameter : The dest is NULL.");
+
+       while (*src) {
+               switch (*src) {
+               case '\n':
+                       return NULL;
+               case '\r':
+               case ' ':
+                       src++;
+                       break;
+               default:
+                       start = true;
+                       break;
+               }
+               if (start) break;
+       }
+
+       quoted = FALSE;
+       cursor = src;
+       if (MSGSVC_VMSG_VER_1_1 == ver) {
+               while (*cursor) {
+                       if ('=' == *cursor && __msgsvc_vmsg_check_quoted(src, cursor - src, &quoted)) {
+                               if ('\r' == *(cursor+1) && '\n' == *(cursor+2))
+                                       cursor += 2;
+                       } else {
+                               if ('\r' == *cursor && '\n' == *(cursor+1) && ' ' != *(cursor+2))
+                                       break;
+                               if ('\n' == *cursor && ' ' != *(cursor+1))
+                                       break;
+                       }
+
+                       cursor++;
+               }
+       }
+       else {
+               while (*cursor) {
+                       if ('\r' == *cursor && '\n' == *(cursor+1) && ' ' != *(cursor+2))
+                               break;
+
+                       if ('\n' == *cursor && ' ' != *(cursor+1))
+                               break;
+
+                       cursor++;
+               }
+       }
+
+       if (src == cursor) {
+               *dest = NULL;
+               return NULL;
+       }
+       else {
+               int len = 0;
+               char temp = *cursor;
+               char *new_dest;
+
+               if (prefix)
+                       __msgsvc_vmsg_get_prefix(prefix, src);
+
+               __msgsvc_vmsg_remove_spec_out(prefix);
+
+               *cursor = '\0';
+               *dest = strdup(src);
+               if (MSGSVC_VMSG_VER_1_1 != ver)
+                       __msgsvc_vmsg_remove_folding(*dest);
+
+               if (__msgsvc_vmsg_check_quoted(*dest, -1, &quoted))
+                       len = __msgsvc_vmsg_decode_quoted_val(*dest);
+               if (0 == len)
+                       len = strlen(*dest);
+               new_dest = __msgsvc_vmsg_translate_charset(*dest, len);
+               if (new_dest) {
+                       free(*dest);
+                       *dest = new_dest;
+               }
+               *cursor = temp;
+               return (cursor + 1);
+       }
+}
+
+static int  __msgsvc_vmsg_check_content_type(char **vcard)
+{
+       int i;
+       char *new_start;
+       for (i = VMSG_VALUE_NONE+1; i < VMSG_MAXIMUM_VALUE; i++) {
+               new_start = __msgsvc_vmsg_check_word(*vcard, content_name[i]);
+               if (new_start && (':' == *new_start || ';' == *new_start))
+                       break;
+       }
+
+       if (VMSG_MAXIMUM_VALUE == i)
+               return VMSG_VALUE_NONE;
+       else {
+               *vcard = new_start;
+               return i;
+       }
+}
+
+static inline bool __msgsvc_vmsg_check_base64_encoded(char *src)
+{
+       int ret;
+       char *tmp = src;
+
+       while (*tmp) {
+               if ('B' == *tmp) {
+                       ret = strncmp(tmp, "BASE64", sizeof("BASE64") - 1);
+                       if (!ret)
+                               return true;
+               } else if (':' == *tmp || '\r' == *tmp) {
+                       break;
+               }
+               tmp++;
+       }
+       return false;
+}
+
+static char* __msgsvc_vmsg_decode_base64_val(char *val)
+{
+       gsize size = 0;
+       guchar *decoded_str;
+       char *src;
+       char *dest = NULL;
+
+       src = strchr(val, ':');
+       if (NULL == src)
+               src = val;
+       else
+               src++;
+
+       decoded_str = g_base64_decode(src, &size);
+
+       dest = (char *)calloc((src-val)+size+1, sizeof(char));
+       snprintf(dest, (src-val)+1, "%s", val);
+       snprintf(dest+(src-val), size+1, "%s", decoded_str);
+       g_free(decoded_str);
+
+       return dest;
+}
+
+static inline char*  __msgsvc_vmsg_pass_unsupported(char *vmsg)
+{
+       while (*vmsg) {
+               if ('\n' == *vmsg)
+                       return (vmsg + 1);
+               vmsg++;
+       }
+
+       return NULL;
+}
+
+static inline char* __msgsvc_vmsg_get_content_value(char *val)
+{
+       char *temp;
+
+       temp = strchr(val, ':');
+       if (temp)
+               temp++;
+       else
+               temp = val;
+
+       MSG_ERR_RET_VM('\0' == *(temp) || '\r' == *(temp) || '\n' == *(temp),
+               NULL, "Invalid vcard content");
+
+       return temp;
+}
+
+static char* __msgsvc_vmsg_remove_escape_char(char *str)
+{
+       const char *s = SAFE_STR(str);
+       char *r = (char *)s;
+       while (*s) {
+               if (*s == '\\' && *(s+1)) {
+                       char *n = (char*)(s+1);
+                       switch (*n) {
+                       case 'n':
+                       case 'N':
+                               *r = '\n';
+                               s++;
+                               break;
+                       case ';':
+                       case ':':
+                       case ',':
+                       case '<':
+                       case '>':
+                       case '\\':
+                               *r = *n;
+                               s++;
+                               break;
+                       case 0xA1: // en/em backslash
+                               if (*(n+1) && 0xAC == *(n+1)) {
+                                       *r = *n;
+                                       r++;
+                                       *r = *(n+1);
+                                       s+=2;
+                               }
+                               break;
+                       case 0x81:  // en/em backslash
+                               if (*(n+1) && 0x5F == *(n+1)) {
+                                       *r = *n;
+                                       r++;
+                                       *r = *(n+1);
+                                       s+=2;
+                               }
+                               break;
+                       default:
+                               *r = *s;
+                               break;
+                       }
+                       r++;
+                       s++;
+               }
+               else {
+                       *r = *s;
+                       r++;
+                       s++;
+               }
+       }
+       *r = '\0';
+       return str;
+}
+
+static inline msg_error_t __msgsvc_vmsg_get_read_status(MSG_MESSAGE_INFO_S *pMsg, char *val)
+{
+       char *temp;
+
+       temp = __msgsvc_vmsg_get_content_value(val);
+       MSG_ERR_RET_VM(NULL == temp, MSG_ERR_INVALID_PARAMETER, "Invalid parameter : read status");
+
+       temp = __msgsvc_vmsg_remove_escape_char(temp);
+
+       if (strcmp(temp, content_name[VMSG_INDICATION_READ_STATUS_READ]) == 0)
+               pMsg->bRead = true;
+       else if (strcmp(temp, content_name[VMSG_INDICATION_READ_STATUS_UNREAD]) == 0)
+               pMsg->bRead = false;
+       else
+               return MSG_ERR_INVALID_PARAMETER;
+       MSG_DEBUG("pMsg->bRead = %d",pMsg->bRead);
+       return MSG_SUCCESS;
+}
+
+static inline msg_error_t __msgsvc_vmsg_get_msg_box(MSG_MESSAGE_INFO_S *pMsg, char *val)
+{
+       char *temp;
+
+       temp = __msgsvc_vmsg_get_content_value(val);
+       MSG_ERR_RET_VM(NULL == temp, MSG_ERR_INVALID_PARAMETER, "Invalid parameter : msg box");
+
+       temp = __msgsvc_vmsg_remove_escape_char(temp);
+
+       if (strcmp(temp, content_name[VMSG_INDICATION_MSG_BOX_DRAFT]) == 0) {
+               pMsg->folderId = MSG_DRAFT_ID;
+               pMsg->direction=MSG_DIRECTION_TYPE_MO;
+               pMsg->networkStatus=MSG_NETWORK_NOT_SEND;
+       }
+       else if (strcmp(temp, content_name[VMSG_INDICATION_MSG_BOX_INBOX]) == 0) {
+               pMsg->folderId = MSG_INBOX_ID;
+               pMsg->direction=MSG_DIRECTION_TYPE_MT;
+               pMsg->networkStatus=MSG_NETWORK_RECEIVED;
+       }
+       else if (strcmp(temp, content_name[VMSG_INDICATION_MSG_BOX_SENT]) == 0) {
+               pMsg->folderId = MSG_SENTBOX_ID;
+               pMsg->direction=MSG_DIRECTION_TYPE_MO;
+               pMsg->networkStatus=MSG_NETWORK_SEND_SUCCESS;
+       }
+       else
+               return MSG_ERR_INVALID_PARAMETER;
+       MSG_DEBUG("pMsg->folderId = %d",pMsg->folderId);
+       return MSG_SUCCESS;
+}
+
+static inline msg_error_t __msgsvc_vmsg_get_msg_type(MSG_MESSAGE_INFO_S *pMsg, char *val)
+{
+       char *temp;
+
+       temp = __msgsvc_vmsg_get_content_value(val);
+       MSG_ERR_RET_VM(NULL == temp, MSG_ERR_INVALID_PARAMETER, "Invalid parameter : msg type");
+
+       temp = __msgsvc_vmsg_remove_escape_char(temp);
+
+       if (strcmp(temp, content_name[VMSG_INDICATION_MESSAGE_TYPE_MSG]) == 0) {
+               pMsg->msgType.mainType = MSG_SMS_TYPE;
+               pMsg->msgType.subType = MSG_NORMAL_SMS;
+               pMsg->msgType.classType = MSG_CLASS_NONE;
+       }
+       else if (strcmp(temp, content_name[VMSG_INDICATION_MESSAGE_TYPE_INET]) == 0) {
+               //To do
+       }
+       else
+               return MSG_ERR_INVALID_PARAMETER;
+       MSG_DEBUG("pMsg->msgType.subType = %d",pMsg->msgType.subType);
+       return MSG_SUCCESS;
+}
+
+static inline msg_error_t __msgsvc_vmsg_get_address(MSG_MESSAGE_INFO_S *pMsg, char *prefix, char *val, int* vCardCnt)
+{
+       char *temp;
+       MSG_DEBUG("vCardCnt is : %d",*vCardCnt);
+       if ((pMsg->folderId == MSG_SENTBOX_ID || pMsg->folderId == MSG_DRAFT_ID) && *vCardCnt == 1)
+               return MSG_SUCCESS;
+
+       if (pMsg->folderId == MSG_INBOX_ID && *vCardCnt > 1)
+               return MSG_SUCCESS;
+
+       temp = __msgsvc_vmsg_get_content_value(val);
+       MSG_ERR_RET_VM(NULL == temp, MSG_ERR_INVALID_PARAMETER, "Invalid parameter : address");
+
+       temp = __msgsvc_vmsg_remove_escape_char(temp);
+       MSG_ADDRESS_INFO_S * addrInfo = NULL;
+
+       pMsg->nAddressCnt++;
+       MSG_DEBUG("Address is : %s",temp);
+       MSG_DEBUG("Address Cnt : %d",pMsg->nAddressCnt);
+
+
+       if (pMsg->addressList == NULL) {
+               addrInfo = (MSG_ADDRESS_INFO_S *)calloc(1, sizeof(MSG_ADDRESS_INFO_S));
+       } else {
+               addrInfo = (MSG_ADDRESS_INFO_S *)realloc(pMsg->addressList, pMsg->nAddressCnt * sizeof(MSG_ADDRESS_INFO_S));
+       }
+
+       if (addrInfo == NULL) {
+               return MSG_ERR_INVALID_PARAMETER;
+       }
+       pMsg->addressList = addrInfo;
+
+       pMsg->addressList[pMsg->nAddressCnt-1].addressType = MSG_ADDRESS_TYPE_PLMN;
+       pMsg->addressList[pMsg->nAddressCnt-1].recipientType = MSG_RECIPIENTS_TYPE_TO;
+       strncpy(pMsg->addressList[pMsg->nAddressCnt-1].addressVal, temp, MAX_ADDRESS_VAL_LEN);
+       MSG_DEBUG("pMsg->addressList[pMsg->nAddressCnt-1].addressVal = %s",pMsg->addressList[pMsg->nAddressCnt-1].addressVal);
+       return MSG_SUCCESS;
+}
+
+static inline msg_error_t __msgsvc_vmsg_get_msg_date(MSG_MESSAGE_INFO_S *pMsg, char *val)
+{
+       char *temp;
+
+       temp = __msgsvc_vmsg_get_content_value(val);
+       MSG_ERR_RET_VM(NULL == temp, MSG_ERR_INVALID_PARAMETER, "Invalid parameter : date");
+
+       temp = __msgsvc_vmsg_remove_escape_char(temp);
+       MSG_DEBUG("pMsg->displayTime = %s", temp);
+       struct tm displayTime;
+       if ( __msgsvc_vmsg_convert_vdata_to_tm_str(temp, &displayTime))
+               pMsg->displayTime = mktime(&displayTime);
+       else
+               pMsg->displayTime = time(NULL);
+       return MSG_SUCCESS;
+}
+
+static inline msg_error_t __msgsvc_vmsg_get_msg_subject(MSG_MESSAGE_INFO_S *pMsg, char *val)
+{
+       char *temp;
+
+       temp = __msgsvc_vmsg_get_content_value(val);
+       MSG_ERR_RET_VM(NULL == temp, MSG_ERR_INVALID_PARAMETER, "Invalid parameter : subject");
+
+       temp = __msgsvc_vmsg_remove_escape_char(temp);
+
+       if (temp && temp[0] != '\0')
+               strncpy(pMsg->subject, temp, MAX_SUBJECT_LEN);
+       MSG_DEBUG("pMsg->subject = %s",pMsg->subject);
+       return MSG_SUCCESS;
+}
+
+static inline bool __msgsvc_vmsg_get_msg_begin(MSG_MESSAGE_INFO_S *pMsg, char *val, int *vCardCnt)
+{
+       pMsg->encodeType = MSG_ENCODE_AUTO;
+
+       char *temp;
+
+       temp = __msgsvc_vmsg_get_content_value(val);
+       MSG_ERR_RET_VM(NULL == temp, MSG_ERR_INVALID_PARAMETER, "Invalid parameter : body");
+
+       temp = __msgsvc_vmsg_remove_escape_char(temp);
+
+       if (temp && temp[0] != '\0' && strcmp(temp, "VCARD") == 0) {
+               (*vCardCnt)++;
+               return true;
+       }
+       return false;
+}
+
+static inline bool __msgsvc_vmsg_get_msg_end(MSG_MESSAGE_INFO_S *pMsg, char *val)
+{
+       pMsg->encodeType = MSG_ENCODE_AUTO;
+
+       char *temp;
+
+       temp = __msgsvc_vmsg_get_content_value(val);
+       MSG_ERR_RET_VM(NULL == temp, MSG_ERR_INVALID_PARAMETER, "Invalid parameter : body");
+
+       temp = __msgsvc_vmsg_remove_escape_char(temp);
+
+       if (temp && temp[0] != '\0' && strcmp(temp, "VMSG") == 0) {
+               MSG_DEBUG("VMessage decoding completed");
+               return true;
+       } else if (temp && temp[0] != '\0' && strcmp(temp, "VCARD") == 0) {
+               MSG_DEBUG("VMessage decoding completed");
+               return false;
+       }
+       return false;
+}
+
+static inline msg_error_t __msgsvc_vmsg_get_msg(int ver, char *vmsg, MSG_MESSAGE_INFO_S  *record)
+{
+       int type;
+       char *cursor, *new_start, *val, *prefix;
+
+       MSG_MESSAGE_INFO_S *pMsg = record;
+       int vCardCnt = 0;
+       bool isDateAvailable = false;
+       pMsg->msgId = 0;
+       pMsg->threadId = 0;
+       bool end = false;
+
+       cursor = vmsg;
+       while (cursor) {
+               val = NULL;
+               prefix = NULL;
+               bool base64_encoded = false;
+               char *bodyStart = cursor;
+               type =  __msgsvc_vmsg_check_content_type(&cursor);
+
+               if (VMSG_VALUE_NONE == type) {
+
+                       if (isDateAvailable == true) {
+                               isDateAvailable = false;
+                               //body decoding
+                               MSG_DEBUG("Decoding body :");
+                               bodyStart = __msgsvc_vmsg_pass_unsupported(bodyStart);
+                               int i =0;
+                               char tempMsgText[MAX_MSG_TEXT_LEN + 1] = {0, };
+                               while (bodyStart) {
+                                       if (i >= MAX_MSG_TEXT_LEN)
+                                               break;
+                                       if (*bodyStart == 'E' && *(bodyStart+1) == 'N' && *(bodyStart+2) == 'D' && *(bodyStart+3) == ':') {
+                                               i++;
+                                               break;
+                                       }
+                                       tempMsgText[i] = *bodyStart;
+                                       bodyStart++;
+                                       i++;
+                               }
+                               tempMsgText[i] = '\0';
+                               char * temp = __msgsvc_vmsg_remove_escape_char(tempMsgText);
+                               strcpy(pMsg->msgText, temp);
+                               MSG_DEBUG("pMsg->msgText : %s", pMsg->msgText);
+                               pMsg->dataSize = strlen(pMsg->msgText);
+                               pMsg->bTextSms = true;
+                               base64_encoded = __msgsvc_vmsg_check_base64_encoded(pMsg->msgText);
+
+                               if (base64_encoded) {
+                                       char * decodedText = NULL;
+                                       decodedText = __msgsvc_vmsg_decode_base64_val(pMsg->msgText);
+                                       if (decodedText) {
+                                               strncpy(pMsg->msgText, decodedText, MAX_MSG_TEXT_LEN);
+                                               pMsg->dataSize = strlen(pMsg->msgText);
+                                               free(decodedText);
+                                       } else {
+                                               strcpy(pMsg->msgText, "");
+                                               pMsg->dataSize = 0;
+                                       }
+                               }
+                               g_free(prefix);
+                               g_free(val);
+                               return MSG_SUCCESS;
+                       }else {
+                               new_start =  __msgsvc_vmsg_pass_unsupported(cursor);
+                               if (new_start) {
+                                       cursor = new_start;
+                                       continue;
+                               }
+                               else
+                                       break;
+                       }
+               }
+
+               base64_encoded = __msgsvc_vmsg_check_base64_encoded(cursor);
+
+               new_start = __msgsvc_vmsg_get_val(ver, cursor, &prefix, &val);
+
+               if (NULL == new_start) {
+                       g_free(prefix);
+                       g_free(val);
+                       continue;
+               }
+
+               if (NULL == val) {
+                       cursor = new_start;
+                       g_free(prefix);
+                       g_free(val);
+                       continue;
+               }
+
+               if (base64_encoded) {
+                       char *temp = __msgsvc_vmsg_decode_base64_val(val);
+                       g_free(val);
+                       val = temp;
+               }
+               switch (type) {
+               case VMSG_INDICATION_READ_STATUS:
+                       __msgsvc_vmsg_get_read_status(pMsg, val);
+                       break;
+               case VMSG_INDICATION_MSG_BOX:
+                       __msgsvc_vmsg_get_msg_box(pMsg, val);
+                       break;
+               case VMSG_INDICATION_MESSAGE_TYPE:
+                       __msgsvc_vmsg_get_msg_type(pMsg, val);
+                       break;
+               case VMSG_VCARD_TEL:
+                       __msgsvc_vmsg_get_address(pMsg, prefix, val, &vCardCnt);
+                       break;
+               case VMSG_BODY_PROPERTY_DATE:
+                       isDateAvailable = true;
+                       __msgsvc_vmsg_get_msg_date(pMsg, val);
+                       break;
+               case VMSG_BODY_PROPERTY_SUBJECT:
+                       __msgsvc_vmsg_get_msg_subject(pMsg, val);
+                       break;
+               case VMSG_MSG_BEGIN:
+                       end = __msgsvc_vmsg_get_msg_begin(pMsg, val, &vCardCnt);
+               case VMSG_MSG_END:
+                       end = __msgsvc_vmsg_get_msg_end(pMsg, val);
+                       if (end) {
+                               g_free(val);
+                               g_free(prefix);
+                               return MSG_SUCCESS;
+                       } else
+                               break;
+               default:
+                       MSG_ERR("Invalid parameter : __msgsvc_vmsg_check_content_type() Failed(%d)", type);
+                       g_free(val);
+                       g_free(prefix);
+                       return MSG_ERR_INVALID_PARAMETER;
+               }
+               g_free(val);
+               g_free(prefix);
+               cursor = new_start;
+       }
+
+       MSG_ERR("Invalid vmsg");
+       return MSG_ERR_INVALID_PARAMETER;
+}
+
+msg_error_t MsgVMessageDecodeSMS(const char *vmsg_stream, MSG_MESSAGE_INFO_S *pMsg)
+{
+       MSG_BEGIN();
+
+       int ret, ver;
+
+       char *vmsg = (char *)vmsg_stream;
+
+       char *MMSsend, *MMSretrieve, *MMSnoti;
+
+       MSG_ERR_RET_VM(NULL == vmsg_stream, MSG_ERR_INVALID_PARAMETER, "Invalid Parameter : vmsg");
+
+       vmsg  = __msgsvc_vmsg_check_word(vmsg, "BEGIN:VMSG");
+       MSG_ERR_RET_VM(NULL == vmsg, MSG_ERR_INVALID_PARAMETER, "Invalid parameter : The vmsg is invalid.");
+
+       //check for mms()
+       MMSsend = vmsg;
+       MMSretrieve = vmsg;
+       MMSnoti = vmsg;
+
+       MMSsend = __msgsvc_vmsg_check_word(MMSsend, "X-MESSAGE-TYPE:MMS SEND");
+       MSG_ERR_RET_VM(NULL != MMSsend, MSG_ERR_INVALID_MESSAGE, "Invalid parameter : The vmsg format is invalid.");
+
+       MMSretrieve = __msgsvc_vmsg_check_word(MMSretrieve, "X-MESSAGE-TYPE:MMS RETRIEVE");
+       MSG_ERR_RET_VM(NULL != MMSretrieve, MSG_ERR_INVALID_MESSAGE, "Invalid parameter : The vmsg format is invalid.");
+
+       MMSnoti = __msgsvc_vmsg_check_word(MMSnoti, "X-MESSAGE-TYPE:MMS NOTIFICATION");
+       MSG_ERR_RET_VM(NULL != MMSnoti, MSG_ERR_INVALID_MESSAGE, "Invalid parameter : The vmsg format is invalid.");
+
+       //decode sms()
+       __msgsvc_vmsg_initial();
+
+       vmsg = __msgsvc_vmsg_check_word(vmsg, "VERSION:1.1");
+       MSG_ERR_RET_VM(NULL == vmsg, MSG_ERR_INVALID_PARAMETER, "Invalid parameter : The vmsg format is invalid.");
+
+       ver = MSGSVC_VMSG_VER_1_1;
+
+       ret = __msgsvc_vmsg_get_msg(ver, vmsg, pMsg);
+       if (MSG_SUCCESS!= ret) {
+               return ret;
+       }
+       MSG_END();
+       return MSG_SUCCESS;
+}
+
+