RSA sync with private
authorChangseok Oh <seok.oh@samsung.com>
Fri, 7 Dec 2012 08:58:54 +0000 (17:58 +0900)
committerChangseok Oh <seok.oh@samsung.com>
Fri, 7 Dec 2012 08:58:54 +0000 (17:58 +0900)
123 files changed:
CMakeLists.txt
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/submit-handler/MsgSubmitHandler.cpp
framework/transaction-manager/MsgCmdHandlerStorage.cpp
framework/transaction-manager/MsgCmdHandlerTransport.cpp
framework/transaction-manager/MsgTransManager.cpp
include/common/MsgInternalTypes.h
include/common/MsgMmsTypes.h
include/common/MsgStorageTypes.h
include/common/MsgTypes.h
include/framework/MsgDeliverHandler.h
include/framework/MsgPluginManager.h
include/framework/MsgSettingHandler.h
include/framework/MsgStorageHandler.h
include/mapi/msg.h
include/mapi/msg_storage.h
include/mapi/msg_types.h
include/msg_helper/MsgHelper.h
include/proxy/MsgHandle.h
include/proxy/MsgProxyListener.h
include/utils/MsgContact.h
include/utils/MsgDebug.h
include/utils/MsgGconfWrapper.h
include/utils/MsgNotificationWrapper.h
include/utils/MsgSoundPlayer.h
include/utils/MsgTextConvert.h
include/utils/MsgUtilFile.h
include/utils/MsgUtilFunction.h
include/utils/MsgVMessage.h [new file with mode: 0755]
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
msg-service.manifest
msg_helper/CMakeLists.txt
msg_helper/MsgSensorWrapper.cpp
msg_helper/MsgSoundPlayer.cpp
msg_helper/main.cpp
packaging/msg-service.spec [changed mode: 0644->0755]
plugin/mms_plugin/CMakeLists.txt
plugin/mms_plugin/MmsPluginContentCodec.cpp
plugin/mms_plugin/MmsPluginDebug.cpp
plugin/mms_plugin/MmsPluginDecode.cpp
plugin/mms_plugin/MmsPluginEncode.cpp
plugin/mms_plugin/MmsPluginEventHandler.cpp
plugin/mms_plugin/MmsPluginHttp.cpp
plugin/mms_plugin/MmsPluginInternal.cpp
plugin/mms_plugin/MmsPluginMIME.cpp
plugin/mms_plugin/MmsPluginMessage.cpp
plugin/mms_plugin/MmsPluginSmil.cpp
plugin/mms_plugin/MmsPluginStorage.cpp
plugin/mms_plugin/MmsPluginTextConvert.cpp [new file with mode: 0755]
plugin/mms_plugin/MmsPluginTransport.cpp
plugin/mms_plugin/MmsPluginUserAgent.cpp
plugin/mms_plugin/MmsPluginUtil.cpp
plugin/mms_plugin/include/MmsPluginHttp.h
plugin/mms_plugin/include/MmsPluginMessage.h
plugin/mms_plugin/include/MmsPluginStorage.h
plugin/mms_plugin/include/MmsPluginTextConvert.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginTypes.h
plugin/sms_plugin/CMakeLists.txt
plugin/sms_plugin/SmsPluginCallback.cpp
plugin/sms_plugin/SmsPluginCbMsgHandler.cpp
plugin/sms_plugin/SmsPluginConcatHandler.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/SmsPluginSimMsg.h
plugin/sms_plugin/include/SmsPluginTransport.h
plugin/sms_plugin/include/SmsPluginTypes.h
plugin/sms_plugin/include/SmsPluginUAManager.h
proxy/MsgHandleControl.cpp
proxy/MsgHandleSetting.cpp
proxy/MsgHandleStorage.cpp
proxy/MsgHandleTransport.cpp
proxy/MsgProxyListener.cpp
utils/CMakeLists.txt
utils/MsgContact.cpp
utils/MsgDebug.cpp
utils/MsgGconfWrapper.cpp
utils/MsgIpcSocket.cpp
utils/MsgMmsMessage.cpp
utils/MsgNotificationWrapper.cpp
utils/MsgSoundPlayer.cpp
utils/MsgSqliteWrapper.cpp
utils/MsgTextConvert.cpp
utils/MsgUtilFile.cpp
utils/MsgUtilStorage.cpp
utils/MsgVMessage.cpp [new file with mode: 0755]
vobject-engine/CMakeLists.txt [new file with mode: 0755]
vobject-engine/VCard.c [new file with mode: 0755]
vobject-engine/VCardCalUtil.c [new file with mode: 0755]
vobject-engine/VMessage.c [new file with mode: 0755]
vobject-engine/include/VCard.h [new file with mode: 0755]
vobject-engine/include/VMessage.h [new file with mode: 0755]
vobject-engine/include/VTypes.h [new file with mode: 0755]
vobject-engine/include/vobject.h [new file with mode: 0755]
vobject-engine/test_code/CQ_VCARD.c [new file with mode: 0755]
vobject-engine/test_code/uts_vdata_vcard_decode.c [new file with mode: 0755]
vobject-engine/test_code/uts_vdata_vcard_encode.c [new file with mode: 0755]

index 78c3582..15c97d7 100755 (executable)
@@ -2,6 +2,7 @@
 ##########################################################
 # Set Variables
 ##########################################################
+SET(VOBJECT-LIB msg_vobject)
 SET(UTILS-LIB msg_utils)
 SET(PLUGIN-MANAGER-LIB msg_plugin_manager)
 SET(FW-HANDLER-LIB msg_framework_handler)
@@ -10,11 +11,12 @@ SET(TRANS-PROXY-LIB msg_transaction_proxy)
 SET(MAPI-LIB msg_mapi)
 SET(SMS-PLUGIN-LIB msg_sms_plugin)
 SET(MMS-PLUGIN-LIB msg_mms_plugin)
-SET(MMS-LANGUAGE-PACK-LIB msg_mms_language_pack)
+
 
 ##########################################################
 # Add Subdirectories
 ##########################################################
+ADD_SUBDIRECTORY(vobject-engine)
 ADD_SUBDIRECTORY(utils)
 ADD_SUBDIRECTORY(framework)
 ADD_SUBDIRECTORY(proxy)
index 3494f19..15756dc 100755 (executable)
@@ -66,6 +66,7 @@ INCLUDE_DIRECTORIES(
        ${CMAKE_SOURCE_DIR}/include/common
        ${CMAKE_SOURCE_DIR}/include/framework
        ${CMAKE_SOURCE_DIR}/include/utils
+       ${CMAKE_SOURCE_DIR}/vobject-engine/include      
 )
 
 INCLUDE(FindPkgConfig)
index a932bd8..cd8f36c 100755 (executable)
@@ -101,7 +101,7 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques
 
                if (subType == MSG_RETRIEVE_AUTOCONF_MMS) {
                        // play message-tone when MMS retrieved
-                       MsgSoundPlayStart();
+                       MsgSoundPlayStart(false);
 
                        // add phone log
                        MSG_DEBUG("Enter MsgAddPhoneLog() for mms message.");
@@ -158,29 +158,25 @@ msg_error_t MsgHandleIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti)
 
        msg_error_t err = MSG_SUCCESS;
 
-       if (pMsgInfo->msgType.mainType == MSG_SMS_TYPE)
-       {
-               err = MsgHandleSMS(pMsgInfo, pSendNoti);
+       if (pMsgInfo->msgType.mainType == MSG_SMS_TYPE) {
 
-               if (err == MSG_SUCCESS && *pSendNoti == true)
-               {
-                       MsgSoundPlayStart();
+               bool bOnlyNoti = false;
 
-                       if (pMsgInfo->msgType.subType >= MSG_MWI_VOICE_SMS && pMsgInfo->msgType.subType <= MSG_MWI_OTHER_SMS) {
-                               if (pMsgInfo->bStore == false) {
-                                       MsgInsertNoti(pMsgInfo);
-                                       *pSendNoti = false;
-                                       return err;
-                               }
-                       }
+               err = MsgHandleSMS(pMsgInfo, pSendNoti, &bOnlyNoti);
 
-                       int smsCnt = 0, mmsCnt = 0;
+               if (err == MSG_SUCCESS) {
+                       MsgSoundPlayStart(false);
+                       if (*pSendNoti == true) {
+                               int smsCnt = 0, mmsCnt = 0;
 
-                       smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
-                       mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
+                               smsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_SMS_TYPE);
+                               mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
 
-                       MsgSettingHandleNewMsg(smsCnt, mmsCnt);
-                       MsgInsertNoti(&dbHandle, pMsgInfo);
+                               MsgSettingHandleNewMsg(smsCnt, mmsCnt);
+                               MsgInsertNoti(&dbHandle, pMsgInfo);
+                       } else if (bOnlyNoti == true) {
+                               MsgInsertNoti(pMsgInfo);
+                       }
                }
        }
        else if (pMsgInfo->msgType.mainType == MSG_MMS_TYPE)
@@ -205,7 +201,7 @@ msg_error_t MsgHandleIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti)
 }
 
 
-msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti)
+msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti, bool *bOnlyNoti)
 {
        msg_error_t err = MSG_SUCCESS;
 
@@ -291,15 +287,15 @@ msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti)
                                break;
                }
        } else if (pMsgInfo->msgType.subType == MSG_STATUS_REPORT_SMS) {
-               msg_thread_id_t convId = 0;
-
-               // Get Address ID
-               MsgExistAddress(&dbHandle, pMsgInfo, &convId);
+               *pSendNoti = false;
+               *bOnlyNoti = true;
+       } else if (pMsgInfo->msgType.subType >= MSG_MWI_VOICE_SMS && pMsgInfo->msgType.subType <= MSG_MWI_OTHER_SMS) {
+               if (pMsgInfo->bStore == false) {
+                       *pSendNoti = false;
+                       *bOnlyNoti = true;
+               }
+       } 
 
-               MSG_DEBUG("Conversation ID : [%d], Value : [%s]", convId, pMsgInfo->addressList[0].addressVal);
-
-               pMsgInfo->threadId = convId;
-       }
 
        return err;
 }
@@ -343,15 +339,17 @@ msg_error_t MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo,  bool *pSendNoti)
                        return err;
                }
        } else if (pMsgInfo->msgType.subType == MSG_READORGIND_MMS || pMsgInfo->msgType.subType == MSG_DELIVERYIND_MMS) {
-               MsgSoundPlayStart();
-               *pSendNoti = false;
+               if (MsgInsertMmsReportToNoti(&dbHandle, pMsgInfo) == MSG_SUCCESS) {
+                       MsgSoundPlayStart(false);
+                       *pSendNoti = false;
+               }
        }
 
        //In the case of m-notification-ind, we should decide whether to send m-notify-response-ind or http 'Get'
        //submit request
        if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS && bFiltered == false) {
                if (request.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS && bReject == false) {
-                       MsgSoundPlayStart();
+                       MsgSoundPlayStart(false);
 
                        int smsCnt = 0;
                        int mmsCnt = 0;
index 02c6ba4..87482e0 100755 (executable)
@@ -30,6 +30,9 @@
 #include "MsgTransManager.h"
 #include "MsgStorageTypes.h"
 #include "MsgSoundPlayer.h"
+#include "MsgCmdHandler.h"
+#include "MsgUtilStorage.h"
+#include "MsgNotificationWrapper.h"
 
 #include <errno.h>
 #include <glib.h>
@@ -117,7 +120,9 @@ msg_error_t InitMmsDir()
                }
        }
 
-       chmod( MSG_IPC_DATA_PATH, S_IRWXU | S_IRWXG ); //public shared file: pass data by file
+       if(chmod( MSG_IPC_DATA_PATH, S_IRWXU | S_IRWXG ) !=0) { //public shared file: pass data by file
+               MSG_DEBUG("Fail to chmod [%s].", MSG_IPC_DATA_PATH);
+       }
        chown( MSG_IPC_DATA_PATH, 0, 6502 );
 
        return MSG_SUCCESS;
@@ -179,6 +184,10 @@ void SendMobileTrackerMsg()
        {
                MSG_DEBUG("Assign Default Msg");
                msgText = strdup(MSG_MOBILE_TRACKER_MSG);
+               if (msgText == NULL) {
+                       MSG_DEBUG("msgText is NULL.");
+                       return;
+               }
        }
 
        MSG_DEBUG("mobile tracker msg : [%s]", msgText);
@@ -194,6 +203,8 @@ void SendMobileTrackerMsg()
        if (orgRecipientList == NULL)
        {
                MSG_DEBUG("recipient list is NULL");
+               free(msgText);
+               msgText = NULL;
                return;
        }
 
@@ -261,6 +272,9 @@ void SendMobileTrackerMsg()
 
 void* StartMsgServer(void*)
 {
+
+       MsgOpenContactSvc();
+
        try
        {
                MsgTransactionManager::instance()->run();
@@ -277,6 +291,8 @@ void* StartMsgServer(void*)
        if (g_main_loop_is_running(mainloop))
                g_main_loop_quit(mainloop);
 
+       MsgCloseContactSvc();
+
        return (void*)0;
 }
 
@@ -369,6 +385,7 @@ void* InitMsgServer(void*)
        // Register Callback to get the change of contact
        MsgInitContactSvc(&MsgContactChangedCallback);
 
+       MsgCleanAndResetNoti();
        MsgSoundInitRepeatAlarm();
 
        return (void*)0;
index 6c0197f..f2d32cd 100755 (executable)
@@ -485,11 +485,11 @@ MsgPlugin::MsgPlugin(MSG_MAIN_TYPE_T mainType, const char *libPath): mSupportedM
        if (libPath == NULL)
                THROW(MsgException::INVALID_PARAM, "libPath NULL");
 
-       void* libHandle = NULL;
+       mLibHandler = NULL;
 
-       libHandle = dlopen(libPath, RTLD_NOW);
+       mLibHandler = dlopen(libPath, RTLD_NOW);
 
-       if (!libHandle)
+       if (!mLibHandler)
                THROW(MsgException::PLUGIN_ERROR, "ERROR dlopen library : [%s] [%s]", libPath, dlerror());
 
        // Clear Error
@@ -498,7 +498,7 @@ MsgPlugin::MsgPlugin(MSG_MAIN_TYPE_T mainType, const char *libPath): mSupportedM
        // assign the c function pointers
        msg_error_t(*pFunc)(MSG_PLUGIN_HANDLER_S*) = NULL;
 
-       pFunc = (msg_error_t(*)(MSG_PLUGIN_HANDLER_S*))dlsym(libHandle, "MsgPlgCreateHandle");
+       pFunc = (msg_error_t(*)(MSG_PLUGIN_HANDLER_S*))dlsym(mLibHandler, "MsgPlgCreateHandle");
 
        char *error = dlerror();
 
@@ -526,14 +526,15 @@ MsgPlugin::MsgPlugin(MSG_MAIN_TYPE_T mainType, const char *libPath): mSupportedM
        if (registerListener(&fwListener) != MSG_SUCCESS)
                THROW(MsgException::PLUGIN_ERROR, "ERROR to register listener");
 
-//     dlclose(libHandle);
 }
 
 
 MsgPlugin::~MsgPlugin()
 {
-
-
+       this->finalize();
+       // close mLibHandler.
+       if (mLibHandler != NULL)
+               dlclose(mLibHandler);
 }
 
 
@@ -766,8 +767,8 @@ void MsgPluginManager::finalize()
 
        for (it = plgMap.begin(); it != plgMap.end(); it++)
        {
-               MsgPlugin temp = it->second;
-               temp.finalize();
+               MsgPlugin *temp = it->second;
+               delete temp;
        }
 
        plgMap.clear();
@@ -799,7 +800,7 @@ void MsgPluginManager::loadPlugins(const char* path)
                if (pDupPlgCheck)
                        THROW(MsgException::PLUGIN_ERROR, "Plugin for type %d is duplicated", mainType);
 
-               MsgPlugin newPlg(mainType, libPath);
+               MsgPlugin *newPlg = new MsgPlugin(mainType, libPath);
 
                plgMap.insert(make_pair(mainType, newPlg));
        }
@@ -816,6 +817,6 @@ MsgPlugin* MsgPluginManager::getPlugin(MSG_MAIN_TYPE_T mainType)
        if (it == plgMap.end())
                return NULL;
 
-       return &(it->second);
+       return it->second;
 }
 
index a9d46a6..d69e436 100755 (executable)
@@ -25,8 +25,6 @@
 /*==================================================================================================
                                                                STATIC FUNCTION PROTOTYPES
 ==================================================================================================*/
-static char* msg_clean_country_code(char *src);
-static char* msg_normalize_number(char *src);
 
 /*==================================================================================================
                                      FUNCTION IMPLEMENTATION
@@ -101,7 +99,7 @@ msg_error_t MsgSetConfigData(const MSG_SETTING_S *pSetting)
                        err = MsgSetCBMsgOpt(pSetting, true);
                        break;
                case MSG_VOICEMAIL_OPT :
-                       err = MsgSetVoiceMailOpt(pSetting);
+                       err = MsgSetVoiceMailOpt(pSetting, true);
                        break;
                case MSG_MSGSIZE_OPT:
                        err = MsgSetMsgSizeOpt(pSetting);
@@ -213,6 +211,16 @@ msg_error_t MsgSetGeneralOpt(const MSG_SETTING_S *pSetting)
                }
        }
 
+#ifdef __NOT_USED_BY_DESIGN_CHANGE__
+       iValue = MsgSettingGetInt(MSG_ALERT_TONE);
+       if (iValue != (int)generalOpt.alertTone) {
+               if (MsgSettingSetInt(MSG_ALERT_TONE, (int)generalOpt.alertTone) != MSG_SUCCESS) {
+                       MSG_DEBUG("Error to set config data [%s]", MSG_ALERT_TONE);
+                       return MSG_ERR_SET_SETTING;
+               }
+       }
+#endif /* __NOT_USED_BY_DESIGN_CHANGE__ */
+
        return MSG_SUCCESS;
 }
 
@@ -440,6 +448,13 @@ msg_error_t MsgSetMMSSendOpt(const MSG_SETTING_S *pSetting)
                        return MSG_ERR_SET_SETTING;
                }
        }
+#ifdef __NOT_USED_BY_DESIGN_CHANGE__
+       if (MsgSettingSetBool(MMS_SEND_KEEP_COPY, sendOpt.bKeepCopy) != MSG_SUCCESS)
+       {
+               MSG_DEBUG("Error to set config data [%s]", MMS_SEND_KEEP_COPY);
+               return MSG_ERR_SET_SETTING;
+       }
+#endif /* __NOT_USED_BY_DESIGN_CHANGE__ */
 
        MsgSettingGetBool(MMS_SEND_BODY_REPLYING, &bValue);
        if (bValue != sendOpt.bBodyReplying) {
@@ -808,10 +823,12 @@ msg_error_t MsgSetCBMsgOpt(const MSG_SETTING_S *pSetting, bool bSetSim)
        return err;
 }
 
-msg_error_t MsgSetVoiceMailOpt(const MSG_SETTING_S *pSetting)
+
+msg_error_t MsgSetVoiceMailOpt(const MSG_SETTING_S *pSetting, bool bSetSim)
 {
        MSG_VOICEMAIL_OPT_S voiceMailOpt;
        char *pValue = NULL;
+       msg_error_t err = MSG_SUCCESS;
 
        memcpy(&voiceMailOpt, &(pSetting->option.voiceMailOpt), sizeof(MSG_VOICEMAIL_OPT_S));
 
@@ -819,15 +836,20 @@ msg_error_t MsgSetVoiceMailOpt(const MSG_SETTING_S *pSetting)
        if (pValue != NULL && strcmp(pValue, voiceMailOpt.mailNumber) == 0) {
                /* Value is same with previous one. Therefore, we don't need to save it. */
        } else {
-               if (MsgSettingSetString(VOICEMAIL_NUMBER, voiceMailOpt.mailNumber) != MSG_SUCCESS) {
-                       MSG_DEBUG("Error to set config data [%s]", VOICEMAIL_NUMBER);
-
-                       if (pValue != NULL) {
-                               free(pValue);
-                               pValue = NULL;
+               if (bSetSim == true) {
+                       err = MsgSetConfigInSim(pSetting);
+
+                       if (err == MSG_SUCCESS) {
+                               err = MsgSettingSetString(VOICEMAIL_NUMBER, voiceMailOpt.mailNumber);
+                               if (err != MSG_SUCCESS)
+                                       MSG_DEBUG("Error to set config data [%s]", VOICEMAIL_NUMBER);
+                       } else {
+                               MSG_DEBUG("Error to set config data in sim [%d]", err);
                        }
-
-                       return MSG_ERR_SET_SETTING;
+               } else {
+                       err = MsgSettingSetString(VOICEMAIL_NUMBER, voiceMailOpt.mailNumber);
+                       if (err != MSG_SUCCESS)
+                               MSG_DEBUG("Error to set config data [%s]", VOICEMAIL_NUMBER);
                }
        }
 
@@ -836,7 +858,7 @@ msg_error_t MsgSetVoiceMailOpt(const MSG_SETTING_S *pSetting)
                pValue = NULL;
        }
 
-       return MSG_SUCCESS;
+       return err;
 }
 
 
@@ -864,6 +886,12 @@ void MsgGetGeneralOpt(MSG_SETTING_S *pSetting)
        memset(&(pSetting->option.generalOpt), 0x00, sizeof(MSG_GENERAL_OPT_S));
 
        MsgSettingGetBool(MSG_KEEP_COPY, &pSetting->option.generalOpt.bKeepCopy);
+
+#ifdef __NOT_USED_BY_DESIGN_CHANGE__
+       pSetting->option.generalOpt.alertTone = (MSG_ALERT_TONE_T)MsgSettingGetInt(MSG_ALERT_TONE);
+
+       MsgSettingGetBool(MSG_AUTO_ERASE, &pSetting->option.generalOpt.bAutoErase);
+#endif /* __NOT_USED_BY_DESIGN_CHANGE__ */
 }
 
 
@@ -901,6 +929,13 @@ void MsgGetSMSCList(MSG_SETTING_S *pSetting)
 
                pSetting->option.smscList.smscData[i].pid = (MSG_SMS_PID_T)MsgSettingGetInt(keyName);
 
+#ifdef __NOT_USED_BY_DESIGN_CHANGE__
+               memset(keyName, 0x00, sizeof(keyName));
+               snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_DCS, i);
+
+               pSetting->option.smscList.smscData[i].dcs = (msg_encode_type_t)MsgSettingGetInt(keyName);
+#endif /* __NOT_USED_BY_DESIGN_CHANGE__ */
+
                memset(keyName, 0x00, sizeof(keyName));
                snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_VAL_PERIOD, i);
 
@@ -963,6 +998,10 @@ void MsgGetMMSSendOpt(MSG_SETTING_S *pSetting)
 
        MsgSettingGetBool(MMS_SEND_READ_REPLY, &pSetting->option.mmsSendOpt.bReadReply);
 
+#ifdef __NOT_USED_BY_DESIGN_CHANGE__
+       MsgSettingGetBool(MSG_KEEP_COPY, &pSetting->option.mmsSendOpt.bKeepCopy);
+#endif /* __NOT_USED_BY_DESIGN_CHANGE__ */
+
        MsgSettingGetBool(MMS_SEND_BODY_REPLYING, &pSetting->option.mmsSendOpt.bBodyReplying);
 
        MsgSettingGetBool(MMS_SEND_HIDE_RECIPIENTS, &pSetting->option.mmsSendOpt.bHideRecipients);
@@ -1136,183 +1175,253 @@ msg_error_t MsgSetConfigInSim(const MSG_SETTING_S *pSetting)
        return err;
 }
 
-static char* msg_clean_country_code(char *src)
+#ifdef __NOT_USED_BY_ENV_CHANGE__
+void MsgSetDefaultConfig()
 {
-       int ret = 1;
+       bool bTmp = false;
+       char keyName[128];
+
+       // Set Default General SendOpt
+       if (MsgSettingGetBool(MSG_KEEP_COPY, &bTmp) < 0)
+               MsgSettingSetBool(MSG_KEEP_COPY, true);
+
+       if (MsgSettingGetInt(MSG_ALERT_TONE) < 0)
+               MsgSettingSetInt(MSG_ALERT_TONE, (int)MSG_ALERT_TONE_ONCE);
+
+       if (MsgSettingGetBool(MSG_AUTO_ERASE, &bTmp) < 0)
+               MsgSettingGetBool(MSG_AUTO_ERASE, false);
+
+       // Set Default SMS SendOpt
+       if (MsgSettingGetInt(SMS_SEND_DCS) < 0)
+               MsgSettingSetInt(SMS_SEND_DCS, (int)MSG_ENCODE_AUTO);
+
+       if (MsgSettingGetInt(SMS_SEND_NETWORK_MODE) < 0)
+               MsgSettingSetInt(SMS_SEND_NETWORK_MODE, (int)MSG_SMS_NETWORK_CS_ONLY);
+
+       if (MsgSettingGetBool(SMS_SEND_REPLY_PATH, &bTmp) < 0)
+               MsgSettingSetBool(SMS_SEND_REPLY_PATH, false);
+
+       if (MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &bTmp) < 0)
+               MsgSettingSetBool(SMS_SEND_DELIVERY_REPORT, false);
+
+       if (MsgSettingGetInt(SMS_SEND_SAVE_STORAGE) < 0)
+               MsgSettingSetInt(SMS_SEND_SAVE_STORAGE, (int)MSG_SMS_SAVE_STORAGE_PHONE);
+
+       // Set Default SMSC List
+       if (MsgSettingGetInt(SMSC_SELECTED) < 0)
+               MsgSettingSetInt(SMSC_SELECTED, 0);
+
+       if (MsgSettingGetInt(SMSC_TOTAL_COUNT) < 0)
+               MsgSettingSetInt(SMSC_TOTAL_COUNT, 1);
+
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", SMSC_PID, 0);
+
+       if (MsgSettingGetInt(keyName) < 0)
+               MsgSettingSetInt(keyName, (int)MSG_PID_TEXT);
+
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", SMSC_VAL_PERIOD, MSG_VAL_MAXIMUM);
+
+       if (MsgSettingGetInt(keyName) < 0)
+               MsgSettingSetInt(keyName, 0);
+
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", SMSC_NAME, 0);
+
+       char *smscName = NULL;
+
+       smscName = MsgSettingGetString(keyName);
+
+       if (smscName == NULL) {
+               MsgSettingSetString(keyName, (char*)"SMS Centre 1");
+       } else {
+               free(smscName);
+               smscName = NULL;
+       }
+
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", SMSC_TON, 0);
+
+       if (MsgSettingGetInt(keyName) < 0)
+               MsgSettingSetInt(keyName, (int)MSG_TON_INTERNATIONAL);
+
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", SMSC_NPI, 0);
+
+       if (MsgSettingGetInt(keyName) < 0)
+               MsgSettingSetInt(keyName, (int)MSG_NPI_ISDN);
+
+       memset(keyName, 0x00, sizeof(keyName));
+       sprintf(keyName, "%s/%d", SMSC_ADDRESS, 0);
+
+       char *smscAddress = NULL;
+
+       smscAddress = MsgSettingGetString(keyName);
+
+       if (smscAddress == NULL) {
+               MsgSettingSetString(keyName, (char*)"8210911111");
+       } else {
+               free(smscAddress);
+               smscAddress = NULL;
+       }
+
+       // Set Default MMS Send Opt
+       if (MsgSettingGetInt(MMS_SEND_MSG_CLASS) < 0)
+               MsgSettingSetInt(MMS_SEND_MSG_CLASS, (int)MSG_CLASS_AUTO);
+
+       if (MsgSettingGetInt(MMS_SEND_PRIORITY) < 0)
+               MsgSettingSetInt(MMS_SEND_PRIORITY, (int)MSG_MESSAGE_PRIORITY_NORMAL);
+
+       if (MsgSettingGetInt(MMS_SEND_EXPIRY_TIME) < 0)
+               MsgSettingSetInt(MMS_SEND_EXPIRY_TIME, 86400);
+
+       if (MsgSettingGetInt(MMS_SEND_DELIVERY_TIME) < 0)
+               MsgSettingSetInt(MMS_SEND_DELIVERY_TIME, 0);
+
+       if (MsgSettingGetInt(MMS_SEND_CUSTOM_DELIVERY) < 0)
+               MsgSettingSetInt(MMS_SEND_CUSTOM_DELIVERY, 0);
+
+       if (MsgSettingGetBool(MMS_SEND_SENDER_VISIBILITY, &bTmp) < 0)
+               MsgSettingSetBool(MMS_SEND_SENDER_VISIBILITY, false);
+
+       if (MsgSettingGetBool(MMS_SEND_DELIVERY_REPORT, &bTmp) < 0)
+               MsgSettingSetBool(MMS_SEND_DELIVERY_REPORT, true);
+
+       if (MsgSettingGetBool(MMS_SEND_READ_REPLY, &bTmp) < 0)
+               MsgSettingSetBool(MMS_SEND_READ_REPLY, false);
+
+       if (MsgSettingGetBool(MMS_SEND_KEEP_COPY, &bTmp) < 0)
+               MsgSettingSetBool(MMS_SEND_KEEP_COPY, false);
+
+       if (MsgSettingGetBool(MMS_SEND_BODY_REPLYING, &bTmp) < 0)
+               MsgSettingSetBool(MMS_SEND_BODY_REPLYING, false);
+
+       if (MsgSettingGetBool(MMS_SEND_HIDE_RECIPIENTS, &bTmp) < 0)
+               MsgSettingSetBool(MMS_SEND_HIDE_RECIPIENTS, false);
+
+       if (MsgSettingGetInt(MMS_SEND_REPLY_CHARGING) < 0)
+               MsgSettingSetInt(MMS_SEND_REPLY_CHARGING, (int)MSG_REPLY_CHARGING_NONE);
+
+       if (MsgSettingGetInt(MMS_SEND_REPLY_CHARGING_DEADLINE) < 0)
+               MsgSettingSetInt(MMS_SEND_REPLY_CHARGING_DEADLINE, 0);
 
-       switch (src[ret++]-'0')
+       if (MsgSettingGetInt(MMS_SEND_REPLY_CHARGING_SIZE) < 0)
+               MsgSettingSetInt(MMS_SEND_REPLY_CHARGING_SIZE, 0);
+
+       // Set Default MMS Recv Opt
+       if (MsgSettingGetInt(MMS_RECV_HOME_NETWORK) < 0)
+               MsgSettingSetInt(MMS_RECV_HOME_NETWORK, (int)MSG_HOME_AUTO_DOWNLOAD);
+
+       if (MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK) < 0)
+               MsgSettingSetInt(MMS_RECV_ABROAD_NETWORK, (int)MSG_ABROAD_RESTRICTED);
+
+       if (MsgSettingGetInt(MMS_RECV_READ_RECEIPT) < 0)
+               MsgSettingSetInt(MMS_RECV_READ_RECEIPT, (int)MSG_SEND_READ_REPORT_NEVER);
+
+       if (MsgSettingGetBool(MMS_RECV_DELIVERY_RECEIPT, &bTmp) < 0)
+               MsgSettingSetBool(MMS_RECV_DELIVERY_RECEIPT, true);
+
+       if (MsgSettingGetBool(MMS_RECV_REJECT_UNKNOWN, &bTmp) < 0)
+               MsgSettingSetBool(MMS_RECV_REJECT_UNKNOWN, false);
+
+       if (MsgSettingGetBool(MMS_RECV_REJECT_ADVERTISE, &bTmp) < 0)
+               MsgSettingSetBool(MMS_RECV_REJECT_ADVERTISE, false);
+
+       // Set Default MMS Style Opt
+       if (MsgSettingGetInt(MMS_STYLE_FONT_SIZE) < 0)
+               MsgSettingSetInt(MMS_STYLE_FONT_SIZE, 30);
+
+       if (MsgSettingGetInt(MMS_STYLE_FONT_STYLE) < 0)
+               MsgSettingSetInt(MMS_STYLE_FONT_STYLE, 0);
+
+       if (MsgSettingGetInt(MMS_STYLE_FONT_COLOR_RED) < 0)
+               MsgSettingSetInt(MMS_STYLE_FONT_COLOR_RED, 0);
+
+       if (MsgSettingGetInt(MMS_STYLE_FONT_COLOR_GREEN) < 0)
+               MsgSettingSetInt(MMS_STYLE_FONT_COLOR_GREEN, 0);
+
+       if (MsgSettingGetInt(MMS_STYLE_FONT_COLOR_BLUE) < 0)
+               MsgSettingSetInt(MMS_STYLE_FONT_COLOR_BLUE, 0);
+
+       if (MsgSettingGetInt(MMS_STYLE_FONT_COLOR_HUE) < 0)
+               MsgSettingSetInt(MMS_STYLE_FONT_COLOR_HUE, 255);
+
+       if (MsgSettingGetInt(MMS_STYLE_BG_COLOR_RED) < 0)
+               MsgSettingSetInt(MMS_STYLE_BG_COLOR_RED, 255);
+
+       if (MsgSettingGetInt(MMS_STYLE_BG_COLOR_GREEN) < 0)
+               MsgSettingSetInt(MMS_STYLE_BG_COLOR_GREEN, 255);
+
+       if (MsgSettingGetInt(MMS_STYLE_BG_COLOR_BLUE) < 0)
+               MsgSettingSetInt(MMS_STYLE_BG_COLOR_BLUE, 255);
+
+       if (MsgSettingGetInt(MMS_STYLE_BG_COLOR_HUE) < 0)
+               MsgSettingSetInt(MMS_STYLE_FONT_COLOR_HUE, 255);
+
+       if (MsgSettingGetInt(MMS_STYLE_PAGE_DUR) < 0)
+               MsgSettingSetInt(MMS_STYLE_PAGE_DUR, 2);
+
+       if (MsgSettingGetInt(MMS_STYLE_PAGE_CUSTOM_DUR) < 0)
+               MsgSettingSetInt(MMS_STYLE_PAGE_CUSTOM_DUR, 0);
+
+       if (MsgSettingGetInt(MMS_STYLE_PAGE_DUR_MANUAL) < 0)
+               MsgSettingSetInt(MMS_STYLE_PAGE_DUR_MANUAL, 0);
+
+       // Set Default Push Msg Opt
+       if (MsgSettingGetBool(PUSH_RECV_OPTION, &bTmp) < 0)
+               MsgSettingSetBool(PUSH_RECV_OPTION, false);
+
+       if (MsgSettingGetInt(PUSH_SERVICE_TYPE) < 0)
+               MsgSettingSetInt(PUSH_SERVICE_TYPE, (int)MSG_PUSH_SERVICE_PROMPT);
+
+       // Set Default Cb Msg Opt
+       if (MsgSettingGetBool(CB_RECEIVE, &bTmp) < 0)
+               MsgSettingSetBool(CB_RECEIVE, false);
+
+       if (MsgSettingGetBool(CB_ALL_CHANNEL, &bTmp) < 0)
+               MsgSettingSetBool(CB_ALL_CHANNEL, false);
+
+       if (MsgSettingGetInt(CB_MAX_SIM_COUNT) < 0)
+               MsgSettingSetInt(CB_MAX_SIM_COUNT, 0);
+
+       if (MsgSettingGetInt(CB_CHANNEL_COUNT) < 0)
+               MsgSettingSetInt(CB_CHANNEL_COUNT, 0);
+
+       for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++)
        {
-               case 1:
-               case 7:
-                       break;
-               case 2:
-                       switch (src[ret++]-'0')
-                       {
-                               case 0:
-                               case 7:
-                                       break;
-                               case 1:
-                               case 2:
-                               case 3:
-                               case 4:
-                               case 5:
-                               case 6:
-                               case 8:
-                               case 9:
-                                       ret += 1;
-                                       break;
-                               default:
-                                       MSG_DEBUG("The parameter(src:%s) has invalid character set", src);
-                                       break;
-                       }
-                       break;
-               case 3:
-                       switch (src[ret++]-'0')
-                       {
-                               case 0:
-                               case 1:
-                               case 2:
-                               case 3:
-                               case 4:
-                               case 6:
-                               case 9:
-                                       break;
-                               case 5:
-                               case 7:
-                               case 8:
-                                       ret += 1;
-                                       break;
-                               default:
-                                       MSG_DEBUG("The parameter(src:%s) has invalid character set", src);
-                                       break;
-                       }
-                       break;
-               case 4:
-                       switch (src[ret++]-'0')
-                       {
-                               case 0:
-                               case 1:
-                               case 3:
-                               case 4:
-                               case 5:
-                               case 6:
-                               case 7:
-                               case 8:
-                               case 9:
-                                       break;
-                               case 2:
-                                       ret += 1;
-                                       break;
-                               default:
-                                       MSG_DEBUG("The parameter(src:%s) has invalid character set", src);
-                                       break;
-                       }
-                       break;
-               case 5:
-                       switch (src[ret++]-'0')
-                       {
-                               case 1:
-                               case 2:
-                               case 3:
-                               case 4:
-                               case 5:
-                               case 6:
-                               case 7:
-                               case 8:
-                                       break;
-                               case 0:
-                               case 9:
-                                       ret += 1;
-                                       break;
-                               default:
-                                       MSG_DEBUG("The parameter(src:%s) has invalid character set", src);
-                                       break;
-                       }
-                       break;
-               case 6:
-                       switch (src[ret++]-'0')
-                       {
-                               case 0:
-                               case 1:
-                               case 2:
-                               case 3:
-                               case 4:
-                               case 5:
-                               case 6:
-                                       break;
-                               case 7:
-                               case 8:
-                               case 9:
-                                       ret += 1;
-                                       break;
-                               default:
-                                       MSG_DEBUG("The parameter(src:%s) has invalid character set", src);
-                                       break;
-                       }
-                       break;
-               case 8:
-                       switch (src[ret++]-'0')
-                       {
-                               case 1:
-                               case 2:
-                               case 4:
-                               case 6:
-                                       break;
-                               case 0:
-                               case 3:
-                               case 5:
-                               case 7:
-                               case 8:
-                               case 9:
-                                       ret += 1;
-                                       break;
-                               default:
-                                       MSG_DEBUG("The parameter(src:%s) has invalid character set", src);
-                                       break;
-                       }
-                       break;
-               case 9:
-                       switch (src[ret++]-'0')
-                       {
-                               case 0:
-                               case 1:
-                               case 2:
-                               case 3:
-                               case 4:
-                               case 5:
-                               case 8:
-                                       break;
-                               case 6:
-                               case 7:
-                               case 9:
-                                       ret += 1;
-                                       break;
-                               default:
-                                       MSG_DEBUG("The parameter(src:%s) has invalid character set", src);
-                                       break;
-                       }
-                       break;
-               case 0:
-               default:
-                       MSG_DEBUG("The parameter(src:%s) has invalid character set", src);
-                       return src;
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", CB_LANGUAGE, i);
+
+               if (MsgSettingGetBool(keyName, &bTmp) < 0)
+                       MsgSettingSetBool(keyName, false);
        }
 
-       return &src[ret];
-}
+       // Set Default SOS Msg Opt
+       if (MsgSettingGetBool(SOS_SEND_OPTION, &bTmp) < 0)
+               MsgSettingSetBool(SOS_SEND_OPTION, false);
 
-static char* msg_normalize_number(char *src)
-{
-       char *normalized_number;
+       if (MsgSettingGetInt(SOS_RECIPIENT_COUNT) < 0)
+               MsgSettingSetInt(SOS_RECIPIENT_COUNT, 0);
 
-       if ('+' == src[0])
-               normalized_number = msg_clean_country_code(src);
-       else if ('0' == src[0])
-               normalized_number = src+1;
-       else
-               normalized_number = src;
+       if (MsgSettingGetInt(SOS_REPEAT_COUNT) < 0)
+               MsgSettingSetInt(SOS_REPEAT_COUNT, (int)MSG_SOS_REPEAT_ONCE);
+
+       char *tmpValue = NULL;
+
+       tmpValue = MsgSettingGetString(keyName);
+
+       if (tmpValue == NULL) {
+               MsgSettingSetString(keyName, NULL);
+       } else {
+               free(tmpValue);
+               tmpValue = NULL;
+       }
 
-       MSG_DEBUG("src = %s, normalized = %s", src, normalized_number);
+       if (MsgSettingGetInt(SOS_ALERT_TYPE) < 0)
+               MsgSettingSetInt(SOS_ALERT_TYPE, (int)MSG_SOS_ALERT_TYPE_SOS);
 
-       return normalized_number;
+       if (MsgSettingGetInt(MSGSIZE_OPTION) < 0)
+               MsgSettingSetInt(MSGSIZE_OPTION, 300);
 }
+#endif /* __NOT_USED_BY_ENV_CHANGE__ */
\ No newline at end of file
index 1bdb0dc..7ae1e35 100755 (executable)
 #include <sys/stat.h>
 #include <errno.h>
 
+#include <VMessage.h>
+#include <VCard.h>
+#include "MsgVMessage.h"
+
 #include "MsgDebug.h"
 #include "MsgUtilFile.h"
 #include "MsgUtilStorage.h"
@@ -814,9 +818,79 @@ msg_error_t MsgStoResetDatabase()
 }
 
 
-msg_error_t MsgStoBackupMessage()
+msg_error_t MsgStoBackupMessage(msg_message_backup_type_t type, const char *filepath)
 {
+       msg_error_t     err = MSG_SUCCESS;
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+       int rowCnt = 0;
+       int index = 0;
+       MSG_MESSAGE_INFO_S       msgInfo = {0, };
+       char*                   encoded_data = NULL;
+
+       char fileName[MSG_FILENAME_LEN_MAX+1];
+       memset(fileName, 0x00, sizeof(fileName));
+       strncpy(fileName, filepath, MSG_FILENAME_LEN_MAX);
+       if (remove(fileName) != 0) {
+               MSG_DEBUG("Fail to delete [%s].", fileName);
+       }
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       MSG_DEBUG("backup type = %d, path = %s", type, filepath);
+
+       if (type == MSG_BACKUP_TYPE_SMS) {
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                               "SELECT MSG_ID FROM %s "
+                               "WHERE STORAGE_ID = %d AND MAIN_TYPE = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, MSG_STORAGE_PHONE, MSG_SMS_TYPE);
+       } else if (type == MSG_BACKUP_TYPE_MMS) {
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                               "SELECT MSG_ID FROM %s "
+                               "WHERE STORAGE_ID = %d AND MAIN_TYPE = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, MSG_STORAGE_PHONE, MSG_MMS_TYPE);
+       } else if (type == MSG_BACKUP_TYPE_ALL) {
+               snprintf(sqlQuery, sizeof(sqlQuery),
+                               "SELECT MSG_ID FROM %s "
+                               "WHERE STORAGE_ID = %d;",
+                               MSGFW_MESSAGE_TABLE_NAME, MSG_STORAGE_PHONE);
+
+       }
+
+       err = dbHandle.getTable(sqlQuery, &rowCnt);
+
+       if (err != MSG_SUCCESS) {
+               dbHandle.freeTable();
+               return err;
+       }
+       MSG_DEBUG("backup number = %d", rowCnt);
+
+       for (int i = 0; i < rowCnt; i++) {
+               err = MsgStoGetMessage(dbHandle.getColumnToInt(++index), &msgInfo, NULL);
+               if(err != MSG_SUCCESS) {
+                       dbHandle.freeTable();
+                       return err;
+               }
+
+               encoded_data = MsgVMessageAddRecord(&dbHandle, &msgInfo);
+
+               if (encoded_data != NULL) {
+                       if (MsgAppendFile(fileName, encoded_data, strlen(encoded_data)) == false) {
+                               dbHandle.freeTable();
+                               free(encoded_data);
+                               return MSG_ERR_STORAGE_ERROR;
+                       }
+
+                       free(encoded_data);
+               }
+
+               memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
+       }
+
+       dbHandle.freeTable();
+       MSG_END();
        return MSG_SUCCESS;
+
 }
 
 msg_error_t MsgStoUpdateMms(MSG_MESSAGE_INFO_S *pMsg)
@@ -855,8 +929,275 @@ msg_error_t MsgStoUpdateMms(MSG_MESSAGE_INFO_S *pMsg)
        return MSG_SUCCESS;
 }
 
-msg_error_t MsgStoRestoreMessage()
+msg_error_t MsgStoRestoreMessage(const char *filepath)
 {
+       msg_error_t err = MSG_SUCCESS;
+       MSG_MESSAGE_INFO_S msgInfo = {0,};
+
+       VTree* vMsg = NULL;
+       VObject* pObject = NULL;
+
+       int dataSize = 0;
+
+       char fileName[MSG_FILENAME_LEN_MAX+1];
+       char *pData = NULL;
+       char *pCurrent = NULL;
+       char *pTemp = NULL;
+
+#ifdef MSG_FOR_DEBUG
+       char sample[10000] = "BEGIN:VMSG\r\nX-MESSAGE-TYPE:SMS\r\nX-IRMC-BOX:INBOX\r\nX-SS-DT:20100709T155811Z\r\nBEGIN:VBODY\r\nX-BODY-SUBJECT:hekseh\r\nX-BODY-CONTENTS;ENCODING=BASE64:aGVsbG93b3JsZA==\r\nEND:VBODY\r\nBEGIN:VCARD\r\nVERSION:2.1\r\nTEL:01736510664\r\nEND:VCARD\r\nEND:VMSG\r\n";
+       vMsg = vmsg_decode(sample);
+#else
+       memset(fileName, 0x00, sizeof(fileName));
+       strncpy(fileName, filepath, MSG_FILENAME_LEN_MAX);
+       pData = MsgOpenAndReadMmsFile(fileName, 0, -1, &dataSize);
+       if (pData == NULL)
+               return MSG_ERR_STORAGE_ERROR;
+
+       pCurrent = pData;
+
+       while ((pTemp = strstr(pCurrent, "END:VMSG")) != NULL)
+       {
+               MSG_DEBUG("Start Position: %s", pCurrent);
+
+               while (*pCurrent == '\r' || *pCurrent == '\n')
+                       pCurrent++;
+
+               MSG_DEBUG("Start Position2: %s", pCurrent);
+
+               vMsg = vmsg_decode(pCurrent);
+#endif
+
+               pObject = vMsg->pTop;
+
+               memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+               while (1)
+               {
+                       while (1)
+                       {
+                               MSG_DEBUG("pObject type [%d], pObject Value [%s]", pObject->property, pObject->pszValue[0]);
+
+                               switch (pObject->property)
+                               {
+                                       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"))) {
+                                                       msgInfo.msgType.mainType = MSG_MMS_TYPE;
+                                                       msgInfo.msgType.subType = MSG_RETRIEVE_AUTOCONF_MMS;
+                                               } else if (!strncmp(pObject->pszValue[0], "MMS SEND", strlen("MMS SEND"))) {
+                                                       msgInfo.msgType.mainType = MSG_MMS_TYPE;
+                                                       msgInfo.msgType.subType = MSG_SENDCONF_MMS;
+                                               } else if (!strncmp(pObject->pszValue[0], "MMS NOTIFICATION", strlen("MMS NOTIFICATION"))) {
+                                                       msgInfo.msgType.mainType = MSG_MMS_TYPE;
+                                                       msgInfo.msgType.subType = MSG_NOTIFICATIONIND_MMS;
+                                               } else {
+                                                       vmsg_free_vtree_memory(vMsg);
+                                                       return MSG_ERR_STORAGE_ERROR;
+                                               }
+                                       }
+                                       break;
+
+                                       case VMSG_TYPE_MSGBOX :
+                                       {
+                                               if(!strncmp(pObject->pszValue[0], "INBOX", strlen("INBOX"))) {
+                                                       msgInfo.folderId= MSG_INBOX_ID;
+                                                       msgInfo.direction=MSG_DIRECTION_TYPE_MT;
+
+                                                       msgInfo.networkStatus=MSG_NETWORK_RECEIVED;
+                                               } else if(!strncmp(pObject->pszValue[0], "OUTBOX", strlen("OUTBOX"))) {
+                                                       msgInfo.folderId= MSG_OUTBOX_ID;
+                                                       msgInfo.direction=MSG_DIRECTION_TYPE_MO;
+
+                                                       msgInfo.networkStatus=MSG_NETWORK_SEND_FAIL;
+                                               } else if(!strncmp(pObject->pszValue[0], "SENTBOX", strlen("SENTBOX"))) {
+                                                       msgInfo.folderId= MSG_SENTBOX_ID;
+                                                       msgInfo.direction=MSG_DIRECTION_TYPE_MO;
+
+                                                       msgInfo.networkStatus=MSG_NETWORK_SEND_SUCCESS;
+                                               } else if(!strncmp(pObject->pszValue[0], "DRAFTBOX", strlen("DRAFTBOX"))) {
+                                                       msgInfo.folderId=MSG_DRAFT_ID;
+                                                       msgInfo.direction=MSG_DIRECTION_TYPE_MO;
+
+                                                       msgInfo.networkStatus=MSG_NETWORK_NOT_SEND;
+                                               } else {
+                                                       vmsg_free_vtree_memory(vMsg);
+                                                       return MSG_ERR_STORAGE_ERROR;
+                                               }
+                                       }
+                                       break;
+
+                                       case VMSG_TYPE_STATUS :
+                                       {
+                                               if(!strncmp(pObject->pszValue[0], "READ", strlen("READ"))) {
+                                                       msgInfo.bRead = true;
+                                               } else if(!strncmp(pObject->pszValue[0], "UNREAD", strlen("UNREAD"))) {
+                                                       msgInfo.bRead = false;
+                                               } else {
+                                                       vmsg_free_vtree_memory(vMsg);
+                                                       return MSG_ERR_STORAGE_ERROR;
+                                               }
+                                       }
+                                       break;
+
+                                       case VMSG_TYPE_DATE :
+                                       {
+                                               struct tm       displayTime;
+
+                                               if (!_convert_vdata_str_to_tm(pObject->pszValue[0], &displayTime)) {
+                                                       vmsg_free_vtree_memory( vMsg );
+                                                       return MSG_ERR_STORAGE_ERROR;
+                                               }
+
+                                               msgInfo.displayTime = mktime(&displayTime);
+                                       }
+                                       break;
+
+                                       case VMSG_TYPE_SUBJECT :
+                                       {
+                                               MSG_DEBUG("subject length is [%d].", strlen(pObject->pszValue[0]));
+
+                                               if(strlen(pObject->pszValue[0]) > 0) {
+                                                       strncpy(msgInfo.subject, pObject->pszValue[0], MAX_SUBJECT_LEN);
+                                                       if ( msgInfo.subject[strlen(pObject->pszValue[0])-1] == '\r' )
+                                                               msgInfo.subject[strlen(pObject->pszValue[0])-1]= '\0';
+                                               }
+                                       }
+                                       break;
+
+                                       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);
+                                                                       return MSG_ERR_STORAGE_ERROR;
+                                                               }
+
+                                                               if (MsgWriteIpcFile(fileName, pObject->pszValue[0], pObject->numOfBiData) == false) {
+                                                                       vmsg_free_vtree_memory(vMsg);
+                                                                       return MSG_ERR_STORAGE_ERROR;
+                                                               }
+
+                                                               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 {
+                                                       msgInfo.bTextSms = true;
+                                                       if(msgInfo.msgType.subType == MSG_NOTIFICATIONIND_MMS) {
+
+                                                                       msgInfo.bTextSms = true;
+
+                                                               // Save Message Data into File
+                                                               char fileName[MAX_COMMON_INFO_SIZE+1];
+                                                               memset(fileName, 0x00, sizeof(fileName));
+
+                                                               if (MsgCreateFileName(fileName) == false) {
+                                                                       vmsg_free_vtree_memory(vMsg);
+                                                                       return MSG_ERR_STORAGE_ERROR;
+                                                               }
+
+                                                               if (MsgWriteIpcFile(fileName, pObject->pszValue[0], pObject->numOfBiData) == false) {
+                                                                       vmsg_free_vtree_memory(vMsg);
+                                                                       return MSG_ERR_STORAGE_ERROR;
+                                                               }
+                                                               strncpy(msgInfo.msgData, MSG_IPC_DATA_PATH, MAX_MSG_DATA_LEN);
+                                                               strncat(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN-strlen(msgInfo.msgData));
+                                                               msgInfo.dataSize = strlen(fileName);
+                                                               MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(msgInfo.msgType.mainType);
+                                                               err =  plg->restoreMsg(&msgInfo, pObject->pszValue[0], pObject->numOfBiData, NULL);
+
+                                                       } else {
+//////////////// From here was avaliable
+                                                               char    retrievedFilePath[MAX_FULL_PATH_SIZE] = {0,};
+                                                               MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(msgInfo.msgType.mainType);
+                                                               err =  plg->restoreMsg(&msgInfo, pObject->pszValue[0], pObject->numOfBiData, retrievedFilePath);
+                                                               msgInfo.bTextSms = false;
+
+                                                               char fileName[MAX_COMMON_INFO_SIZE+1];
+                                                               memset(fileName, 0x00, sizeof(fileName));
+
+                                                               if (MsgCreateFileName(fileName) == false) {
+                                                                       vmsg_free_vtree_memory(vMsg);
+                                                                       return MSG_ERR_STORAGE_ERROR;
+                                                               }
+                                                               MSG_DEBUG("fileName: %s, retrievedFilePath: %s (%d)", fileName, retrievedFilePath, strlen(retrievedFilePath));
+
+                                                               if (MsgWriteIpcFile(fileName, retrievedFilePath, strlen(retrievedFilePath)+ 1) == false) {
+                                                                       vmsg_free_vtree_memory(vMsg);
+                                                                       return MSG_ERR_STORAGE_ERROR;
+                                                               }
+                                                               strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+                                                               msgInfo.dataSize = strlen(retrievedFilePath) + 1;
+
+                                                               if (err != MSG_SUCCESS)
+                                                                       return vmsg_free_vtree_memory(vMsg);
+///////////////////////////
+                                                       }
+                                               }
+                                       }
+                                       break;
+
+                                       case VCARD_TYPE_TEL :
+                                       {
+                                               msgInfo.nAddressCnt++;
+
+                                               msgInfo.addressList[msgInfo.nAddressCnt-1].addressType = MSG_ADDRESS_TYPE_PLMN;
+                                               msgInfo.addressList[msgInfo.nAddressCnt-1].recipientType = MSG_RECIPIENTS_TYPE_TO;
+
+                                               strncpy(msgInfo.addressList[msgInfo.nAddressCnt-1].addressVal, pObject->pszValue[0], MAX_ADDRESS_VAL_LEN);
+                                       }
+                                       break;
+                               }
+
+                               if (pObject->pSibling != NULL)
+                                       pObject = pObject->pSibling;
+                               else
+                                       break;
+                       }
+
+                       if (vMsg->pNext != NULL) {
+                               vMsg = vMsg->pNext;
+                               pObject = vMsg->pTop;
+                       } else {
+                               break;
+                       }
+               }
+
+               msgInfo.bBackup = true; // Set Backup Flag
+               msgInfo.storageId = MSG_STORAGE_PHONE; // Set Storage Id
+               msgInfo.priority = MSG_MESSAGE_PRIORITY_NORMAL; // Set Priority
+
+               err = MsgStoAddMessage(&msgInfo, NULL);
+               if (err != MSG_SUCCESS) {
+                       MSG_DEBUG("MsgStoAddMessage() error : %d", err);
+               }
+
+               if (msgInfo.msgType.mainType == MSG_MMS_TYPE)
+                       MsgStoUpdateMms(&msgInfo);
+
+               vmsg_free_vtree_memory(vMsg);
+
+               vMsg = NULL;
+               pCurrent = pTemp + strlen("END:VMSG");
+       }
+
        return MSG_SUCCESS;
 }
 
index d8c27ff..1c5af1e 100755 (executable)
@@ -56,104 +56,6 @@ bool delLogRunning = false;
 /*==================================================================================================
                                      FUNCTION FOR THREAD
 ==================================================================================================*/
-static gboolean startToDeleteNoti(void *pVoid)
-{
-       MSG_BEGIN();
-
-       msg_id_list_s *pMsgIdList = (msg_id_list_s *)pVoid;
-
-       MSG_DEBUG("pMsgIdList->nCount [%d]", pMsgIdList->nCount);
-
-       delNotiMx.lock();
-
-       while (delNotiRunning) {
-               delNoticv.wait(delNotiMx.pMutex());
-       }
-
-       delNotiRunning = true;
-
-       for (int i = 0; i < pMsgIdList->nCount; i++) {
-               MsgDeleteNotiByMsgId(pMsgIdList->msgIdList[i]);
-
-               /** sleep for moment */
-               if ((i%100 == 0) && (i != 0))
-                       usleep(70000);
-       }
-
-       delNotiRunning = false;
-
-       delNoticv.signal();
-       delNotiMx.unlock();
-
-       // memory free
-       if (pMsgIdList != NULL) {
-               //free peer info list
-               if (pMsgIdList->msgIdList != NULL)
-                       delete [] pMsgIdList->msgIdList;
-
-               delete [] pMsgIdList;
-       }
-
-       MSG_END();
-
-       return FALSE;
-}
-
-
-static gboolean startToDeletePhoneLog(void *pVoid)
-{
-       MSG_BEGIN();
-
-       msg_id_list_s *pMsgIdList = (msg_id_list_s *)pVoid;
-
-       MSG_DEBUG("pMsgIdList->nCount [%d]", pMsgIdList->nCount);
-
-       delLogMx.lock();
-
-       while (delLogRunning){
-               delLogcv.wait(delLogMx.pMutex());
-       }
-
-       delLogRunning = true;
-
-       int transBegin = MsgContactSVCBeginTrans();
-
-       for (int i = 0; i < pMsgIdList->nCount; i++) {
-               if (transBegin == 0)
-                       MsgDeletePhoneLog(pMsgIdList->msgIdList[i]);
-
-               /** sleep for moment */
-               if ((i%100 == 0) && (i!=0)) {
-                       if (transBegin == 0) {
-                               MsgContactSVCEndTrans(true);
-                               usleep(70000);
-                       }
-                       transBegin = MsgContactSVCBeginTrans();
-               }
-       }
-
-       if (transBegin == 0)
-               MsgContactSVCEndTrans(true);
-
-       delLogRunning = false;
-
-       delLogcv.signal();
-       delLogMx.unlock();
-
-       // memory free
-       if (pMsgIdList != NULL) {
-               //free peer info list
-               if (pMsgIdList->msgIdList != NULL)
-                       delete [] pMsgIdList->msgIdList;
-
-               delete [] pMsgIdList;
-       }
-
-       MSG_END();
-
-       return FALSE;
-}
-
 static gboolean updateUnreadMsgCount(void *pVoid)
 {
        MSG_BEGIN();
@@ -530,38 +432,8 @@ msg_error_t MsgStoUpdateThreadReadStatus(msg_thread_id_t threadId)
        msg_error_t err = MSG_SUCCESS;
 
        int rowCnt = 0;
-       int index = 1;
-       msg_id_list_s *pUnreadMsgIdList = NULL;
-
-       pUnreadMsgIdList = (msg_id_list_s *)new char[sizeof(msg_id_list_s)];
-       memset(pUnreadMsgIdList, 0x00, sizeof(msg_id_list_s));
-
        char sqlQuery[MAX_QUERY_LEN+1];
 
-       // Get MSG_ID List
-       memset(sqlQuery, 0x00, sizeof(sqlQuery));
-       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s A WHERE CONV_ID = %d AND READ_STATUS = 0;",
-                       MSGFW_MESSAGE_TABLE_NAME, threadId);
-
-       err = dbHandle.getTable(sqlQuery, &rowCnt);
-
-       if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
-               dbHandle.freeTable();
-               return err;
-       }
-
-       pUnreadMsgIdList->nCount = rowCnt;
-
-       MSG_DEBUG("unreadMsgIdList.nCount [%d]", pUnreadMsgIdList->nCount);
-
-       pUnreadMsgIdList->msgIdList = (msg_message_id_t *)new char[sizeof(msg_message_id_t) * rowCnt];
-
-       for (int i = 0; i < rowCnt; i++)
-               pUnreadMsgIdList->msgIdList[i] = dbHandle.getColumnToInt(index++);
-
-       dbHandle.freeTable();
-
-
        // Get sim MSG_ID
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
        snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s A \
@@ -601,20 +473,8 @@ msg_error_t MsgStoUpdateThreadReadStatus(msg_thread_id_t threadId)
                MSG_DEBUG("updateUnreadMsgCount() Error");
        }
 
-       if (pUnreadMsgIdList->nCount > 0) {
-               if (g_idle_add(startToDeleteNoti, (void *)pUnreadMsgIdList) == 0) {
-                       MSG_DEBUG("startToDeleteNoti not invoked: %s", strerror(errno));
-                       // memory free
-                       if (pUnreadMsgIdList != NULL) {
-                               //free peer info list
-                               if (pUnreadMsgIdList->msgIdList != NULL)
-                                       delete [] pUnreadMsgIdList->msgIdList;
+       MsgRefreshNoti();
 
-                               delete [] pUnreadMsgIdList;
-                       }
-                       err = MSG_ERR_UNKNOWN;
-               }
-       }
        MSG_END();
 
        return MSG_SUCCESS;
@@ -913,11 +773,12 @@ msg_error_t MsgStoDeleteMessage(msg_message_id_t msgId, bool bCheckIndication)
 
                MsgSettingSetIndicator(smsCnt, mmsCnt);
 
-               MsgDeleteNotiByMsgId(msgId);
+//             MsgDeleteNotiByMsgId(msgId);
+               MsgRefreshNoti();
        }
 
        //Delete phone log
-       MsgDeletePhoneLog(msgId);
+//     MsgDeletePhoneLog(msgId);
 
        return MSG_SUCCESS;
 }
@@ -970,6 +831,10 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD
        /*** Get msg id list **/
        msg_id_list_s *pToDeleteMsgIdList = NULL;
        pToDeleteMsgIdList = (msg_id_list_s *)new char[sizeof(msg_id_list_s)];
+       if (pToDeleteMsgIdList == NULL) {
+               MSG_DEBUG("pToDeleteMsgIdList is NULL.");
+               return MSG_ERR_NULL_POINTER;
+       }
        memset(pToDeleteMsgIdList, 0x00, sizeof(msg_id_list_s));
 
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
@@ -1039,7 +904,7 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD
                        }
 
                        //Delete phone log
-                       MsgDeletePhoneLog(dbHandle.getColumnToInt(i));
+//                     MsgDeletePhoneLog(dbHandle.getColumnToInt(i));
                }
 
                dbHandle.freeTable();
@@ -1185,18 +1050,8 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD
 /*** Create thread  for noti and phone log delete. **/
        if (!bOnlyDB) {
                if (pToDeleteMsgIdList->nCount > 0) {
-
-                       msg_id_list_s *pToDeleteMsgIdListCpy = NULL;
-                       pToDeleteMsgIdListCpy = (msg_id_list_s *)new char[sizeof(msg_id_list_s)];
-                       memset(pToDeleteMsgIdListCpy, 0x00, sizeof(msg_id_list_s));
-
-                       pToDeleteMsgIdListCpy->nCount = pToDeleteMsgIdList->nCount;
-
-                       pToDeleteMsgIdListCpy->msgIdList = (msg_message_id_t *)new char[sizeof(msg_message_id_t)*pToDeleteMsgIdList->nCount];
-                       memcpy(pToDeleteMsgIdListCpy->msgIdList, pToDeleteMsgIdList->msgIdList, sizeof(msg_message_id_t)*pToDeleteMsgIdList->nCount);
-
-                       if (g_idle_add(startToDeleteNoti, (void *)pToDeleteMsgIdList) == 0) {
-                               MSG_DEBUG("startToDeleteNoti not invoked: %s", strerror(errno));
+//                     if (g_idle_add(startToDeletePhoneLog, (void *)pToDeleteMsgIdList) == 0) {
+//                             MSG_DEBUG("startToDeletePhoneLog not invoked: %s", strerror(errno));
                                // memory free
                                if (pToDeleteMsgIdList != NULL) {
                                        //free peer info list
@@ -1205,21 +1060,10 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD
 
                                        delete [] pToDeleteMsgIdList;
                                }
-                               err = MSG_ERR_UNKNOWN;
-                       }
-
-                       if (g_idle_add(startToDeletePhoneLog, (void *)pToDeleteMsgIdListCpy) == 0) {
-                               MSG_DEBUG("startToDeletePhoneLog not invoked: %s", strerror(errno));
-                               // memory free
-                               if (pToDeleteMsgIdListCpy != NULL) {
-                                       //free peer info list
-                                       if (pToDeleteMsgIdListCpy->msgIdList != NULL)
-                                               delete [] pToDeleteMsgIdListCpy->msgIdList;
+//                             err = MSG_ERR_UNKNOWN;
+//                     }
 
-                                       delete [] pToDeleteMsgIdListCpy;
-                               }
-                               err = MSG_ERR_UNKNOWN;
-                       }
+                       MsgRefreshNoti();
                }
        }
 /*** **/
@@ -1454,6 +1298,7 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList)
 
        MsgSettingSetIndicator(smsCnt, mmsCnt);
 
+#if 0
 /*** Create thread  for noti and phone log delete. **/
        if (pMsgIdList->nCount > 0) {
                msg_id_list_s *pToDeleteMsgIdList = NULL;
@@ -1497,6 +1342,9 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList)
                }
        }
 /*** **/
+#endif
+
+       MsgRefreshNoti();
 
        MSG_END();
        return MSG_SUCCESS;
@@ -1505,8 +1353,9 @@ msg_error_t MsgStoDeleteMessageByList(msg_id_list_s *pMsgIdList)
 
 msg_error_t MsgStoMoveMessageToFolder(msg_message_id_t msgId, msg_folder_id_t destFolderId)
 {
+       msg_error_t err = MSG_SUCCESS;
        MSG_MESSAGE_TYPE_S msgType;
-       msg_thread_id_t convId;
+       msg_thread_id_t convId = 0;
 
        MsgStoGetMsgType(msgId, &msgType);
 
@@ -1539,9 +1388,9 @@ msg_error_t MsgStoMoveMessageToFolder(msg_message_id_t msgId, msg_folder_id_t de
        dbHandle.finalizeQuery();
 
        /* update conversation table */
-       MsgStoUpdateConversation(&dbHandle, convId);
+       err = MsgStoUpdateConversation(&dbHandle, convId);
 
-       return MSG_SUCCESS;
+       return err;
 }
 
 
@@ -1914,7 +1763,7 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M
                // Encode MMS specific data to MMS_MESSAGE_DATA_S
                if (pMsg->dataSize > MAX_MSG_DATA_LEN) {
                        // Save Message Data into File
-                       char tempFileName[MAX_COMMON_INFO_SIZE+1];
+                       char tempFileName[MSG_FILENAME_LEN_MAX+1];
                        memset(tempFileName, 0x00, sizeof(tempFileName));
 
                        if (MsgCreateFileName(tempFileName) == false) {
@@ -1934,7 +1783,6 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M
                                return MSG_ERR_STORAGE_ERROR;
                        }
                        strncpy(pMsg->msgData, tempFileName, MAX_MSG_DATA_LEN);
-                       //pMsg->dataSize = strlen(fileName);
                        pMsg->bTextSms = false;
                } else {
                        strncpy(pMsg->msgData, pDestMsg, pMsg->dataSize);
@@ -2056,7 +1904,7 @@ msg_error_t MsgStoGetFolderViewList(msg_folder_id_t folderId, const MSG_SORT_RUL
                        index++;
                } else {
                        pTmp->pData = (void *)new char[pTmp->dataSize + 2];
-                       memset(pTmp->pData, 0x00, sizeof(pTmp->pData));
+                       memset(pTmp->pData, 0x00, pTmp->dataSize + 2);
 
                        dbHandle.getColumnToString(index++, pTmp->dataSize+1, (char *)pTmp->pData);
                }
@@ -2128,7 +1976,7 @@ msg_error_t MsgStoAddSyncMLMessage(MSG_MESSAGE_INFO_S *pMsgInfo, int extId, int
 
        pMsgInfo->msgId = (msg_message_id_t)rowId;
 
-       MsgSoundPlayStart();
+       MsgSoundPlayStart(false);
 
        int smsCnt = 0;
        int mmsCnt = 0;
@@ -2921,21 +2769,10 @@ msg_error_t MsgStoSearchMessage(const char *pSearchString, msg_struct_list_s *pT
        // Search - Address, Name
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
-       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT C.CONV_ID, C.UNREAD_CNT, C.SMS_CNT, C.MMS_CNT, C.DISPLAY_NAME, \
-                       B.MAIN_TYPE, B.SUB_TYPE, B.MSG_DIRECTION, B.DISPLAY_TIME, B.MSG_TEXT \
-                       FROM %s A, %s B, %s C \
-                       WHERE A.CONV_ID = B.CONV_ID AND B.FOLDER_ID > 0 AND B.FOLDER_ID < %d \
-                       AND ( B.MSG_TEXT LIKE '%%%s%%' ESCAPE '\\' \
-                       OR B.SUBJECT LIKE '%%%s%%' ESCAPE '\\' \
-                       OR A.ADDRESS_VAL LIKE '%%%s%%' ESCAPE '\\' \
-                       OR A.DISPLAY_NAME LIKE '%%%s%%' ESCAPE '\\' \
-                       OR A.FIRST_NAME LIKE '%%%s%%' ESCAPE '\\' \
-                       OR A.LAST_NAME LIKE '%%%s%%' ESCAPE '\\' ) \
-                       AND A.CONV_ID = C.CONV_ID \
-                       ORDER BY B.DISPLAY_TIME DESC;",
-                       MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSGFW_CONVERSATION_TABLE_NAME,
-                       MSG_SPAMBOX_ID, ext2_str, ext2_str, ext2_str, ext2_str, ext2_str, ext2_str);
-
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONV_ID, UNREAD_CNT, SMS_CNT, MMS_CNT, DISPLAY_NAME, \
+                       MAIN_TYPE, SUB_TYPE, MSG_DIRECTION, DISPLAY_TIME, MSG_TEXT \
+                       FROM %s WHERE DISPLAY_NAME LIKE '%%%s%%' ESCAPE '\\' ORDER BY DISPLAY_TIME DESC;",
+                       MSGFW_CONVERSATION_TABLE_NAME, ext2_str);
 
        if (ext1_str) {
                free(ext1_str);
@@ -3213,7 +3050,7 @@ msg_error_t MsgStoSearchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int of
                } else {
                        MSG_DEBUG("pTmp->dataSize [%d]", pTmp->dataSize);
                        pTmp->pData = (void *)new char[pTmp->dataSize + 2];
-                       memset(pTmp->pData, 0x00, sizeof(pTmp->pData));
+                       memset(pTmp->pData, 0x00, pTmp->dataSize + 2);
 
                        dbHandle.getColumnToString(index++, pTmp->dataSize+1, (char *)pTmp->pData);
                }
@@ -3561,6 +3398,10 @@ msg_error_t MsgStoGetThreadInfo(msg_thread_id_t threadId, MSG_THREAD_VIEW_S *pTh
 
                memset(pThreadInfo->threadData, 0x00, sizeof(pThreadInfo->threadData));
                dbHandle.getColumnToString(index++, MAX_THREAD_DATA_LEN, pThreadInfo->threadData);
+
+               int protectedCnt = dbHandle.getColumnToInt(index++);
+               if (protectedCnt > 0)
+                       pThreadInfo->bProtected = true;
        }
 
        dbHandle.freeTable();
index 80fe3a8..5a3b26e 100755 (executable)
@@ -288,28 +288,6 @@ msg_error_t MsgStoGetSubject(msg_message_id_t msgId, char *pSubject)
        return MSG_SUCCESS;
 }
 
-
-msg_error_t MsgStoUpdateNetworkStatus(MSG_MESSAGE_INFO_S *pMsgInfo, msg_network_status_t status)
-{
-       MSG_BEGIN();
-
-       msg_error_t err = MSG_SUCCESS;
-
-       char sqlQuery[MAX_QUERY_LEN+1];
-
-       memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
-       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d WHERE MSG_ID = %d;",
-                       MSGFW_MESSAGE_TABLE_NAME, status, pMsgInfo->msgId);
-
-       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
-               return MSG_ERR_DB_EXEC;
-
-       MSG_END();
-       return err;
-}
-
-
 msg_error_t MsgStoGetRecipientList(msg_message_id_t msgId, MSG_RECIPIENTS_LIST_S *pRecipientList)
 {
        if (pRecipientList == NULL) {
index 8d0eccb..1de9676 100755 (executable)
@@ -331,7 +331,7 @@ void MsgCopyReqInfo(MSG_REQUEST_INFO_S *pSrc, int addrIdx, MSG_REQUEST_INFO_S *p
 {
        MSG_BEGIN();
 
-       memset(pDest, 0x00, sizeof(pDest));
+       memset(pDest, 0x00, sizeof(MSG_REQUEST_INFO_S));
 
        // Copy Request ID
        pDest->reqId = pSrc->reqId;
index 6c40024..13ebc2e 100755 (executable)
@@ -1050,9 +1050,15 @@ int MsgBackupMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
        msg_error_t err = MSG_SUCCESS;
 
        int eventSize = 0;
+       char path[MSG_FILEPATH_LEN_MAX+1] = {0,};
+       msg_message_backup_type_t type;
 
-       err = MsgStoBackupMessage();
+       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);
+
+       err = MsgStoBackupMessage(type, path);
        if (err == MSG_SUCCESS)
                MSG_DEBUG("Command Handle Success : MsgBackupMessageHandler()");
        else
@@ -1070,9 +1076,11 @@ int MsgRestoreMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
        msg_error_t err = MSG_SUCCESS;
 
        int eventSize = 0;
-
+       char path[MSG_FILEPATH_LEN_MAX+1] = {0,};
+       memcpy(&path, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(path));
+       MSG_DEBUG("path = %s", path);
        // Reset DB
-       err = MsgStoRestoreMessage();
+       err = MsgStoRestoreMessage(path);
 
        if (err == MSG_SUCCESS)
                MSG_DEBUG("Command Handle Success : MsgStoRestoreMessage()");
@@ -1133,7 +1141,7 @@ int MsgGetThreadIdByAddressHandler(const MSG_CMD_S *pCmd, char **ppEvent)
        MSG_DEBUG("*addrCnt [%d]", *addrCnt);
 
        msgInfo.nAddressCnt = *addrCnt;
-       for(int i=0; i<(*addrCnt); i++)
+       for(int i=0; i<msgInfo.nAddressCnt; i++)
                memcpy(&msgInfo.addressList[i], (MSG_ADDRESS_INFO_S *)(pCmd->cmdData+sizeof(int)+(sizeof(MSG_ADDRESS_INFO_S)*i)), sizeof(MSG_ADDRESS_INFO_S));
 
        char* encodedData = NULL;
@@ -1199,6 +1207,196 @@ int MsgGetThreadInfoHandler(const MSG_CMD_S *pCmd, char **ppEvent)
        return eventSize;
 }
 
+
+#ifdef MMS_REPORT_OPERATIONS
+int MsgCheckReadReportRequestedHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_DEBUG();
+       msg_error_t err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Message ID
+       msg_message_id_t* MsgId = (msg_message_id_t*)pCmd->cmdData;
+
+       // Check ReadReport Is Requested
+       bool    bReadReportRequested;
+
+       bReadReportRequested = MsgStoCheckReadReportRequested(*MsgId);
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoCheckSendReadReport()");
+
+               // Encoding ReadReportIsSent Data
+               dataSize = MsgEncodeReadReportRequested(bReadReportRequested, &encodedData);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoCheckReadReportIsSent()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeStorageEvent(encodedData, dataSize, MSG_EVENT_PLG_CHECK_READ_REPORT_REQUESTED, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgCheckReadReportIsSentHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_DEBUG();
+       msg_error_t err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Message ID
+       msg_message_id_t* MsgId = (msg_message_id_t*)pCmd->cmdData;
+
+       // Check ReadReport Is Sent
+       bool    bReadReportIsSent;
+
+       MSG_DEBUG("#### MSGID = %d ####", *MsgId);
+
+       bReadReportIsSent = MsgStoCheckReadReportIsSent(*MsgId);
+       MSG_DEBUG("######## 1. bReadStatusIsSent = %d #######", bReadReportIsSent);
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoCheckReadReportIsSent()");
+
+               // Encoding ReadReportIsSent Data
+               dataSize = MsgEncodeReadReportIsSent(bReadReportIsSent, &encodedData);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoCheckReadReportIsSent()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeStorageEvent(encodedData, dataSize, MSG_EVENT_PLG_CHECK_READ_REPORT_IS_SENT, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgSetReadReportSendStatusHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_DEBUG();
+       msg_error_t err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Message ID
+       msg_message_id_t msgId;
+       int     readReportSendStatus;
+
+       memcpy(&msgId, (char*)pCmd + sizeof(MSG_CMD_TYPE_T), sizeof(msg_message_id_t));
+       memcpy(&readReportSendStatus, (char*)pCmd + sizeof(MSG_CMD_TYPE_T) + sizeof(msg_message_id_t), sizeof(int));
+
+       // Set Read Report Send Status
+       err = MsgStoSetReadReportSendStatus(msgId, readReportSendStatus);
+
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoUpdateReadStatus()");
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoUpdateReadStatus()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeStorageEvent(encodedData, dataSize, MSG_EVENT_PLG_SET_READ_REPORT_SEND_STATUS, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetMmsVersionHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_DEBUG();
+       msg_error_t err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Message ID
+       msg_message_id_t* MsgId = (msg_message_id_t*)pCmd->cmdData;
+
+       // Check ReadReport Is Sent
+       int     version;
+
+       MSG_DEBUG("#### MSGID = %d ####", *MsgId);
+
+       version = MsgStoGetMmsVersion(*MsgId);
+       MSG_DEBUG("######## 1. version = %x #######", version);
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgStoCheckReadReportIsSent()");
+
+               // Encoding ReadReportIsSent Data
+               dataSize = MsgEncodeMmsVersion(version, &encodedData);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgStoCheckReadReportIsSent()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeStorageEvent(encodedData, dataSize, MSG_EVENT_PLG_GET_MMS_VERSION, err, (void**)ppEvent);
+
+       return eventSize;
+}
+
+
+int MsgGetMmsStatusInfoHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       MSG_DEBUG();
+       msg_error_t err = MSG_SUCCESS;
+
+       char* encodedData = NULL;
+       AutoPtr<char> buf(&encodedData);
+
+       int dataSize = 0, eventSize = 0;
+
+       // Get Message ID
+       msg_message_id_t* MsgId = (msg_message_id_t*)pCmd->cmdData;
+
+       MMS_STATUS_INFO_S mmsStatusInfo;
+
+       MSG_DEBUG("#### MSGID = %d ####", *MsgId);
+
+       err = MsgStoGetMmsStatusInfo(*MsgId,&mmsStatusInfo);
+       if (err == MSG_SUCCESS)
+       {
+               MSG_DEBUG("Command Handle Success : MsgGetMmsStatusInfoHandler()");
+
+               // Encoding ReadReportIsSent Data
+               dataSize = MsgEncodeMmsStatusInfo(&mmsStatusInfo, &encodedData);
+       }
+       else
+       {
+               MSG_DEBUG("Command Handle Fail : MsgGetMmsStatusInfoHandler()");
+       }
+
+       // Make Event Data
+       eventSize = MsgMakeStorageEvent(encodedData, dataSize, MSG_EVENT_PLG_GET_MMS_STATUS_INFO, err, (void**)ppEvent);
+
+       return eventSize;
+}
+#endif
+
+
 int MsgAddPushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent)
 {
        msg_error_t err = MSG_SUCCESS;
index 6f24787..dcf03e9 100755 (executable)
@@ -30,6 +30,7 @@
 #include "MsgTransManager.h"
 #include "MsgPluginManager.h"
 #include "MsgCmdHandler.h"
+#include "MsgUtilStorage.h"
 
 #include <alarm.h>
 
@@ -104,18 +105,22 @@ int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                err = MsgStoDeleteMessage(reqInfo.msgInfo.msgId, true);
 
        /** send storage CB */
-       if ((err == MSG_SUCCESS || err != MSG_ERR_PLUGIN_STORAGE) && bNewMsg && reqInfo.msgInfo.msgPort.valid == false) {
-
-               msg_id_list_s msgIdList;
-               msg_message_id_t msgIds[1];
-               memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
+       msg_id_list_s msgIdList;
+       msg_message_id_t msgIds[1];
+       memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
 
-               msgIdList.nCount = 1;
-               msgIds[0] = reqInfo.msgInfo.msgId;
-               msgIdList.msgIdList = msgIds;
+       msgIdList.nCount = 1;
+       msgIds[0] = reqInfo.msgInfo.msgId;
+       msgIdList.msgIdList = msgIds;
 
+       if ((err == MSG_SUCCESS || err != MSG_ERR_PLUGIN_STORAGE) && bNewMsg && reqInfo.msgInfo.msgPort.valid == false) {
                MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_INSERT, &msgIdList);
+       } else if (err == MSG_ERR_SECURITY_ERROR) { // Case of MDM enabled, it returns MSG_ERR_SECURITY_ERROR.
+               MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
+       } else {
+               MSG_DEBUG("No need to broadcast storage change CB");
        }
+
        return eventSize;
 }
 
index 0c31928..38cc69b 100755 (executable)
@@ -519,6 +519,13 @@ bool MsgTransactionManager::checkPrivilege(MSG_CMD_TYPE_T CmdType, const char *p
                return false;
        }
 
+#ifdef MSG_FOR_DEBUG
+       for (int i = 0; i < MAX_COOKIE_LEN; i++)
+       {
+               MSG_DEBUG("cookie : [%02x]", pCookie[i]);
+       }
+#endif
+
        // Check Cookie
        size_t cookieSize;
        gid_t gid;
index 0f9e7fe..0d30587 100755 (executable)
 #define MSG_SMIL_FILE_PATH             MSG_DATA_ROOT_PATH"smildata/"
 #define MSG_IPC_DATA_PATH                      MSG_DATA_ROOT_PATH"ipcdata/"
 #define MSG_THUMBNAIL_PATH             MSG_DATA_PATH"thumbnails/"
+// temporary
+#define TPDU_LOG_FILE                          MSG_DATA_ROOT_PATH"tpduLog.txt"
+#define MSG_NATIONAL_SIM       "memory/private/msg-service/national_sim"
+#define MSG_SIM_MSISDN "memory/private/msg-service/msisdn"
 #define MAX_FULL_PATH_SIZE             320     // max length for internal file path
-#define VALID_ADDRESS_LEN              8
 #define MAX_PRECONFIG_NUM              8
 #define MAX_THREAD_ADDR_LEN    40
 #define MAX_THREAD_NAME_LEN    195
@@ -53,7 +56,6 @@
 /*vconf keys*/
 #define MSG_SIM_IMSI                   "memory/private/msg-service/sim_imsi"
 #define MSG_SIM_CHANGED        "memory/private/msg-service/sim_changed"
-#define MSG_SIM_MSISDN "memory/private/msg-service/msisdn"
 
 #define DEFAULT_SETTING_PATH                           "db/private/msg-service"
 
@@ -213,23 +215,23 @@ typedef struct
        msg_storage_id_t                storageId;                                                                              /**< Indicates where the message is saved. */
        int                                             nAddressCnt;                                                                    /**< Indicates the count of addresses. */
        MSG_ADDRESS_INFO_S              addressList[MAX_TO_ADDRESS_CNT];                                /**< Indicates the address information list. */
-       char                                    replyAddress[MAX_PHONE_NUMBER_LEN+1];   /**< Indicates the reply address. */
+       char                                    replyAddress[MAX_PHONE_NUMBER_LEN+1];                   /**< Indicates the reply address. */
        char                                    subject[MAX_SUBJECT_LEN+1];                                             /**< Indicates the message subject. */
-       time_t                                  displayTime;                                                                                                    /**< Indicates the display time related to the specific operation. */
-       msg_network_status_t    networkStatus;                                                                                                  /**< Indicates the network status of the message. */
-       msg_encode_type_t               encodeType;                                                                                                     /**< Indicates the string encoding type. */
-       bool                                    bRead;                                                                                                                          /**< Indicates whether the message is read or not. */
-       bool                                    bProtected;                                                                                                             /**< Indicates whether the message is protected or not. */
-       bool                                    bBackup;                                                                                                                        /**< Indicates whether the message was restored from PC. */
-       msg_priority_type_t             priority;                                                                                                                       /**< Indicates the priority of the message. */
-       msg_direction_type_t    direction;                                                                                                                      /**< Indicates whether the message is MO or MT (affecting address). */
-       MSG_PORT_INFO_S                 msgPort;                                                                                                                        /**< Indicates the port number information. */
-       bool                                            bTextSms;                                                                                                               /**< Indicates whether the message is just a text message or not. */
-       size_t                                  dataSize;                                                                                                                       /**< Indicates the data size. The unit is byte. */
+       time_t                                  displayTime;                                                                    /**< Indicates the display time related to the specific operation. */
+       msg_network_status_t    networkStatus;                                                                  /**< Indicates the network status of the message. */
+       msg_encode_type_t               encodeType;                                                                             /**< Indicates the string encoding type. */
+       bool                                    bRead;                                                                                  /**< Indicates whether the message is read or not. */
+       bool                                    bProtected;                                                                             /**< Indicates whether the message is protected or not. */
+       bool                                    bBackup;                                                                                /**< Indicates whether the message was restored from PC. */
+       msg_priority_type_t             priority;                                                                               /**< Indicates the priority of the message. */
+       msg_direction_type_t    direction;                                                                              /**< Indicates whether the message is MO or MT (affecting address). */
+       MSG_PORT_INFO_S                 msgPort;                                                                                /**< Indicates the port number information. */
+       bool                                    bTextSms;                                                                               /**< Indicates whether the message is just a text message or not. */
+       size_t                                  dataSize;                                                                               /**< Indicates the data size. The unit is byte. */
        char                                    msgData[MAX_MSG_DATA_LEN+1];                                    /**< Indicates the message payload information as a body. */
        char                                    msgText[MAX_MSG_TEXT_LEN+1];
-       char                                                                            thumbPath[MSG_FILEPATH_LEN_MAX];
-       bool                                    bStore;
+       char                                    thumbPath[MSG_FILEPATH_LEN_MAX+1];
+       bool                                    bStore;                                                                                 /**< Indicates whether the message is stored or not if it is MWI message. */
 } MSG_MESSAGE_INFO_S;
 
 typedef struct
index df41c2d..26608d4 100755 (executable)
@@ -54,8 +54,8 @@
  *     @brief  Represents text information.
  */
 typedef struct  {
-       char                    szTransInId[MAX_SMIL_TRANSIN_ID];  /**< Indicates the In SMIL transition id */
-       char                    szTransOutId[MAX_SMIL_TRANSOUT_ID]; /**< Indicates the Out SMIL transition id */
+       char                    szTransInId[MAX_SMIL_TRANSIN_ID + 1];  /**< Indicates the In SMIL transition id */
+       char                    szTransOutId[MAX_SMIL_TRANSOUT_ID + 1]; /**< Indicates the Out SMIL transition id */
        int                             nRepeat; /**< Indicates the text needs to be displayed repeatedly */
        int                             nBegin;  /**< Indicates the begin time */
        int                             nEnd;   /**< Indicates the end time */
@@ -74,8 +74,8 @@ typedef struct  {
  *     @brief  Represents video information.
  */
 typedef struct {
-       char                    szTransInId[MAX_SMIL_TRANSIN_ID]; /**< Indicates the In SMIL transition id */
-       char                    szTransOutId[MAX_SMIL_TRANSOUT_ID];  /**< Indicates the Out SMIL transition id */
+       char                    szTransInId[MAX_SMIL_TRANSIN_ID + 1]; /**< Indicates the In SMIL transition id */
+       char                    szTransOutId[MAX_SMIL_TRANSOUT_ID + 1];  /**< Indicates the Out SMIL transition id */
        int                             nRepeat; /**< Indicates the video needs to be displayed repeatedly */
        int                             nBegin;  /**< Indicates the begin time */
        int                             nEnd;   /**< Indicates the end time */
@@ -90,14 +90,14 @@ typedef struct
 {
        MmsSmilMediaType        mediatype; /**< Indicates the SMIL media type. see enum MmsSmilMediaType */
 
-       char                    szSrc[MSG_FILEPATH_LEN_MAX];/**< Indicates the media source name */
-       char                    szFileName[MSG_FILENAME_LEN_MAX]; /**< Indicates the file name */
-       char                    szFilePath[MSG_FILEPATH_LEN_MAX]; /**< Indicates the file path */
-       char                    szContentID[MSG_MSG_ID_LEN+1]; /**< Indicates the content id */
-       char                    regionId[MAX_SMIL_REGION_ID]; /**< Indicates the region id */
-       char                    szAlt[MAX_SMIL_ALT_LEN]; /**< Indicates the alternative text to be displayed in failure case */
+       char                    szSrc[MSG_FILEPATH_LEN_MAX + 1];/**< Indicates the media source name */
+       char                    szFileName[MSG_FILENAME_LEN_MAX + 1]; /**< Indicates the file name */
+       char                    szFilePath[MSG_FILEPATH_LEN_MAX + 1]; /**< Indicates the file path */
+       char                    szContentID[MSG_MSG_ID_LEN + 1]; /**< Indicates the content id */
+       char                    regionId[MAX_SMIL_REGION_ID + 1]; /**< Indicates the region id */
+       char                    szAlt[MAX_SMIL_ALT_LEN + 1]; /**< Indicates the alternative text to be displayed in failure case */
        MsgDrmType              drmType; /**< Indicates the drm type. see enum MsgDrmType */
-       char                    szDrm2FullPath[MSG_FILEPATH_LEN_MAX];  /**< Indicates the fullpath of the DRM */
+       char                    szDrm2FullPath[MSG_FILEPATH_LEN_MAX + 1];  /**< Indicates the fullpath of the DRM */
        union{
                MmsSmilText     sText;  /**< Indicates the text attributes */
                MmsSmilAVI      sAVI; /**< Indicates the video attributes */
@@ -110,11 +110,11 @@ typedef struct
 typedef struct
 {
        MimeType        mediatype;      /**< Indicates the file mime type. see enum MimeType */
-       char            szFileName[MSG_FILENAME_LEN_MAX]; /**< Indicates the file name */
-       char            szFilePath[MSG_FILEPATH_LEN_MAX]; /**< Indicates the file path */
+       char            szFileName[MSG_FILENAME_LEN_MAX + 1]; /**< Indicates the file name */
+       char            szFilePath[MSG_FILEPATH_LEN_MAX + 1]; /**< Indicates the file path */
        int             fileSize;        /**< Indicates the size of the file */
        MsgDrmType      drmType; /**< Indicates the drm type. see enum MsgDrmType */
-       char            szDrm2FullPath[MSG_FILEPATH_LEN_MAX]; /**< Indicates the fullpath of the DRM */
+       char            szDrm2FullPath[MSG_FILEPATH_LEN_MAX + 1]; /**< Indicates the fullpath of the DRM */
 }MMS_ATTACH_S;
 
 /**
@@ -147,7 +147,7 @@ typedef struct
  */
 typedef struct
 {
-       char                            szID[MAX_SMIL_REGION_ID]; /**< Indicates the ID of region information */
+       char                            szID[MAX_SMIL_REGION_ID + 1]; /**< Indicates the ID of region information */
        MMS_LENGTH              nLeft; /**< Indicates the left co-ordinate of the region */
        MMS_LENGTH              nTop; /**< Indicates the top co-ordinate of the region */
        MMS_LENGTH              width; /**< Indicates the width of the region */
@@ -173,10 +173,10 @@ typedef struct
  */
 typedef struct
 {
-       char                    szID[MAX_SMIL_TRANSITION_ID];   /**< Indicates the ID of transition information */
-       MmsSmilTransType        nType;                                  /**< Indicates the transition type. see enum MmsSmilTransType */
+       char                                    szID[MAX_SMIL_TRANSITION_ID + 1];       /**< Indicates the ID of transition information */
+       MmsSmilTransType                nType;                                  /**< Indicates the transition type. see enum MmsSmilTransType */
        MmsSmilTransSubType     nSubType;                               /**< Indicates the transition sub type. see enum MmsSmilTransSubType */
-       int                     nDur;                                   /**< Indicates the transition duration */
+       int                                     nDur;                                   /**< Indicates the transition duration */
 }MMS_SMIL_TRANSITION;
 
 
@@ -185,9 +185,9 @@ typedef struct
  */
 typedef struct
 {
-       char            szID[MAX_SMIL_META_ID];                         /**< Indicates the ID of meta information */
-       char            szName[MAX_SMIL_META_NAME];             /**< Indicates the Name */
-       char            szContent[MAX_SMIL_META_CONTENT];       /**< Indicates the content */
+       char            szID[MAX_SMIL_META_ID + 1];                             /**< Indicates the ID of meta information */
+       char            szName[MAX_SMIL_META_NAME + 1];         /**< Indicates the Name */
+       char            szContent[MAX_SMIL_META_CONTENT + 1];   /**< Indicates the content */
 }MMS_SMIL_META;
 
 
@@ -197,8 +197,8 @@ typedef struct
 typedef struct
 {
        bool                    valid;                                                                          /**< Indicates whether application id information is used or not. */
-       char                    appId[MAX_MMS_JAVA_APPID_LEN+1];                        /**< application id, it should not exceed 32 chars */
-       char                    replyToAppId[MAX_MMS_JAVA_APPID_LEN+1]; /**< reply to application id, application id, it should not exceeded 32 chars */
+       char                    appId[MAX_MMS_JAVA_APPID_LEN + 1];                      /**< application id, it should not exceed 32 chars */
+       char                    replyToAppId[MAX_MMS_JAVA_APPID_LEN + 1];       /**< reply to application id, application id, it should not exceeded 32 chars */
 }MMS_APPID_INFO_S;
 
 
@@ -207,9 +207,9 @@ typedef struct
 
 typedef struct
 {
-       char                                    szMsgID[MMS_MSG_ID_LEN+1];
-       char                                    retrievedFilePath[MAX_FULL_PATH_SIZE_S];
-       char                                    szTrID[MMS_TR_ID_LEN+1];
+       char                                    szMsgID[MMS_MSG_ID_LEN + 1];
+       char                                    retrievedFilePath[MAX_FULL_PATH_SIZE_S + 1];
+       char                                    szTrID[MMS_TR_ID_LEN + 1];
        MMS_APPID_INFO_S        msgAppId;
 }MMS_RECV_DATA_S;
 
@@ -219,7 +219,7 @@ typedef struct
  */
 typedef struct _MMS_MESSAGE_DATA_S
 {
-       char                                    szSmilFilePath[MSG_FILEPATH_LEN_MAX];   /**< Indicates the SMIL file path */
+       char                                    szSmilFilePath[MSG_FILEPATH_LEN_MAX + 1];       /**< Indicates the SMIL file path */
        int                                             pageCnt;        /**< The count of the SMIL pages */
        GList                                   *pagelist;      /**< The pointer to SMIL pages list */
        int                                             regionCnt;      /**< The count of the SMIL regions */
index 2334c47..fae4736 100755 (executable)
  *     @defgroup       MESSAGING_STORAGE_TYPES Messaging Storage Types
  *     @{
  */
-
-/*==================================================================================================
-                                    DEFINES
-==================================================================================================*/
-#define MAX_SEGMENT_NUM                        15
-
-
 /*==================================================================================================
                                          STRUCTURES
 ==================================================================================================*/
index 33c9bdf..3a6671e 100755 (executable)
@@ -247,9 +247,9 @@ typedef struct
        unsigned long                   received;
        unsigned long                   created;
        unsigned long                   expires;
-       char                                    id[MAX_WAPPUSH_ID_LEN];
-       char                                    href[MAX_WAPPUSH_HREF_LEN];
-       char                                    contents[MAX_WAPPUSH_CONTENTS_LEN];
+       char                                    id[MAX_WAPPUSH_ID_LEN + 1];
+       char                                    href[MAX_WAPPUSH_HREF_LEN + 1];
+       char                                    contents[MAX_WAPPUSH_CONTENTS_LEN + 1];
 } MSG_PUSH_MESSAGE_S;
 
 
@@ -260,8 +260,8 @@ typedef struct
 {
        int             invalObjectCnt;
        int             invalServiceCnt;
-       char            invalObjectUrl[MAX_PUSH_CACHEOP_INVALID_OBJECT_MAX][MAX_PUSH_CACHEOP_MAX_URL_LEN];
-       char            invalServiceUrl[MAX_PUSH_CACHEOP_INVALID_SERVICE_MAX][MAX_PUSH_CACHEOP_MAX_URL_LEN];
+       char            invalObjectUrl[MAX_PUSH_CACHEOP_INVALID_OBJECT_MAX][MAX_PUSH_CACHEOP_MAX_URL_LEN + 1];
+       char            invalServiceUrl[MAX_PUSH_CACHEOP_INVALID_SERVICE_MAX][MAX_PUSH_CACHEOP_MAX_URL_LEN + 1];
 } MSG_PUSH_CACHEOP_S;
 
 
@@ -283,9 +283,9 @@ typedef struct
 {
        msg_syncml_message_type_t       syncmlType;
        int                                                     pushBodyLen;
-       char                                                    pushBody[MAX_WAPPUSH_CONTENTS_LEN];
+       char                                                    pushBody[MAX_WAPPUSH_CONTENTS_LEN + 1];
        int                                                             wspHeaderLen;
-       char                                                    wspHeader[MAX_WAPPUSH_CONTENTS_LEN];
+       char                                                    wspHeader[MAX_WAPPUSH_CONTENTS_LEN + 1];
 }MSG_SYNCML_MESSAGE_DATA_S;
 
 
@@ -294,18 +294,18 @@ typedef struct
  */
  typedef struct
 {
-       char                                                    pushHeader[MAX_WAPPUSH_CONTENTS_LEN];
+       char                                                    pushHeader[MAX_WAPPUSH_CONTENTS_LEN + 1];
        int                                                     pushBodyLen;
-       char                                                    pushBody[MAX_WAPPUSH_CONTENTS_LEN];
+       char                                                    pushBody[MAX_WAPPUSH_CONTENTS_LEN + 1];
 }MSG_LBS_MESSAGE_DATA_S;
 
 
 typedef struct
 {
-       char                                                    pushHeader[MAX_WAPPUSH_CONTENTS_LEN];
+       char                                                    pushHeader[MAX_WAPPUSH_CONTENTS_LEN + 1];
        int                                                     pushBodyLen;
-       char                                                    pushBody[MAX_WAPPUSH_CONTENTS_LEN];
-       char                                                    pushAppId[MAX_WAPPUSH_ID_LEN];
+       char                                                    pushBody[MAX_WAPPUSH_CONTENTS_LEN + 1];
+       char                                                    pushAppId[MAX_WAPPUSH_ID_LEN + 1];
 }MSG_PUSH_MESSAGE_DATA_S;
 
 /**
@@ -313,7 +313,7 @@ typedef struct
  */
 typedef struct
 {
-       char addressVal[MAX_ADDRESS_VAL_LEN+1];
+       char addressVal[MAX_ADDRESS_VAL_LEN + 1];
        int type;
        int status;
        time_t statusTime;
@@ -322,9 +322,9 @@ typedef struct
 
 typedef struct
 {
-       char contentType[MAX_WAPPUSH_CONTENT_TYPE_LEN];
-       char appId[MAX_WAPPUSH_ID_LEN];
-       char pkgName[MSG_FILEPATH_LEN_MAX];
+       char contentType[MAX_WAPPUSH_CONTENT_TYPE_LEN + 1];
+       char appId[MAX_WAPPUSH_ID_LEN + 1];
+       char pkgName[MSG_FILEPATH_LEN_MAX + 1];
        bool bLaunch;
 }MSG_PUSH_EVENT_INFO_S;
 
index 0f0100b..131a6a5 100755 (executable)
@@ -29,7 +29,7 @@
 ==================================================================================================*/
 msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_request_id_t reqID);
 msg_error_t MsgHandleIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti);
-msg_error_t MsgHandleSMS(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);
 
 /*==================================================================================================
index 551efb9..fa32baa 100755 (executable)
@@ -79,14 +79,14 @@ private:
        MSG_MAIN_TYPE_T                         mSupportedMsg;
        MSG_PLUGIN_HANDLER_S    mPlgHandler;
 
-        void*                                  mLibHandler;    // plugin library pointer
+       void    *mLibHandler;    // plugin library pointer
 };
 
 
 /*==================================================================================================
                                      GLOBAL VARIABLES
 ==================================================================================================*/
-typedef std::map<MSG_MAIN_TYPE_T, MsgPlugin> MsgPluginMap;
+typedef std::map<MSG_MAIN_TYPE_T, MsgPlugin*> MsgPluginMap;
 
 
 /*==================================================================================================
index 7b6823d..3b32ad9 100755 (executable)
@@ -41,6 +41,7 @@ msg_error_t MsgSetMMSStyleOpt(const MSG_SETTING_S *pSetting);
 msg_error_t MsgSetPushMsgOpt(const MSG_SETTING_S *pSetting);
 msg_error_t MsgSetCBMsgOpt(const MSG_SETTING_S *pSetting, bool bSetSim);
 msg_error_t MsgSetVoiceMailOpt(const MSG_SETTING_S *pSetting);
+msg_error_t MsgSetVoiceMailOpt(const MSG_SETTING_S *pSetting, bool bSetSim);
 msg_error_t MsgSetMsgSizeOpt(const MSG_SETTING_S *pSetting);
 
 void MsgGetGeneralOpt(MSG_SETTING_S *pSetting);
index 17dfaf9..c328aeb 100755 (executable)
@@ -50,8 +50,8 @@ msg_error_t MsgAddDefaultFolders();
 msg_error_t MsgAddDefaultAddress();
 msg_error_t MsgStoResetDatabase();
 
-msg_error_t MsgStoBackupMessage();
-msg_error_t MsgStoRestoreMessage();
+msg_error_t MsgStoBackupMessage(msg_message_backup_type_t type, const char *filepath);
+msg_error_t MsgStoRestoreMessage(const char *filepath);
 
 msg_error_t MsgStoAddMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S* pSendOptInfo);
 msg_error_t MsgStoUpdateMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S* pSendOptInfo);
@@ -82,6 +82,7 @@ msg_error_t MsgStoGetRejectMsgList(const char *pNumber, msg_struct_list_s *pReje
 msg_error_t MsgStoGetReportStatus(msg_message_id_t msgId, int *count, MSG_REPORT_STATUS_INFO_S **pReportStatus);
 msg_error_t MsgStoGetThreadIdByAddress(const MSG_MESSAGE_INFO_S *pMsg, msg_thread_id_t *pThreadId);
 msg_error_t MsgStoGetThreadUnreadCnt(msg_thread_id_t ThreadId, int *cnt);
+
 msg_error_t MsgStoGetAddressList(const msg_thread_id_t threadId, msg_struct_list_s *pAddrList);
 msg_error_t MsgStoGetThreadInfo(msg_thread_id_t threadId, MSG_THREAD_VIEW_S *pThreadInfo);
 msg_error_t MsgStoGetMessageList(msg_folder_id_t folderId, msg_thread_id_t threadId, msg_message_type_t msgType, msg_storage_id_t storageId, msg_struct_list_s *pMsgList);
index 9731f59..c710535 100755 (executable)
@@ -235,6 +235,7 @@ int msg_set_msgsize_opt(msg_handle_t handle, msg_struct_t msg_struct);
 
 // text length calculate
 int msg_calculate_text_length(msg_handle_t handle, const char* msg_text, msg_encode_type_t msg_encode_type, unsigned int *text_size, unsigned int *segment_size);
+int msg_util_calculate_text_length(const char* msg_text, msg_encode_type_t msg_encode_type_to, unsigned int *text_size, unsigned int *segment_size, msg_encode_type_t *msg_encode_type_in);
 
 #ifdef __cplusplus
 }
index e6351c1..43aabed 100755 (executable)
@@ -914,6 +914,7 @@ handle is Message handle.
 int msg_get_message(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_t msg, msg_struct_t send_opt);
 
 int msg_get_conversation(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_t conv);
+int msg_get_vobject_data(msg_handle_t handle, msg_message_id_t msg_id, void** encoded_data);
 
 /**
 
@@ -1676,6 +1677,8 @@ int msg_get_mem_size(msg_handle_t handle, unsigned int* memsize);
  * None
  *
  * \param input - msg_handle_t  handle is Message handle.
+ * \param input - msg_message_backup_type_t  type is backup_type.
+ * \param input - backup_filepath is path to backup message.
  *
  * \return Return Type int (msg_error_t) \n
  * - MSG_SUCCESS                                       Success in operation.
@@ -1697,14 +1700,16 @@ int msg_get_mem_size(msg_handle_t handle, unsigned int* memsize);
  *
  * msg_handle_t msgHandle = NULL;
  * msg_error_t err;
+ * msg_message_backup_type_t type = MSG_BACKUP_TYPE_MMS;
+ * const char *filepath = "/backup_mms"
  *
  * ...
- * err = msg_backup_message(&msgHandle);
+ * err = msg_backup_message(&msgHandle, type, filepath);
  * ...
  * \endcode
  */
 /*================================================================================================*/
-int msg_backup_message(msg_handle_t handle);
+int msg_backup_message(msg_handle_t handle, msg_message_backup_type_t type, const char *backup_filepath);
 
 
 /**
@@ -1728,6 +1733,8 @@ int msg_backup_message(msg_handle_t handle);
  * None
  *
  * \param input - msg_handle_t  handle is Message handle.
+ * \param input - backup_filepath is path of backup file for restore.
+ *
  *
  * \return Return Type int (msg_error_t) \n
  * - MSG_SUCCESS                                       Success in operation.
@@ -1749,13 +1756,14 @@ int msg_backup_message(msg_handle_t handle);
  *
  * msg_handle_t msgHandle = NULL;
  * msg_error_t err;
+ * const char *filepath = "/backup_mms"
   * ...
- * err = msg_restore_message(&msgHandle);
+ * err = msg_restore_message(&msgHandle, filepath);
  * ...
  * \endcode
  */
 /*================================================================================================*/
-int msg_restore_message(msg_handle_t handle);
+int msg_restore_message(msg_handle_t handle, const char *backup_filepath);
 
 
 /**
@@ -2083,10 +2091,13 @@ int msg_get_report_status(msg_handle_t handle, msg_message_id_t msg_id, msg_stru
 
 int msg_get_address_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_list_s *msg_address_list);
 
+
 int msg_get_thread_id_by_address(msg_handle_t handle, msg_struct_list_s *msg_address_list, msg_thread_id_t *thread_id);
 
+
 int msg_get_thread(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_t msg_thread);
 
+
 int msg_get_message_list(msg_handle_t handle, msg_folder_id_t folder_id, msg_thread_id_t thread_id, msg_message_type_t msg_type, msg_storage_id_t storage_id, msg_struct_list_s *msg_list);
 
 
index 86d6e4b..ce44eaa 100755 (executable)
@@ -69,7 +69,7 @@
 /**
  *     @brief  Defines the maximum file name length
  */
-#define        MSG_FILENAME_LEN_MAX            255
+#define        MSG_FILENAME_LEN_MAX    255
 
 /**
  *     @brief  Defines the maximum message id length
@@ -300,6 +300,11 @@ typedef int msg_read_report_status_t;
 */
 typedef unsigned short msg_message_type_t;
 
+/**
+ *     @brief  Represents a Message Backup Type.
+ *     The values for this type SHOULD be in _MSG_MESSAGE_BACKUP_TYPE_E
+*/
+typedef unsigned int msg_message_backup_type_t;
 
 /**
  *     @brief  Represents a thread ID. \n
@@ -354,6 +359,7 @@ enum _MSG_STRUCT_E {
        MSG_STRUCT_SETTING_GENERAL_OPT = 0x2900,                                /**< Indicates the MSG_STRUCT_SETTING_GENERAL_OPT */
        MSG_STRUCT_SETTING_MSGSIZE_OPT = 0x2c00,                                        /**< Indicates the MSG_STRUCT_SETTING_MSGSIZE_OPT */
 
+
        MSG_STRUCT_SYNCML_INFO = 0x3100,                                        /**< Indicates the MSG_STRUCT_SYNCML_INFO */
        MSG_STRUCT_COUNT_INFO = 0x3200,                                 /**< Indicates the MSG_STRUCT_COUNT_INFO */
        MSG_STRUCT_THREAD_COUNT_INFO = 0x3300,          /**< Indicates the MSG_STRUCT_THREAD_COUNT_INFO */
@@ -792,6 +798,16 @@ enum _MSG_MESSAGE_TYPE_E
        MSG_TYPE_SMS_ETWS_SECONDARY,    /** < CB - ETWS Secondary Notification */
 };
 
+/**
+ *     @brief  Represents 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
+{
+       MSG_BACKUP_TYPE_ALL = 0,
+       MSG_BACKUP_TYPE_SMS,
+       MSG_BACKUP_TYPE_MMS,
+};
 
 /**
  *     @brief  Represents the values of an error code. \n
@@ -962,6 +978,8 @@ enum _MSG_ENCODE_TYPE_E
        MSG_ENCODE_8BIT,                /**< The string encoding type is 8 BIT */
        MSG_ENCODE_UCS2,                /**< The string encoding type is UCS2 */
        MSG_ENCODE_AUTO,                /**< The string encoding type is AUTO */
+
+       MSG_ENCODE_GSM7BIT_ABNORMAL, /**< The string encoding type is GSM7BIT, but abnormal character included */
 };
 
 
@@ -1117,6 +1135,7 @@ typedef enum      _MimeType
        MIME_APPLICATION_VND_SMAF                                                       = 0x111a,  /**< Indicates the application smaf type */
        MIME_APPLICATION_VND_RN_REALMEDIA                                       = 0x111b,  /**< Indicates the application rn real media type */
        MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE              = 0x111c,  /**< Indicates the application j2me java archive type */
+       MIME_APPLICATION_VND_SAMSUNG_THEME                              = 0x111d,  /**< Indicates the application samsung theme type */
        MIME_APPLICATION_VND_EXCEL                                                      = 0x111e,  /**< Indicates the application excel type */
        MIME_APPLICATION_VND_POWERPOINT                                 = 0x111f,  /**< Indicates the application power point type */
        MIME_APPLICATION_VND_MSWORD                                             = 0x1120,        /**< Indicates the application ms word type */
index fb45a21..a13eff2 100755 (executable)
@@ -24,7 +24,8 @@
                                        DEFINES
 ==================================================================================================*/
 
-#define MSG_SOUND_START        "SOUND_START"
+#define MSG_NORMAL_SOUND_START "NORMAL_SOUND_START"
+#define MSG_EMERGENCY_SOUND_START      "EMERGENCY_SOUND_START"
 #define MSG_SOUND_STOP         "SOUND_STOP"
 
 #define MAX_SOUND_FILE_LEN 1024
@@ -43,14 +44,15 @@ typedef void (*msg_sensor_cb)();
 
 // SoundPlayer
 msg_error_t MsgSoundPlayUninit();
-void MsgSoundPlayStart();
+void MsgSoundPlayStart(bool isEmergency);
 void MsgSoundPlayStop();
 int MsgSoundPlayMelody(char *pMsgToneFilePath, bool bIncreasing);
 void MsgSoundPlayVibration();
+void MsgSoundPlayDtmf();
 
 //Sensor FW wrapper.
 msg_error_t MsgSensorConnect();
 void MsgSensorDisconnect();
 msg_error_t MsgRegSensorCB(msg_sensor_cb cb);
 
-#endif // MSG_HELPER_H
\ No newline at end of file
+#endif // MSG_HELPER_H
index 9e6a608..dc4a07c 100755 (executable)
@@ -43,8 +43,8 @@ class MsgHandle
                virtual ~MsgHandle();
 
                // Control
-               void openHandle();
-               void closeHandle(MsgHandle* pHandle);
+               void openHandle();
+               void closeHandle(MsgHandle* pHandle);
 
                // Transport
                msg_error_t submitReq(MSG_REQUEST_S* pReq);
@@ -122,9 +122,9 @@ class MsgHandle
                msg_error_t setMsgSizeOpt(msg_struct_t msg_struct);
 
                //Backup & Restore
-               msg_error_t backupMessage();
-               msg_error_t restoreMessage();
-
+               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
                msg_error_t searchMessage(const char *pSearchString, msg_struct_list_s *pThreadViewList);
                msg_error_t searchMessage(const MSG_SEARCH_CONDITION_S *pSearchCon, int offset, int limit, msg_struct_list_s *pMsgList);
@@ -146,19 +146,20 @@ class MsgHandle
        private:
                void connectSocket();
                void    disconnectSocket();
-               void write(const char *pCmd, int CmdSize, char **ppEvent);
+               void write(const char *pCmd, int CmdSize, char **ppEvent);
                void read(char **ppEvent);
-               void generateConnectionId(char *ConnectionId);
+               void generateConnectionId(char *ConnectionId);
                void convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSource, MSG_MESSAGE_INFO_S *pDest);
                void convertSendOptStruct(const MSG_SENDINGOPT_S* pSrc, MSG_SENDINGOPT_INFO_S* pDest, MSG_MESSAGE_TYPE_S msgType);
                int getSettingCmdSize(MSG_OPTION_TYPE_T optionType);
+               bool CheckEventData(char *pEventData);
 
-               char            mConnectionId[20];
-               short   mCounter;
+               char mConnectionId[20];
+               short mCounter;
 
-               char                            mCookie[MAX_COOKIE_LEN];
+               char mCookie[MAX_COOKIE_LEN];
 
-               MsgIpcClientSocket      mClientSock;
+               MsgIpcClientSocket mClientSock;
 };
 
 #endif // MSG_HANDLE_H
index c4735be..d45f970 100755 (executable)
@@ -140,6 +140,9 @@ public:
 
        int getRemoteFd();
        int readFromSocket(char** buf, unsigned int* len);
+#ifdef CHECK_SENT_STATUS_CALLBACK
+       int getSentStatusCbCnt();
+#endif
 
 private:
        MsgProxyListener();
index 49c7a0b..5896c6a 100755 (executable)
@@ -44,8 +44,8 @@ bool MsgDeleteContact(int index);
 
 int MsgGetContactNameOrder();
 
-msg_error_t MsgAddPhoneLog(const MSG_MESSAGE_INFO_S *pMsgInfo);
-msg_error_t MsgDeletePhoneLog(msg_message_id_t msgId);
+void MsgAddPhoneLog(const MSG_MESSAGE_INFO_S *pMsgInfo);
+void MsgDeletePhoneLog(msg_message_id_t msgId);
 
 int MsgContactSVCBeginTrans();
 int MsgContactSVCEndTrans(bool bSuccess);
index f6a6dfa..a7f44ec 100755 (executable)
@@ -106,16 +106,34 @@ int get_tid();
        } while (0)
 
 
-#define MSG_SMS_VLD(fmt, ...)\
+#define MSG_SMS_VLD_INFO(fmt, ...)\
        do\
        {\
-               SLOG(LOG_DEBUG, MSG_SMS_VALID_TAG, "%s, "fmt"\n", __TIMESTAMP__, ##__VA_ARGS__);\
+               SLOG(LOG_DEBUG, MSG_SMS_VALID_TAG, "[SMS INFO]%s, "fmt"\n", __TIMESTAMP__, ##__VA_ARGS__);\
        } while (0)
 
-#define MSG_MMS_VLD(fmt, ...)\
+#define MSG_SMS_VLD_TXT(fmt, ...)\
        do\
        {\
-               SLOG(LOG_DEBUG, MSG_MMS_VALID_TAG, "%s, "fmt"\n", __TIMESTAMP__, ##__VA_ARGS__);\
+               SLOG(LOG_DEBUG, MSG_SMS_VALID_TAG, "[SMS_TEXT]%s, "fmt"\n", __TIMESTAMP__, ##__VA_ARGS__);\
+       } while (0)
+
+#define MSG_MMS_VLD_INFO(fmt, ...)\
+       do\
+       {\
+               SLOG(LOG_DEBUG, MSG_MMS_VALID_TAG, "[MMS INFO]%s, "fmt"\n", __TIMESTAMP__, ##__VA_ARGS__);\
+       } while (0)
+
+#define MSG_MMS_VLD_TXT(fmt, ...)\
+       do\
+       {\
+               SLOG(LOG_DEBUG, MSG_MMS_VALID_TAG, "[MMS TEXT]%s, "fmt"\n", __TIMESTAMP__, ##__VA_ARGS__);\
+       } while (0)
+
+#define MSG_MMS_VLD_FILE(fmt, ...)\
+       do\
+       {\
+               SLOG(LOG_DEBUG, MSG_MMS_VALID_TAG, "[MMS FILE]%s, "fmt"\n", __TIMESTAMP__, ##__VA_ARGS__);\
        } while (0)
 
 #elif defined(LOG_ENABLE)
index 82c3212..3180335 100755 (executable)
@@ -54,6 +54,7 @@ char*                         MsgSettingGetString(const char *pKey);
 int                            MsgSettingGetInt(const char *pKey);
 int                            MsgSettingGetBool(const char *pKey, bool *pVal);
 
+void   MsgChangePmState();
 msg_error_t    MsgSettingHandleNewMsg(int SmsCnt, int MmsCnt);
 msg_error_t    MsgSettingSetIndicator(int SmsCnt, int MmsCnt);
 
index 153ee88..59d6321 100755 (executable)
 /*==================================================================================================
                                          DEFINES
 ==================================================================================================*/
+#define MSG_APP_PACKAGE_NAME   "message"
 #define NORMAL_MSG_ICON_PATH   "/usr/apps/org.tizen.message/res/icons/default/small/org.tizen.message.noti.png"
 #define VOICE_MSG_ICON_PATH            "/usr/apps/org.tizen.message/res/icons/default/small/org.tizen.message.voice.png"
 #define CB_MSG_ICON_PATH                       "/usr/apps/org.tizen.message/res/icons/default/small/org.tizen.message.noti.png"
 #define NOTI_MSG_ICON_PATH             "/usr/apps/org.tizen.message/res/icons/default/small/org.tizen.message.noti.png"
 
-#define MSG_APP_PACKAGE_NAME   "message"
 #define MSG_APP_LOCALEDIR                      "/usr/apps/org.tizen.message/res/locale"
-
 #define SENDING_MULTIMEDIA_MESSAGE_FAILED      "Sending multimedia message failed"
 #define MULTIMEDIA_MESSAGE_SENT                                        "Multimedia message sent"
 #define RETRIEVING_MESSAGE_FAILED                                      "Retrieving message failed"
 #define MESSAGE_RETRIEVED                                                              "Message retrieved"
+#define SMS_MESSAGE_SENT                                       "Message sent"
+#define SMS_MESSAGE_SENDING_FAIL                       "Sending message failed"
 
+#define NOTIFICATION_PRIV_ID DEFAULT_SETTING_PATH"/notification_priv_id"
 
 /*==================================================================================================
                                      FUNCTION PROTOTYPES
@@ -53,10 +55,10 @@ msg_error_t MsgInsertSmsReportToNoti(MsgDbHandler *pDbHandle, msg_message_id_t M
 
 msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg);
 
-msg_error_t MsgDeleteNotiByMsgId(msg_message_id_t msgId);
-
-msg_error_t MsgDeleteNotiByThreadId(msg_thread_id_t ThreadId);
+msg_error_t MsgRefreshNoti();
+msg_error_t MsgCleanAndResetNoti();
 
 msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg);
+msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt);
 
 #endif // MSG_QUICKPANEL_WRAPPER_H
index ce690e8..492bf52 100755 (executable)
                                     DEFINES
 ==================================================================================================*/
 
+
 /*==================================================================================================
                                     INCLUDE FILES
 ==================================================================================================*/
 
 
+
 /*==================================================================================================
                                      FUNCTION PROTOTYPES
 ==================================================================================================*/
-void MsgSoundPlayStart();
+void MsgSoundPlayStart(bool isEmergency);
 void MsgSoundPlayStop();
 
 bool MsgSoundSetRepeatAlarm();
@@ -40,3 +42,4 @@ int MsgSoundGetUnreadMsgCnt();
 void MsgSoundInitRepeatAlarm();
 
 #endif // MSG_SOUND_PLAYER_H
+
index d15bc4c..7f6fd4d 100755 (executable)
@@ -257,7 +257,7 @@ public:
        MsgTextConvert();
        ~MsgTextConvert();
 
-       int convertUTF8ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_LANGUAGE_ID_T *pLangId);
+       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);
        int convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT msg_encode_type_t *pCharType);
 
@@ -266,7 +266,7 @@ public:
        int convertEUCKRToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN  int srcTextLen);
 
 private:
-       int convertUCS2ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_LANGUAGE_ID_T *pLangId);
+       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);
        int convertUCS2ToGSM7bitAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown);
 
        int convertGSM7bitToUCS2(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, IN MSG_LANG_INFO_S *pLangInfo);
index b072cc1..7081c08 100755 (executable)
@@ -23,9 +23,6 @@
 ==================================================================================================*/
 #define FM_READ_WRITE_BUFFER_MAX (1024*1024*3)
 
-#define TPDU_LOG_FILE "/opt/etc/msg-service/tpduLog.txt"
-
-
 /*==================================================================================================
                                        FUNCTION PROTOTYPES
 ==================================================================================================*/
index 51bc9d0..efb1c5f 100755 (executable)
@@ -96,7 +96,7 @@ void MsgDecodeFilterFlag(char *pSrc, bool *pSetFlag);
 
 void MsgDecodeMsgType(char *pSrc, MSG_MESSAGE_TYPE_S* pMsgType);
 
-void   MsgDecodeContactCount(char *pSrc,  MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList);
+void MsgDecodeContactCount(char *pSrc,  MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList);
 
 void MsgDecodeMemSize(char *pSrc, unsigned int *memsize);
 
diff --git a/include/utils/MsgVMessage.h b/include/utils/MsgVMessage.h
new file mode 100755 (executable)
index 0000000..9e46d6a
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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_VMESSAGE_H
+#define MSG_VMESSAGE_H
+
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgStorageTypes.h"
+#include "MsgInternalTypes.h"
+#include "MsgUtilStorage.h"
+
+/*==================================================================================================
+                                     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);
+bool _convert_vdata_str_to_tm(const char* szText, struct tm * tm);
+
+#endif //MSG_VMESSAGE_H
+
index cf24235..f9e7d71 100755 (executable)
 ==================================================================================================*/
 EXPORT_API int msg_open_msg_handle(msg_handle_t *handle)
 {
-       MsgHandle* pHandle = new MsgHandle();
-
        if (handle == NULL)
        {
                MSG_FATAL("Input Paramter is NULL");
                return -EINVAL;
        }
+       MsgHandle* pHandle = new MsgHandle();
 
        // Create MsgHandle
        *handle = (msg_handle_t)pHandle;
index 62a41a8..66512f5 100755 (executable)
@@ -338,8 +338,11 @@ int msg_set_filter_info_str(void *filter, int field, char *value, int size)
        switch (field)
        {
        case MSG_FILTER_VALUE_STR :
-               strncpy(filter_data->filterValue, value, size);
+       {
+               int len = (size > MAX_FILTER_VALUE_LEN)?MAX_FILTER_VALUE_LEN:size;
+               strncpy(filter_data->filterValue, value, len);
                break;
+       }
        default :
                return MSG_ERR_INVALID_PARAMETER;
        }
index b813f2e..bc29e2d 100755 (executable)
@@ -264,12 +264,18 @@ int msg_message_get_str_value(void *data, int field, char *value, int size)
        case MSG_MESSAGE_MMS_TEXT_STR :
                if (msg_data->pData)
                {
-                       int data_len = 0;
-                       ((size_t)size >= msg_data->dataSize)? (data_len = msg_data->dataSize) : data_len = size;
-                       memset(value, 0, size);
-                       memcpy(value, msg_data->pData, data_len);
+                       if (msg_data->mainType == MSG_SMS_TYPE) {
+                               int data_len = 0;
+                               ((size_t)size >= msg_data->dataSize)? (data_len = msg_data->dataSize) : data_len = size;
+                               memset(value, 0, size);
+                               memcpy(value, msg_data->pData, data_len);
+                       } else if (msg_data->mainType == MSG_MMS_TYPE) {
+                               memset(value, 0, size);
+                               strncpy(value, (char *)msg_data->pData, size);
+                       }
                }
                break;
+
        default :
                ret = MSG_ERR_INVALID_PARAMETER;
                break;
@@ -337,22 +343,27 @@ int msg_message_set_int_value(void *data, int field, int value)
                break;
        case MSG_MESSAGE_TYPE_INT :
        {
-        if (value == MSG_TYPE_SMS) {
-               msg_data->mainType = MSG_SMS_TYPE;
-               msg_data->subType = MSG_NORMAL_SMS;
-        } 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) {
-               msg_data->mainType = MSG_MMS_TYPE;
+               if (value == MSG_TYPE_SMS) {
+                       msg_data->mainType = MSG_SMS_TYPE;
+                       msg_data->subType = MSG_NORMAL_SMS;
+               }
+               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) {
+                       msg_data->mainType = MSG_MMS_TYPE;
                        msg_data->subType = MSG_SENDREQ_JAVA_MMS;
-        } 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) {
-               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_SYNCML) {
+                       msg_data->mainType = MSG_SMS_TYPE;
+                       msg_data->subType = MSG_SYNCML_CP;
+               }
+               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) {
                        msg_data->mainType = MSG_SMS_TYPE;
                        msg_data->subType = MSG_ETWS_SMS;
                }
@@ -529,6 +540,12 @@ void msg_message_copy_message(MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_HIDDEN_S *
                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));
        }
+
+       if (strlen(pSrc->thumbPath) > 0) {
+               memset(pDst->thumbPath, 0x00, sizeof(pDst->thumbPath));
+               memcpy(pDst->thumbPath, pSrc->thumbPath, sizeof(pDst->thumbPath));
+       }
+
 }
 
 int msg_cb_message_get_int_value(void *data, int field, int *value)
@@ -571,6 +588,7 @@ int msg_cb_message_get_int_value(void *data, int field, int *value)
                        break;
                case MSG_CB_MSG_ETWS_WARNING_TYPE_INT :
                        *value = cb_msg->etwsWarningType;
+                       break;
                default :
                        ret = MSG_ERR_INVALID_PARAMETER;
                        break;
index 7231f24..053e298 100755 (executable)
@@ -22,7 +22,7 @@
 #include "MsgTypes.h"
 #include "MsgMmsTypes.h"
 #include "MsgMmsMessage.h"
-#include "MsgDebug.h"\r
+#include "MsgDebug.h"
 
 #include "msg.h"
 #include "msg_private.h"
@@ -43,14 +43,14 @@ typedef struct
 {
        MmsSmilMediaType        mediatype; /**< Indicates the SMIL media type. see enum MmsSmilMediaType */
 
-       char                    szSrc[MSG_FILEPATH_LEN_MAX];/**< Indicates the media source name */
-       char                    szFileName[MSG_FILENAME_LEN_MAX]; /**< Indicates the file name */
-       char                    szFilePath[MSG_FILEPATH_LEN_MAX]; /**< Indicates the file path */
-       char                    szContentID[MSG_MSG_ID_LEN+1]; /**< Indicates the content id */
-       char                    regionId[MAX_SMIL_REGION_ID]; /**< Indicates the region id */
-       char                    szAlt[MAX_SMIL_ALT_LEN]; /**< Indicates the alternative text to be displayed in failure case */
+       char                    szSrc[MSG_FILEPATH_LEN_MAX + 1];/**< Indicates the media source name */
+       char                    szFileName[MSG_FILENAME_LEN_MAX + 1]; /**< Indicates the file name */
+       char                    szFilePath[MSG_FILEPATH_LEN_MAX + 1]; /**< Indicates the file path */
+       char                    szContentID[MSG_MSG_ID_LEN + 1]; /**< Indicates the content id */
+       char                    regionId[MAX_SMIL_REGION_ID + 1]; /**< Indicates the region id */
+       char                    szAlt[MAX_SMIL_ALT_LEN + 1]; /**< Indicates the alternative text to be displayed in failure case */
        MsgDrmType              drmType; /**< Indicates the drm type. see enum MsgDrmType */
-       char                    szDrm2FullPath[MSG_FILEPATH_LEN_MAX];  /**< Indicates the fullpath of the DRM */
+       char                    szDrm2FullPath[MSG_FILEPATH_LEN_MAX + 1];  /**< Indicates the fullpath of the DRM */
        msg_struct_s *pText;
        msg_struct_s *pAVI;
 } MMS_MEDIA_HIDDEN_S;
@@ -824,21 +824,21 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int
                        strncpy(mms_media_data->szFileName, value, MSG_FILEPATH_LEN_MAX);
                } else if (field == MSG_MMS_MEDIA_FILEPATH_STR) {
                        char *filename = NULL;
-                       if (value != NULL) {\r
-                               MSG_DEBUG("media file path = %s", value);\r
-                               strncpy(mms_media_data->szFilePath, value, MSG_FILEPATH_LEN_MAX);\r
-                               filename = strrchr(value, '/');\r
-                               if (filename != NULL) {\r
-                                       strncpy(mms_media_data->szFileName, filename + 1, MSG_FILENAME_LEN_MAX-1);\r
-                                       strncpy(mms_media_data->szContentID, filename + 1, MSG_MSG_ID_LEN);\r
-                               } else {\r
-                                       strncpy(mms_media_data->szFileName, value + 1, MSG_FILENAME_LEN_MAX-1);\r
-                                       strncpy(mms_media_data->szContentID, value + 1, MSG_MSG_ID_LEN);\r
-                               }\r
-                       } else {\r
-                               MSG_DEBUG("media file path is NULL");\r
-                               err = MSG_ERR_INVALID_PARAMETER;\r
-                       }\r
+                       if (value != NULL) {
+                               MSG_DEBUG("media file path = %s", value);
+                               strncpy(mms_media_data->szFilePath, value, MSG_FILEPATH_LEN_MAX);
+                               filename = strrchr(value, '/');
+                               if (filename != NULL) {
+                                       strncpy(mms_media_data->szFileName, filename + 1, MSG_FILENAME_LEN_MAX);
+                                       strncpy(mms_media_data->szContentID, filename + 1, MSG_MSG_ID_LEN);
+                               } else {
+                                       strncpy(mms_media_data->szFileName, value + 1, MSG_FILENAME_LEN_MAX);
+                                       strncpy(mms_media_data->szContentID, value + 1, MSG_MSG_ID_LEN);
+                               }
+                       } else {
+                               MSG_DEBUG("media file path is NULL");
+                               err = MSG_ERR_INVALID_PARAMETER;
+                       }
                } else if (field == MSG_MMS_MEDIA_CONTENT_ID_STR)
                        strncpy(mms_media_data->szContentID, value, MSG_MSG_ID_LEN);
                else if (field == MSG_MMS_MEDIA_REGION_ID_STR)
@@ -860,24 +860,24 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int
                        char *filename = NULL;
                        char *filepath = value;
 
-                       if (filepath != NULL) {\r
-                               MSG_DEBUG("attach file path = %s", filepath);\r
-                               mms_attach_data->mediatype = MIME_UNKNOWN;\r
-                               mms_attach_data->fileSize = -1;\r
-
-                               strncpy(mms_attach_data->szFilePath, filepath, MSG_FILEPATH_LEN_MAX-1);\r
-\r
-                               filename = strrchr(filepath, '/');\r
-                               if (filename != NULL) {\r
-                                       strncpy(mms_attach_data->szFileName, filename + 1, MSG_FILENAME_LEN_MAX-1);\r
-                               } else {\r
-                                       strncpy(mms_attach_data->szFileName, filepath, MSG_FILENAME_LEN_MAX-1);\r
-                               }\r
-\r
-                       } else {\r
-                               MSG_DEBUG("attach file path is NULL");\r
-                               err = MSG_ERR_INVALID_PARAMETER;\r
-                       }\r
+                       if (filepath != NULL) {
+                               MSG_DEBUG("attach file path = %s", filepath);
+                               mms_attach_data->mediatype = MIME_UNKNOWN;
+                               mms_attach_data->fileSize = -1;
+
+                               strncpy(mms_attach_data->szFilePath, filepath, MSG_FILEPATH_LEN_MAX);
+
+                               filename = strrchr(filepath, '/');
+                               if (filename != NULL) {
+                                       strncpy(mms_attach_data->szFileName, filename + 1, MSG_FILENAME_LEN_MAX);
+                               } else {
+                                       strncpy(mms_attach_data->szFileName, filepath, MSG_FILENAME_LEN_MAX);
+                               }
+
+                       } else {
+                               MSG_DEBUG("attach file path is NULL");
+                               err = MSG_ERR_INVALID_PARAMETER;
+                       }
                } else if (field == MSG_MMS_ATTACH_DRM_FULLPATH_STR)
                        strncpy(mms_attach_data->szDrm2FullPath, value, MSG_FILEPATH_LEN_MAX);
                else
@@ -908,9 +908,9 @@ int msg_mms_set_str_value(msg_struct_s *msg_struct, int field, char *value, int
                if (field == MSG_MMS_META_ID_STR)
                        strncpy(mms_meta_data->szID, value, MAX_SMIL_META_ID);
                else if (field == MSG_MMS_META_NAME_STR)
-                       strncpy(mms_meta_data->szID, value, MAX_SMIL_META_NAME);
+                       strncpy(mms_meta_data->szName, value, MAX_SMIL_META_NAME);
                else if (field == MSG_MMS_META_CONTENT_STR)
-                       strncpy(mms_meta_data->szID, value, MAX_SMIL_META_CONTENT);
+                       strncpy(mms_meta_data->szContent, value, MAX_SMIL_META_CONTENT);
                else
                        err = MSG_ERR_INVALID_PARAMETER;
        }
@@ -1127,7 +1127,7 @@ void convert_to_media_data(const msg_struct_s *pSrc, MMS_MEDIA_S *pDest)
        memcpy(dst_media->szSrc, src_media->szSrc, MSG_FILEPATH_LEN_MAX);
        memcpy(dst_media->szFileName, src_media->szFileName, MSG_FILEPATH_LEN_MAX);
        memcpy(dst_media->szFilePath, src_media->szFilePath, MSG_FILEPATH_LEN_MAX);
-       memcpy(dst_media->szContentID, src_media->szContentID, MSG_MSG_ID_LEN+1);
+       memcpy(dst_media->szContentID, src_media->szContentID, MSG_MSG_ID_LEN);
        memcpy(dst_media->regionId, src_media->regionId, MAX_SMIL_REGION_ID);
        memcpy(dst_media->szAlt, src_media->szAlt, MAX_SMIL_ALT_LEN);
 
@@ -1154,7 +1154,7 @@ void convert_from_media_data(const MMS_MEDIA_S *pSrc, msg_struct_s *pDest)
        memcpy(dst_media->szSrc, src_media->szSrc, MSG_FILEPATH_LEN_MAX);
        memcpy(dst_media->szFileName, src_media->szFileName, MSG_FILEPATH_LEN_MAX);
        memcpy(dst_media->szFilePath, src_media->szFilePath, MSG_FILEPATH_LEN_MAX);
-       memcpy(dst_media->szContentID, src_media->szContentID, MSG_MSG_ID_LEN+1);
+       memcpy(dst_media->szContentID, src_media->szContentID, MSG_MSG_ID_LEN);
        memcpy(dst_media->regionId, src_media->regionId, MAX_SMIL_REGION_ID);
        memcpy(dst_media->szAlt, src_media->szAlt, MAX_SMIL_ALT_LEN);
 
index 6240ef5..e333f3e 100755 (executable)
@@ -362,7 +362,7 @@ int msg_set_smsc_opt_int(void *smsc_opt, int field, int value)
        switch (field)
        {
        case MSG_SMSC_SELECTED_ID_INT :
-               ret = smsc_opt_data->selected;
+               smsc_opt_data->selected = value;
                break;
        default :
                ret = MSG_ERR_INVALID_PARAMETER;
index 987ca79..ec35d38 100755 (executable)
@@ -422,6 +422,30 @@ EXPORT_API int msg_get_message(msg_handle_t handle, msg_message_id_t msg_id, msg
        return err;
 }
 
+EXPORT_API int msg_get_vobject_data(msg_handle_t handle, msg_message_id_t msg_id, void** result_data)
+{
+       msg_error_t err =  MSG_SUCCESS;
+
+       if (handle == NULL || result_data == NULL)
+       {
+               MSG_FATAL("handle or result_data is NULL");
+               return -EINVAL;
+       }
+
+       MsgHandle* pHandle = (MsgHandle*)handle;
+
+       try
+       {
+               err = pHandle->getVobject(msg_id, result_data);
+       }
+       catch (MsgException& e)
+       {
+               MSG_FATAL("%s", e.what());
+               return MSG_ERR_STORAGE_ERROR;
+       }
+
+       return err;
+}
 EXPORT_API int msg_get_conversation(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_t conv)
 {
        msg_error_t err =  MSG_SUCCESS;
@@ -808,19 +832,20 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_
                catch (MsgException& e)
                {
                        MSG_FATAL("%s", e.what());
+                       msg_release_struct((msg_struct_t *)&msg_s);
                        return MSG_ERR_STORAGE_ERROR;
                }
 
                if (msg_type == MSG_TYPE_MMS && msgInfo->pMmsData) //free pMmsData directly. It is added to enhance performance
                        delete [] static_cast<char*>(msgInfo->pMmsData);
 
+               msg_release_struct((msg_struct_t *)&msg_s);
+
                if (err < 0)
                {
                        MSG_DEBUG("err [%d]", err);
                        return err;
                }
-
-               msg_release_struct((msg_struct_t *)&msg_s);
        }
 
        return MSG_SUCCESS;
@@ -904,16 +929,17 @@ EXPORT_API int msg_generate_sms(msg_handle_t handle, msg_folder_id_t folder_id,
                catch (MsgException& e)
                {
                        MSG_FATAL("%s", e.what());
+                       msg_release_struct((msg_struct_t *)&msg_s);
                        return MSG_ERR_STORAGE_ERROR;
                }
 
+               msg_release_struct((msg_struct_t *)&msg_s);
+
                if (err < 0)
                {
                        MSG_DEBUG("err [%d]", err);
                        return err;
                }
-
-               msg_release_struct((msg_struct_t *)&msg_s);
        }
 
        return MSG_SUCCESS;
@@ -997,11 +1023,11 @@ EXPORT_API int msg_get_mem_size(msg_handle_t handle, unsigned int* memsize)
 
 }
 
-EXPORT_API int msg_backup_message(msg_handle_t handle)
+EXPORT_API int msg_backup_message(msg_handle_t handle, msg_message_backup_type_t type, const char *backup_filepath)
 {
        msg_error_t err =  MSG_SUCCESS;
 
-       if (handle == NULL)
+       if (handle == NULL || backup_filepath == NULL)
        {
                return -EINVAL;
        }
@@ -1010,7 +1036,7 @@ EXPORT_API int msg_backup_message(msg_handle_t handle)
 
        try
        {
-               err = pHandle->backupMessage();
+               err = pHandle->backupMessage(type, backup_filepath);
        }
        catch (MsgException& e)
        {
@@ -1022,11 +1048,11 @@ EXPORT_API int msg_backup_message(msg_handle_t handle)
 }
 
 
-EXPORT_API int msg_restore_message(msg_handle_t handle)
+EXPORT_API int msg_restore_message(msg_handle_t handle, const char *backup_filepath)
 {
        msg_error_t err =  MSG_SUCCESS;
 
-       if (handle == NULL)
+       if (handle == NULL || backup_filepath == NULL)
        {
                return -EINVAL;
        }
@@ -1035,7 +1061,7 @@ EXPORT_API int msg_restore_message(msg_handle_t handle)
 
        try
        {
-               err = pHandle->restoreMessage();
+               err = pHandle->restoreMessage(backup_filepath);
        }
        catch (MsgException& e)
        {
@@ -2109,7 +2135,7 @@ int msg_report_status_set_int(void *report_info, int field, int value)
 {
        msg_error_t err =  MSG_SUCCESS;
        if(!report_info)
-               return MSG_ERR_NULL_POINTER;
+       return MSG_ERR_NULL_POINTER;
 
        MSG_REPORT_STATUS_INFO_S *pReport = (MSG_REPORT_STATUS_INFO_S *)report_info;
        switch(field)
index b7461d7..c4e8463 100755 (executable)
@@ -1364,21 +1364,23 @@ EXPORT_API int msg_list_length(msg_list_handle_t list_handle)
        return (int)g_list_length((GList *)list_handle);
 }
 
-
 EXPORT_API int msg_calculate_text_length(msg_handle_t handle, const char* msg_text, msg_encode_type_t msg_encode_type, unsigned int *text_size, unsigned int *segment_size)
 {
        msg_error_t err = MSG_SUCCESS;
 
-       try
-       {
-               if (msg_text == NULL || strlen(msg_text) == 0) {
-                       err = MSG_ERR_INVALID_PARAMETER;
-                       return err;
-               }
-       }
-       catch (exception& e)
-       {
-               MSG_FATAL("%s", e.what());
+       msg_encode_type_t msg_encode_type_in;
+       err = msg_util_calculate_text_length(msg_text, msg_encode_type, text_size, segment_size, &msg_encode_type_in);
+
+       MSG_DEBUG("msg_encode_type_in [%d]", msg_encode_type_in);
+
+       return err;
+}
+
+EXPORT_API int msg_util_calculate_text_length(const char* msg_text, msg_encode_type_t msg_encode_type_to, unsigned int *text_size, unsigned int *segment_size, msg_encode_type_t *msg_encode_type_in)
+{
+       msg_error_t err = MSG_SUCCESS;
+
+       if (msg_text == NULL || text_size == NULL || segment_size == NULL) {
                err = MSG_ERR_INVALID_PARAMETER;
                return err;
        }
@@ -1390,6 +1392,8 @@ EXPORT_API int msg_calculate_text_length(msg_handle_t handle, const char* msg_te
        int bufSize = (160*MAX_SEGMENT_NUM) + 1;
        int textSize = 0;
 
+       bool bAbnormal = false;
+
        textSize = strlen(msg_text);
 
        unsigned char decodeData[bufSize];
@@ -1400,10 +1404,10 @@ EXPORT_API int msg_calculate_text_length(msg_handle_t handle, const char* msg_te
        *text_size = 0;
        *segment_size = 0;
 
-       switch (msg_encode_type)
+       switch (msg_encode_type_to)
        {
        case MSG_ENCODE_GSM7BIT :
-               decodeLen = textCvt.convertUTF8ToGSM7bit(decodeData, bufSize, (const unsigned char*)msg_text, textSize, &langId);
+               decodeLen = textCvt.convertUTF8ToGSM7bit(decodeData, bufSize, (const unsigned char*)msg_text, textSize, &langId, &bAbnormal);
                break;
        case MSG_ENCODE_UCS2 :
                decodeLen = textCvt.convertUTF8ToUCS2(decodeData, bufSize, (const unsigned char*)msg_text, textSize);
@@ -1413,37 +1417,50 @@ EXPORT_API int msg_calculate_text_length(msg_handle_t handle, const char* msg_te
                break;
        default :
                err = MSG_ERR_INVALID_PARAMETER;
+               return err;
                break;
        }
 
        // calculate segment size.
        int headerLen = 1;
        int concat = 5;
-       int lang = 3;
+//     int lang = 3;
 
-       int headerSize = 0;
+//     int headerSize = 0;
        int segSize = 0;
 
-       if (langId != MSG_LANG_ID_RESERVED) {
-               MSG_DEBUG("National Language Exists");
-               headerSize += lang;
-       }
+//     if (langId != MSG_LANG_ID_RESERVED) {
+//             MSG_DEBUG("National Language Exists");
+//             headerSize += lang;
+//     }
 
-       if (msg_encode_type == MSG_ENCODE_GSM7BIT || encodeType == MSG_ENCODE_GSM7BIT) {
+       if (msg_encode_type_to == MSG_ENCODE_GSM7BIT || encodeType == MSG_ENCODE_GSM7BIT) {
                MSG_DEBUG("MSG_ENCODE_GSM7BIT");
 
-               if (((decodeLen+headerSize)/160) > 1)
-                       segSize = ((140*8) - ((headerLen + concat + headerSize)*8)) / 7;
+//             if (((decodeLen+headerSize)/160) > 1)
+//                     segSize = ((140*8) - ((headerLen + concat + headerSize)*8)) / 7;
+               if(decodeLen > 160)
+                       segSize = ((140*8) - ((headerLen + concat)*8)) / 7;
                else
                        segSize = 160;
 
-       } else if (msg_encode_type == MSG_ENCODE_UCS2 || encodeType == MSG_ENCODE_UCS2) {
+               if (bAbnormal)
+                       *msg_encode_type_in = MSG_ENCODE_GSM7BIT_ABNORMAL;
+               else
+                       *msg_encode_type_in = MSG_ENCODE_GSM7BIT;
+
+       } 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+headerSize)/140) > 1)
+//                     segSize = 140 - (headerLen + concat + headerSize);
+               if(decodeLen > 140)
+                       segSize = 140 - (headerLen + concat);
                else
                        segSize = 140;
+
+               *msg_encode_type_in = MSG_ENCODE_UCS2;
+
        } else {
                MSG_DEBUG("Unsupported encode type.");
                err = MSG_ERR_INVALID_PARAMETER;
index 30ece6d..2e28a9f 100755 (executable)
@@ -555,6 +555,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) {
+               msg_release_struct(&req_t);
                return MSG_ERR_MEMORY_ERROR;
        }
 
index f0c794b..5fef746 100755 (executable)
        <assign>
                <filesystem path="/usr/lib/libmsg_mapi.so.0" label="_"/>
                <filesystem path="/usr/lib/libmsg_mapi.so.0.1.0" label="_"/>
-                <filesystem path="/usr/lib/libmsg_framework_handler.so" label="_"/>
-                <filesystem path="/usr/lib/libmsg_mms_language_pack.so" label="_"/>
-                <filesystem path="/usr/lib/libmsg_mms_plugin.so" label="_"/>
-                <filesystem path="/usr/lib/libmsg_plugin_manager.so" label="_"/>
-                <filesystem path="/usr/lib/libmsg_sms_plugin.so" label="_"/>
-                <filesystem path="/usr/lib/libmsg_transaction_manager.so" label="_"/>
-                <filesystem path="/usr/lib/libmsg_transaction_proxy.so" label="_"/>
-                <filesystem path="/usr/lib/libmsg_utils.so" label="_"/>
+               <filesystem path="/usr/lib/libmsg_framework_handler.so" label="_"/>
+               <filesystem path="/usr/lib/libmsg_mms_plugin.so" label="_"/>
+               <filesystem path="/usr/lib/libmsg_plugin_manager.so" label="_"/>
+               <filesystem path="/usr/lib/libmsg_sms_plugin.so" label="_"/>
+               <filesystem path="/usr/lib/libmsg_transaction_manager.so" label="_"/>
+               <filesystem path="/usr/lib/libmsg_transaction_proxy.so" label="_"/>
+               <filesystem path="/usr/lib/libmsg_utils.so" label="_"/>
+               <filesystem path="/usr/lib/libmsg_vobject.so" label="_"/>
        </assign>
 </manifest>
index 049b3a8..ab024a4 100755 (executable)
@@ -29,7 +29,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(msg_helper_pkgs REQUIRED glib-2.0 dlog vconf devman_haptic mm-player mm-fileinfo mm-player sensor)
+pkg_check_modules(msg_helper_pkgs REQUIRED glib-2.0 dlog vconf devman_haptic mm-fileinfo mm-player mm-sound svi sensor)
 
 FOREACH(flag ${msg_helper_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 4e615ca..acea44a 100755 (executable)
@@ -68,7 +68,14 @@ void MsgSensorDisconnect()
        if (sensorHandler < 0)
                return;
 
-       sf_stop(sensorHandler);
+       try
+       {
+               sf_stop(sensorHandler);
+       }
+       catch(int exception)
+       {
+               MSG_FATAL("sf_stop error[%d]", exception);
+       }
        sf_disconnect(sensorHandler);
 }
 
index 88dd1f0..23b95f4 100755 (executable)
 #include "MsgHelper.h"
 
 #include <devman_managed.h>
-//#include <svi.h>
+#include <svi.h>
 
 #include <mm_error.h>
 #include <mm_player.h>
 #include <mm_session_private.h>
-
+#include <mm_sound.h>
 
 extern void worker_done();
 
@@ -142,34 +142,46 @@ void* MsgPlayThread(void *data)
 
        bool bSoundOn = false;
        bool bVibrationOn = false;
-       int callStatus = 0;     /* 0 - off, 1 - sound, 2 - vibration */
+       int callStatus = 0;
+       /* 0 - off, 1 - sound, 2 - vibration */
        int alertOnCall = 0;
 
+       bool isEmergency = false;
+
+       if (data)
+               isEmergency = (bool)data;
+
        char *msg_tone_file_path = NULL;
        AutoPtr<char> buf(&msg_tone_file_path);
 
-       char *tmpFileFath = NULL;
+       msg_tone_file_path = new char[MAX_SOUND_FILE_LEN];
 
-       tmpFileFath = MsgSettingGetString(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
-
-       if (tmpFileFath == NULL || MsgGetFileSize(tmpFileFath) < 1) {
-               msg_tone_file_path = new char[MAX_SOUND_FILE_LEN];
-               strncpy(msg_tone_file_path, DEFAULT_FILE, MAX_SOUND_FILE_LEN-1);
+       if (isEmergency) {
        } else {
-               msg_tone_file_path = new char[MAX_SOUND_FILE_LEN];
-               strncpy(msg_tone_file_path, tmpFileFath, MAX_SOUND_FILE_LEN-1);
-               free(tmpFileFath);
-               tmpFileFath = NULL;
+               char *tmpFileFath = NULL;
+
+               tmpFileFath = MsgSettingGetString(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
+
+               if (tmpFileFath == NULL || MsgGetFileSize(tmpFileFath) < 1) {
+                       strncpy(msg_tone_file_path, DEFAULT_FILE, MAX_SOUND_FILE_LEN-1);
+               } else {
+                       strncpy(msg_tone_file_path, tmpFileFath, MAX_SOUND_FILE_LEN-1);
+                       free(tmpFileFath);
+                       tmpFileFath = NULL;
+               }
        }
 
-       MSG_DEBUG("Sound File [%s]", msg_tone_file_path);
+       MSG_DEBUG("Emergency=[%d], Sound File [%s]", isEmergency, msg_tone_file_path);
 
        MsgSettingGetBool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &bSoundOn);
        MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &bVibrationOn);
 
        int err = MM_ERROR_NONE;
 
-       err = mm_session_init(MM_SESSION_TYPE_NOTIFY);
+       if (isEmergency)
+               err = mm_session_init(MM_SESSION_TYPE_EMERGENCY);
+       else
+               err = mm_session_init(MM_SESSION_TYPE_NOTIFY);
 
        if(err != MM_ERROR_NONE)
                MSG_DEBUG("MM Session Init Failed");
@@ -201,7 +213,7 @@ void* MsgPlayThread(void *data)
                        MSG_DEBUG("Call is active & Alert on Call - Sound");
 
                        if (bSoundOn)
-                               MsgSoundPlayMelody(msg_tone_file_path, false);
+                               MsgSoundPlayDtmf();
                } else if (alertOnCall == 2) {
                        MSG_DEBUG("Call is active & Alert on Call - Vibration");
 
@@ -266,7 +278,7 @@ msg_error_t MsgSoundPlayUninit()
 }
 
 
-void MsgSoundPlayStart()
+void MsgSoundPlayStart(bool isEmergency)
 {
        MSG_BEGIN();
 
@@ -282,7 +294,7 @@ void MsgSoundPlayStart()
 
        pthread_t tid;
 
-       if (pthread_create(&tid, NULL, &MsgPlayThread, (void*)NULL) == 0) {
+       if (pthread_create(&tid, NULL, &MsgPlayThread, (void*)isEmergency) == 0) {
                MSG_DEBUG("Ring alert thread created = %d", tid);
        } else {
                MSG_DEBUG("Creating Thread was failed");
@@ -386,7 +398,7 @@ int MsgSoundPlayMelody(char *pMsgToneFilePath, bool bIncreasing)
 void MsgSoundPlayVibration()
 {
        MSG_BEGIN();
-/*
+
        int ret = 0;
        int vibLevel = 0;
        char ivtFilePath[MAX_SOUND_FILE_LEN] = {0,};
@@ -400,7 +412,7 @@ void MsgSoundPlayVibration()
 
                g_timeout_add(MSG_VIBRATION_INTERVAL , MsgSoundVibTimeout, NULL);
 
-               // set timer to stop vibration, then play melody
+               /* set timer to stop vibration, then play melody */
                svi_get_path(SVI_TYPE_VIB, SVI_VIB_NOTIFICATION_MESSAGE, ivtFilePath, sizeof(ivtFilePath));
                ret = device_haptic_play_file(dev_handle, ivtFilePath, HAPTIC_TEST_ITERATION, vibLevel);
 
@@ -408,7 +420,25 @@ void MsgSoundPlayVibration()
                        MSG_DEBUG("Fail to play haptic : [%d]", ret);
                }
        }
-*/
+
+       MSG_END();
+}
+
+void MsgSoundPlayDtmf()
+{
+       MSG_BEGIN();
+
+       int ret = 0;
+       int hToneHandle = 0;
+
+       ret = mm_sound_play_tone(MM_SOUND_TONE_PROP_BEEP2, VOLUME_TYPE_SYSTEM, 1.0, 300, &hToneHandle);
+
+       if(ret < 0) {
+               MSG_DEBUG("play tone failed\n");
+       } else {
+               MSG_DEBUG("play tone success\n");
+       }
+
        MSG_END();
 }
 
index 94115aa..4b725d1 100755 (executable)
@@ -59,12 +59,17 @@ int main(int argc, char** argv)
 
        MSG_DEBUG("argv[0] [%s] ", argv[0]);
 
-       if(strcmp(argv[0],MSG_SOUND_START)==0)
+       if(g_strcmp0(argv[0], MSG_NORMAL_SOUND_START) == 0)
        {
-               MsgSoundPlayStart();
+               MsgSoundPlayStart(false);
                notEnd = true;
        }
-       else if(strcmp(argv[0],MSG_SOUND_STOP)==0)
+       if(g_strcmp0(argv[0], MSG_EMERGENCY_SOUND_START) == 0)
+       {
+               MsgSoundPlayStart(true);
+               notEnd = true;
+       }
+       else if(g_strcmp0(argv[0],MSG_SOUND_STOP) == 0)
        {
                MsgSoundPlayStop();
        }
old mode 100644 (file)
new mode 100755 (executable)
index c7cfb59..86c2481
@@ -17,7 +17,7 @@ BuildRequires: cmake
 BuildRequires: pkgconfig(alarm-service)
 BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(capi-appfw-application)
-BuildRequires: pkgconfig(contacts-service)
+BuildRequires: pkgconfig(contacts-service2)
 BuildRequires: pkgconfig(db-util)
 BuildRequires: pkgconfig(devman_haptic)
 BuildRequires: pkgconfig(dlog)
@@ -31,6 +31,7 @@ BuildRequires: pkgconfig(media-thumbnail)
 BuildRequires: pkgconfig(mm-fileinfo)
 BuildRequires: pkgconfig(mm-player)
 BuildRequires: pkgconfig(mm-session)
+BuildRequires: pkgconfig(mm-sound)
 BuildRequires: pkgconfig(network)
 BuildRequires: pkgconfig(notification)
 BuildRequires: pkgconfig(pmapi)
@@ -129,20 +130,155 @@ then
     mkdir -p %{buildroot}/opt/usr/dbspace/
     sqlite3 /opt/usr/dbspace/.msg_service.db "PRAGMA journal_mode = PERSIST;
 
-    CREATE TABLE MSG_CONVERSATION_TABLE ( CONV_ID INTEGER NOT NULL , UNREAD_CNT INTEGER DEFAULT 0 , SMS_CNT INTEGER DEFAULT 0 , MMS_CNT INTEGER DEFAULT 0 , MAIN_TYPE INTEGER NOT NULL , SUB_TYPE INTEGER NOT NULL , MSG_DIRECTION INTEGER NOT NULL , DISPLAY_TIME INTEGER , DISPLAY_NAME TEXT , MSG_TEXT TEXT );
-    CREATE TABLE MSG_ADDRESS_TABLE ( ADDRESS_ID INTEGER PRIMARY KEY , CONV_ID INTEGER  NOT NULL , ADDRESS_TYPE INTEGER , RECIPIENT_TYPE INTEGER , ADDRESS_VAL TEXT , CONTACT_ID INTEGER , DISPLAY_NAME TEXT , FIRST_NAME TEXT , LAST_NAME TEXT , IMAGE_PATH TEXT , SYNC_TIME DATETIME , FOREIGN KEY (CONV_ID) REFERENCES MSG_CONVERSATION_TABLE (CONV_ID) );
-    CREATE TABLE MSG_FOLDER_TABLE ( FOLDER_ID INTEGER PRIMARY KEY , FOLDER_NAME TEXT NOT NULL , FOLDER_TYPE INTEGER DEFAULT 0 );
-    CREATE TABLE MSG_MESSAGE_TABLE ( MSG_ID INTEGER PRIMARY KEY , CONV_ID INTEGER NOT NULL , FOLDER_ID INTEGER NOT NULL , STORAGE_ID INTEGER NOT NULL , MAIN_TYPE INTEGER NOT NULL , SUB_TYPE INTEGER NOT NULL , DISPLAY_TIME DATETIME , DATA_SIZE INTEGER DEFAULT 0 , NETWORK_STATUS INTEGER DEFAULT 0 , READ_STATUS INTEGER DEFAULT 0 , PROTECTED INTEGER DEFAULT 0 , PRIORITY INTEGER DEFAULT 0 , MSG_DIRECTION INTEGER NOT NULL , SCHEDULED_TIME DATETIME , BACKUP INTEGER DEFAULT 0 , SUBJECT TEXT , MSG_DATA TEXT , THUMB_PATH TEXT , MSG_TEXT TEXT , ATTACHMENT_COUNT INTEGER DEFAULT 0 , FOREIGN KEY (CONV_ID) REFERENCES MSG_CONVERSATION_TABLE (CONV_ID) , FOREIGN KEY (FOLDER_ID) REFERENCES MSG_FOLDER_TABLE (FOLDER_ID) );
-    CREATE TABLE MSG_SIM_TABLE ( MSG_ID INTEGER , SIM_ID INTEGER NOT NULL , FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
-    CREATE TABLE MSG_PUSH_TABLE ( MSG_ID INTEGER , ACTION INTEGER , CREATED INTEGER , EXPIRES INTEGER , ID TEXT , HREF TEXT , CONTENT TEXT , FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
-    CREATE TABLE MSG_CBMSG_TABLE ( MSG_ID INTEGER , CB_MSG_ID INTEGER NOT NULL , FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
-    CREATE TABLE MSG_SYNCML_TABLE ( MSG_ID INTEGER , EXT_ID INTEGER NOT NULL , PINCODE INTEGER NOT NULL , FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
-    CREATE TABLE MSG_SMS_SENDOPT_TABLE ( MSG_ID INTEGER , DELREP_REQ INTEGER NOT NULL , KEEP_COPY INTEGER NOT NULL , REPLY_PATH INTEGER NOT NULL , FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
-    CREATE TABLE MSG_FILTER_TABLE ( FILTER_ID INTEGER PRIMARY KEY , FILTER_TYPE INTEGER NOT NULL , FILTER_VALUE TEXT NOT NULL , FILTER_ACTIVE INTEGER DEFAULT 0);
-    CREATE TABLE MSG_MMS_MESSAGE_TABLE ( MSG_ID INTEGER , TRANSACTION_ID TEXT , MESSAGE_ID TEXT , FWD_MESSAGE_ID TEXT , CONTENTS_LOCATION TEXT , FILE_PATH TEXT , VERSION INTEGER NOT NULL , DATA_TYPE INTEGER DEFAULT -1 , DATE DATETIME , HIDE_ADDRESS INTEGER DEFAULT 0 , ASK_DELIVERY_REPORT INTEGER DEFAULT 0 , REPORT_ALLOWED INTEGER DEFAULT 0 , READ_REPORT_ALLOWED_TYPE INTEGER DEFAULT 0 , ASK_READ_REPLY INTEGER DEFAULT 0 , READ INTEGER DEFAULT 0 , READ_REPORT_SEND_STATUS INTEGER DEFAULT 0 , READ_REPORT_SENT INTEGER DEFAULT 0 , PRIORITY INTEGER DEFAULT 0 , KEEP_COPY INTEGER DEFAULT 0 , MSG_SIZE INTEGER NOT NULL , MSG_CLASS INTEGER DEFAULT -1 , EXPIRY_TIME DATETIME , CUSTOM_DELIVERY_TIME INTEGER DEFAULT 0 , DELIVERY_TIME DATETIME , MSG_STATUS INTEGER DEFAULT -1 , FOREIGN KEY (MSG_ID) REFERENCES MSG_MESSAGE_TABLE (MSG_ID) );
-    CREATE TABLE MSG_MMS_PREVIEW_INFO_TABLE ( MSG_ID INTEGER, TYPE INTEGER, VALUE TEXT, COUNT INTEGER, PRIMARY KEY (MSG_ID, TYPE)  ON CONFLICT REPLACE FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) ON DELETE CASCADE);
-    CREATE TABLE MSG_REPORT_TABLE ( MSG_ID INTEGER , ADDRESS_VAL TEXT , STATUS_TYPE INTEGER , STATUS INTEGER DEFAULT 0 , TIME DATETIME);
-    CREATE TABLE MSG_PUSHCFG_TABLE ( PUSH_ID INTEGER , CONTENT_TYPE TEXT, APP_ID TEXT, PKG_NAME TEXT, LAUNCH INTEGER, APPCODE INTEGER, SECURE INTEGER);
+    CREATE TABLE MSG_CONVERSATION_TABLE (
+       CONV_ID INTEGER PRIMARY KEY ,
+       UNREAD_CNT INTEGER DEFAULT 0 ,
+       SMS_CNT INTEGER DEFAULT 0 ,
+       MMS_CNT INTEGER DEFAULT 0 ,
+       MAIN_TYPE INTEGER DEFAULT 0 ,
+       SUB_TYPE INTEGER DEFAULT 0 ,
+       MSG_DIRECTION INTEGER DEFAULT 0 ,
+       DISPLAY_TIME DATETIME ,
+       DISPLAY_NAME TEXT ,
+       MSG_TEXT TEXT );
+
+    CREATE TABLE MSG_ADDRESS_TABLE (
+       ADDRESS_ID INTEGER PRIMARY KEY ,
+       CONV_ID INTEGER  NOT NULL ,
+       ADDRESS_TYPE INTEGER ,
+       RECIPIENT_TYPE INTEGER ,
+       ADDRESS_VAL TEXT ,
+       CONTACT_ID INTEGER ,
+       DISPLAY_NAME TEXT ,
+       FIRST_NAME TEXT ,
+       LAST_NAME TEXT ,
+       IMAGE_PATH TEXT ,
+       SYNC_TIME DATETIME ,
+       FOREIGN KEY (CONV_ID) REFERENCES MSG_CONVERSATION_TABLE (CONV_ID) );
+
+    CREATE TABLE MSG_FOLDER_TABLE (
+       FOLDER_ID INTEGER PRIMARY KEY ,
+       FOLDER_NAME TEXT NOT NULL ,
+       FOLDER_TYPE INTEGER DEFAULT 0 );
+
+    CREATE TABLE MSG_MESSAGE_TABLE (
+       MSG_ID INTEGER PRIMARY KEY ,
+       CONV_ID INTEGER NOT NULL ,
+       FOLDER_ID INTEGER NOT NULL ,
+       STORAGE_ID INTEGER NOT NULL ,
+       MAIN_TYPE INTEGER NOT NULL ,
+       SUB_TYPE INTEGER NOT NULL ,
+       DISPLAY_TIME DATETIME ,
+       DATA_SIZE INTEGER DEFAULT 0 ,
+       NETWORK_STATUS INTEGER DEFAULT 0 ,
+       READ_STATUS INTEGER DEFAULT 0 ,
+       PROTECTED INTEGER DEFAULT 0 ,
+       PRIORITY INTEGER DEFAULT 0 ,
+       MSG_DIRECTION INTEGER NOT NULL ,
+       SCHEDULED_TIME DATETIME ,
+       BACKUP INTEGER DEFAULT 0 ,
+       SUBJECT TEXT ,
+       MSG_DATA TEXT ,
+       THUMB_PATH TEXT ,
+       MSG_TEXT TEXT ,
+       ATTACHMENT_COUNT INTEGER DEFAULT 0 ,
+       FOREIGN KEY (CONV_ID) REFERENCES MSG_CONVERSATION_TABLE (CONV_ID) ,
+       FOREIGN KEY (FOLDER_ID) REFERENCES MSG_FOLDER_TABLE (FOLDER_ID) );
+
+    CREATE TABLE MSG_SIM_TABLE (
+       MSG_ID INTEGER PRIMARY KEY ,
+       SIM_ID INTEGER NOT NULL ,
+       FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
+
+    CREATE TABLE MSG_PUSH_TABLE (
+       MSG_ID INTEGER PRIMARY KEY ,
+       ACTION INTEGER ,
+       CREATED INTEGER ,
+       EXPIRES INTEGER ,
+       ID TEXT ,
+       HREF TEXT ,
+       CONTENT TEXT ,
+       FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
+
+    CREATE TABLE MSG_CBMSG_TABLE (
+       MSG_ID INTEGER PRIMARY KEY ,
+       CB_MSG_ID INTEGER NOT NULL ,
+       FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
+
+    CREATE TABLE MSG_SYNCML_TABLE (
+       MSG_ID INTEGER PRIMARY KEY ,
+       EXT_ID INTEGER NOT NULL ,
+       PINCODE INTEGER NOT NULL ,
+       FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
+
+    CREATE TABLE MSG_SCHEDULED_TABLE (
+       MSG_ID INTEGER PRIMARY KEY ,
+       ALARM_ID INTEGER NOT NULL ,
+       FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
+
+    CREATE TABLE MSG_SMS_SENDOPT_TABLE (
+       MSG_ID INTEGER PRIMARY KEY ,
+       DELREP_REQ INTEGER NOT NULL ,
+       KEEP_COPY INTEGER NOT NULL ,
+       REPLY_PATH INTEGER NOT NULL ,
+       FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
+
+    CREATE TABLE MSG_FILTER_TABLE (
+       FILTER_ID INTEGER PRIMARY KEY ,
+       FILTER_TYPE INTEGER NOT NULL ,
+       FILTER_VALUE TEXT NOT NULL ,
+       FILTER_ACTIVE INTEGER DEFAULT 0 );
+
+    CREATE TABLE MSG_MMS_MESSAGE_TABLE (
+       MSG_ID INTEGER PRIMARY KEY ,
+       TRANSACTION_ID TEXT ,
+       MESSAGE_ID TEXT ,
+       FWD_MESSAGE_ID TEXT ,
+       CONTENTS_LOCATION TEXT ,
+       FILE_PATH TEXT ,
+       VERSION INTEGER NOT NULL ,
+       DATA_TYPE INTEGER DEFAULT -1 ,
+       DATE DATETIME ,
+       HIDE_ADDRESS INTEGER DEFAULT 0 ,
+       ASK_DELIVERY_REPORT INTEGER DEFAULT 0 ,
+       REPORT_ALLOWED INTEGER DEFAULT 0 ,
+       READ_REPORT_ALLOWED_TYPE INTEGER DEFAULT 0 ,
+       ASK_READ_REPLY INTEGER DEFAULT 0 ,
+       READ INTEGER DEFAULT 0 ,
+       READ_REPORT_SEND_STATUS INTEGER DEFAULT 0 ,
+       READ_REPORT_SENT INTEGER DEFAULT 0 ,
+       PRIORITY INTEGER DEFAULT 0 ,
+       KEEP_COPY INTEGER DEFAULT 0 ,
+       MSG_SIZE INTEGER NOT NULL ,
+       MSG_CLASS INTEGER DEFAULT -1 ,
+       EXPIRY_TIME DATETIME ,
+       CUSTOM_DELIVERY_TIME INTEGER DEFAULT 0 ,
+       DELIVERY_TIME DATETIME ,
+       MSG_STATUS INTEGER DEFAULT -1 ,
+       FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
+
+    CREATE TABLE MSG_MMS_PREVIEW_INFO_TABLE (
+       MSG_ID INTEGER NOT NULL ,
+       TYPE INTEGER,
+       VALUE TEXT,
+       COUNT INTEGER,
+       FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID) );
+
+    CREATE TABLE MSG_REPORT_TABLE (
+       MSG_ID INTEGER NOT NULL ,
+       ADDRESS_VAL TEXT ,
+       STATUS_TYPE INTEGER ,
+       STATUS INTEGER DEFAULT 0 ,
+       TIME DATETIME );
+
+    CREATE TABLE MSG_PUSHCFG_TABLE (
+       PUSH_ID INTEGER PRIMARY KEY ,
+       CONTENT_TYPE TEXT,
+       APP_ID TEXT,
+       PKG_NAME TEXT,
+       LAUNCH INTEGER,
+       APPCODE INTEGER,
+       SECURE INTEGER );
 
     CREATE INDEX MSG_CONVERSATION_INDEX ON MSG_CONVERSATION_TABLE(CONV_ID);
     CREATE INDEX MSG_FOLDER_INDEX ON MSG_FOLDER_TABLE(FOLDER_ID);
@@ -342,6 +478,8 @@ vconftool set -t string memory/private/msg-service/sim_imsi "" -i -u $vcuid
 vconftool set -t bool memory/private/msg-service/national_sim 0 -i -u $vcuid
 vconftool set -t string memory/private/msg-service/msisdn "" -i -u $vcuid
 
+vconftool set -t int db/private/msg-service/notification_priv_id 0 -u $vcuid
+
 /sbin/ldconfig
 /bin/systemctl daemon-reload
 if [ "$1" = "1" ]; then
@@ -364,6 +502,7 @@ fi
 %{_libdir}/libmsg_transaction_manager.so
 %{_libdir}/libmsg_utils.so
 %{_libdir}/libmsg_transaction_proxy.so
+%{_libdir}/libmsg_vobject.so
 /usr/share/license/msg-service/LICENSE
 
 %files devel
@@ -396,7 +535,6 @@ fi
 %manifest mms-plugin.manifest
 %defattr(-,root,root,-)
 %{_libdir}/libmsg_mms_plugin.so
-%{_libdir}/libmsg_mms_language_pack.so
 /usr/share/license/msg-service/LICENSE
 
 %changelog
index 7420f0e..1a0b0ce 100755 (executable)
@@ -8,48 +8,13 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 
-##########################################################
-# Define MMS Language Pack
-##########################################################
-
-SET(MMS-LANGUAGE-PACK-SRCS
-       LanguagePack/MmsPluginWmLngLatinUni.cpp
-       LanguagePack/MmsPluginWmLngString.cpp
-       LanguagePack/MmsPluginWmLngUTF8Uni.cpp
-       LanguagePack/MmsPluginWmLngUniUTF8.cpp
-)
-
-INCLUDE_DIRECTORIES(
-    ${CMAKE_SOURCE_DIR}/include/mapi
-       ${CMAKE_SOURCE_DIR}/include/common
-       ${CMAKE_SOURCE_DIR}/include/utils
-       ${CMAKE_CURRENT_SOURCE_DIR}/include
-)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(mms_language_pkgs REQUIRED glib-2.0 dlog)
-
-FOREACH(flag ${mms_language_pkgs_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g")
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
-
-ADD_LIBRARY(${MMS-LANGUAGE-PACK-LIB} SHARED ${MMS-LANGUAGE-PACK-SRCS})
-TARGET_LINK_LIBRARIES(${MMS-LANGUAGE-PACK-LIB} ${mms_language_pkgs_LDFLAGS} ${UTILS-LIB})
-
-INSTALL(TARGETS ${MMS-LANGUAGE-PACK-LIB} LIBRARY DESTINATION lib)
 
 ##########################################################
 # Define MMS Plugin
 ##########################################################
 
 SET(MMS-PLUGIN-SRCS
+       MmsPluginTextConvert.cpp
        MmsPluginTransport.cpp
        MmsPluginMain.cpp
        MmsPluginEventHandler.cpp
@@ -77,6 +42,7 @@ INCLUDE_DIRECTORIES(
        ${CMAKE_SOURCE_DIR}/include/framework
        ${CMAKE_SOURCE_DIR}/include/msg_helper
        ${CMAKE_SOURCE_DIR}/include/utils
+       ${CMAKE_SOURCE_DIR}/include/mapi
        ${CMAKE_CURRENT_SOURCE_DIR}/include
 )
 
@@ -96,7 +62,7 @@ ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
 
 ADD_LIBRARY(${MMS-PLUGIN-LIB} SHARED ${MMS-PLUGIN-SRCS})
-TARGET_LINK_LIBRARIES(${MMS-PLUGIN-LIB} ${mms_plugin_pkgs_LDFLAGS} ${MMS-LANGUAGE-PACK-LIB} ${UTILS-LIB})
+TARGET_LINK_LIBRARIES(${MMS-PLUGIN-LIB} ${mms_plugin_pkgs_LDFLAGS} ${UTILS-LIB})
 
 INSTALL(TARGETS ${MMS-PLUGIN-LIB} LIBRARY DESTINATION lib)
 
index 4d9cbb6..720d5fd 100755 (executable)
 #include <ctype.h>
 #include "MsgDebug.h"
 #include "MmsPluginCodec.h"
-#include "MmsPluginCodec.h"
+#include "MmsPluginTextConvert.h"
 #include "MmsPluginMIME.h"
 #include "MmsPluginMessage.h"
-#include "MmsPluginWmLngPack.h"
 #include "MmsPluginUtil.h"
 const int MSG_MAX_CH_PER_LINE = 75;
 
@@ -408,14 +407,9 @@ char *_MsgDecodeText(char *pOri)
        char *pDecQ2 = NULL;
        bool bEncoding = false;
        int     nCharset = MSG_CHARSET_UTF8;
-       int     nChar = 0;
-       int     nByte = 0;
        int     nTemp = 0;
        char *pReturnStr = NULL;
        char *pConvertedStr = NULL;
-       MCHAR *mszTempStr = NULL;
-
-       MCHAR *pmszOutTextStr = NULL;
 
        char szTempBuf[MSG_LOCAL_TEMP_BUF_SIZE] = {0};
 
@@ -452,7 +446,7 @@ char *_MsgDecodeText(char *pOri)
                     && ((pDecEnd = strstr(pDecQ2 + 1, MSG_STR_DEC_END))!= NULL)) {     //"=?"
                        bEncoding = true;
 
-                       /* charset problem
+                       /* fixme: charset problem
                         * pDecStart ~ pDecQ : charSet & MSG_CHARSET_USC2 ~ MSG_CHARSET_UTF8 & LATIN
                         */
 
@@ -556,442 +550,57 @@ char *_MsgDecodeText(char *pOri)
                }
        }
 
-__RETURN:
-
-       pTemp = pSrc;
-       nTemp = strlen(pSrc);
-
-       switch (nCharset) {
-       case MSG_CHARSET_UTF16:
-       case MSG_CHARSET_USC2:
 
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_USC2 \n");
-
-               if (pTemp) {
-                       // mmf file name display patch
-                       if (((UINT8)pTemp[0] == 0xFF && (UINT8)pTemp[1] == 0xFE) || ((UINT8)pTemp[0] == 0xFE && (UINT8)pTemp[1] == 0xFF)) {
-
-                               nChar = (nTemp / 2 - 1);
-
-                               // Re check char-set
-                               if (MsgIsUTF8String((unsigned char *)pTemp + 2, nTemp - 2)) {
-                                       strncpy(pTemp, pTemp + 2, strlen(pTemp + 2));
-                                       nTemp = nTemp - 2;
-                                       MSG_DEBUG("_MsgDecodeText: real char-set = MSG_CHARSET_UTF8.\n");
-                                       break;
-                               }
-
-                               mszTempStr = (unsigned short *)malloc(nChar * sizeof(unsigned short));
-                               if (mszTempStr == NULL) {
-                                       MSG_DEBUG("_MsgDecodeText: 1. Memory Full !!! \n");
-                                       goto __CATCH;
-                               }
 
-                               memcpy(mszTempStr, ((unsigned short *)pTemp + 1), nChar * sizeof(unsigned short));
-
-                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short *)pTemp + 1), nChar);
-
-                               pConvertedStr = (char *)malloc(nByte + 1);
-                               if (pConvertedStr) {
-                                       MsgUnicode2UTF ((unsigned char *)pConvertedStr, nByte + 1, mszTempStr, nChar);
-                               }
-                       } else {
-                               nChar = (nTemp / 2);
+__RETURN:
 
-                               if (nChar == 0) {
-                                       nChar = 2;
-                               }
+       pTemp = strdup(pSrc);
+       nTemp = strlen(pSrc);
 
-                               // Re check char-set
-                               if (MsgIsUTF8String((unsigned char *)pTemp, nTemp)) {
-                                       MSG_DEBUG("_MsgDecodeText: real char-set = MSG_CHARSET_UTF8.\n");
-                                       break;
-                               }
+       {//temp brace;
+               const char *pToCharSet = "UTF-8";
 
-                               mszTempStr = (unsigned short *)malloc(nChar * sizeof(unsigned short));
-                               if (mszTempStr == NULL) {
-                                       MSG_DEBUG("_MsgDecodeText: 2. Memory Full !!! \n");
-                                       goto __CATCH;
-                               }
+               UINT16 charset_code =  _MmsGetBinaryValue(MmsCodeCharSet, nCharset);
 
-                               memcpy(mszTempStr, ((unsigned short *)pTemp), nChar * sizeof(unsigned short));
+               const char *pFromCharSet = MmsPluginTextConvertGetCharSet(charset_code);
 
-                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short *)pTemp), nChar);
+               if (pFromCharSet != NULL && strcmp(pFromCharSet, pToCharSet) != 0) {//Not UTF-8
+                       char *pDest = NULL;
+                       int destLen = 0;
 
-                               pConvertedStr = (char *)malloc(nByte + 1);
-                               if (pConvertedStr) {
-                                       MsgUnicode2UTF ((unsigned char *)pConvertedStr, nByte + 1, mszTempStr, nChar);
-                               }
+                       if (MmsPluginTextConvert(pToCharSet, pFromCharSet, pTemp, nTemp, &pDest, &destLen) == false) {
+                               MSG_DEBUG("MmsPluginTextConvert Fail");
                        }
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_US_ASCII:
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_US_ASCII \n");
-               break;
-
-       case MSG_CHARSET_UTF8:
-
-               /* UTF8 is  default charset of Messenger */
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_UTF8 \n");
-
-               break;
-
-       case MSG_CHARSET_ISO_8859_1:
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_1 \n");
-
-               nByte = nTemp * 3;
-
-               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
-               if (pmszOutTextStr == NULL) {
-                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
-                       goto __CATCH;
-               }
-
-               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
-               if (pConvertedStr) {
-                       WmConvertLatinCode2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
-                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
-               }
-
-               if (pmszOutTextStr) {
-                       free(pmszOutTextStr);
-                       pmszOutTextStr = NULL;
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_ISO_8859_2:
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_2 \n");
-
-               nByte = nTemp * 3;
-
-               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
-               if (pmszOutTextStr == NULL) {
-                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
-                       goto __CATCH;
-               }
-
-               pConvertedStr =  (char *)malloc(sizeof(char *) * (nByte + 1));
-               if (pConvertedStr) {
-                       WmConvertLatin2Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
-                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
-               }
-
-               if (pmszOutTextStr) {
-                       free(pmszOutTextStr);
-                       pmszOutTextStr = NULL;
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_ISO_8859_3:
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_3 \n");
-
-               nByte = WmGetLatin32UTFCodeSize((unsigned char *)pTemp, nTemp);
-
-               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
-               if (pmszOutTextStr == NULL) {
-                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
-                       goto __CATCH;
-               }
-
-               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
-               if (pConvertedStr) {
-                       WmConvertLatin3Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
-                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
-               }
-
-               if (pmszOutTextStr) {
-                       free(pmszOutTextStr);
-                       pmszOutTextStr = NULL;
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_ISO_8859_4:
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_4 \n");
-
-               nByte = WmGetLatin42UTFCodeSize((unsigned char *)pTemp, nTemp);
-
-               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
-               if (pmszOutTextStr == NULL) {
-                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
-                       goto __CATCH;
-               }
-
-               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
-               if (pConvertedStr) {
-                       WmConvertLatin4Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
-                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
-               }
-
-               if (pmszOutTextStr) {
-                       free(pmszOutTextStr);
-                       pmszOutTextStr = NULL;
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_ISO_8859_5:
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_5 \n");
-
-               nByte = WmGetLatin52UTFCodeSize((unsigned char *)pTemp, nTemp);
-
-               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
-               if (pmszOutTextStr == NULL) {
-                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
-                       goto __CATCH;
-               }
-
-               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
-               if (pConvertedStr) {
-                       WmConvertLatin5Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
-                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
-               }
-
-               if (pmszOutTextStr) {
-                       free(pmszOutTextStr);
-                       pmszOutTextStr = NULL;
-               }
 
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_ISO_8859_7:
-
-               /* Greek */
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_9 \n");
-
-               nByte = MsgGetLatin72UTFCodeSize((unsigned char *)pTemp, nTemp);
-               pConvertedStr = (char *)malloc( nByte + 1);
-               if (pConvertedStr) {
-                       MsgLatin7code2UTF((unsigned char *)pConvertedStr, nByte + 1 , (unsigned char *)pTemp, nTemp);
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_ISO_8859_8:
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_8 \n");
-
-               nByte = WmGetLatin82UTFCodeSize((unsigned char *)pTemp, nTemp);
-
-               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
-               if (pmszOutTextStr == NULL) {
-                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
-                       goto __CATCH;
-               }
-
-               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
-               if (pConvertedStr) {
-                       WmConvertLatin8Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
-                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
-               }
-
-               if (pmszOutTextStr) {
-                       free(pmszOutTextStr);
-                       pmszOutTextStr = NULL;
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_ISO_8859_9:
-               /* Turkish */
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_9 \n");
-
-               nByte = MsgGetLatin52UTFCodeSize((unsigned char *)pTemp, nTemp);
-               pConvertedStr = (char *)malloc(nByte + 1);
-               if (pConvertedStr) {
-                       MsgLatin5code2UTF((unsigned char *)pConvertedStr, nByte + 1 , (unsigned char *)pTemp, nTemp);
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_ISO_8859_15:
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_ISO_8859_15 \n");
-
-               nByte = WmGetLatin152UTFCodeSize((unsigned char *)pTemp, nTemp);
-
-               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
-               if (pmszOutTextStr == NULL) {
-                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
-                       goto __CATCH;
-               }
-
-               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
-               if (pConvertedStr) {
-                       WmConvertLatin15Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
-                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
-               }
-
-               if (pmszOutTextStr) {
-                       free(pmszOutTextStr);
-                       pmszOutTextStr = NULL;
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_WIN1251:
-       case MSG_CHARSET_WINDOW_1251:
-       case MSG_CHARSET_WINDOWS_1251:
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_WINDOWS_1251 \n");
-
-               nByte = nTemp * 3;
-
-               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
-               if (pmszOutTextStr == NULL) {
-                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
-                       goto __CATCH;
-               }
-
-               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
-               if (pConvertedStr) {
-                       WmConvertWin1251Code2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
-                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
-               }
-
-               if (pmszOutTextStr) {
-                       free(pmszOutTextStr);
-                       pmszOutTextStr = NULL;
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_KOI8_R:
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_KOI8_R \n");
-
-               nByte = nTemp * 3;
-
-               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
-               if (pmszOutTextStr == NULL) {
-                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
-                       goto __CATCH;
-               }
-
-               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
-               if (pConvertedStr) {
-                       WmConvertKoi8rCode2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
-                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
-               }
-
-               if (pmszOutTextStr) {
-                       free(pmszOutTextStr);
-                       pmszOutTextStr = NULL;
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       case MSG_CHARSET_KOI8_U:
-
-               MSG_DEBUG("_MsgDecodeText: MSG_CHARSET_KOI8_U \n");
-
-               nByte = nTemp * 3;
-
-               pmszOutTextStr = (unsigned short *)malloc(sizeof(MCHAR *) * (nByte + 1));
-               if (pmszOutTextStr == NULL) {
-                       MSG_DEBUG("_MsgDecodeText : Out Text String null !!! \n");
-                       goto __CATCH;
-               }
-
-               pConvertedStr = (char *)malloc(sizeof(char *) * (nByte + 1));
-               if (pConvertedStr) {
-                       WmConvertKoi8uCode2PCode(pmszOutTextStr, sizeof(MCHAR *) * (nByte + 1), pTemp);
-                       WmConvert2LCode(pConvertedStr, sizeof(char *) * (nByte + 1), pmszOutTextStr);
-               }
-
-               if (pmszOutTextStr) {
-                       free(pmszOutTextStr);
-                       pmszOutTextStr = NULL;
-               }
-
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
-
-       default:
-
-               MSG_DEBUG("_MsgDecodeText: Other charsets \n");
-
-               nByte = MsgGetLatin2UTFCodeSize((unsigned char *)pTemp, nTemp);
-               pConvertedStr = (char *)malloc(nByte + 1);
-               if (pConvertedStr) {
-                       MsgLatin2UTF((unsigned char *)pConvertedStr, nByte + 1, (unsigned char *)pTemp, nTemp);
+                       if (pDest) {
+                               free(pTemp);
+                               pTemp = strdup(pDest);
+                               nTemp = destLen;
+                               free(pDest);
+                       }
                }
 
-               pTemp = pConvertedStr;
-               nTemp = nByte;
-
-               break;
        }
 
        pReturnStr = (char *)malloc(nTemp + 1);
+
        if (pReturnStr == NULL) {
                goto __CATCH;
        }
+
        memset(pReturnStr, 0, nTemp + 1);
 
-       if (pTemp)
+       if (pTemp) {
                memcpy(pReturnStr, pTemp, nTemp);
+               free(pTemp);
+               pTemp = NULL;
+       }
 
        if (pConvertedStr) {
                free(pConvertedStr);
                pConvertedStr = NULL;
        }
 
-       if (mszTempStr) {
-               free(mszTempStr);
-               mszTempStr = NULL;
-       }
-
        if(pRe) {
                free(pRe);
                pRe = NULL;
@@ -1011,11 +620,6 @@ __CATCH:
                pConvertedStr = NULL;
        }
 
-       if (mszTempStr) {
-               free(mszTempStr);
-               mszTempStr = NULL;
-       }
-
        if(pRe) {
                free(pRe);
                pRe = NULL;
@@ -1026,6 +630,11 @@ __CATCH:
                pSrc = NULL;
        }
 
+       if (pTemp) {
+               free(pTemp);
+               pTemp = NULL;
+       }
+
        return NULL;
 }
 
index 7b56160..3562aa7 100755 (executable)
@@ -104,6 +104,8 @@ const char *MmsDebugGetMimeType(MimeType mimeType)
                return "MIME_APPLICATION_VND_RN_REALMEDIA";
        case MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE:
                return "MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE";
+       case MIME_APPLICATION_VND_SAMSUNG_THEME:
+               return "MIME_APPLICATION_VND_SAMSUNG_THEME";
        case MIME_APPLICATION_VND_EXCEL:
                return "MIME_APPLICATION_VND_EXCEL";
        case MIME_APPLICATION_X_HDMLC:
index 91862e7..08f3729 100755 (executable)
@@ -37,6 +37,7 @@
 #include "MmsPluginDrm.h"
 #include "MsgDrmWrapper.h"
 #endif
+#include "MmsPluginTextConvert.h"
 #include "MmsPluginUtil.h"
 
 static bool _MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength);          /* bufLen < gMmsDecodeMaxLen */
@@ -925,6 +926,11 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                         * MMS_CODE_PREVIOUSLYSENTBY shall be a pair with MMS_CODE_PREVIOUSLYSENTDATE
                         */
 
+                       /*
+                        * fixme: There is no proper field to store this information.
+                        * Just increase pointer now.
+                        */
+
                        if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
                                MSG_DEBUG("MmsBinaryDecodeMsgHeader : 1. invalid MMS_CODE_PREVIOUSLYSENTBY \n");
                                goto __CATCH;
@@ -949,6 +955,11 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                         * MMS_CODE_PREVIOUSLYSENTDATE shall be a pair with MMS_CODE_PREVIOUSLYSENTBY
                         */
 
+                       /*
+                        * fixme: There is no proper field to store this information.
+                        * Just increase pointer now.
+                        */
+
                        if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
                                MSG_DEBUG("MmsBinaryDecodeMsgHeader : 1. invalid MMS_CODE_PREVIOUSLYSENTDATE \n");
                                goto __CATCH;
@@ -1015,11 +1026,36 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
 
 __RETURN:
 
+       if (mmsHeader.pTo == NULL && pLastTo) {
+               free(pLastTo);
+       }
+
+       if (mmsHeader.pCc == NULL && pLastCc) {
+               free(pLastCc);
+       }
+
+       if (mmsHeader.pBcc == NULL && pLastBcc) {
+               free(pLastBcc);
+       }
+
        MSG_DEBUG("MmsBinaryDecodeMsgHeader: success\n");
        return true;
 
 
 __CATCH:
+
+       if (mmsHeader.pTo == NULL && pLastTo) {
+               free(pLastTo);
+       }
+
+       if (mmsHeader.pCc == NULL && pLastCc) {
+               free(pLastCc);
+       }
+
+       if (mmsHeader.pBcc == NULL && pLastBcc) {
+               free(pLastBcc);
+       }
+
        MSG_DEBUG("MmsBinaryDecodeMsgHeader: failed\n");
 
        return false;
@@ -1057,6 +1093,8 @@ bool MmsBinaryDecodeContentType(FILE *pFile, char *szFilePath, int totalLength)
 
 __CATCH:
 
+       /* fixme: Delete multipart using MmsDeleteMsg() */
+
        return false;
 }
 #endif
@@ -1066,8 +1104,6 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength)
        int length = 0;
        int offset = 0;
 
-       MsgMultipart *pMultipart = NULL;
-
        MSG_DEBUG("MmsBinaryDecodeMsgBody:\n");
 
        if (szFilePath != NULL)
@@ -1120,8 +1156,8 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength)
        default:
 
                /* Single part message ---------------------------------------------- */
-
-               strcpy(mmsHeader.msgBody.szOrgFilePath, szFilePath);
+               if (szFilePath != NULL)
+                       strcpy(mmsHeader.msgBody.szOrgFilePath, szFilePath);
 
                offset = _MmsGetDecodeOffset();
                if (offset >= totalLength)
@@ -1148,21 +1184,6 @@ __RETURN:
 
 __CATCH:
 
-       if (pMultipart) {
-               if (pMultipart->pBody) {
-                       if (pMultipart->pBody->body.pText) {
-                               free(pMultipart->pBody->body.pText);
-                               pMultipart->pBody->body.pText = NULL;
-                       }
-
-                       free(pMultipart->pBody);
-                       pMultipart->pBody = NULL;
-               }
-
-               free(pMultipart);
-               pMultipart = NULL;
-       }
-
        return false;
 }
 
@@ -1414,10 +1435,6 @@ __RETURN:
 
 __CATCH:
 
-       if (szTypeString) {
-               free(szTypeString);
-               szTypeString = NULL;
-       }
        return false;
 }
 
@@ -1828,7 +1845,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                                                Well-known-charset = Any-charset | Integer-value
                                                ; Both are encoded using values from Character Set Assignments table in Assigned Numbers
                                                Any-charset = <Octet 128>
-                                               ; Equivalent to the special RFC2616 charset value Â¡Â°*¡±
+                                               ; Equivalent to the special RFC2616 charset value ï¿½ï¿½*��
                                        */
 
                                        int     charset = 0;
@@ -1877,7 +1894,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                                if (szTemp == NULL)
                                        goto __CATCH;
 
-                               if (_MmsBinaryDecodeGetBytes(pFile, szTemp, valueLength, totalLength) < 0) {
+                               if (_MmsBinaryDecodeGetBytes(pFile, szTemp, valueLength, totalLength) == false) {
                                        MSG_DEBUG("MmsBinaryDecodePartHeader : default _MmsBinaryDecodeGetBytes() fail\n");
                                        if (szTemp) {
                                                free(szTemp);
@@ -2272,12 +2289,13 @@ bool MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType,
 
                        pLastMultipart->pNext   = pMultipart;
                        pLastMultipart                  = pMultipart;
+                       pPreMultipart = pMultipart;
                }
 
                pMsgType->contentSize += pMultipart->pBody->size;
 
                nEntries--;
-               pPreMultipart = pMultipart;
+
                MmsDebugPrintMulitpartEntry(pMultipart, index++);
 
        }
@@ -2516,7 +2534,7 @@ bool __MmsParseDCFInfo(FILE *pFile, MsgDRMInfo *pDrmInfo, int totalLength)
 
        memset(szContentURI, 0, contentURILen + 1);
 
-       if (_MmsBinaryDecodeGetBytes(pFile, szContentURI, contentURILen + 1, totalLength) < 0) {
+       if (_MmsBinaryDecodeGetBytes(pFile, szContentURI, contentURILen + 1, totalLength) == false) {
                MSG_DEBUG("__MmsParseDCFInfo : contentType is invalid\n");
                goto __CATCH;
        }
@@ -2744,7 +2762,9 @@ bool MmsBinaryDecodeDRMMessage(FILE *pFile, char *szFilePath, MsgType *pMsgType,
                goto __CATCH;
        }
 
-       remove(szTempFilePath);
+       if (remove(szTempFilePath) != 0)
+               MSG_DEBUG("remove fail");
+
        isFileCreated = false;
 
        if (MmsBinaryDecodeMovePointer(pFile, offset + fullBodyLength, totalLength) == false)
@@ -2759,9 +2779,10 @@ __RETURN:
        return true;
 
 __CATCH:
-       if (isFileCreated)
-               remove(szTempFilePath);
-
+       if (isFileCreated) {
+               if (remove(szTempFilePath) != 0)
+                       MSG_DEBUG("remove fail");
+       }
        if (pRawData) {
                free(pRawData);
                pRawData = NULL;
@@ -2985,6 +3006,11 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
                                        goto __CATCH;
                                }
 
+                               if (pszOrgData) {
+                                       free(pszOrgData);
+                                       pszOrgData = NULL;
+                               }
+
                                MsgFflush(hFile);
                                MsgCloseFile(hFile);
 
@@ -3110,11 +3136,6 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
                hConvertedFile = NULL;
        }
 
-       if (hTempFile != NULL) {
-               MsgCloseFile(hTempFile);
-               hTempFile = NULL;
-       }
-
        if (pszMmsLoadTempBuf) {
                free(pszMmsLoadTempBuf);
                pszMmsLoadTempBuf = NULL;
@@ -3125,11 +3146,6 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
                pszOrgData = NULL;
        }
 
-       if (hFile != NULL) {
-               MsgCloseFile(hFile);
-               hFile = NULL;
-       }
-
        remove(szTempFile);
        remove(szTempFilePath);
 
@@ -3168,9 +3184,14 @@ __CATCH:
                hFile = NULL;
        }
 
-       remove(szTempFile);
-       remove(szTempFilePath);
-       remove(MMS_DECODE_DRM_CONVERTED_TEMP_FILE);     //remove convertin result if it goes to __CATCH
+       if (remove(szTempFile) != 0)
+               MSG_DEBUG("remove fail");
+
+       if (remove(szTempFilePath) != 0)
+               MSG_DEBUG("remove fail");
+
+       if (remove(MMS_DECODE_DRM_CONVERTED_TEMP_FILE) != 0)
+               MSG_DEBUG("remove fail");       //remove convertin result if it goes to __CATCH
 
        return false;
 }
@@ -3231,7 +3252,10 @@ __CATCH:
 
        if (hConvertedFile != NULL) {
                MsgCloseFile(hConvertedFile);
-               remove(MMS_DECODE_DRM_CONVERTED_TEMP_FILE);
+
+               if (remove(MMS_DECODE_DRM_CONVERTED_TEMP_FILE) != 0)
+                       MSG_DEBUG("remove fail");
+
                hConvertedFile = NULL;
        }
 
@@ -3836,11 +3860,6 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen,
 
 __RETURN:
 
-       if (pData) {
-               free(pData);
-               pData = NULL;
-       }
-
        return length;
 
 __CATCH:
@@ -3988,11 +4007,6 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
 
 __RETURN:
 
-       if (pData) {
-               free(pData);
-               pData = NULL;
-       }
-
        szBuff[0] = '\0';
        length = 0;
 
@@ -4174,10 +4188,6 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
        return szBuff;
 
 __RETURN:
-       if (pData) {
-               free(pData);
-               pData = NULL;
-       }
 
        *pLength = 1;
 
@@ -4218,7 +4228,7 @@ static bool __MmsBinaryDecodeCharset(FILE *pFile, UINT32 *nCharSet, int *pCharSe
         *                                              ; Both are encoded using values from
         *                                                Character Set Assignments table in Assigned Numbers
         *                                       Any-charset = <Octet 128>
-        *                                              ; Equivalent to the special RFC2616 charset value Â¡Â°*¡±
+        *                                              ; Equivalent to the special RFC2616 charset value ï¿½ï¿½*��
         */
 
        if (pFile == NULL || nCharSet == NULL || pCharSetLen == NULL)
@@ -4263,16 +4273,11 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen
        UINT32 valueLength = 0;
        UINT32 charSet = 0;
        int charSetLen = 0;
-       int nChar = 0;
-       int nRead2 = 0;
-       int nByte = 0;
        int nTemp = 0;
        char *pData = NULL;
        char *pTempData = NULL;
        unsigned short *mszTempStr = NULL;
        char *pConvertedStr = NULL;
-       char *pNewData = NULL;
-
 
        MSG_DEBUG("__MmsBinaryDecodeEncodedString: decode string..\n");
 
@@ -4330,172 +4335,32 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen
                        strncpy(szBuff, pData, bufLen - 1);
                }
 
-               switch (charSet) {
-               case MSG_CHARSET_UTF16:
-               case MSG_CHARSET_USC2:
-
-                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_USC2 \n");
+               {//temp brace
 
                        nTemp = strlen(szBuff);
-                       pTempData = (char *)malloc(nTemp + 1);
-                       if (pTempData == NULL) {
-                               MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n");
-                               goto __CATCH;
-                       }
-
-                       memset(pTempData, 0, nTemp + 1);
-                       memcpy(pTempData, szBuff, nTemp + 1);
-
-                       if (((UINT8)pTempData[0]) == 0xFF && ((UINT8)pTempData[1]) == 0xFE) {
-                               if ((nChar = (nTemp / 2 - 1)) <= 0)     {
-                                       MSG_DEBUG("__MmsBinaryDecodeEncodedString(%d) : nChar is invalid value (%d), charset(%d)\n", __LINE__, nChar, charSet);
-                                       goto __CATCH ;
-                               }
-
-                               mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short));
-                               if (mszTempStr == NULL) {
-                                       MSG_DEBUG("MmsGetMediaPartData : 1. Memory Full !!! \n");
-                                       goto __CATCH;
-                               }
 
-                               memcpy(mszTempStr, ((unsigned short*)pTempData + 1), nChar * sizeof(unsigned short));
+                       const char *pToCharSet = "UTF-8";
 
-                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTempData + 1), nChar);
+                       UINT16 charset_code =  _MmsGetBinaryValue(MmsCodeCharSet, charSet);
 
-                               pConvertedStr = (char *)malloc(nByte + 1);
-                               if (pConvertedStr)
-                                       MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar);
-                       } else {
-                               if ((nChar = (nTemp / 2)) <= 0) {
-                                       MSG_DEBUG("__MmsBinaryDecodeEncodedString(%d) : nChar is invalid value (%d), charset(%d)\n", __LINE__, nChar, charSet);
-                                       goto __CATCH ;
-                               }
-
-                               mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short));
-                               if (mszTempStr == NULL) {
-                                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: 2. Memory Full !!! \n");
-                                       goto __CATCH;
-                               }
-
-                               memcpy(mszTempStr, ((unsigned short*)pTempData), nChar * sizeof(unsigned short));
-
-                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTempData), nChar);
-
-                               pConvertedStr = (char *)malloc(nByte + 1);
-                               if (pConvertedStr != NULL)
-                                       MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar);
-                       }
-
-                       if (pConvertedStr != NULL) {
-                               pNewData = pConvertedStr;
-                               nRead2 = nByte;
-
-                               strncpy(szBuff, pNewData, bufLen - 1);
-                       }
-
-                       break;
-
-               case MSG_CHARSET_US_ASCII:
-
-                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_US_ASCII \n");
-
-               case MSG_CHARSET_UTF8:
-
-                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_UTF8 or Others \n");
-
-                       pNewData = pTempData;
-                       nRead2 = nTemp;
-
-                       break;
-
-               case MSG_CHARSET_ISO_8859_7: /* Greek */
-
-                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_ISO_8859_7 \n");
-
-                       nTemp = strlen(szBuff);
-                       pTempData = (char *)malloc(nTemp + 1);
-                       if (pTempData == NULL)
-                       {
-                               MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n");
-                               goto __CATCH;
-                       }
-
-                       memset(pTempData, 0 , nTemp + 1);
-                       memcpy(pTempData, szBuff, nTemp + 1);
-
-                       nByte = MsgGetLatin72UTFCodeSize((unsigned char*)pTempData, nTemp);
-                       pConvertedStr = (char *)malloc(nByte + 1);
-
-                       if (pConvertedStr != NULL) {
-                               MsgLatin7code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTempData, nTemp);
-
-                               pNewData = pConvertedStr;
-                               nRead2 = nByte;
-
-                               strncpy(szBuff, pNewData, bufLen - 1);
-                       }
-
-                       break;
-
-               case MSG_CHARSET_ISO_8859_9: /* Turkish */
-
-                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: MSG_CHARSET_ISO_8859_9 \n");
-
-                       nTemp = strlen(szBuff);
-                       pTempData = (char *)malloc(nTemp + 1);
-                       if (pTempData == NULL) {
-                               MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n");
-                               goto __CATCH;
-                       }
-
-                       memset(pTempData, 0 , nTemp + 1);
-                       memcpy(pTempData, szBuff, nTemp + 1);
-
-                       nByte = MsgGetLatin52UTFCodeSize((unsigned char*)pTempData, nTemp);
-                       pConvertedStr = (char *)malloc(nByte + 1);
-
-                       if (pConvertedStr != NULL) {
-                               MsgLatin5code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTempData, nTemp);
-
-                               pNewData = pConvertedStr;
-                               nRead2 = nByte;
-
-                               strncpy(szBuff, pNewData, bufLen - 1);
-                       }
-
-                       break;
-
-               default:
-
-                       MSG_DEBUG("__MmsBinaryDecodeEncodedString: Other charsets \n");
-
-                       nTemp = strlen(szBuff);
-                       pTempData = (char *)malloc(nTemp + 1);
-                       if (pTempData == NULL) {
-                               MSG_DEBUG("__MmsBinaryDecodeEncodedString: Memory Full \n");
-                               goto __CATCH;
+                       const char *pFromCharSet = MmsPluginTextConvertGetCharSet(charset_code);
+                       if (pFromCharSet == NULL || !strcmp(pFromCharSet, pToCharSet)) {
+                               return true;
                        }
 
-                       memset(pTempData, 0, nTemp + 1);
-                       memcpy(pTempData, szBuff, nTemp + 1);
-
-                       nByte = MsgGetLatin2UTFCodeSize((unsigned char*)pTempData, nTemp);
-                       pConvertedStr = (char *)malloc(nByte + 1);
+                       char *pDest = NULL;
+                       int destLen = 0;
 
-                       if (pConvertedStr != NULL) {
-                               MsgLatin2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTempData, nTemp);
+                       if (MmsPluginTextConvert(pToCharSet, pFromCharSet, szBuff, nTemp, &pDest, &destLen) == false) {
+                               MSG_DEBUG("MmsPluginTextConvert Fail");
 
-                               pNewData = pConvertedStr;
-                               nRead2 = nByte;
+                       } else {
 
-                               strncpy(szBuff, pNewData, bufLen - 1);
+                               memset(szBuff, 0x00, bufLen);
+                               snprintf(szBuff, destLen, "%s", pDest);
                        }
-
-                       break;
-
-               } //switch (charset)
-
-       } //switch (__MmsDecodeValueLength....)
+               }
+       }
 
        if (pData) {
                free(pData);
@@ -4618,6 +4483,8 @@ MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength)
                        }
                }
 
+               /* fixme: charset transformation */
+
                break;
        }
 
@@ -4723,6 +4590,9 @@ 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
+
                        pUTF8Buff = (char *)malloc(utf8BufSize + 1);
                        if (pUTF8Buff == NULL) {
                                MSG_DEBUG("__MmsDecodeGetFilename: pUTF8Buff alloc fail \n");
@@ -4832,8 +4702,7 @@ bool _MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bR
        pMsg->msgID = msgID;
 
        /*      read from MMS raw file  */
-       if (szFullPath != NULL)
-               strncpy(pMsg->szFileName, szFullPath + strlen(MSG_DATA_PATH), strlen(szFullPath + strlen(MSG_DATA_PATH)));
+       strncpy(pMsg->szFileName, szFullPath + strlen(MSG_DATA_PATH), strlen(szFullPath + strlen(MSG_DATA_PATH)));
 
        MSG_DEBUG("szFullPath = (%s)", szFullPath);
 
@@ -5232,8 +5101,8 @@ bool _MsgParseParameter(MsgType *pType, char *pSrc)
 
                                if (pUTF8Buff) {
                                        if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) {
-                                               if ((MSG_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) {
-                                                       nameLen = (MSG_FILENAME_LEN_MAX-1) - strlen(pExt);
+                                               if ((MSG_LOCALE_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) {
+                                                       nameLen = (MSG_LOCALE_FILENAME_LEN_MAX-1) - strlen(pExt);
                                                } else {
                                                        nameLen = strlen(pUTF8Buff) - strlen(pExt);
                                                }
@@ -5241,7 +5110,7 @@ bool _MsgParseParameter(MsgType *pType, char *pSrc)
                                                strncpy(pType->param.szName, pUTF8Buff, nameLen);
                                                strcat (pType->param.szName, pExt);
                                        } else {
-                                               strncpy(pType->param.szName, pUTF8Buff, (MSG_FILENAME_LEN_MAX-1));
+                                               strncpy(pType->param.szName, pUTF8Buff, (MSG_LOCALE_FILENAME_LEN_MAX-1));
                                        }
                                        free(pUTF8Buff);
                                        pUTF8Buff = NULL;
@@ -5435,6 +5304,9 @@ char *MsgConvertLatin2UTF8FileName(char *pSrc)
 
                length = strlen(pSrc);
                utf8BufSize = MsgGetLatin2UTFCodeSize((unsigned char*)pSrc, length);
+               if (utf8BufSize < 3)
+                       utf8BufSize = 3; //min value
+
                pUTF8Buff = (char *)malloc(utf8BufSize + 1);
 
                if (pUTF8Buff == NULL) {
@@ -5476,10 +5348,7 @@ __CATCH:
                free(pUTF8Buff);
                pUTF8Buff = NULL;
        }
-       if (pData) {
-               free(pData);
-               pData = NULL;
-       }
+
        return NULL;
 }
 
@@ -6140,7 +6009,7 @@ bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
        case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE:
        case MIME_MULTIPART_ALTERNATIVE:
 
-               /*
+               /* fixme:
                 * Policy: multipart/alternative
                 * multipart/alternative message has only several parts of media.
                 * You should choose one of them and make the alternative part
@@ -6375,11 +6244,12 @@ bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
 
                if (pSelectedPart == NULL) {
                        MSG_DEBUG("MsgResolveNestedMultipart : MIME_MULTIPART_REPORT [no selected part]\n");
-                       MSG_DEBUG("MsgResolveNestedMultipart : MIME_MULTIPART_REPORT [no selected part]\n");
 
                        pRemoveList = pPartBody->body.pMultipart->pNext;
-                       pSelectedPart = pPartBody->body.pMultipart;
-                       pSelectedPart->pNext = NULL;
+                       if (pPartBody->body.pMultipart != NULL) {
+                               pSelectedPart = pPartBody->body.pMultipart;
+                               pSelectedPart->pNext = NULL;
+                       }
                } else {
                        if (pPrevPart == NULL) {
                                // first part is selected
@@ -6481,10 +6351,6 @@ char *MsgResolveContentURI(char *szSrc)
        return szReturn;
 
 __CATCH:
-       if (szTemp) {
-               free(szTemp);
-               szTemp = NULL;
-       }
 
        return NULL;
 }
@@ -6711,17 +6577,17 @@ bool _MsgParsePartHeader(MsgType *pType, const char *pRawData, int nRawData)
 #endif
                        case MSG_FILED_CONTENT_REPLACE_POS:
                                MsgMIMERemoveQuote(szFieldValue);
-                               strncpy(pType->szContentRepPos, szFieldValue, sizeof(pType->szContentRepPos));
+                               strncpy(pType->szContentRepPos, szFieldValue, sizeof(pType->szContentRepPos) - 1);
                                break;
 
                        case MSG_FILED_CONTENT_REPLACE_SIZE:
                                MsgMIMERemoveQuote(szFieldValue);
-                               strncpy(pType->szContentRepSize, szFieldValue, sizeof(pType->szContentRepSize));
+                               strncpy(pType->szContentRepSize, szFieldValue, sizeof(pType->szContentRepSize) - 1);
                                break;
 
                        case MSG_FILED_CONTENT_REPLACE_INDEX:
                                MsgMIMERemoveQuote(szFieldValue);
-                               strncpy(pType->szContentRepIndex, szFieldValue, sizeof(pType->szContentRepIndex));
+                               strncpy(pType->szContentRepIndex, szFieldValue, sizeof(pType->szContentRepIndex) - 1);
                                break;
 
                        default:
@@ -7938,10 +7804,10 @@ bool _MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *p
        }
 
        if (pPartType->param.szName[0] == '\0' && pPartType->param.szFileName[0] == '\0')
-               strcpy(pPartType->param.szName, pPartType->param.szFileName);
+               snprintf(pPartType->param.szName, sizeof(pPartType->param.szName), "%s", pPartType->param.szFileName);
 
-       if (pPartType->param.szName) {
-               strcpy(szFileName, pPartType->param.szName);
+       if (pPartType->param.szName[0] != '\0') {
+               snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%s", pPartType->param.szName);
        } else {
                snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%lu", (unsigned long)index);
        }
@@ -8152,6 +8018,8 @@ char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msg
                                memcpy(mszTempStr, ((unsigned short*)pTemp + 1), nChar * sizeof(unsigned short));
 
                                nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTemp + 1), nChar);
+                               if (nByte < 3)
+                                       nByte = 3; //min value
 
                                pConvertedStr = (char *)malloc(nByte + 1);
                                if (pConvertedStr != NULL)
index 314f940..2b9b577 100755 (executable)
@@ -281,11 +281,6 @@ static bool __MmsBinaryEncodeMmsVersion2(FILE *pFile)
                goto __CATCH;
        }
 
-       if (majorVer < 1) {
-               MSG_DEBUG("__MmsBinaryEncodeMmsVersion2: invalid major version (%d)\n", majorVer);
-               goto __CATCH;
-       }
-
        if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < 2) {
                if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf2, &gCurMmsEncodeBuffPos2,
                                                                                        gMmsEncodeMaxLen2, &gMmsEncodeCurOffset2) == false) {
@@ -908,6 +903,7 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
                        goto __CATCH;
                }
 
+               /** fixme: Reply-charging-deadline */
                if (pMsg->mmsAttrib.replyCharge.deadLine.time > 0) {
                        if (__MmsBinaryEncodeTime(pFile, MMS_CODE_REPLYCHARGINGDEADLINE, pMsg->mmsAttrib.replyCharge.deadLine) == false) {
                                MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: replyCharging __MmsBinaryEncodeTime fail\n");
@@ -915,6 +911,7 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
                        }
                }
 
+               /** fixme: Reply-charging-size */
                if (pMsg->mmsAttrib.replyCharge.chargeSize > 0) {
                        length = MmsBinaryEncodeIntegerLen(pMsg->mmsAttrib.replyCharge.chargeSize);
 
@@ -934,6 +931,7 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
                        }
                }
 
+               /** fixme: Reply-charging-ID  ----> used only when reply message  */
                if (pMsg->mmsAttrib.replyCharge.szChargeID[0]) {
                        length = MmsBinaryEncodeTextStringLen((UINT8*)pMsg->mmsAttrib.replyCharge.szChargeID);
                        if (length == -1) {
@@ -1017,6 +1015,221 @@ bool MmsBinaryEncodeSendReqHdrContTypeFildCode(FILE *pFile, int msgID)
        return ret;
 }
 
+#if 0
+bool
+_MmsBinaryEncodeForwardReqHdr(FILE* pFile, char* szContentLocation, char* szForwardTo, char* szForwardCc, char* szForwardBcc)
+{
+       int             length  = 0;
+       UINT8   fieldCode = 0xff;
+       UINT8   fieldValue = 0xff;
+       UINT32  date    = 0;
+
+
+       __MmsCleanEncodeBuff();
+
+       /* msgType */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
+       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_FORWARD_REQ) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: msgType error\n");
+               goto __CATCH;
+       }
+
+
+       /* trID (other type of message) */
+       if (__MmsBinaryEncodeTrID(pFile, NULL, 0) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: __MmsBinaryEncodeTrID error\n");
+               goto __CATCH;
+       }
+
+
+       /* MMS version (currently we use 1.0 : VDF Spain's version) */
+       if (__MmsBinaryEncodeMmsVersion(pFile) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: __MmsBinaryEncodeMmsVersion error\n");
+               goto __CATCH;
+       }
+
+
+       /* Date = Long-integer */
+       if (!__MmsBinaryEncodeDate(pFile))
+       {
+                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: __MmsBinaryEncodeDate error\n");
+                       goto __CATCH;
+       }
+
+       /* From : Insert Token mode */
+       if (__MmsBinaryEncodeFrom(pFile) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: __MmsBinaryEncodeFrom fail\n");
+               goto __CATCH;
+       }
+
+
+       /* To = Encoded-string */
+       if (__MmsBinaryEncodeAddress(pFile,
+                                                                 MMS_CODE_TO,
+                                                                 szForwardTo) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: To __MmsBinaryEncodeAddress fail\n");
+               goto __CATCH;
+       }
+
+
+       /* Cc = Encoded-string */
+       if (__MmsBinaryEncodeAddress(pFile,
+                                                                 MMS_CODE_CC,
+                                                                 szForwardCc) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: Cc __MmsBinaryEncodeAddress fail\n");
+               goto __CATCH;
+       }
+
+
+       /* Bcc = Encoded-string */
+       if (__MmsBinaryEncodeAddress(pFile,
+                                                                 MMS_CODE_BCC,
+                                                                 szForwardBcc) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: Bcc __MmsBinaryEncodeAddress fail\n");
+               goto __CATCH;
+       }
+
+
+       /* Expiry Time  : Value-length Absolute-token Date-value */
+       if (gMmsSetup.sendSetup.bExpiryUseCustomTime == true) //jhlee expiry time use custom time
+       {
+               if (__MmsBinaryEncodeTime(pFile,
+                                                          MMS_CODE_EXPIRYTIME,
+                                                          gMmsSetup.sendSetup.expiryCustomTime) == false)
+               {
+                       MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: expiryTime __MmsBinaryEncodeTime fail\n");
+                       goto __CATCH;
+               }
+       }
+       else
+       {
+               if (__MmsBinaryEncodeTime(pFile,
+                                                          MMS_CODE_EXPIRYTIME,
+                                                          gMmsSetup.sendSetup.expiryTime) == false)
+               {
+                       MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: expiryTime __MmsBinaryEncodeTime fail\n");
+                       goto __CATCH;
+               }
+
+       }
+
+
+       /* Delivery Time  : Value-length Absolute-token Date-value */
+       if (__MmsBinaryEncodeTime(pFile,
+                                                          MMS_CODE_DELIVERYTIME,
+                                                          gMmsSetup.sendSetup.deliveryTime) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: deliveryTime __MmsBinaryEncodeTime fail\n");
+               goto __CATCH;
+       }
+
+
+       /* Report Allowed */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80;
+       if (gMmsSetup.recvSetup.bSendDeliveryReport)
+               fieldValue  = _MmsGetBinaryValue(MmsCodeReportAllowed,
+                                                                                 MMS_REPORTALLOWED_YES) | 0x80;
+       else
+               fieldValue  = _MmsGetBinaryValue(MmsCodeReportAllowed,
+                                                                                 MMS_REPORTALLOWED_NO) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: Report Allowed error\n");
+               goto __CATCH;
+       }
+
+
+       /* Delivery Report */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT) | 0x80;
+       if (gMmsSetup.recvSetup.bSendDeliveryReport)
+               fieldValue  = _MmsGetBinaryValue(MmsCodeDeliveryReport,
+                                                                                 MMS_REPORT_YES) | 0x80;
+       else
+               fieldValue  = _MmsGetBinaryValue(MmsCodeDeliveryReport,
+                                                                                 MMS_REPORT_NO) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: Report Allowed error\n");
+               goto __CATCH;
+       }
+
+
+       /* Read Reply */
+       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY) | 0x80;
+       if (gMmsSetup.recvSetup.bSendDeliveryReport)
+               fieldValue  = _MmsGetBinaryValue(MmsCodeReadReply,
+                                                                                 MMS_REPORT_YES) | 0x80;
+       else
+               fieldValue  = _MmsGetBinaryValue(MmsCodeReadReply,
+                                                                                 MMS_REPORT_NO) | 0x80;
+       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: Read Reply error\n");
+               goto __CATCH;
+       }
+
+
+       /* Content Location */
+       if (szContentLocation[0])
+       {
+               length = MmsBinaryEncodeTextStringLen((UINT8*)szContentLocation);
+               if (length == -1)
+               {
+                       MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: szContentLocation MmsBinaryEncodeTextStringLen fail\n");
+                       goto __CATCH;
+               }
+
+               if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1))   // + fieldCode
+               {
+                       if (MsgWriteDataFromEncodeBuffer(pFile,
+                                                               gpMmsEncodeBuf,
+                                                               &gCurMmsEncodeBuffPos,
+                                                               gMmsEncodeMaxLen,
+                                                               &gMmsEncodeCurOffset) == false)
+                       {
+                               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: MsgWriteDataFromEncodeBuffer fail \n");
+                               goto __CATCH;
+                       }
+               }
+
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode,
+                                                                                                                                         MMS_CODE_CONTENTLOCATION) | 0x80;
+               if (MmsBinaryEncodeTextString(pFile, (UINT8*)szContentLocation, length) == false)
+               {
+                       MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: szContentLocation MmsBinaryEncodeTextString fail\n");
+                       goto __CATCH;
+               }
+       }
+
+       /* flush remained data on encoding file */
+       if (MsgWriteDataFromEncodeBuffer(pFile,
+                                                 gpMmsEncodeBuf,
+                                                 &gCurMmsEncodeBuffPos,
+                                                 gMmsEncodeMaxLen,
+                                                 &gMmsEncodeCurOffset) == false)
+       {
+               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: remained data MsgWriteDataFromEncodeBuffer fail \n");
+               goto __CATCH;
+       }
+
+       return true;
+
+__CATCH:
+
+       MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset);
+       return false;
+}
+#endif
+
+
 bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus)
 {
        int length      = 0;
@@ -1166,6 +1379,10 @@ bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_
                goto __CATCH;
        }
 
+       /* fixme: msgContentType */
+       /* fixme: msgHeader */
+       /* fixme: msgBody */
+
        /* flush remained data on encoding file */
        if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
                                                                                gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
@@ -1844,7 +2061,7 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
                }
 
                /* start = Text-string ----------------------- */
-               if (pType->param.szStart && pType->param.szStart[0]) {
+               if (pType->param.szStart[0]) {
                        /* start = Text-string */
                        length  = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStart);
                        if (length == -1) {
@@ -2874,7 +3091,7 @@ static bool MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length)
                goto __CATCH;
        }
 
-       /* Write charset on buffer -> integer value not long-integer */
+       /* fixme: Write charset on buffer -> integer value not long-integer */
        if (MmsBinaryEncodeInteger(pFile, charset, charLeng) == false) {
                MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeInteger fail.\n");
                goto __CATCH;
@@ -3035,11 +3252,6 @@ static bool __MmsBinaryEncodeMmsVersion(FILE *pFile)
                goto __CATCH;
        }
 
-       if (majorVer < 1) {
-               MSG_DEBUG("__MmsBinaryEncodeMmsVersion: invalid major version (%d)\n", majorVer);
-               goto __CATCH;
-       }
-
        if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 2) {
                if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
                                                                                gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
index 9caddf1..4b428ca 100755 (executable)
@@ -76,7 +76,8 @@ void MmsPluginEventHandler::handleMmsReceivedData(mmsTranQEntity *pRequest, char
                listener.pfMmsConfIncomingCb(&msgInfo, &pRequest->reqID);
 
                //MsgDeleteFile(pRetrievedFilePath + strlen(MSG_DATA_PATH)); // not ipc
-               remove(pRetrievedFilePath); // not ipc
+               if (remove(pRetrievedFilePath) != 0)
+                       MSG_DEBUG("remove fail");
                break;
 
        // received data is retrieve-conf
@@ -93,7 +94,8 @@ void MmsPluginEventHandler::handleMmsReceivedData(mmsTranQEntity *pRequest, char
                break;
 
        case eMMS_READREPORT_CONF:
-               remove(pRetrievedFilePath);
+               if (remove(pRetrievedFilePath) != 0)
+                       MSG_DEBUG("remove fail");
                break;
        default:
                break;
index a396728..ad6b731 100755 (executable)
@@ -103,6 +103,7 @@ static void __http_print_profile(CURL *curl)
 
        curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT, &port);
        MSG_DEBUG("profile http local: port %ld", port);
+
        MSG_DEBUG("**************************************************************************************************");
 }
 
@@ -111,7 +112,6 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int
        char szBuffer[1025] = {0, };
        char pcheader[HTTP_REQUEST_LEN] = {0, };
 
-
        bool nResult = __httpGetHeaderField(MMS_HH_CONTENT_TYPE, szBuffer);
        if (nResult) {
                snprintf(pcheader, HTTP_REQUEST_LEN, "Content-Type: %s", szBuffer);
@@ -312,16 +312,32 @@ static MMS_NET_ERROR_T __httpReceiveData(void *ptr, size_t size, size_t nmemb, v
                if (pMmsPlgCd->final_content_buf == NULL) {
                        MSG_DEBUG("Body Lenghth Read = %d", length_received);
                        pMmsPlgCd->final_content_buf = (unsigned char *)malloc((length_received + 1) * sizeof(unsigned char));
+
+                       if (pMmsPlgCd->final_content_buf == NULL) {
+                               MSG_DEBUG("malloc fail");
+                               return eMMS_HTTP_EVENT_RECV_DATA_ERROR;
+                       }
+
                        memset(pMmsPlgCd->final_content_buf,0x0,((length_received + 1) * sizeof(unsigned char)));
                        MSG_DEBUG(" Global g_final_content_buf=%0x", pMmsPlgCd->final_content_buf);
                } else {
                        //realloc pHttpEvent->bodyLen extra and memset
-                       pMmsPlgCd->final_content_buf = (unsigned char *)realloc(pMmsPlgCd->final_content_buf,
+
+                       unsigned char * buf = (unsigned char *)realloc(pMmsPlgCd->final_content_buf,
                                        (pMmsPlgCd->bufOffset + length_received + 1) * sizeof(unsigned char));
+
+                       if (buf == NULL) {
+                               MSG_DEBUG("realloc fail");
+                               return eMMS_HTTP_EVENT_RECV_DATA_ERROR;
+                       }
+
+                       pMmsPlgCd->final_content_buf = buf;
                        MSG_DEBUG("Body Lenghth Read = %d Content Length = %d", length_received, pMmsPlgCd->bufOffset);
                        memset((pMmsPlgCd->final_content_buf +pMmsPlgCd->bufOffset), 0x0,
                                        ((length_received + 1) * sizeof(unsigned char)));
                        MSG_DEBUG(" Global g_final_content_buf=%0x", pMmsPlgCd->final_content_buf);
+
+
                }
 
                //copy body
index e4c2dc9..262b089 100755 (executable)
@@ -262,7 +262,6 @@ void MmsPluginInternal::processDeliveryInd(MSG_MESSAGE_INFO_S *pMsgInfo)
        pMsgInfo->dataSize = 0;
        memset(pMsgInfo->msgData, 0x00, MAX_MSG_DATA_LEN + 1);
 
-
        strncpy(pMsgInfo->msgData, getMmsDeliveryStatus(status.msgStatus), MAX_MSG_DATA_LEN);
        pMsgInfo->dataSize  = strlen(pMsgInfo->msgData);
        MSG_DEBUG("Delivery Status = %s", pMsgInfo->msgData);
@@ -278,8 +277,6 @@ void MmsPluginInternal::processDeliveryInd(MSG_MESSAGE_INFO_S *pMsgInfo)
 
                pMsgInfo->msgId = (msg_message_id_t)tmpId;
 
-               MmsPluginStorage::instance()->addMmsNoti(pMsgInfo);
-
        } else {
                MSG_DEBUG("Can not find MMS message in DB");
        }
@@ -322,7 +319,6 @@ void MmsPluginInternal::processReadOrgInd(MSG_MESSAGE_INFO_S *pMsgInfo)
                Status.readStatus = mmsHeader.readStatus;
 
                MmsPluginStorage::instance()->insertReadReport(pMsgInfo->msgId, mmsHeader.pFrom->szAddr, &Status);
-               MmsPluginStorage::instance()->addMmsNoti(pMsgInfo);
 
        } else {
                MSG_DEBUG("Can't not find Message!");
@@ -458,7 +454,10 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
 
                snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s%s", MSG_IPC_DATA_PATH, filename + 1);
 
-               rename(pRetrievedFilePath, fullPath);
+               int ret  = rename(pRetrievedFilePath, fullPath);
+               if (ret != 0) {
+                       MSG_DEBUG("File rename Error: %s", strerror(errno));
+               }
 
                if (chmod(fullPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) != 0) {
                        MSG_DEBUG("File Write Error: %s", strerror(errno));
@@ -496,12 +495,12 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
 
                pSmilDoc = MmsSmilGetPresentationData(pMsgInfo->msgId);
                MmsSmilParseSmilDoc(&msgData, pSmilDoc);
+               MmsRemovePims(&msgData);
 
                MmsPluginStorage::instance()->getMmsMessage(&pMsg);
                strcpy(szFileName, pMsg->szFileName);
 
                err = pStorage->getMsgText(&msgData, pMsgInfo->msgText);
-               MmsMakePreviewInfo(pMsgInfo->msgId, &msgData);
                bMultipartRelated = true;
        } else {
                MSG_DEBUG("Multipart mixed message doesn't support mms conversation");
@@ -526,11 +525,31 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
 
                                strcpy((char *)szBuf, partHeader.param.szFileName);
                                sprintf(partHeader.param.szFileName, MSG_DATA_PATH"%s", szBuf);
-                               if (!bMultipartRelated || MmsCheckAdditionalMedia(&msgData, &partHeader))
+                               if (!bMultipartRelated || MmsCheckAdditionalMedia(&msgData, &partHeader)) {
+                                       MMS_ATTACH_S *attachment = NULL;
+                                       int tempType;
+
+                                       attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1);
+
+                                       MsgGetTypeByFileName(&tempType, partHeader.param.szFileName);
+                                       attachment->mediatype = (MimeType)tempType;
+
+                                       strcpy(attachment->szFilePath, partHeader.param.szFileName);
+
+                                       strncpy(attachment->szFileName, partHeader.param.szName, MSG_FILENAME_LEN_MAX - 1);
+
+                                       attachment->fileSize = partHeader.contentSize;
+
+                                       _MsgMmsAddAttachment(&msgData, attachment);
                                        attachCount++;
+
+                               }
+
                        }
                }
        }
+
+       MmsMakePreviewInfo(pMsgInfo->msgId, &msgData);
        MSG_DEBUG("attachCount [%d]", attachCount);
        err = pStorage->updateMmsAttachCount(pMsgInfo->msgId, attachCount);
 
index 02796d2..bb0fe73 100755 (executable)
@@ -188,6 +188,7 @@ static const MimeTable mimeTable[] = {
        {"application/vnd.smaf",                                                                "mmf",                          true,           MIME_APPLICATION_VND_SMAF,                                              MIME_APPLICATION_X_SMAF,                                MIME_APPLICATION_SOUNDPLAYER,                   MIME_MAINTYPE_AUDIO,            UNDEFINED_BINARY        },
        {"application/vnd.rn-realmedia",                                                "rm",                           true,           MIME_APPLICATION_VND_RN_REALMEDIA,                              MIME_APPLICATION_VND_RN_REALMEDIA,              MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
        {"application/vnd.sun.j2me.java-archive",                               "jar",                          true,           MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE,             MIME_APPLICATION_JAVA_ARCHIVE,                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
+       {"application/vnd.samsung.theme",                                               "thm",                          true,           MIME_APPLICATION_VND_SAMSUNG_THEME,                             MIME_APPLICATION_VND_SAMSUNG_THEME,             MIME_APPLICATION_THEMEVIEWER,                   MIME_MAINTYPE_THEME,            UNDEFINED_BINARY        },
        {"application/vnd.ms-excel",                                                    "xls",                          true,           MIME_APPLICATION_VND_EXCEL,                                             MIME_APPLICATION_X_EXCEL,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
        {"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        },
@@ -272,11 +273,16 @@ static const MimeTable mimeTable[] = {
 
        //116
        {"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
        {"image/x-bmp",                                                                         "bmp",                          false,          MIME_IMAGE_X_BMP,                                                               MIME_IMAGE_BMP,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            UNDEFINED_BINARY        },
 
+       // 120
        {"message/rfc822",                                                                              "elm",                          false,          MIME_MESSAGE_RFC822,                                                    MIME_MESSAGE_RFC822,                                    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_MESSAGE,          UNDEFINED_BINARY        },
 
+       //121
        {"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    },
@@ -405,6 +411,7 @@ static const ExtTable extTable[] = {
        {"dcf",                 MIME_APPLICATION_VND_OMA_DRM_CONTENT},
        {"rv",                          MIME_VIDEO_X_PN_REALVIDEO},
        {"ro",                          MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML},
+       {"thm",                 MIME_APPLICATION_VND_SAMSUNG_THEME},
        {"xls",                 MIME_APPLICATION_X_EXCEL},
        {"pdf",                 MIME_APPLICATION_PDF},
        {"ppt",                 MIME_APPLICATION_X_POWERPOINT},
@@ -472,6 +479,7 @@ static int mimeTableEnum[] =
        MIME_APPLICATION_VND_SMAF       ,
        MIME_APPLICATION_VND_RN_REALMEDIA       ,
        MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE      ,
+       MIME_APPLICATION_VND_SAMSUNG_THEME      ,
        MIME_APPLICATION_VND_EXCEL      ,
        MIME_APPLICATION_VND_POWERPOINT,
        MIME_APPLICATION_VND_MSWORD,
@@ -553,6 +561,8 @@ static int mimeTableEnum[] =
        MIME_IMAGE_SVG  ,
        MIME_IMAGE_SVG1 ,
        MIME_IMAGE_VND_WAP_WBMP ,
+       MIME_IMAGE_VND_TMO_GIF,
+       MIME_IMAGE_VND_TMO_JPG,
        MIME_IMAGE_X_BMP        ,
 
 
index b9e980a..a61285b 100755 (executable)
@@ -391,11 +391,6 @@ bool MmsInsertPartFromFile(MmsMsg *pMsg, char *szTitleName, char *szOrgFilePath,
 
                if (MmsIsText(pMsg->msgType.type) == true) {
                        pMsg->msgType.param.charset = MSG_CHARSET_UTF8;
-                       if (pMultipart)
-                               pMultipart->type.encoding       = MSG_ENCODING_8BIT;
-               } else {
-                       if (pMultipart)
-                               pMultipart->type.encoding       = MSG_ENCODING_BINARY;
                }
 
                strncpy(pMsg->msgBody.szOrgFilePath, szOrgFilePath, MSG_FILEPATH_LEN_MAX - 1);
@@ -508,7 +503,7 @@ MsgMultipart *MmsAllocMultipart(void)
 
        pMultipart->pBody = (MsgBody *)malloc(sizeof(MsgBody));
 
-       if (pMultipart == NULL)
+       if (pMultipart->pBody == NULL)
                goto __CATCH;
 
        MmsInitMsgType(&pMultipart->type);
@@ -777,7 +772,7 @@ bool MmsComposeMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDIN
        time(&RawTime);
        timeInfo = localtime(&RawTime);
        nTimeInSecs = mktime(timeInfo);
-       pMmsMsg->mmsAttrib.date = nTimeInSecs;
+       pMmsMsg->mmsAttrib.date = nTimeInSecs;  // todo: need to subtract timeline value to make GMT+0 time
 
        //setting subject
        strcpy(pMmsMsg->mmsAttrib.szSubject, pMsgInfo->subject);
@@ -878,8 +873,10 @@ bool MmsComposeMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDIN
        for (int i = 0; i < _MsgMmsGetAttachCount(pMsgData); ++i) {
                MMS_ATTACH_S *pMedia = _MsgMmsGetAttachment(pMsgData, i);
                if (pMedia->szFilePath[0] != 0) {
-                       if (!MmsInsertPartFromFile(pMmsMsg, pMedia->szFileName, pMedia->szFilePath, NULL))
+                       if (!MmsInsertPartFromFile(pMmsMsg, pMedia->szFileName, pMedia->szFilePath, NULL)) {
+                               free(pMedia);
                                return false;
+                       }
                }
        }
 
index 8cd19b6..f4d8adf 100755 (executable)
@@ -333,6 +333,10 @@ void MmsSmilGetElement(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node)
                                        else
                                                pMedia->sMedia.sAVI.nDurTime =  MmsSmilGetTime((char *)pAttr->children->content);
 
+#ifdef MMS_SMIL_ANIMATE
+                                       if (cmd[ELEMENT_ANIMATE])
+                                               pMedia->sMedia.sAVI.nDur = MmsSmilGetTime((char *)pAttr->children->content);
+#endif
                                        break;
 
                                case ATTRIBUTE_SRC:
@@ -345,6 +349,8 @@ void MmsSmilGetElement(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node)
                                                MmsMsg *pMsg;
 
                                                szSrc = MsgChangeHexString((char *)pAttr->children->content);
+                                               if (szSrc == NULL)
+                                                       break;
 
                                                memcpy(pMedia->szSrc, szSrc, strlen(szSrc) + 1);
                                                free(szSrc);
@@ -519,6 +525,39 @@ void MmsSmilGetElement(MMS_MESSAGE_DATA_S *pMmsMsg, xmlNode *a_node)
                                case ATTRIBUTE_CONTENT:
                                        strncpy(pMeta->szContent, (char *)pAttr->children->content, MAX_SMIL_META_CONTENT - 1);
                                        break;
+#ifdef MMS_SMIL_ANIMATE
+                               case ATTRIBUTE_ATTRIBUTE_NAME:
+                                       strcpy(pMedia->sMedia.sAVI.nAttributeName, (char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_ATTRIBUTE_TYPE:
+                                       strcpy(pMedia->sMedia.sAVI.nAttributeType, (char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_TARGET_ELEMENT:
+                                       strcpy(pMedia->sMedia.sAVI.nTargetElement, (char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_FROM:
+                                       pMedia->sMedia.sAVI.nFrom = atoi((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_TO:
+                                       pMedia->sMedia.sAVI.nTo = atoi((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_BY:
+                                       pMedia->sMedia.sAVI.nBy = atoi((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_VALUES:
+                                       pMedia->sMedia.sAVI.nValues = atoi((char *)pAttr->children->content);
+                                       break;
+
+                               case ATTRIBUTE_CALCMODE:
+                                       strcpy(pMedia->sMedia.sAVI.nCalcMode, (char *)pAttr->children->content);
+                                       break;
+#endif
                                default:
                                        MSG_DEBUG("Undefined Attribute was found!!!!!");
                                }
@@ -930,6 +969,24 @@ int        MmsSmilGetAttrID(char *pString)
                return ATTRIBUTE_END;
        else if (!strcmp(pString, "repeatCount"))
                return ATTRIBUTE_REPEAT_COUNT;
+#ifdef MMS_SMIL_ANIMATE
+       else if (!strcmp(pString, "attributeName"))
+               return ATTRIBUTE_ATTRIBUTE_NAME;
+       else if (!strcmp(pString, "attributeType"))
+               return ATTRIBUTE_ATTRIBUTE_TYPE;
+       else if (!strcmp(pString, "targetElement"))
+               return ATTRIBUTE_TARGET_ELEMENT;
+       else if (!strcmp(pString, "from"))
+               return ATTRIBUTE_FROM;
+       else if (!strcmp(pString, "to"))
+               return ATTRIBUTE_TO;
+       else if (!strcmp(pString, "by"))
+               return ATTRIBUTE_BY;
+       else if (!strcmp(pString, "values"))
+               return ATTRIBUTE_VALUES;
+       else if (!strcmp(pString, "calcMode"))
+               return ATTRIBUTE_CALCMODE;
+#endif
        else
                return -1;
 }
@@ -1877,7 +1934,7 @@ xmlNode *__MmsCreateMMNode(MMS_MEDIA_S *pstSmilMedia, char *pszContentID)
                return NULL;
        }
 
-       if (pstSmilMedia) {
+       if (pstMedia) {
                char szFilePathWithCid[MMS_CONTENT_ID_LEN + 5];         // for "cid:"
 
                MSG_DEBUG("[Set Attribute] Region Id ");
index 57ba4bc..9d58de9 100755 (executable)
@@ -157,7 +157,10 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                int size = 0;
 
                snprintf((char *)filepath, MSG_FILEPATH_LEN_MAX+1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
-               MsgGetFileSize(filepath, &size);
+               if (MsgGetFileSize(filepath, &size) == false) {
+                       THROW(MsgException::MMS_PLG_ERROR, "MMS Message MsgGetFileSize Error");
+               }
+
                pMsgInfo->dataSize = size;
 
                _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
@@ -517,8 +520,16 @@ msg_error_t        MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN
                        MmsDrm2SetConvertState(MMS_DRM2_CONVERT_FINISH);
 
                        if (bRetToConvert) {
-                               remove(mmsHeader.msgType.szOrgFilePath);
-                               rename(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, mmsHeader.msgType.szOrgFilePath);
+                               int ret;
+                               ret = remove(mmsHeader.msgType.szOrgFilePath);
+                               if (ret != 0) {
+                                       MSG_DEBUG("remove fail\n");
+                               }
+
+                               ret = rename(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, mmsHeader.msgType.szOrgFilePath);
+                               if (ret != 0) {
+                                       MSG_DEBUG("rename fail\n");
+                               }
 
                                if (MmsDrm2ReadMsgConvertedBody(pMsg, true, false, NULL) == false) {
                                        MSG_DEBUG("MmsLoadMsg:MmsDrm2ReadMsgConvertedBody() returns false\n");
@@ -612,9 +623,6 @@ msg_error_t MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN
 
        pMsg->dataSize = nSize;
 
-       if (err != MSG_SUCCESS)
-               MSG_DEBUG("MmsPlgUpdateMessage : Update MMS Message Failed");
-
        MSG_END();
 
        return err;
@@ -625,6 +633,7 @@ FREE_CATCH:
        }
 
 L_CATCH:
+       MSG_DEBUG("MmsPlgUpdateMessage : Update MMS Message Failed");
        MSG_END();
        {
                MmsMsg *pMsg;
@@ -1176,7 +1185,7 @@ msg_error_t MmsPluginStorage::getMsgText(MMS_MESSAGE_DATA_S *pMmsMsg, char *pMsg
                for (int j = 0; j < pPage->mediaCnt; ++j) {
                        pMedia = _MsgMmsGetMedia(pPage, j);
 
-                       if (pMedia->mediatype == MMS_SMIL_MEDIA_TEXT && pMedia->szFilePath != NULL) {
+                       if (pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) {
                                pMmsMsgText = MsgOpenAndReadMmsFile(pMedia->szFilePath, 0, -1, &textLen);
                                if (pMmsMsgText)
                                        strncpy(pMsgText, pMmsMsgText, MAX_MSG_TEXT_LEN);
@@ -1230,19 +1239,6 @@ msg_error_t MmsPluginStorage::insertPreviewInfo(int msgId, int type, char *value
        return MSG_SUCCESS;
 }
 
-msg_error_t MmsPluginStorage::addMmsNoti(MSG_MESSAGE_INFO_S *pMsgInfo)
-{
-       MSG_BEGIN();
-
-       msg_error_t     err = MSG_SUCCESS;
-
-       err = MsgInsertMmsReportToNoti(&dbHandle, pMsgInfo);
-
-       MSG_END();
-
-       return err;
-}
-
 /* This API is not used anywhere now */
 msg_error_t    MmsPluginStorage::plgGetRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg, char *filePath)
 {
@@ -1268,8 +1264,16 @@ msg_error_t      MmsPluginStorage::plgGetRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG
                        MmsDrm2SetConvertState(MMS_DRM2_CONVERT_FINISH);
 
                        if (bRetToConvert) {
-                               remove(mmsHeader.msgType.szOrgFilePath);
-                               rename(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, mmsHeader.msgType.szOrgFilePath);
+                               int ret;
+                               ret = remove(mmsHeader.msgType.szOrgFilePath);
+                               if (ret != 0) {
+                                       MSG_DEBUG("remove fail\n");
+                               }
+
+                               ret = rename(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, mmsHeader.msgType.szOrgFilePath);
+                               if (ret != 0) {
+                                       MSG_DEBUG("rename fail\n");
+                               }
 
                                if (MmsDrm2ReadMsgConvertedBody(pMsg, true, false, NULL) == false) {
                                        MSG_DEBUG("MmsLoadMsg:MmsDrm2ReadMsgConvertedBody() returns false\n");
@@ -1360,10 +1364,6 @@ msg_error_t      MmsPluginStorage::plgGetRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG
 
 
        pMsg->dataSize = nSize;
-
-       if (err != MSG_SUCCESS)
-               MSG_DEBUG("MmsPlgUpdateMessage : Update MMS Message Failed");
-
        MSG_END();
 
        return err;
@@ -1375,6 +1375,7 @@ FREE_CATCH:
        }
 
 L_CATCH:
+       MSG_DEBUG("MmsPlgUpdateMessage : Update MMS Message Failed");
        MSG_END();
        {
                MmsMsg *pMsg;
diff --git a/plugin/mms_plugin/MmsPluginTextConvert.cpp b/plugin/mms_plugin/MmsPluginTextConvert.cpp
new file mode 100755 (executable)
index 0000000..3980b50
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 <glib.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "MmsPluginMIME.h"
+#include "MmsPluginCodec.h"
+#include "MmsPluginTextConvert.h"
+#include "MsgDebug.h"
+#include "MmsPluginUtil.h"
+
+const char *MmsPluginTextConvertGetCharSet(int MIBEnum)
+{
+       const char * result_str = NULL;
+
+       result_str = MmsGetTextByCode(MmsCodeCharSet, (unsigned short int)MIBEnum);
+       MSG_DEBUG("[MIBEnum = %d, Charset = %s]", MIBEnum, result_str);
+
+       return result_str;
+}
+
+bool MmsPluginTextConvert(const char *pToCodeSet, const char *pFromCodeset, const char *pSrc, int srcLen, char **ppDest, int *pDestLen)
+{
+       char *pDest = NULL;
+       gsize bytes_read = 0;
+       gsize bytes_written = 0;
+       GError *error = NULL;
+
+       if (pToCodeSet == NULL || pFromCodeset == NULL) {
+               MSG_DEBUG("Error input parameter Codeset to = %s, from = %s", pToCodeSet, pFromCodeset);
+               goto __CATCH;
+       }
+
+       MSG_DEBUG("Codeset to = %s, from = %s", pToCodeSet, pFromCodeset);
+
+       if (pSrc == NULL || ppDest == NULL || pDestLen == NULL) {
+               MSG_DEBUG("Error input parameter pSrc = %p, ppDest = %p, pDestLen = %p", pSrc, ppDest, pDestLen);
+               goto __CATCH;
+       }
+
+       pDest = g_convert (pSrc, srcLen,
+                       pToCodeSet, pFromCodeset,
+              &bytes_read, &bytes_written,
+              &error);
+
+       if (error != NULL) {
+               printf("Error in g_convert, GError = %d:%s, pSrc = %s\n", error->code, error->message, pSrc);
+               goto __CATCH;
+       }
+
+       if (pDest == NULL || bytes_written == 0 || bytes_read == 0) {
+               printf("Error in g_convert, pDest = %s, bytes_written = %d, bytes_read = %d\n", pDest, bytes_written, bytes_read);
+               goto __CATCH;
+       }
+
+       *ppDest = pDest;
+       *pDestLen = bytes_written;
+
+       return true;
+
+__CATCH:
+       if (pDest)
+               g_free(pDest);
+
+       return false;
+}
index 3379751..96b1d5b 100755 (executable)
@@ -80,14 +80,18 @@ void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo)
                break;
 
        case MSG_NOTIFYRESPIND_MMS:
+       {
                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);
-               remove(pReqInfo->msgInfo.msgData);
+               int ret = remove(pReqInfo->msgInfo.msgData);
+               if (ret != 0) {
+                       MSG_DEBUG("remove fail\n");
+               }
                break;
-
+       }
        case MSG_RETRIEVE_MMS:
                MSG_DEBUG("######### MANUAL RETRIEVE : GET TRANSACTION");
                reqItem.msgId = pReqInfo->msgInfo.msgId;
@@ -99,25 +103,33 @@ void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo)
                break;
 
        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(pReqInfo->msgInfo.msgData);
+               int ret = remove(pReqInfo->msgInfo.msgData);
+               if (ret != 0) {
+                       MSG_DEBUG("remove fail\n");
+               }
                break;
-
+       }
        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(pReqInfo->msgInfo.msgData);
+               int ret = remove(pReqInfo->msgInfo.msgData);
+               if (ret != 0) {
+                       MSG_DEBUG("remove fail\n");
+               }
                break;
-
+       }
        case MSG_FORWARD_MMS:
                MSG_DEBUG("######### SEND FORWARD MSG : POST TRANSACTION");
                reqItem.msgId = pReqInfo->msgInfo.msgId;
index 0f60d01..7851ff6 100755 (executable)
@@ -619,8 +619,18 @@ bool MmsPluginUaManager::processReceivedData(int msgId, char *pRcvdBody, int rcv
                        MmsDrm2SetConvertState(MMS_DRM2_CONVERT_FINISH);
 
                        if (bRetToConvert) {
-                               remove(mmsHeader.msgType.szOrgFilePath);
-                               rename(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, mmsHeader.msgType.szOrgFilePath);
+                               int ret;
+                               ret = remove(mmsHeader.msgType.szOrgFilePath);
+                               if (ret != 0) {
+                                       MSG_DEBUG("remove fail\n");
+                                       goto ERR_MMS_UA_PROCESS_CONF;
+                               }
+
+                               ret = rename(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, mmsHeader.msgType.szOrgFilePath);
+                               if (ret != 0) {
+                                       MSG_DEBUG("rename fail\n");
+                                       goto ERR_MMS_UA_PROCESS_CONF;
+                               }
 
                                if (MmsDrm2ReadMsgConvertedBody(&pMsg, true, true, retrievedFilePath) == false) {
                                        MSG_DEBUG("MmsLoadMsg:MmsDrm2ReadMsgConvertedBody() returns false\n");
index cc83b9f..819ccf4 100755 (executable)
@@ -56,9 +56,14 @@ bool makeVideoThumbnail(char *srcPath, char *dstPath)
                return false;
        }
 
-       mm_file_create_content_attrs(&content_attrs, srcPath);
-       fileRet = mm_file_get_attrs(content_attrs, &err_attr_name, MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &trackCount, NULL);
+       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_DEBUG("mm_file_get_attrs fails [%s]", err_attr_name);
 
index 920a231..8bf279f 100755 (executable)
@@ -69,11 +69,12 @@ class MmsPluginHttpAgent
 #define MSG_MMS_HH_LANGUAGE         "zh-cn, en"
 #define MSG_MMS_HH_ENCODING         "deflate,gzip"
 
-#define MSG_MMS_HH_USER_AGENT          "Tizen", "Mozilla/5.0 (Linux; U; Tizen 1.0; en-us) AppleWebKit/534.46 (KHTML, like Gecko) Mobile Tizen Browser/1.0"
+#define MSG_MMS_HH_USER_AGENT          "Mozilla/5.0 (Linux; U; Tizen 1.0; en-us) AppleWebKit/534.46 (KHTML, like Gecko) Mobile Tizen Browser/1.0"
 #define MSG_MMS_WAP_PROFILE         ""
 
 typedef unsigned int MMS_HTTP_HEADER_FIELD_T;
 
+
 enum _MMS_HTTP_HEADER_FIELD_E {
        MMS_HH_CONTENT_TYPE,
        MMS_HH_HOST,
index ff0abf9..10ef8ff 100755 (executable)
@@ -159,7 +159,7 @@ typedef enum {
 typedef enum {
        MMS_MSGSTATUS_NONE = -1,        // backward compatibility
        MMS_MSGSTATUS_ERROR = -1,       // error return in Get method
-       MMS_MSGSTATUS_EXPIRED = 0,
+       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,
@@ -173,7 +173,7 @@ typedef enum {
 typedef        enum {
        MMS_READSTATUS_NONE = -1,                       // no touch status
        MMS_IS_READ = 0,
-       MMS_IS_DELETED = 1
+       MMS_IS_DELETED = 1      // Deleted without being read
 } MmsReadStatus;
 
 
index 02bf1f6..7b1c9f9 100755 (executable)
@@ -68,7 +68,6 @@ public:
 
        MmsMsgMultiStatus *getMultiStatus(msg_message_id_t msgId);
        msg_error_t getMsgText(MMS_MESSAGE_DATA_S *pMmsMsg, char *pMsgText);
-       msg_error_t addMmsNoti(MSG_MESSAGE_INFO_S *pMsgInfo);
 
 private:
        msg_error_t addMmsMsgToDB(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, int attachCnt = 0);
diff --git a/plugin/mms_plugin/include/MmsPluginTextConvert.h b/plugin/mms_plugin/include/MmsPluginTextConvert.h
new file mode 100755 (executable)
index 0000000..a63e0c5
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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_TEXT_CONVERT_H
+#define MMS_PLUGIN_TEXT_CONVERT_H
+
+#include <glib.h>
+
+const char *MmsPluginTextConvertGetCharSet(int MIBEnum);
+
+bool MmsPluginTextConvert(const char *pToCodeSet, const char *pFromCodeSet, const char *pSrc, int srcLen, char **ppDest, int *pDestLen);
+
+#endif
index 26b62fc..03909e9 100755 (executable)
@@ -273,7 +273,6 @@ typedef enum {
 
 #define DEFAULT_MMSC_URL               NOW_MMSC_URL
 #define DEFAULT_MMSC_IP                NOW_MMSC_IP
-#define DEFAULT_MMSC_PORT
 #define DEFAULT_HTTP_PROXY     NOW_MMSC_PROXY
 #define DEFAULT_HTTP_PROXY_PORT        NOW_MMSC_PROXY_PORT
 
index 564488c..e6a8f0d 100755 (executable)
@@ -40,7 +40,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 drm-client dlog vconf)
+pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 drm-client dlog vconf dbus-glib-1)
 
 FOREACH(flag ${sms_plugin_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index ca8ba50..c7e0b0f 100755 (executable)
@@ -96,6 +96,7 @@ void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, v
        TelSmsDatapackageInfo_t* pDataPackage = (TelSmsDatapackageInfo_t*)data;
 
        SMS_TPDU_S tpdu;
+       memset(&tpdu, 0x00, sizeof(SMS_TPDU_S));
 
        // Decode Incoming Message
        SmsPluginTpduCodec::decodeTpdu(pDataPackage->szData, pDataPackage->MsgLength, &tpdu);
@@ -149,14 +150,26 @@ void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, v
        {
                if (tpdu.tpduType == SMS_TPDU_DELIVER)
                {
-                       if (SmsPluginConcatHandler::instance()->IsConcatMsg(&(tpdu.data.deliver.userData)) == true ||
-                               SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(tpdu.data.deliver.userData)) == true)
-                       {
-                               SmsPluginConcatHandler::instance()->handleConcatMsg(&tpdu); // Call Concat Msg Handler
+                       if (tpdu.data.deliver.dcs.msgClass == SMS_MSG_CLASS_2) {
+                               // For GCF test, 34.2.5.3
+                               SmsPluginSimMsg::instance()->setSmsData((const char*)pDataPackage->Sca, (const char *)pDataPackage->szData, pDataPackage->MsgLength);
                        }
-                       else
-                       {
-                               SmsPluginEventHandler::instance()->handleMsgIncoming(&tpdu); // Call Event Handler
+
+                       if (tpdu.data.deliver.dcs.codingGroup == SMS_GROUP_DISCARD) {
+                               if (tpdu.data.deliver.dcs.bIndActive == false) {
+                                       SmsPluginSetting::instance()->setMwiInfo(tpdu.data.deliver.dcs.indType + MSG_MWI_VOICE_SMS, 0);
+                               }
+                               SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS);
+                       } else {
+                               if (SmsPluginConcatHandler::instance()->IsConcatMsg(&(tpdu.data.deliver.userData)) == true ||
+                                       SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(tpdu.data.deliver.userData)) == true)
+                               {
+                                       SmsPluginConcatHandler::instance()->handleConcatMsg(&tpdu); // Call Concat Msg Handler
+                               }
+                               else
+                               {
+                                       SmsPluginEventHandler::instance()->handleMsgIncoming(&tpdu); // Call Event Handler
+                               }
                        }
                }
                else if (tpdu.tpduType == SMS_TPDU_STATUS_REP)
@@ -299,7 +312,6 @@ 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
@@ -379,19 +391,29 @@ void TapiEventSaveSimMsg(TapiHandle *handle, int result, void *data, void *user_
 {
        MSG_DEBUG("TapiEventSaveSimMsg is called. result [%d]", result);
 
-       if (result != TAPI_API_SUCCESS || data == NULL)
-       {
-               MSG_DEBUG("Error. data is NULL.");
-               SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)0, false);
-               return;
-       }
+       int simId = -1;
+
+       if (data != NULL)
+               simId = *((int*)data);
+       else
+               MSG_DEBUG("Data(SIM Msg ID) is NULL");
+
+       SmsPluginSimMsg::instance()->setSaveSimMsgEvent(simId, result);
+}
 
-       int simId = *((int*)data);
 
-       MSG_DEBUG("sim ID : [%d], status : [%d]", simId, (TelSmsCause_t)result);
+void TapiEventSaveClass2Msg(TapiHandle *handle, int result, void *data, void *user_data)
+{
+       MSG_DEBUG("TapiEventSaveSimMsg is called. result [%d]", result);
 
-       SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)simId, true);
+       int simId = -1;
 
+       if (data != NULL)
+               simId = *((int*)data);
+       else
+               MSG_DEBUG("Data(SIM Msg ID) is NULL");
+
+       SmsPluginSimMsg::instance()->setSaveClass2MsgEvent(simId, result);
 }
 
 
@@ -570,6 +592,12 @@ void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_da
        {
                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(NULL, -1, false);
 
                return;
@@ -616,6 +644,20 @@ void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_da
                MSG_DEBUG("MSG_PID_TEXT is inserted to PID");
        }
 
+#if 0
+       /*Get the DCS value*/
+       if (0x00 == (0x08 & smsParam->ParamIndicator))
+       {
+               smscList.smscData[index].dcs = smsParam->TpDataCodingScheme;
+               MSG_DEBUG("dcs : %d", smscList.smscData[index].dcs);
+       }
+       else
+       {
+               smscList.smscData[index].dcs = MSG_ENCODE_GSM7BIT;
+               MSG_DEBUG("DCS is not present");
+       }
+#endif
+
        /*Get the ValidityPeriod value*/
        if (0x00 == (0x10 & smsParam->ParamIndicator))
        {
@@ -685,12 +727,18 @@ void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user
 
 void TapiEventSetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data)
 {
-       MSG_DEBUG("TapiEventSetMailboxInfo is called.");
+       MSG_DEBUG("TapiEventSetMailboxInfo is called. result = [%d]", result);
+
+       bool bRet = true;
+
+       if (result != TAPI_SIM_ACCESS_SUCCESS)
+               bRet = false;
+
+       SmsPluginSetting::instance()->setResultFromSim(bRet);
 }
 
 void TapiEventGetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data)
 {
-#if 0 // New TAPI
        MSG_DEBUG("TapiEventGetMailboxInfo is called.");
 
        if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL)
@@ -726,17 +774,22 @@ void TapiEventGetMailboxInfo(TapiHandle *handle, int result, void *data, void *u
        }
 
        SmsPluginSetting::instance()->setMailboxInfoEvent(&mbList, true);
-#endif
 }
 
 void TapiEventSetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data)
 {
-       MSG_DEBUG("TapiEventSetMwiInfo is called.");
+       MSG_DEBUG("TapiEventSetMwiInfo is called. result = [%d]", result);
+
+       bool bRet = true;
+
+       if (result != TAPI_SIM_ACCESS_SUCCESS)
+               bRet = false;
+
+       SmsPluginSetting::instance()->setResultFromSim(bRet);
 }
 
 void TapiEventGetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data)
 {
-#if 0 // New TAPI
        MSG_DEBUG("TapiEventGetMwiInfo is called.");
 
        if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL)
@@ -753,12 +806,10 @@ void TapiEventGetMwiInfo(TapiHandle *handle, int result, void *data, void *user_
        memcpy(&simMwiInfo, MwiInfo, sizeof(SMS_SIM_MWI_INFO_S));
 
        SmsPluginSetting::instance()->setMwiInfoEvent(&simMwiInfo, true);
-#endif
 }
 
 void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data)
 {
-#if 0 // New TAPI
        MSG_DEBUG("TapiEventGetMsisdnInfo is called.");
 
        if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL)
@@ -779,7 +830,6 @@ void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *us
                        break;
                }
        }
-#endif
 }
 
 void TapiEventSatSmsRefresh(TapiHandle *handle, int result, void *data, void *user_data)
@@ -827,6 +877,7 @@ void TapiEventSatSendSms(TapiHandle *handle, const char *noti_id, void *data, vo
 
 }
 
+
 void TapiEventSatMoSmsCtrl(TapiHandle *handle, int result, void *data, void *user_data)
 {
        MSG_DEBUG("TapiEventSatMoSmsCtrl is called.");
index a189038..9f42046 100755 (executable)
@@ -102,7 +102,7 @@ void SmsPluginCbMsgHandler::handleCbMsg(TelSmsCbMsg_t *pCbMsg)
                MakeCbMsg(CbMsgPage, &cbMsg);
 
                // Convert to MSG_MESSAGE_INFO_S
-               convertCbMsgToMsginfo(cbMsg, &msgInfo);
+               convertCbMsgToMsginfo(&cbMsg, &msgInfo);
 
                // Add CB Msg into DB
                msg_error_t err = MSG_SUCCESS;
@@ -322,7 +322,7 @@ void SmsPluginCbMsgHandler::Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
        char cbData[(MAX_CBMSG_PAGE_SIZE*MAX_CBMSG_PAGE_NUM)+1];
 
        memset(cbData, 0x00, sizeof(cbData));
-       memcpy(cbData, pCbMsg->szMsgData, pCbMsg->Length);
+       memcpy(cbData, pCbMsg->szMsgData, sizeof(pCbMsg->szMsgData));
        cbData[pCbMsg->Length] = '\0';
 
        pCbPage->cbMsgType = (SMS_CBMSG_TYPE_T)cbData[0];
@@ -570,21 +570,21 @@ void SmsPluginCbMsgHandler::MakeCbMsg(SMS_CBMSG_PAGE_S CbPage, SMS_CBMSG_S *pCbM
 }
 
 
-void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S cbMsg, MSG_MESSAGE_INFO_S *pMsgInfo)
+void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo)
 {
-       pMsgInfo->msgId = (msg_message_id_t)cbMsg.msgId;
+       pMsgInfo->msgId = (msg_message_id_t)pCbMsg->msgId;
 
        pMsgInfo->folderId = MSG_CBMSGBOX_ID;
 
        // Convert Type values
        pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
 
-       if (cbMsg.cbMsgType == SMS_CBMSG_TYPE_CBS)
+       if (pCbMsg->cbMsgType == SMS_CBMSG_TYPE_CBS)
                pMsgInfo->msgType.subType = MSG_CB_SMS;
-       else if (cbMsg.cbMsgType == SMS_CBMSG_TYPE_JAVACBS)
+       else if (pCbMsg->cbMsgType == SMS_CBMSG_TYPE_JAVACBS)
                pMsgInfo->msgType.subType = MSG_JAVACB_SMS;
 
-       switch(cbMsg.classType)
+       switch(pCbMsg->classType)
        {
                case SMS_MSG_CLASS_0:
                        pMsgInfo->msgType.classType = MSG_CLASS_0;
@@ -600,6 +600,7 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S cbMsg, MSG_MESSAGE
                        break;
                default:
                        pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+                       break;
        }
 
        pMsgInfo->storageId = MSG_STORAGE_PHONE;
@@ -615,32 +616,32 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S cbMsg, MSG_MESSAGE
        pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
        pMsgInfo->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_UNKNOWN;
 
-       getDisplayName(cbMsg.msgId, pMsgInfo->addressList[0].addressVal);
+       getDisplayName(pCbMsg->msgId, pMsgInfo->addressList[0].addressVal);
        MSG_DEBUG("%s", pMsgInfo->addressList[0].addressVal);
 
        pMsgInfo->msgPort.valid = false;
        pMsgInfo->msgPort.dstPort = 0;
        pMsgInfo->msgPort.srcPort = 0;
 
-       pMsgInfo->displayTime = cbMsg.recvTime;
+       pMsgInfo->displayTime = pCbMsg->recvTime;
        MSG_DEBUG("recvTime is %s", ctime(&pMsgInfo->displayTime));
 
-       int bufSize = cbMsg.msgLength*2;
+       int bufSize = pCbMsg->msgLength*2;
 
        char tmpBuf[bufSize];
        memset(tmpBuf, 0x00, sizeof(tmpBuf));
 
-       MSG_DEBUG("LENGTH %d CB MSG %s", cbMsg.msgLength, cbMsg.msgData);
+       MSG_DEBUG("LENGTH %d CB MSG %s", pCbMsg->msgLength, pCbMsg->msgData);
 
        // Convert Data values
-       pMsgInfo->dataSize = convertTextToUtf8((unsigned char*)tmpBuf, bufSize, &cbMsg);
+       pMsgInfo->dataSize = convertTextToUtf8((unsigned char*)tmpBuf, bufSize, pCbMsg);
 
        if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN)
        {
                pMsgInfo->bTextSms = false;
 
                // Save Message Data into File
-               char fileName[MAX_COMMON_INFO_SIZE+1];
+               char fileName[MSG_FILENAME_LEN_MAX+1];
                memset(fileName, 0x00, sizeof(fileName));
 
                if (MsgCreateFileName(fileName) == false)
index 502c526..7be928e 100755 (executable)
@@ -15,6 +15,7 @@
 */
 
 #include "MsgDebug.h"
+#include "MsgException.h"
 #include "MsgCppTypes.h"
 #include "MsgUtilFile.h"
 #include "SmsPluginStorage.h"
@@ -177,6 +178,213 @@ void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu)
        MSG_END();
 }
 
+#ifdef CONCAT_SIM_MSG_OPERATION
+void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t SimMsgId, bool bRead)
+{
+       MSG_BEGIN();
+
+       if (pTpdu->tpduType != SMS_TPDU_DELIVER)
+       {
+               MSG_DEBUG("The TPDU type is not deliver [%d]", pTpdu->tpduType);
+               return;
+       }
+
+       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)
+               {
+                       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;
+
+                       memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
+                       memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_ADDRESS_S));
+                       memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_DCS_S));
+
+                       msg.bRead = bRead;
+
+                       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)
+               {
+                       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;
+
+                       memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
+                       memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_ADDRESS_S));
+                       memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_DCS_S));
+
+                       msg.bRead = bRead;
+
+                       if (msg.totalSeg > MAX_SEGMENT_NUM)
+                       {
+                               MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
+                               return;
+                       }
+
+                       break;
+               }
+       }
+
+       unsigned char segCnt = checkConcatMsg(&msg, &(pTpdu->data.deliver.userData));
+
+       addToSimIdList(msg.msgRef, SimMsgId);
+
+       if (segCnt == msg.totalSeg)
+       {
+               MSG_DEBUG("RECEIVED LAST CONCAT : %d", segCnt);
+
+               int dataSize = 0;
+               char* pUserData = NULL;
+               AutoPtr<char> dataBuf(&pUserData);
+
+               MSG_MESSAGE_INFO_S msgInfo = {0};
+
+               dataSize = makeConcatUserData(msg.msgRef, &pUserData);
+
+               if (dataSize >= 0)
+               {
+                       MSG_DEBUG("TOTAL DATA : %s", pUserData);
+
+                       convertSimMsgToMsginfo(&msg, pUserData, dataSize, &msgInfo);
+
+                       // set Sim Message ID
+                       msgInfo.msgId = SimMsgId;
+
+                       // set read status
+                       msgInfo.bRead = bRead;
+
+                       /// 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);
+                       MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
+                       MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
+                       MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
+                       MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
+                       MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
+                       MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
+                       MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
+                       MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
+                       MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
+                       MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
+                       MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
+                       MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
+
+                       if (msgInfo.bTextSms == true)
+                               MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
+                       else
+                               MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
+
+                       MSG_DEBUG("###############################################################");
+
+                       // Remove from List
+                       removeFromConcatList(msg.msgRef);
+                       removeFromSimIdList(msg.msgRef);
+
+                       //add msgInfo to msg list
+                       SmsPluginStorage::instance()->addSimMsgToList(&msgInfo, true);
+
+                       // Callback to MSG FW
+                       SmsPluginEventHandler::instance()->callbackGetSimMsg();
+               }
+       }
+       else
+       {
+               //add index count to msg list
+               SmsPluginStorage::instance()->addSimMsgToList(NULL, false);
+
+               // Callback to MSG FW
+               SmsPluginEventHandler::instance()->callbackGetSimMsg();
+       }
+
+       MSG_END();
+}
+
+
+void SmsPluginConcatHandler::handleBrokenMsg()
+{
+       if (concatList.size() <= 0 || simIdList.size() <= 0)
+       {
+               MSG_DEBUG("No Broken Concatenated Message");
+               return;
+       }
+
+       do
+       {
+               int index = 0, dataSize = 0;
+               char* pUserData = NULL;
+               AutoPtr<char> dataBuf(&pUserData);
+
+               MSG_MESSAGE_INFO_S msgInfo = {0};
+
+               dataSize = makeConcatUserData(concatList[index].msgRef, &pUserData);
+
+               if (dataSize > 0)
+               {
+                       MSG_DEBUG("TOTAL DATA : %s", pUserData);
+
+                       SMS_CONCAT_MSG_S msg;
+                       memset(&msg, 0x00, sizeof(SMS_CONCAT_MSG_S));
+
+                       msg.msgRef = concatList[index].msgRef;
+                       msg.totalSeg = concatList[index].totalSeg;
+
+                       memcpy(&(msg.timeStamp.time.absolute), &(concatList[index].timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
+                       memcpy(&(msg.originAddress), &(concatList[index].originAddress), sizeof(SMS_ADDRESS_S));
+                       memcpy(&(msg.dcs), &(concatList[index].dcs), sizeof(SMS_DCS_S));
+
+                       convertSimMsgToMsginfo(&msg, pUserData, dataSize, &msgInfo);
+
+                       // set Sim Message ID
+                       msgInfo.msgId = 0;
+
+                       // set read status
+                       msgInfo.bRead = concatList[index].bRead;
+
+                       /// 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);
+                       MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
+                       MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
+                       MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
+                       MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
+                       MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
+                       MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
+                       MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
+                       MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
+                       MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
+                       MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
+                       MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
+                       MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
+                       if (msgInfo.bTextSms == true)
+                               MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
+                       else
+                       MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
+                       MSG_DEBUG("###############################################################");
+
+                       //add msgInfo to msg list
+                       SmsPluginStorage::instance()->addSimMsgToList(&msgInfo, true);
+               }
+
+               removeFromConcatList(concatList[index].msgRef);
+               removeFromSimIdList(concatList[index].msgRef);
+       }while (concatList.size() > 0);
+}
+#endif
+
 
 unsigned char SmsPluginConcatHandler::checkConcatMsg(SMS_CONCAT_MSG_S *pConcatMsg, SMS_USERDATA_S *pUserData)
 {
@@ -288,9 +496,12 @@ void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu,
        pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
        pMsgInfo->msgType.subType = MSG_NORMAL_SMS;
 
-       /** set folder id (temporary) */
+       /** set folder id */
        pMsgInfo->folderId = MSG_INBOX_ID;
 
+       /** set storage id */
+       pMsgInfo->storageId = MSG_STORAGE_PHONE;
+
        switch(pTpdu->dcs.msgClass)
        {
                case SMS_MSG_CLASS_0:
@@ -307,6 +518,7 @@ void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu,
                        break;
                default:
                        pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+                       break;
        }
 
        pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
@@ -318,6 +530,59 @@ void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu,
 
        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);
+       }
+
+***/
 
        pMsgInfo->displayTime = rawtime;
 
@@ -369,18 +634,30 @@ void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu,
        MSG_DEBUG("Data Size [%d]", pMsgInfo->dataSize);
        MSG_DEBUG("Data [%s]", tmpBuf);
 
+#ifdef MSG_FW_FOR_DEBUG
+printf("\n");
+
+for (int i = 0; i < pMsgInfo->dataSize; i++)
+{
+       printf("[%02x]", tmpBuf[i]);
+}
+
+printf("\n");
+#endif
 
        if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN) {
                pMsgInfo->bTextSms = false;
 
                /** Save Message Data into File */
-               char fileName[MAX_COMMON_INFO_SIZE+1];
+               char fileName[MSG_FILENAME_LEN_MAX+1];
                memset(fileName, 0x00, sizeof(fileName));
 
-               MsgCreateFileName(fileName);
+               if (MsgCreateFileName(fileName) == false)
+                       THROW(MsgException::FILE_ERROR, "########  MsgCreateFileName Fail !!! #######");
 
                MSG_DEBUG("Save Message Data into file : size[%d] name[%s]\n", pMsgInfo->dataSize, fileName);
-               MsgWriteIpcFile(fileName, tmpBuf, pMsgInfo->dataSize);
+               if (MsgWriteIpcFile(fileName, tmpBuf, pMsgInfo->dataSize) == false)
+                       THROW(MsgException::FILE_ERROR, "########  MsgWriteIpcFile Fail !!! #######");
 
                strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
        } else {
@@ -392,6 +669,175 @@ void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu,
 }
 
 
+#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
+       pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
+       pMsgInfo->msgType.subType = MSG_CONCAT_SIM_SMS;
+
+       // 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;
+       }
+
+       pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+       pMsgInfo->bRead = false;
+       pMsgInfo->bProtected = false;
+       pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+       pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
+
+       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);
+       }
+
+***/
+
+       pMsgInfo->displayTime = rawtime;
+
+       // 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);
+
+       pMsgInfo->msgPort.valid = false;
+       pMsgInfo->msgPort.dstPort = 0;
+       pMsgInfo->msgPort.srcPort = 0;
+
+       // 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)
+               {
+                       MSG_DEBUG("Get SIM ID [%d] - List Index [%d]", simIdList[i].simId, concatSimMsg.simIdCnt);
+
+                       concatSimMsg.simIdList[concatSimMsg.simIdCnt] = simIdList[i].simId;
+                       concatSimMsg.simIdCnt++;
+               }
+       }
+
+       int bufSize = (MAX_MSG_DATA_LEN*MAX_SEGMENT_NUM) + 1;
+
+       char tmpBuf[bufSize];
+       memset(tmpBuf, 0x00, sizeof(tmpBuf));
+
+       // Convert Data values
+       if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_7BIT)
+       {
+               SMS_LANG_INFO_S langInfo = {0};
+
+               langInfo.bSingleShift = false;
+               langInfo.bLockingShift = false;
+
+               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)
+       {
+               pMsgInfo->encodeType = MSG_ENCODE_8BIT;
+               memcpy(tmpBuf, pUserData, DataSize);
+               pMsgInfo->dataSize = DataSize;
+       }
+       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);
+       }
+
+       MSG_DEBUG("Data Size [%d]", pMsgInfo->dataSize);
+
+       pMsgInfo->bTextSms = false;
+
+       if (pMsgInfo->dataSize > 0)
+               memcpy(concatSimMsg.msgData, tmpBuf, pMsgInfo->dataSize);
+
+       // Save Message Data into File
+       char fileName[MAX_COMMON_INFO_SIZE+1];
+       memset(fileName, 0x00, sizeof(fileName));
+
+       if (MsgCreateFileName(fileName) == false)
+               THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+       if (MsgWriteIpcFile(fileName, (char*)(&concatSimMsg), sizeof(SMS_CONCAT_SIM_MSG_S)) == false)
+               THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+       memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData));
+       strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
+
+       MSG_DEBUG("Save Message Data into file : size[%d] name[%s]", pMsgInfo->dataSize, fileName);
+}
+#endif
+
+
 void SmsPluginConcatHandler::removeFromConcatList(unsigned short MsgRef)
 {
        for (int index = concatList.size(); index >= 0 ; index--) {
@@ -402,3 +848,29 @@ void SmsPluginConcatHandler::removeFromConcatList(unsigned short MsgRef)
                }
        }
 }
+
+#ifdef CONCAT_SIM_MSG_OPERATION
+void SmsPluginConcatHandler::addToSimIdList(unsigned short MsgRef, msg_sim_id_t SimMsgId)
+{
+       SMS_SIM_ID_S simIdStruct;
+
+       simIdStruct.msgRef = MsgRef;
+       simIdStruct.simId = SimMsgId;
+
+       simIdList.push_back(simIdStruct);
+}
+
+
+void SmsPluginConcatHandler::removeFromSimIdList(unsigned short 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);
+               }
+       }
+}
+#endif
index 3a1437e..f618934 100755 (executable)
@@ -156,14 +156,9 @@ void SmsPluginEventHandler::handleMsgIncoming(SMS_TPDU_S *pTpdu)
 
        msg_error_t err = MSG_SUCCESS;
 
-       /** Update Status in Report Table */
        if (msgInfo.msgType.subType == MSG_STATUS_REPORT_SMS) {
-               err = SmsPluginStorage::instance()->addMessage(&msgInfo);
-
-               if (err == MSG_SUCCESS) {
-                       MSG_DEBUG("callback to msg fw");
-                       err = listener.pfMsgIncomingCb(&msgInfo);
-               }
+               /** Status Report Message */
+               err = listener.pfMsgIncomingCb(&msgInfo);
 
                /** Handling of Fail Case ?? */
                SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS);
@@ -185,11 +180,31 @@ void SmsPluginEventHandler::handleMsgIncoming(SMS_TPDU_S *pTpdu)
                        if (err == MSG_SUCCESS) {
                                MSG_DEBUG("callback to msg fw");
                                err = listener.pfMsgIncomingCb(&msgInfo);
+                       } else {
+                               if (msgInfo.msgType.classType == MSG_CLASS_0) {
+                                       MSG_DEBUG("callback for class0 message to msg fw");
+                                       if (listener.pfMsgIncomingCb(&msgInfo) != MSG_SUCCESS)
+                                               MSG_DEBUG("listener.pfMsgIncomingCb is failed!");
+                               }
                        }
 
                        /** Send Deliver Report */
-                       SmsPluginTransport::instance()->sendDeliverReport(err);
+                       if (msgInfo.msgType.classType == MSG_CLASS_0)
+                               SmsPluginTransport::instance()->sendClass0DeliverReport(err);
+                       else
+                               SmsPluginTransport::instance()->sendDeliverReport(err);
                }
+
+               // Tizen Validation System
+               char *msisdn = NULL;
+               msisdn = MsgSettingGetString(MSG_SIM_MSISDN);
+
+               MSG_SMS_VLD_INFO("%d, SMS Receive, %s->%s, %s",  msgInfo.msgId, \
+                                                                                                                               msgInfo.addressList[0].addressVal, \
+                                                                                                                               (msisdn == NULL)?"ME":msisdn, \
+                                                                                                                               (err == MSG_SUCCESS)?"Success":"Fail");
+
+               MSG_SMS_VLD_TXT("%d, [%s]", msgInfo.msgId, msgInfo.msgText);
        }
 }
 
@@ -432,6 +447,60 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp
 
        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;
 
        /** Convert Address values */
@@ -457,9 +526,8 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp
                        msgInfo->msgType.subType = (pTpdu->userData.header[i].udh.specialInd.msgInd+MSG_MWI_VOICE_SMS);
                        msgInfo->bStore = pTpdu->userData.header[i].udh.specialInd.bStore;
 
-                       if (pTpdu->userData.header[i].udh.specialInd.waitMsgNum > 0) {
-                               SmsPluginSetting::instance()->setMwiInfo(msgInfo->msgType.subType, pTpdu->userData.header[i].udh.specialInd.waitMsgNum);
-                       }
+                       MSG_DEBUG("Message waiting number : [%d]", pTpdu->userData.header[i].udh.specialInd.waitMsgNum);
+                       SmsPluginSetting::instance()->setMwiInfo(msgInfo->msgType.subType, pTpdu->userData.header[i].udh.specialInd.waitMsgNum);
 
                        if (pTpdu->userData.length == 0) {
                                switch (msgInfo->msgType.subType) {
@@ -502,6 +570,7 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp
                                break;
                        default:
                                msgInfo->encodeType = MSG_ENCODE_8BIT;
+                               break;
                }
 
                return;
@@ -532,7 +601,7 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp
                msgInfo->dataSize = textCvt.convertGSM7bitToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length, &langInfo);
        } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_8BIT) {
                msgInfo->encodeType = MSG_ENCODE_8BIT;
-               memcpy(msgInfo->msgText, pTpdu->userData.data, pTpdu->userData.length);
+               memcpy(msgInfo->msgText, pTpdu->userData.data, sizeof(pTpdu->userData.data));
                msgInfo->dataSize = pTpdu->userData.length;
        } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
                msgInfo->encodeType = MSG_ENCODE_UCS2;
@@ -553,9 +622,12 @@ void SmsPluginEventHandler::convertStatusRepTpduToMsginfo(const SMS_STATUS_REPOR
        msgInfo->msgType.mainType = MSG_SMS_TYPE;
        msgInfo->msgType.subType = MSG_STATUS_REPORT_SMS;
 
-       /** set folder id (temporary) */
+       /** set folder id */
        msgInfo->folderId = MSG_INBOX_ID;
 
+       /** set storage id */
+       msgInfo->storageId = MSG_STORAGE_PHONE;
+
        switch(pTpdu->dcs.msgClass)
        {
                case SMS_MSG_CLASS_0:
@@ -572,6 +644,7 @@ void SmsPluginEventHandler::convertStatusRepTpduToMsginfo(const SMS_STATUS_REPOR
                        break;
                default:
                        msgInfo->msgType.classType = MSG_CLASS_NONE;
+                       break;
        }
 
        MSG_DEBUG("delivery status : [%d]", pTpdu->status);
@@ -592,6 +665,60 @@ void SmsPluginEventHandler::convertStatusRepTpduToMsginfo(const SMS_STATUS_REPOR
 
        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;
 
        /** Convert Address values */
@@ -616,7 +743,7 @@ void SmsPluginEventHandler::convertStatusRepTpduToMsginfo(const SMS_STATUS_REPOR
                }
        }
 
-       memset(msgInfo->msgText, 0x00, sizeof(MAX_MSG_TEXT_LEN+1));
+       memset(msgInfo->msgText, 0x00, sizeof(msgInfo->msgText));
        msgInfo->dataSize = 0;
 
        if (pTpdu->status <= SMS_STATUS_SMSC_SPECIFIC_LAST) {
index bbe9fc5..1eda548 100755 (executable)
@@ -108,7 +108,8 @@ msg_error_t SmsPlgInitialize()
        MSG_BEGIN();
 
        MSG_DEBUG("set MSG_SIM_CHANGED to MSG_SIM_STATUS_NOT_FOUND.");
-       MsgSettingSetInt(MSG_SIM_CHANGED, MSG_SIM_STATUS_NOT_FOUND);
+       if (MsgSettingSetInt(MSG_SIM_CHANGED, MSG_SIM_STATUS_NOT_FOUND) != MSG_SUCCESS)
+               MSG_DEBUG("MsgSettingSetInt is failed!!");
 
        bool bReady;
        MsgSettingGetBool(VCONFKEY_TELEPHONY_READY, &bReady);
@@ -262,8 +263,14 @@ msg_error_t SmsPlgCheckSimStatus(MSG_SIM_STATUS_T *pStatus)
                else
                {
                        MSG_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet);
+
+                       MsgSettingSetBool(MSG_NATIONAL_SIM, false);
                }
        }
+       else
+       {
+               MsgSettingSetBool(MSG_NATIONAL_SIM, false);
+       }
 
        MsgSettingSetString(MSG_SIM_IMSI, imsi);
 
@@ -310,11 +317,16 @@ msg_error_t SmsPlgCheckDeviceStatus()
 
 msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo)
 {
+       msg_error_t err = MSG_SUCCESS;
+
        // Add Submit SMS into DB
-       if ((pReqInfo->msgInfo.msgId == 0) && pReqInfo->msgInfo.msgPort.valid == false) {
-               if (SmsPluginStorage::instance()->addMessage(&(pReqInfo->msgInfo)) != MSG_SUCCESS) {
-                       MSG_DEBUG("########  addMessage Fail !!");
-                       return MSG_ERR_PLUGIN_STORAGE;
+       if (pReqInfo->msgInfo.msgId == 0) {
+               if (pReqInfo->msgInfo.msgPort.valid == false) {
+                       err = SmsPluginStorage::instance()->addMessage(&(pReqInfo->msgInfo));
+                       if (err != MSG_SUCCESS) {
+                               MSG_DEBUG("########  addMessage Fail !!");
+                               return MSG_ERR_PLUGIN_STORAGE;
+                       }
                }
        }
 
@@ -332,15 +344,22 @@ msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo)
                return MSG_ERR_NO_SIM;
        }
 
-       SMS_REQUEST_INFO_S request = {};
+       SMS_REQUEST_INFO_S *request = NULL;
+
+       request = (SMS_REQUEST_INFO_S *)calloc(1, sizeof(SMS_REQUEST_INFO_S));
+
+       if (request != NULL) {
+               request->reqId = pReqInfo->reqId;
 
-       request.reqId = pReqInfo->reqId;
+               memcpy(&(request->msgInfo), &(pReqInfo->msgInfo), sizeof(MSG_MESSAGE_INFO_S));
+               memcpy(&(request->sendOptInfo), &(pReqInfo->sendOptInfo), sizeof(MSG_SENDINGOPT_INFO_S));
 
-       memcpy(&(request.msgInfo), &(pReqInfo->msgInfo), sizeof(MSG_MESSAGE_INFO_S));
-       memcpy(&(request.sendOptInfo), &(pReqInfo->sendOptInfo), sizeof(MSG_SENDINGOPT_INFO_S));
+               /* Add Request into Queue and Start UA Manger */
+               SmsPluginUAManager::instance()->addReqEntity(request);
+
+               free(request);
+       }
 
-       // Add Request into Queue and Start UA Manger
-       SmsPluginUAManager::instance()->addReqEntity(request);
 
        return MSG_SUCCESS;
 }
@@ -461,7 +480,7 @@ msg_error_t SmsPlgSetMemoryStatus(msg_error_t Error)
                return MSG_ERR_NO_SIM;
        }
 
-       int tapiRet = TAPI_API_SUCCESS, reqId = 0;
+       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)
@@ -475,11 +494,11 @@ msg_error_t SmsPlgSetMemoryStatus(msg_error_t Error)
 
        if (tapiRet == TAPI_API_SUCCESS)
        {
-               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId);
+               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
        }
        else
        {
-               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! return : [%d] #######", tapiRet);
        }
 
        return MSG_SUCCESS;
index 7d3e612..8b4ecf4 100755 (executable)
@@ -292,6 +292,9 @@ MSG_DEBUG("npi [%d]", pAddress->npi);
                langInfo.bLockingShift = false;
 
                textCvt.convertGSM7bitToUTF8((unsigned char*)pAddress->address, MAX_ADDRESS_LEN, (unsigned char*)tmpAddress, tmplength, &langInfo);
+
+               if (tmpAddress)
+                       delete[] tmpAddress;
        }
        else if (pAddress->ton == SMS_TON_INTERNATIONAL)
        {
index 5f38a3b..22c6298 100755 (executable)
@@ -70,6 +70,68 @@ SmsPluginSatHandler* SmsPluginSatHandler::instance()
 
 void SmsPluginSatHandler::refreshSms(void *pData)
 {
+       /*
+       TelSatRefreshInd_t* pRefreshData = (TelSatRefreshInd_t*)pData;
+
+       if (pRefreshData->appType != TAPI_SAT_REFRESH_MSG)
+       {
+               MSG_DEBUG("App Type is wrong. [%d]", pRefreshData->appType);
+               return;
+       }
+
+       commandId = pRefreshData->commandId;
+
+       switch (pRefreshData->refreshMode)
+       {
+               case TAPI_SAT_REFRESH_SIM_INIT_AND_FULL_FCN :
+               case TAPI_SAT_REFRESH_SIM_INIT_AND_FCN :
+               {
+                       for (int i = 0; i < pRefreshData->fileCount; i++)
+                       {
+                               if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_SMSP ||
+                                       (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_SMSP)
+                               {
+                                       bSMSPChanged = true;
+                               }
+                               else if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_CBMI ||
+                                       (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_CBMI)
+                               {
+                                       bCBMIChanged = true;
+                               }
+                       }
+
+                       initSim();
+               }
+               break;
+
+               case TAPI_SAT_REFRESH_FCN :
+               {
+                       for (int i = 0; i < pRefreshData->fileCount; i++)
+                       {
+                               if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_SMSP ||
+                                       (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_SMSP)
+                               {
+                                       bSMSPChanged = true;
+                               }
+                               else if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_CBMI ||
+                                       (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_CBMI)
+                               {
+                                       bCBMIChanged = true;
+                               }
+                       }
+               }
+               break;
+
+               case TAPI_SAT_REFRESH_SIM_INIT :
+               {
+                       initSim();
+               }
+               break;
+
+               default:
+               break;
+       }
+       */
 }
 
 
@@ -319,6 +381,14 @@ void       SmsPluginSatHandler::initSMSCList()
                if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].pid)) != MSG_SUCCESS)
                        break;
 
+#if 0
+               memset(keyName, 0x00, sizeof(keyName));
+               sprintf(keyName, "%s/%d", SMSC_DCS, i);
+
+               if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].dcs)) != MSG_SUCCESS)
+                       break;
+#endif
+
                memset(keyName, 0x00, sizeof(keyName));
                sprintf(keyName, "%s/%d", SMSC_VAL_PERIOD, i);
 
index f7fefb9..80c836c 100755 (executable)
@@ -49,6 +49,7 @@ SmsPluginSetting::SmsPluginSetting()
        // Initialize member variables
        memset(&smscData, 0x00, sizeof(MSG_SMSC_DATA_S));
        memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
+       memset(&simMailboxList, 0x00, sizeof(SMS_SIM_MAILBOX_LIST_S));
 
        bTapiResult = false;
        paramCnt = 0;
@@ -182,6 +183,11 @@ void SmsPluginSetting::setConfigData(const MSG_SETTING_S *pSetting)
 
        switch (pSetting->type)
        {
+#if 0
+               case MSG_SMS_SENDOPT :
+                       setNetworkMode(&pSetting->option.smsSendOpt);
+                       break;
+#endif
                case MSG_SMSC_LIST :
                        setParamList(&pSetting->option.smscList);
                        break;
@@ -239,20 +245,17 @@ msg_error_t SmsPluginSetting::addSMSCList(MSG_SMSC_LIST_S *pSmscList)
 
        char keyName[128];
 
-       if (MsgSettingSetInt(SMSC_TOTAL_COUNT, pSmscList->totalCnt) != MSG_SUCCESS)
-       {
+       if (MsgSettingSetInt(SMSC_TOTAL_COUNT, pSmscList->totalCnt) != MSG_SUCCESS) {
                MSG_DEBUG("Error to set config data [%s]", SMSC_TOTAL_COUNT);
                return MSG_ERR_SET_SETTING;
        }
 
-       if (MsgSettingSetInt(SMSC_SELECTED, pSmscList->selected) != MSG_SUCCESS)
-       {
+       if (MsgSettingSetInt(SMSC_SELECTED, pSmscList->selected) != MSG_SUCCESS) {
                MSG_DEBUG("Error to set config data [%s]", SMSC_SELECTED);
                return MSG_ERR_SET_SETTING;
        }
 
-       for (int i = 0; i < pSmscList->totalCnt; i++)
-       {
+       for (int i = 0; i < pSmscList->totalCnt; i++) {
                memset(keyName, 0x00, sizeof(keyName));
                sprintf(keyName, "%s/%d", SMSC_PID, i);
 
@@ -297,8 +300,7 @@ msg_error_t SmsPluginSetting::addSMSCList(MSG_SMSC_LIST_S *pSmscList)
                        break;
        }
 
-       if (err != MSG_SUCCESS)
-       {
+       if (err != MSG_SUCCESS) {
                MSG_DEBUG("Error to set config data [%s]", keyName);
        }
 
@@ -320,28 +322,24 @@ msg_error_t SmsPluginSetting::addCbOpt(MSG_CBMSG_OPT_S *pCbOpt)
        }
 
        // Set Setting Data into Vconf
-       if (MsgSettingSetBool(CB_RECEIVE, pCbOpt->bReceive) != MSG_SUCCESS)
-       {
+       if (MsgSettingSetBool(CB_RECEIVE, pCbOpt->bReceive) != MSG_SUCCESS) {
                MSG_DEBUG("Error to set config data [%s]", CB_RECEIVE);
                return MSG_ERR_SET_SETTING;
        }
 
-       if (MsgSettingSetInt(CB_MAX_SIM_COUNT, pCbOpt->maxSimCnt) != MSG_SUCCESS)
-       {
+       if (MsgSettingSetInt(CB_MAX_SIM_COUNT, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
                MSG_DEBUG("Error to set config data [%s]", CB_MAX_SIM_COUNT);
                return MSG_ERR_SET_SETTING;
        }
 
-       if (MsgSettingSetInt(CB_CHANNEL_COUNT, pCbOpt->channelData.channelCnt) != MSG_SUCCESS)
-       {
+       if (MsgSettingSetInt(CB_CHANNEL_COUNT, pCbOpt->channelData.channelCnt) != MSG_SUCCESS) {
                MSG_DEBUG("Error to set config data [%s]", CB_CHANNEL_COUNT);
                return MSG_ERR_SET_SETTING;
        }
 
        char keyName[128];
 
-       for (int i = 0; i < pCbOpt->channelData.channelCnt; i++)
-       {
+       for (int i = 0; i < pCbOpt->channelData.channelCnt; i++) {
                memset(keyName, 0x00, sizeof(keyName));
                sprintf(keyName, "%s/%d", CB_CHANNEL_ACTIVATE, i);
 
@@ -384,8 +382,7 @@ void SmsPluginSetting::getCbOpt(MSG_SETTING_S *pSetting)
 
        pSetting->option.cbMsgOpt.channelData.channelCnt = MsgSettingGetInt(CB_CHANNEL_COUNT);
 
-       for (int i = 0; i < pSetting->option.cbMsgOpt.channelData.channelCnt; i++)
-       {
+       for (int i = 0; i < pSetting->option.cbMsgOpt.channelData.channelCnt; i++) {
                memset(keyName, 0x00, sizeof(keyName));
                sprintf(keyName, "%s/%d", CB_CHANNEL_ACTIVATE, i);
 
@@ -414,8 +411,7 @@ void SmsPluginSetting::getCbOpt(MSG_SETTING_S *pSetting)
                }
        }
 
-       for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++)
-       {
+       for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
                memset(keyName, 0x00, sizeof(keyName));
                sprintf(keyName, "%s/%d", CB_LANGUAGE, i);
 
@@ -433,8 +429,7 @@ void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
 
        int ret = TAPI_API_SUCCESS;
 
-       for (int index = 0; index < pSMSCList->totalCnt; index++)
-       {
+       for (int index = 0; index < pSMSCList->totalCnt; index++) {
                /*Setting the SMSP Record index value*/
                smsParam.RecordIndex = (unsigned char)index;
 
@@ -445,8 +440,7 @@ void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
                smsParam.AlphaIdLen = strlen(pSMSCList->smscData[index].name);
                MSG_DEBUG("AlphaIdLen = %ld", smsParam.AlphaIdLen);
 
-               if (smsParam.AlphaIdLen > 0 &&  smsParam.AlphaIdLen <= SMSC_NAME_MAX)
-               {
+               if (smsParam.AlphaIdLen > 0 &&  smsParam.AlphaIdLen <= SMSC_NAME_MAX) {
                        memcpy(smsParam.szAlphaId, pSMSCList->smscData[index].name, smsParam.AlphaIdLen);
                        smsParam.szAlphaId[smsParam.AlphaIdLen] = '\0';
                        MSG_DEBUG("szAlphaId = %s", smsParam.szAlphaId);
@@ -454,8 +448,7 @@ void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
 
                smsParam.ParamIndicator = 0x00;
 
-               if (strlen(pSMSCList->smscData[index].smscAddr.address) > 0)
-               {
+               if (strlen(pSMSCList->smscData[index].smscAddr.address) > 0) {
                        smsParam.ParamIndicator |= 0x02 ;  //enable 2nd Bit
                        MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
 
@@ -471,9 +464,7 @@ void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
                        MSG_DEBUG("address = %s", pSMSCList->smscData[index].smscAddr.address);
 
                        smsParam.TpSvcCntrAddr.DialNumLen = SmsPluginParamCodec::encodeSMSC(pSMSCList->smscData[index].smscAddr.address, smsParam.TpSvcCntrAddr.szDiallingNum);
-               }
-               else
-               {
+               } else {
                        MSG_DEBUG("SMSC Addr is not present");
                }
 
@@ -519,25 +510,18 @@ void SmsPluginSetting::getParamList(MSG_SMSC_LIST_S *pSMSCList)
 
        MSG_SMSC_DATA_S tmpSmscData = {};
 
-       for (int index = 0; index < paramCnt; index++)
-       {
+       for (int index = 0; index < paramCnt; index++) {
                ret = tel_get_sms_parameters(pTapiHandle, index, TapiEventGetParam, NULL);
 
-               if (ret == TAPI_API_SUCCESS)
-               {
+               if (ret == TAPI_API_SUCCESS) {
                        MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
-               }
-               else
-               {
+               } else {
                        THROW(MsgException::SMS_PLG_ERROR, "######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
                }
 
-               if (getParamEvent(&tmpSmscData) == true)
-               {
+               if (getParamEvent(&tmpSmscData) == true) {
                        MSG_DEBUG("######## Get Parameter was Successful !!! #######");
-               }
-               else
-               {
+               } else {
                        THROW(MsgException::SMS_PLG_ERROR, "######## Get Parameter was Failed !!! #######");
                }
 
@@ -567,12 +551,9 @@ int SmsPluginSetting::getParamCount()
 
        ret = tel_get_sms_parameter_count(pTapiHandle, TapiEventGetParamCnt, NULL);
 
-       if (ret == TAPI_API_SUCCESS)
-       {
+       if (ret == TAPI_API_SUCCESS) {
                MSG_DEBUG("######## tel_get_sms_parameter_count() Success !!! #######");
-       }
-       else
-       {
+       } else {
                THROW(MsgException::SMS_PLG_ERROR, "tel_get_sms_parameter_count() Error. [%d]", ret);
        }
 
@@ -586,22 +567,16 @@ bool SmsPluginSetting::getParam(int Index, MSG_SMSC_DATA_S *pSmscData)
 
        ret = tel_get_sms_parameters(pTapiHandle, Index, TapiEventGetParam, NULL);
 
-       if (ret == TAPI_API_SUCCESS)
-       {
+       if (ret == TAPI_API_SUCCESS) {
                MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
                return false;
        }
 
-       if (getParamEvent(pSmscData) == true)
-       {
+       if (getParamEvent(pSmscData) == true) {
                MSG_DEBUG("######## Get Parameter was Successful !!! #######");
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("######## Get Parameter was Failed !!! #######");
                return false;
        }
@@ -621,8 +596,7 @@ bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
        cbConfig.MsgIdMaxCount = pCbOpt->maxSimCnt;
        cbConfig.MsgIdRangeCount = pCbOpt->channelData.channelCnt;
 
-       for (int i = 0; i < cbConfig.MsgIdRangeCount; i++)
-       {
+       for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
                cbConfig.MsgIDs[i].Net3gpp.Selected = (unsigned short)pCbOpt->channelData.channelInfo[i].bActivate;
                cbConfig.MsgIDs[i].Net3gpp.FromMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].from;
                cbConfig.MsgIDs[i].Net3gpp.ToMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].to;
@@ -633,22 +607,16 @@ bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
 
        ret = tel_set_sms_cb_config(pTapiHandle, &cbConfig, TapiEventSetConfigData, NULL);
 
-       if (ret == TAPI_API_SUCCESS)
-       {
+       if (ret == TAPI_API_SUCCESS) {
                MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("######## tel_set_sms_cb_config() Fail !!! return : %d #######", ret);
                return false;
        }
 
-       if (getResultFromSim() == true)
-       {
+       if (getResultFromSim() == true) {
                MSG_DEBUG("######## Set Cb Config was Successful !!! #######");
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("######## Set Cb Config was Failed !!! #######");
                return false;
        }
@@ -663,22 +631,16 @@ bool SmsPluginSetting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
 
        ret = tel_get_sms_cb_config(pTapiHandle, TapiEventGetCBConfig, NULL);
 
-       if (ret == TAPI_API_SUCCESS)
-       {
+       if (ret == TAPI_API_SUCCESS) {
                MSG_DEBUG("######## tel_get_sms_cb_config() Success !!! #######");
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("######## tel_get_sms_cb_config() Fail !!! return : %d #######", ret);
                return false;
        }
 
-       if (getCbConfigEvent(pCbOpt) == true)
-       {
+       if (getCbConfigEvent(pCbOpt) == true) {
                MSG_DEBUG("######## Get Cb Config was Successful !!! #######");
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("######## Get Cb Config was Failed !!! #######");
                return false;
        }
@@ -688,7 +650,6 @@ bool SmsPluginSetting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
 
 void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
 {
-#if 0 // New TAPI
        int ret = TAPI_API_SUCCESS;
 
        TelSimMailBoxNumber_t mailboxInfo = {0,};
@@ -717,22 +678,23 @@ void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
 
        ret = tel_set_sim_mailbox_info(pTapiHandle, &mailboxInfo, TapiEventSetMailboxInfo, NULL);
 
-       if (ret == TAPI_API_SUCCESS)
-       {
+       if (ret == TAPI_API_SUCCESS) {
                MSG_DEBUG("######## tel_set_sim_mailbox_info() Success !!! #######");
-       }
-       else
-       {
+       } else {
                MSG_DEBUG("######## tel_set_sim_mailbox_info() Fail !!! return : %d #######", ret);
        }
 
+       if (getResultFromSim() == true) {
+               MSG_DEBUG("######## Set mailbox info Success !!! #######");
+       } else {
+               THROW(MsgException::SMS_PLG_ERROR, "########  Set mailbox info Failed !!!#######");
+       }
+
        return;
-#endif
 }
 
 bool SmsPluginSetting::getVoiceMailInfo(MSG_VOICEMAIL_OPT_S *pVoiceOpt)
 {
-#if 0 // New TAPI
        int ret = TAPI_API_SUCCESS;
 
        ret = tel_get_sim_mailbox_info(pTapiHandle, TapiEventGetMailboxInfo, NULL);
@@ -751,13 +713,11 @@ bool SmsPluginSetting::getVoiceMailInfo(MSG_VOICEMAIL_OPT_S *pVoiceOpt)
                return false;
        }
 
-#endif
        return true;
 }
 
 void SmsPluginSetting::setMwiInfo(MSG_SUB_TYPE_T type, int count)
 {
-#if 0 // New TAPI
        if (type < MSG_MWI_VOICE_SMS || type > MSG_MWI_OTHER_SMS) {
                MSG_DEBUG("Invalid parameter");
                return;
@@ -786,10 +746,8 @@ void SmsPluginSetting::setMwiInfo(MSG_SUB_TYPE_T type, int count)
                        simMwiInfo.mwi_list.mw_info[0].fax_count = count;
                else if (type == MSG_MWI_EMAIL_SMS)
                        simMwiInfo.mwi_list.mw_info[0].email_count = count;
-               else if (type == MSG_MWI_OTHER_SMS)
+               else // MSG_MWI_OTHER_SMS
                        simMwiInfo.mwi_list.mw_info[0].other_count = count;
-               else
-                       MSG_DEBUG("No match type [%d]", type);
 
                mwReq.mw_data_u.mw.rec_index = simMwiInfo.mwi_list.mw_info[0].rec_index;
                mwReq.mw_data_u.mw.indicator_status = simMwiInfo.mwi_list.mw_info[0].indicator_status;
@@ -810,14 +768,18 @@ void SmsPluginSetting::setMwiInfo(MSG_SUB_TYPE_T type, int count)
                MSG_DEBUG("######## tel_set_sim_messagewaiting_info() Fail !!! return : %d #######", ret);
        }
 
+       if (getResultFromSim() == true) {
+               MSG_DEBUG("######## Set message waiting info Success !!! #######");
+       } else {
+               MSG_DEBUG("######## Set message waiting info fail !!! #######");
+       }
+
        return;
-#endif
 }
 
 
 bool SmsPluginSetting::getMwiInfo(void)
 {
-#if 0 // New TAPI
        int ret = TAPI_API_SUCCESS;
 
        ret = tel_get_sim_messagewaiting_info(pTapiHandle, TapiEventGetMwiInfo, NULL);
@@ -835,10 +797,30 @@ bool SmsPluginSetting::getMwiInfo(void)
                MSG_DEBUG("######## Get Mainbox info was Failed !!! #######");
                return false;
        }
-#endif
+
        return true;
 }
 
+
+bool SmsPluginSetting::getMsisdnInfo(void)
+{
+       int ret = TAPI_API_SUCCESS;
+       bool result = true;
+
+       ret = tel_get_sim_msisdn(pTapiHandle, TapiEventGetMsisdnInfo, NULL);
+
+       if (ret == TAPI_API_SUCCESS) {
+               result = true;
+               MSG_DEBUG("######## tel_get_sim_msisdn() Success !!! #######");
+       } else {
+               result = false;
+               MSG_DEBUG("######## tel_get_sim_msisdn() Fail !!! return : %d #######", ret);
+       }
+
+       return result;
+}
+
+
 void SmsPluginSetting::setParamCntEvent(int ParamCnt)
 {
        mx.lock();
@@ -861,8 +843,7 @@ int SmsPluginSetting::getParamCntEvent()
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
+       if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
                return 0;
        }
@@ -879,8 +860,7 @@ void SmsPluginSetting::setParamEvent(const MSG_SMSC_DATA_S *pSmscData, int Recor
 
        memset(&smscData, 0x00, sizeof(MSG_SMSC_DATA_S));
 
-       if (bTapiResult == true)
-       {
+       if (bTapiResult == true) {
                MSG_DEBUG("Success to get parameter data");
 
                selectedParam = RecordIdx;
@@ -906,16 +886,14 @@ bool SmsPluginSetting::getParamEvent(MSG_SMSC_DATA_S *pSmscData)
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
+       if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
                return false;
        }
 
        memset(pSmscData, 0x00, sizeof(MSG_SMSC_DATA_S));
 
-       if (bTapiResult == true)
-       {
+       if (bTapiResult == true) {
                memcpy(pSmscData, &smscData, sizeof(MSG_SMSC_DATA_S));
        }
 
@@ -931,8 +909,7 @@ void SmsPluginSetting::setCbConfigEvent(const MSG_CBMSG_OPT_S *pCbOpt, bool bSuc
 
        memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
 
-       if (bTapiResult == true)
-       {
+       if (bTapiResult == true) {
                MSG_DEBUG("Success to get cb config data");
 
                memcpy(&cbOpt, pCbOpt, sizeof(MSG_CBMSG_OPT_S));
@@ -956,16 +933,14 @@ bool SmsPluginSetting::getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt)
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
+       if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
                return false;
        }
 
        memset(pCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
 
-       if (bTapiResult == true)
-       {
+       if (bTapiResult == true) {
                memcpy(pCbOpt, &cbOpt, sizeof(MSG_CBMSG_OPT_S));
        }
 
@@ -981,8 +956,7 @@ void SmsPluginSetting::setMailboxInfoEvent(SMS_SIM_MAILBOX_LIST_S *pMailboxList,
 
        memset(&simMailboxList, 0x00, sizeof(SMS_SIM_MAILBOX_LIST_S));
 
-       if (bTapiResult == true)
-       {
+       if (bTapiResult == true) {
                int i = 0;
 
                if (pMailboxList && pMailboxList->count > 0) {
@@ -992,7 +966,17 @@ void SmsPluginSetting::setMailboxInfoEvent(SMS_SIM_MAILBOX_LIST_S *pMailboxList,
                        for (i = 0; i < pMailboxList->count ; i++) {
                                MSG_DEBUG("Mailbox list[%d] type=[%d] address = [%s]", i, pMailboxList->list[i].mb_type, pMailboxList->list[i].num);
                                if (pMailboxList->list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
-                                       MsgSettingSetString(VOICEMAIL_NUMBER, pMailboxList->list[i].num);
+                                       char mailNumber[MAX_PHONE_NUMBER_LEN+1];
+                                       memset(mailNumber, 0x00 , sizeof(mailNumber));
+                                       if (simMailboxList.list[i].ton == MSG_TON_INTERNATIONAL && simMailboxList.list[i].num[0] != '+') {
+                                               snprintf(mailNumber, MAX_PHONE_NUMBER_LEN, "+%s", simMailboxList.list[i].num);
+                                               MSG_DEBUG("MSG_TON_INTERNATIONAL [%s]", mailNumber);
+                                       } else {
+                                               snprintf(mailNumber, MAX_PHONE_NUMBER_LEN, "%s", simMailboxList.list[i].num);
+                                               MSG_DEBUG("[%s]", mailNumber);
+                                       }
+                                       if (MsgSettingSetString(VOICEMAIL_NUMBER, mailNumber) != MSG_SUCCESS)
+                                               MSG_DEBUG("MsgSettingSetString is failed!!");
                                        break;
                                }
                        }
@@ -1016,19 +1000,22 @@ bool SmsPluginSetting::getMailboxInfoEvent(MSG_VOICEMAIL_OPT_S *pVoiceOpt)
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
+       if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
                return false;
        }
 
        memset(pVoiceOpt, 0x00, sizeof(MSG_VOICEMAIL_OPT_S));
 
-       if (bTapiResult == true)
-       {
+       if (bTapiResult == true) {
                for(int i = 0; i < simMailboxList.count; i++) {
                        if (simMailboxList.list[i].mb_type == MSG_SIM_MAILBOX_VOICE) {
-                               snprintf(pVoiceOpt->mailNumber, sizeof(pVoiceOpt->mailNumber), "%s", simMailboxList.list[i].num);
+                               if (simMailboxList.list[i].ton == MSG_TON_INTERNATIONAL && simMailboxList.list[i].num[0] != '+') {
+                                       snprintf(pVoiceOpt->mailNumber, sizeof(pVoiceOpt->mailNumber), "+%s", simMailboxList.list[i].num);
+                               } else {
+                                       snprintf(pVoiceOpt->mailNumber, sizeof(pVoiceOpt->mailNumber), "%s", simMailboxList.list[i].num);
+                               }
+
                                break;
                        }
                }
@@ -1045,8 +1032,7 @@ void SmsPluginSetting::setMwiInfoEvent(SMS_SIM_MWI_INFO_S *pMwiInfo, bool bSucce
 
        memset(&simMwiInfo, 0x00, sizeof(SMS_SIM_MWI_INFO_S));
 
-       if (bTapiResult == true)
-       {
+       if (bTapiResult == true) {
                int mwi_cnt = 0;
                int index = 0;
 
@@ -1072,7 +1058,8 @@ void SmsPluginSetting::setMwiInfoEvent(SMS_SIM_MWI_INFO_S *pMwiInfo, bool bSucce
                                        mwi_cnt = simMwiInfo.cphs_mwi.b_voice1;
                                }
 
-                               MsgSettingSetInt(VOICEMAIL_COUNT, mwi_cnt);
+                               if (MsgSettingSetInt(VOICEMAIL_COUNT, mwi_cnt) != MSG_SUCCESS)
+                                       MSG_DEBUG("MsgSettingSetInt is failed!!");
 
                                if (mwi_cnt > 0) {
                                        MSG_MESSAGE_INFO_S msgInfo = {0,};
@@ -1086,7 +1073,7 @@ void SmsPluginSetting::setMwiInfoEvent(SMS_SIM_MWI_INFO_S *pMwiInfo, bool bSucce
 
                                        snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new voice message", mwi_cnt);
 
-                                       MsgSoundPlayStart();
+                                       MsgSoundPlayStart(false);
                                        MsgInsertNoti(&msgInfo);
                                }
                                break;
@@ -1121,8 +1108,7 @@ bool SmsPluginSetting::getResultFromSim()
 
        mx.unlock();
 
-       if (ret == ETIMEDOUT)
-       {
+       if (ret == ETIMEDOUT) {
                MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
                return false;
        }
@@ -1162,3 +1148,4 @@ SMS_PID_T SmsPluginSetting::convertPid(MSG_SMS_PID_T pid)
 
        return retPid;
 }
+
index 84ab2fa..0c502f3 100755 (executable)
@@ -43,7 +43,7 @@ SmsPluginSimMsg::SmsPluginSimMsg()
        usedCnt = 0;
        totalCnt = 0;
        bTapiResult = false;
-       bClass2Msg = false;
+       memset(&simMsgDataInfo, 0x00, sizeof(simMsgDataInfo));
 }
 
 
@@ -130,7 +130,7 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
        if (submitData.segCount > 1)
                tpdu.data.deliver.bHeaderInd = true;
 
-       int bufLen = 0, reqId = 0;
+       int bufLen = 0;
 
        char buf[MAX_TPDU_DATA_LEN];
 
@@ -162,6 +162,14 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
                simSmsData.SmsData.szData[bufLen] = 0;
                simSmsData.SmsData.MsgLength = bufLen;
 
+#ifdef MSG_FOR_DEBUG
+               MSG_DEBUG("Sim Message.");
+               for (int j = 0; j < simSmsData.SmsData.MsgLength; j++)
+               {
+                       MSG_DEBUG("[%02x]", simSmsData.SmsData.szData[j]);
+               }
+#endif
+
                MSG_DEBUG("Read Status [%d]", pMsgInfo->bRead);
 
                if (pMsgInfo->bRead == true)
@@ -176,11 +184,11 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
 
                if (ret == TAPI_API_SUCCESS)
                {
-                       MSG_DEBUG("########  tel_write_sms_in_sim Success !!! req Id : [%d] #######", reqId);
+                       MSG_DEBUG("########  tel_write_sms_in_sim Success !!!#######");
                }
                else
                {
-                       MSG_DEBUG("########  tel_write_sms_in_sim Fail !!! req Id : [%d] return : [%d] #######", reqId, ret);
+                       MSG_DEBUG("########  tel_write_sms_in_sim Fail !!! return : [%d] #######", ret);
 
                        return MSG_ERR_PLUGIN_STORAGE;
                }
@@ -195,7 +203,7 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
 
                if (bResult == true)
                {
-                       MSG_DEBUG("########  Saving Msg was Successful !!! req Id : [%d] SIM ID : [%d] #######", reqId, SimId);
+                       MSG_DEBUG("########  Saving Msg was Successful !!! SIM ID : [%d] #######", SimId);
 
                        usedCnt = MsgSettingGetInt(SIM_USED_COUNT);
 
@@ -211,7 +219,7 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
                }
                else
                {
-                       MSG_DEBUG("########  Saving Msg was Failed !!! req Id : [%d] SIM ID : [%d] #######", reqId, SimId);
+                       MSG_DEBUG("########  Saving Msg was Failed !!! SIM ID : [%d] #######", SimId);
 
                        return MSG_ERR_PLUGIN_STORAGE;
                }
@@ -224,8 +232,6 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo,
 msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInfo)
 {
        // Reset Flag
-       bClass2Msg = false;
-
        SMS_TPDU_S tpdu;
 
        tpdu.tpduType = SMS_TPDU_DELIVER;
@@ -233,14 +239,7 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
        // Set SMS TPDU Options
        setSmsOptions(&(tpdu.data.deliver));
 
-       // Set TimeStamp
-       convertTimeStamp(pMsgInfo, &(tpdu.data.deliver));
-
-       // Set SMSC Options
-       SMS_ADDRESS_S smsc;
-       SmsPluginTransport::instance()->setSmscOptions(&smsc);
-
-       // Make SMS_SUBMIT_DATA_S from MSG_REQUEST_INFO_S
+       // Make SMS_SUBMIT_DATA_S from MSG_REQUEST_INFO_S to get segment count
        SMS_SUBMIT_DATA_S submitData;
        SmsPluginTransport::instance()->msgInfoToSubmitData(pMsgInfo, &submitData, &(tpdu.data.deliver.dcs.codingScheme), 0);
 
@@ -249,70 +248,36 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
        {
                MSG_DEBUG("SIM storage is full.");
 
+               SmsPluginTransport::instance()->sendDeliverReport(MSG_ERR_SIM_STORAGE_FULL);
+
                return MSG_ERR_SIM_STORAGE_FULL;
        }
 
-       tpdu.data.deliver.userData.headerCnt = 0;
-
-       int bufLen = 0, reqId = 0;
-
-       char buf[MAX_TPDU_DATA_LEN];
-
-       int addrLen = strlen(submitData.destAddress.address);
-
-       tpdu.data.deliver.originAddress.ton = submitData.destAddress.ton;
-       tpdu.data.deliver.originAddress.npi = submitData.destAddress.npi;
-
-       memcpy(tpdu.data.deliver.originAddress.address, submitData.destAddress.address, addrLen);
-       tpdu.data.deliver.originAddress.address[addrLen] = '\0';
+       // Create TelSmsData_t data
+       TelSmsData_t simSmsData = {0,};
 
-       tpdu.data.deliver.userData.length = submitData.userData[0].length;
-       memcpy(tpdu.data.deliver.userData.data, submitData.userData[0].data, submitData.userData[0].length);
-
-       memset(buf, 0x00, sizeof(buf));
-
-       // Encode SMS-DELIVER TPDU
-       bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
-
-       // Make Telephony Structure
-       TelSmsData_t simSmsData;
-       memset((void*)&simSmsData, 0x00, sizeof(simSmsData));
-
-       // Set TPDU data
-       memcpy((void*)simSmsData.SmsData.szData, buf, bufLen);
-
-       simSmsData.SmsData.szData[bufLen] = 0;
-       simSmsData.SmsData.MsgLength = bufLen;
+       memcpy(&simSmsData.SmsData.Sca, &simMsgDataInfo.sca, sizeof(simSmsData.SmsData.Sca));
+       memcpy(&simSmsData.SmsData.szData, &simMsgDataInfo.szData, sizeof(simSmsData.SmsData.szData)-1);
+       simSmsData.SmsData.MsgLength = simMsgDataInfo.msgLength;
 
+       // Set message status
        simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNREAD;
 
        // Save Class 2 Msg in SIM
        int tapiRet = TAPI_API_SUCCESS;
 
-       tapiRet = tel_write_sms_in_sim(pTapiHandle, &simSmsData, TapiEventSaveSimMsg, NULL);
+       tapiRet = tel_write_sms_in_sim(pTapiHandle, &simSmsData, TapiEventSaveClass2Msg, NULL);
 
        if (tapiRet == TAPI_API_SUCCESS)
        {
-               MSG_DEBUG("########  tel_write_sms_in_sim Success !!! req Id : [%d] #######", reqId);
-
-               // Set Flag
-               bClass2Msg = true;
-
                memset(&simMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
                memcpy(&simMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
 
-               usedCnt = MsgSettingGetInt(SIM_USED_COUNT);
-
-               usedCnt++;
-
-               if (MsgSettingSetInt(SIM_USED_COUNT, usedCnt) != MSG_SUCCESS)
-               {
-                       MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
-               }
+               MSG_DEBUG("########  tel_write_sms_in_sim Success !!! #######");
        }
        else
        {
-               MSG_DEBUG("########  tel_write_sms_in_sim Fail !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+               MSG_DEBUG("########  tel_write_sms_in_sim Fail !!! return : [%d] #######", tapiRet);
 
                SmsPluginTransport::instance()->sendDeliverReport(MSG_ERR_STORAGE_ERROR);
 
@@ -326,17 +291,16 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
 void SmsPluginSimMsg::deleteSimMessage(msg_sim_id_t SimMsgId)
 {
        int tapiRet = TAPI_API_SUCCESS;
-       int reqId = 0;
 
        tapiRet = tel_delete_sms_in_sim(pTapiHandle, (int)SimMsgId, TapiEventDeleteSimMsg, NULL);
 
        if (tapiRet == TAPI_API_SUCCESS)
        {
-               MSG_DEBUG("########  tel_delete_sms_in_sim Success !!! req Id : [%d] #######", reqId);
+               MSG_DEBUG("########  tel_delete_sms_in_sim Success !!! #######");
        }
        else
        {
-               THROW(MsgException::SMS_PLG_ERROR, "########  tel_delete_sms_in_sim Fail !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+               THROW(MsgException::SMS_PLG_ERROR, "########  tel_delete_sms_in_sim Fail !!! return : [%d] #######", tapiRet);
        }
 
        msg_sim_id_t SimId = 0;
@@ -348,7 +312,7 @@ void SmsPluginSimMsg::deleteSimMessage(msg_sim_id_t SimMsgId)
 
        if (bResult == true)
        {
-               MSG_DEBUG("########  Deleting Msg was Successful !!! req Id : [%d] SIM ID : [%d] #######", reqId, SimId);
+               MSG_DEBUG("########  Deleting Msg was Successful !!! SIM ID : [%d] #######", SimId);
 
                usedCnt = MsgSettingGetInt(SIM_USED_COUNT);
                totalCnt = MsgSettingGetInt(SIM_TOTAL_COUNT);
@@ -359,11 +323,11 @@ void SmsPluginSimMsg::deleteSimMessage(msg_sim_id_t SimMsgId)
 
                        if (tapiRet == TAPI_API_SUCCESS)
                        {
-                               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId);
+                               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
                        }
                        else
                        {
-                               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+                               MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! return : [%d] #######", tapiRet);
                        }
                }
 
@@ -376,7 +340,7 @@ void SmsPluginSimMsg::deleteSimMessage(msg_sim_id_t SimMsgId)
        }
        else
        {
-               THROW(MsgException::SMS_PLG_ERROR, "########  Deleting Msg was Failed !!! req Id : [%d] SIM ID : [%d] #######", reqId, SimId);
+               THROW(MsgException::SMS_PLG_ERROR, "########  Deleting Msg was Failed !!! SIM ID : [%d] #######", SimId);
        }
 }
 
@@ -595,7 +559,6 @@ bool SmsPluginSimMsg::getSimMsgCntEvent(MSG_SIM_COUNT_S *pSimMsgCnt)
        return true;
 }
 
-
 void SmsPluginSimMsg::setSimMsgEvent(const MSG_MESSAGE_INFO_S *pMsgInfo, bool bSuccess)
 {
        mx.lock();
@@ -646,20 +609,47 @@ bool SmsPluginSimMsg::getSimMsgEvent(MSG_MESSAGE_INFO_S *pMsgInfo)
 }
 
 
-void SmsPluginSimMsg::setSimEvent(msg_sim_id_t SimId, bool bResult)
+void SmsPluginSimMsg::setSaveSimMsgEvent(int simMsgId, int result)
 {
-       if (bClass2Msg == true)
-       {
-               msg_error_t err = MSG_SUCCESS;
+       msg_error_t err = MSG_SUCCESS;
 
-               simMsgInfo.msgId = SimId;
+       mx.lock();
 
-               // Add Deliver Class2 Msg into DB
-               err = SmsPluginStorage::instance()->addSmsMessage(&simMsgInfo);
+       if (result != TAPI_NETTEXT_SENDSMS_SUCCESS) {
+               if (result == TAPI_NETTEXT_ROUTING_NOT_AVAILABLE)
+                       err = MSG_ERR_SIM_STORAGE_FULL;
+               else
+                       err = MSG_ERR_UNKNOWN;
+       }
+
+       if (err == MSG_SUCCESS)
+               bTapiResult = true;
+       else
+               bTapiResult = false;
+
+       cv.signal();
+
+       mx.unlock();
+
+       // Send Deliver Report
+       SmsPluginTransport::instance()->sendDeliverReport(err);
+
+}
+
+
+void SmsPluginSimMsg::setSaveClass2MsgEvent(int simMsgId, int result)
+{
+       msg_error_t err = MSG_SUCCESS;
+
+       if (result == TAPI_NETTEXT_SENDSMS_SUCCESS && simMsgId >= 0) {
+
+               simMsgInfo.msgId = simMsgId;
+
+               err = SmsPluginStorage::instance()->addSimMessage(&simMsgInfo);
 
                if (err == MSG_SUCCESS)
                {
-                       MSG_DEBUG("addMessage() Success !!");
+                       MSG_DEBUG("addSimMessage() Success !!");
 
                        // Callback
                        err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&simMsgInfo);
@@ -668,28 +658,40 @@ void SmsPluginSimMsg::setSimEvent(msg_sim_id_t SimId, bool bResult)
                        {
                                MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
                        }
-               }
-               else
-               {
+
+                       usedCnt = MsgSettingGetInt(SIM_USED_COUNT);
+
+                       usedCnt++;
+
+                       if (MsgSettingSetInt(SIM_USED_COUNT, usedCnt) != MSG_SUCCESS)
+                       {
+                               MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
+                       }
+               } else  {
                        MSG_DEBUG("addMessage() Error !! [%d]", err);
                }
+       } else {
+                       if (result == TAPI_NETTEXT_ROUTING_NOT_AVAILABLE)
+                               err = MSG_ERR_SIM_STORAGE_FULL;
+                       else
+                               err = MSG_ERR_UNKNOWN;
+       }
 
-               // Send Deliver Report
-               SmsPluginTransport::instance()->sendDeliverReport(err);
+       // Send Deliver Report
+       SmsPluginTransport::instance()->sendDeliverReport(err);
+}
 
-               bClass2Msg = false;
-       }
-       else
-       {
-               mx.lock();
 
-               simMsgId = SimId;
-               bTapiResult = bResult;
+void SmsPluginSimMsg::setSimEvent(msg_sim_id_t SimId, bool bResult)
+{
+       mx.lock();
 
-               cv.signal();
+       simMsgId = SimId;
+       bTapiResult = bResult;
 
-               mx.unlock();
-       }
+       cv.signal();
+
+       mx.unlock();
 }
 
 
@@ -717,3 +719,14 @@ bool SmsPluginSimMsg::getSimEvent(msg_sim_id_t *pSimId)
 
        return bTapiResult;
 }
+
+void SmsPluginSimMsg::setSmsData(const char *sca, const char *szData, int msgLength)
+{
+       MSG_DEBUG("Set SMS data(class2 message)");
+
+       memset(&simMsgDataInfo, 0x00, sizeof(simMsgDataInfo));
+
+       memcpy(&simMsgDataInfo.sca, sca, sizeof(simMsgDataInfo.sca)-1);
+       memcpy(&simMsgDataInfo.szData, szData, sizeof(simMsgDataInfo.szData)-1);
+       simMsgDataInfo.msgLength = msgLength;
+}
index b156353..354ec14 100755 (executable)
@@ -37,7 +37,11 @@ SmsPluginStorage* SmsPluginStorage::pInstance = NULL;
 
 SmsPluginStorage::SmsPluginStorage()
 {
-
+/*** No need to connect DB anymore.
+       if (dbHandle.connect() != MSG_SUCCESS) {
+               MSG_DEBUG("DB Connect Fail");
+       }
+***/
 }
 
 
@@ -64,6 +68,9 @@ msg_error_t SmsPluginStorage::updateSentMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_ne
 {
        MSG_BEGIN();
 
+/***  Comment below line to not save the time value after sent status (it could be used later.)
+       time_t curTime = time(NULL);
+***/
        char sqlQuery[MAX_QUERY_LEN+1];
 
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
@@ -89,11 +96,88 @@ msg_error_t SmsPluginStorage::updateSentMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_ne
                MsgAddPhoneLog(pMsgInfo);
        }
 
+
        MSG_END();
 
        return MSG_SUCCESS;
 }
 
+#ifdef SMS_REPORT_OPERATION
+msg_error_t SmsPluginStorage::updateMsgRef(msg_message_id_t MsgId, unsigned char MsgRef)
+{
+       MSG_BEGIN();
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = %d WHERE MSG_ID = %d;",
+                               MSGFW_REPORT_TABLE_NAME, (int)MsgRef, MsgId);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+               MSG_DEBUG("Query Failed : [%s]", sqlQuery);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       /** Set Message Reference for updating report table */
+       tmpMsgRef = MsgRef;
+
+       MSG_DEBUG("MsgRef : %d", MsgRef);
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+
+
+msg_error_t SmsPluginStorage::updateStatusReport(unsigned char MsgRef, msg_delivery_report_status_t Status, time_t DeliveryTime)
+{
+       MSG_BEGIN();
+
+       MSG_DEBUG("tmpMsgRef : %d", tmpMsgRef);
+
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       /** Get Msg Id for Quickpanel Noti */
+       msg_message_id_t msgId = 0;
+
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE MSG_REF = %d;",
+                                       MSGFW_REPORT_TABLE_NAME, (int)tmpMsgRef);
+
+       if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbHandle.stepQuery() == MSG_ERR_DB_ROW)
+               msgId = dbHandle.columnInt(0);
+
+       dbHandle.finalizeQuery();
+
+       /** Update Status */
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+       snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, DELIVERY_REPORT_STATUS = %d, DELIVERY_REPORT_TIME = %lu WHERE MSG_REF = %d;",
+                                       MSGFW_REPORT_TABLE_NAME, Status, DeliveryTime, (int)tmpMsgRef);
+
+       if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS) {
+               MSG_DEBUG("Query Failed : [%s]", sqlQuery);
+               return MSG_ERR_DB_EXEC;
+       }
+
+       /** Insert Quickpanel Noti */
+       msg_error_t ret = MSG_SUCCESS;
+
+       ret = MsgInsertSmsNotiToQuickpanel(&dbHandle, msgId, Status);
+
+       if (ret != MSG_SUCCESS) {
+               MSG_DEBUG("MsgInsertSmsNotiToQuickpanel() Failed : [%d]", ret);
+               return ret;
+       }
+
+       MSG_END();
+
+       return MSG_SUCCESS;
+}
+#endif
 
 msg_error_t SmsPluginStorage::addSimMessage(MSG_MESSAGE_INFO_S *pSimMsgInfo)
 {
@@ -114,6 +198,8 @@ msg_error_t SmsPluginStorage::addSimMessage(MSG_MESSAGE_INFO_S *pSimMsgInfo)
                return err;
        }
 
+       pSimMsgInfo->threadId = convId;
+
        err = dbHandle.getRowId(MSGFW_MESSAGE_TABLE_NAME, &msgId);
 
        if (err != MSG_SUCCESS) {
@@ -230,6 +316,12 @@ msg_error_t SmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
        err = checkStorageStatus(pMsgInfo);
 
        if (err != MSG_SUCCESS) {
+               if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
+                       pMsgInfo->folderId = 0;
+                       if (addSmsMessage(pMsgInfo) != MSG_SUCCESS) {
+                               MSG_DEBUG("addSmsMessage is failed!");
+                       }
+               }
                return err;
        }
 
@@ -551,7 +643,8 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
        mmsCnt = MsgStoGetUnreadCnt(&dbHandle, MSG_MMS_TYPE);
 
        MsgSettingHandleNewMsg(smsCnt, mmsCnt);
-       MsgDeleteNotiByMsgId(msgId);
+//     MsgDeleteNotiByMsgId(msgId);
+       MsgRefreshNoti();
 
        return MSG_SUCCESS;
 }
index 6849f7f..daa2dd6 100755 (executable)
@@ -471,6 +471,36 @@ int SmsPluginTpduCodec::decodeDeliver(const unsigned char *pTpdu, int TpduLen, S
 {
        int offset = 0, udLen = 0;
 
+#if 1
+               char temp[2048];
+               char tempcat[100];
+               memset(temp, 0x00, sizeof(temp));
+               memset(tempcat, 0x00, sizeof(tempcat));
+
+               time_t rawtime;
+               time ( &rawtime );
+
+               sprintf(temp, "[MT] %s", ctime(&rawtime));
+
+               for (int i = 0; i < TpduLen; i++)
+               {
+                       sprintf(tempcat, "[%02x]\n", pTpdu[i]);
+                       strncat(temp, tempcat, sizeof(temp)-strlen(temp)-1);
+                       memset(tempcat, 0x00, sizeof(tempcat));
+               }
+
+
+               sprintf(tempcat, "\n\n\n");
+               strncat(temp, tempcat, sizeof(temp)-strlen(temp)-1);
+
+               //MsgOpenCreateAndOverwriteFile(TPDU_LOG_FILE, temp, strlen(temp));
+               FILE*   pFile=NULL ;
+               pFile = MsgOpenFile(TPDU_LOG_FILE, "a");
+               MsgWriteFile(temp, sizeof(char), strlen(temp), pFile);
+
+               MsgFflush(pFile);
+               MsgCloseFile(pFile);
+#endif
        // TP-MMS
        if (pTpdu[offset] & 0x04)
                pDeliver->bMoreMsg = false;
@@ -518,6 +548,16 @@ int SmsPluginTpduCodec::decodeDeliver(const unsigned char *pTpdu, int TpduLen, S
 
 int SmsPluginTpduCodec::decodeStatusReport(const unsigned char *pTpdu, int TpduLen, SMS_STATUS_REPORT_S *pStatusRep)
 {
+#ifdef LOG_ENABLE
+       printf("\n\n[decodeStatusReport] pTpdu data - Length [%d]\n", TpduLen);
+
+       for (int i = 0; i < TpduLen; i++)
+       {
+               printf(" [%02x]", pTpdu[i]);
+       }
+       printf("\n\n");
+#endif
+
        int offset = 0, udLen = 0;
 
        char* address = NULL;
index e461783..0ce2043 100755 (executable)
@@ -121,7 +121,7 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo)
                        MSG_DEBUG("pSCAInfo [%02x]", smscAddr[j]);
                }
 
-               int bufLen = 0, reqId = 0;
+               int bufLen = 0;
 
                char buf[MAX_TPDU_DATA_LEN];
 
@@ -138,17 +138,29 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo)
                        tpdu.data.submit.destAddress.address[MAX_ADDRESS_LEN] = '\0';
                }
 
+#ifdef MSG_FOR_DEBUG
+MSG_DEBUG("ton [%d]", tpdu.data.submit.destAddress.ton);
+MSG_DEBUG("npi [%d]", tpdu.data.submit.destAddress.npi);
+MSG_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
+#endif
+
+               bool bStatusReport = false;
+
                for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++)
                {
-                       if (submitData.userData[segCnt].headerCnt > 0)
-                       {
+                       if (submitData.userData[segCnt].headerCnt > 0) {
                                tpdu.data.submit.bHeaderInd = true;
-                       }
-                       else
-                       {
+                       } else {
                                tpdu.data.submit.bHeaderInd = false;
                        }
 
+                       if (segCnt == 0 && submitData.segCount > 1) {
+                               bStatusReport = tpdu.data.submit.bStatusReport;
+                               tpdu.data.submit.bStatusReport = false;
+                       } else if ((segCnt+1 == submitData.segCount) && submitData.segCount > 1) {
+                               tpdu.data.submit.bStatusReport = bStatusReport;
+                       }
+
                        memset(&(tpdu.data.submit.userData), 0x00, sizeof(SMS_USERDATA_S));
                        memcpy(&(tpdu.data.submit.userData), &(submitData.userData[segCnt]), sizeof(SMS_USERDATA_S));
 
@@ -172,6 +184,54 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo)
                        memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
                        pkgInfo.Sca[smscLen] = '\0';
 
+#ifdef MSG_FOR_DEBUG
+                       MSG_DEBUG("[submitRequest] TPDU.");
+
+                       for (j = 0; j < pkgInfo.MsgLength; j++)
+                       {
+                               MSG_DEBUG("[%02x]", pkgInfo.szData[j]);
+                       }
+
+                       for (j = 0; j < smscLen; j++)
+                       {
+                               MSG_DEBUG("pkgInfo.pSCA [%02x]", pkgInfo.Sca[j]);
+                       }
+#endif
+
+#ifdef MSG_DEBUG_BY_FILE
+                       char temp[2048];
+                       char tempcat[100];
+                       memset(temp, 0x00, sizeof(temp));
+                       memset(tempcat, 0x00, sizeof(tempcat));
+
+                       time_t rawtime;
+                       time(&rawtime);
+
+                       snprintf(temp, sizeof(temp), "[MO] %s", ctime(&rawtime));
+
+                       for (j = 0; j < pkgInfo.MsgLength; j++)
+                       {
+                               snprintf(tempcat, sizeof(tempcat), "[%02x]\n", pkgInfo.szData[j]);
+                               strncat(temp, tempcat, sizeof(temp)-strlen(temp)-1);
+                               memset(tempcat, 0x00, sizeof(tempcat));
+                       }
+
+
+                       snprintf(tempcat, sizeof(tempcat), "\n\n\n");
+                       strncat(temp, tempcat, sizeof(temp)-strlen(temp)-1);
+
+                       //MSG_DEBUG("temp [%s], length [%d]", temp, strlen(temp));
+
+                       //MsgOpenCreateAndOverwriteFile(TPDU_LOG_FILE, temp, strlen(temp));
+                       FILE*   pFile=NULL ;
+                       pFile = MsgOpenFile(TPDU_LOG_FILE, "a");
+                       MsgWriteFile(temp, sizeof(char), strlen(temp), pFile);
+
+                       MsgFflush(pFile);
+                       MsgCloseFile(pFile);
+
+#endif
+
                        SMS_SENT_INFO_S sentInfo = {};
 
                        bool bMoreMsg = FALSE;
@@ -215,16 +275,29 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo)
                        char *msisdn = NULL;
                        msisdn = MsgSettingGetString(MSG_SIM_MSISDN);
 
-                       MSG_SMS_VLD("[SMS INFO] %d, SMS Send Start, %s->%s, %s",  pReqInfo->msgInfo.msgId, \
+                       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("[SMS TEXT] %d, [%s]", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.msgText);
+                       MSG_SMS_VLD_TXT("%d, [%s]", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.msgText);
 
                        msg_network_status_t retStatus = getNetStatus();
 
-                       MSG_SMS_VLD("[SMS INFO] %d, SMS Send End, %s->%s, %s",  pReqInfo->msgInfo.msgId, \
+       #ifdef MSG_SMS_REPORT
+                       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.
+                                       MsgStoAddDeliveryReportStatus( tmpInfo.msgInfo.msgId, (unsigned char)tmpInfo.msgInfo.referenceId);
+                               }
+                       }
+       #endif
+
+                       MSG_SMS_VLD_INFO("%d, SMS Send End, %s->%s, %s",  pReqInfo->msgInfo.msgId, \
                                                                                                                                        (msisdn == NULL)?"ME":msisdn, \
                                                                                                                                        pReqInfo->msgInfo.addressList[0].addressVal, \
                                                                                                                                        (retStatus == MSG_NETWORK_SEND_SUCCESS)?"Success":"Fail");
@@ -232,11 +305,15 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo)
 
                        if (retStatus == MSG_NETWORK_SEND_SUCCESS)
                        {
+                               if (bMoreMsg == false) {
+                                       MsgInsertTicker("SMS is sent", SMS_MESSAGE_SENT);
+                               }
                                MSG_DEBUG("########  Msg Sent was Successful !!! return : [%d] #######", retStatus);
                        }
                        else
                        {
                                MsgInsertTicker("Sending SMS is failed", NULL);
+                               MsgInsertTicker("Sending SMS is failed", SMS_MESSAGE_SENDING_FAIL);
 
                                SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
 
@@ -261,7 +338,7 @@ void SmsPluginTransport::sendDeliverReport(msg_error_t err)
 
        TelSmsResponse_t response;
 
-       int tapiRet = TAPI_API_SUCCESS, reqId = 0;
+       int tapiRet = TAPI_API_SUCCESS;
 
        if (err == MSG_SUCCESS)
        {
@@ -272,11 +349,11 @@ void SmsPluginTransport::sendDeliverReport(msg_error_t err)
 
                if (tapiRet == TAPI_API_SUCCESS)
                {
-                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId);
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
                }
                else
                {
-                       MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
                }
        }
        else if (err == MSG_ERR_SIM_STORAGE_FULL)
@@ -289,11 +366,11 @@ void SmsPluginTransport::sendDeliverReport(msg_error_t err)
 
                if (tapiRet == TAPI_API_SUCCESS)
                {
-                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId);
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
                }
                else
                {
-                       MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
                }
        }
        else if (err == MSG_ERR_MESSAGE_COUNT_FULL)
@@ -306,11 +383,11 @@ void SmsPluginTransport::sendDeliverReport(msg_error_t err)
 
                if (tapiRet == TAPI_API_SUCCESS)
                {
-                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId);
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Success !!! #######");
                }
                else
                {
-                       MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+                       MSG_DEBUG("########  tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
                }
        }
        else
@@ -336,6 +413,17 @@ void SmsPluginTransport::sendDeliverReport(msg_error_t err)
 
        bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
 
+#ifdef MSG_FOR_DEBUG
+       /////// print DeliverReport tpdu
+       printf("\n\n######## DeliverReport tpdu #########\n");
+       for(int i=0; i < bufLen; i++)
+       {
+               printf("[%02x] ", buf[i]);
+       }
+       printf("\n#################################\n\n");
+       //////
+#endif
+
        // Make Telephony Structure
        TelSmsDatapackageInfo_t pkgInfo;
 
@@ -370,16 +458,144 @@ void SmsPluginTransport::sendDeliverReport(msg_error_t err)
 
        if (tapiRet == TAPI_API_SUCCESS)
        {
-               MSG_DEBUG("########  tel_send_sms_deliver_report() Success !!! req Id : [%d] #######", reqId);
+               MSG_DEBUG("########  tel_send_sms_deliver_report() Success !!! #######");
        }
        else
        {
-               MSG_DEBUG("########  tel_send_sms_deliver_report() Fail !!! req Id : [%d] return : [%d] #######", reqId, tapiRet);
+               MSG_DEBUG("########  tel_send_sms_deliver_report() Fail !!! return : [%d] #######", tapiRet);
        }
 
        MSG_END();
 }
 
+void SmsPluginTransport::sendClass0DeliverReport(msg_error_t err)
+{
+       MSG_BEGIN();
+
+       SMS_TPDU_S tpdu;
+
+       tpdu.tpduType = SMS_TPDU_DELIVER_REP;
+
+       TelSmsResponse_t response;
+
+       int tapiRet = TAPI_API_SUCCESS;
+
+       if (err == MSG_SUCCESS)
+       {
+               tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
+               response = TAPI_NETTEXT_SENDSMS_SUCCESS;
+
+               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_SIM_STORAGE_FULL)
+       {
+               tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
+               response = TAPI_NETTEXT_SENDSMS_SUCCESS;
+
+               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_MESSAGE_COUNT_FULL)
+       {
+               tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
+               response = TAPI_NETTEXT_SENDSMS_SUCCESS;
+
+               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
+       {
+               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_SIM_FULL;
+
+       }
+
+       MSG_DEBUG("err : [%d], response : [%02x]", err, response);
+
+       tpdu.data.deliverRep.bHeaderInd = false;
+       tpdu.data.deliverRep.paramInd = 0x00;
+
+       // Encode SMS-DELIVER-REPORT TPDU
+       int bufLen = 0;
+
+       char buf[MAX_TPDU_DATA_LEN];
+       memset(buf, 0x00, sizeof(buf));
+
+       bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
+
+       // Make Telephony Structure
+       TelSmsDatapackageInfo_t pkgInfo;
+
+       // Set TPDU data
+       memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
+       memcpy((void*)pkgInfo.szData, buf, bufLen);
+
+       pkgInfo.szData[bufLen] = 0;
+       pkgInfo.MsgLength = bufLen;
+
+       // Set SMSC Address
+       SMS_ADDRESS_S smsc;
+
+       // Set SMSC Options
+       setSmscOptions(&smsc);
+
+       // Encode SMSC Address
+       unsigned char smscAddr[MAX_SMSC_LEN];
+       memset(smscAddr, 0x00, sizeof(smscAddr));
+
+       int smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr);
+
+       if (smscLen <= 0) return;
+
+       // Set SMSC data
+       memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
+       memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
+       pkgInfo.Sca[smscLen] = '\0';
+
+       // 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();
+}
+
+
 
 void SmsPluginTransport::setSmsSendOptions(SMS_SUBMIT_S *pSubmit)
 {
@@ -498,12 +714,14 @@ void SmsPluginTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo,
 
        MSG_LANGUAGE_ID_T langId = MSG_LANG_ID_RESERVED;
 
+       bool bAbnormal = false;
+
        // User Data
        if (pMsgInfo->bTextSms == true)
        {
                if (*pCharType == SMS_CHARSET_7BIT)
                {
-                       decodeLen = textCvt.convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, pMsgInfo->dataSize, &langId);
+                       decodeLen = textCvt.convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, &langId, &bAbnormal);
                }
                else if (*pCharType == SMS_CHARSET_8BIT)
                {
@@ -512,11 +730,11 @@ void SmsPluginTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo,
                }
                else if (*pCharType == SMS_CHARSET_UCS2)
                {
-                       decodeLen = textCvt.convertUTF8ToUCS2(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, pMsgInfo->dataSize);
+                       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, pMsgInfo->dataSize, &encodeType);
+                       decodeLen = textCvt.convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, &encodeType);
                        *pCharType = encodeType;
                }
        }
@@ -535,7 +753,7 @@ void SmsPluginTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo,
 
                if (*pCharType == SMS_CHARSET_7BIT)
                {
-                       decodeLen = textCvt.convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &langId);
+                       decodeLen = textCvt.convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &langId, &bAbnormal);
                }
                else if (*pCharType == SMS_CHARSET_8BIT)
                {
@@ -700,14 +918,14 @@ int SmsPluginTransport::getSegmentSize(SMS_CODING_SCHEME_T CodingScheme, int Dat
 
        if (CodingScheme == SMS_CHARSET_7BIT)
        {
-               if (((DataLen+headerSize)/maxSize) > 1)
+               if (((DataLen+headerSize)/maxSize) >= 1)
                        segSize = ((140*8) - ((headerLen + concat + headerSize)*8)) / 7;
                else
                        segSize = DataLen;
        }
        else if (CodingScheme == SMS_CHARSET_8BIT || CodingScheme == SMS_CHARSET_UCS2)
        {
-               if (((DataLen+headerSize)/maxSize) > 1)
+               if (((DataLen+headerSize)/maxSize) >= 1)
                        segSize = 140 - (headerLen + concat + headerSize);
                else
                        segSize = DataLen;
@@ -758,7 +976,7 @@ msg_network_status_t SmsPluginTransport::getNetStatus()
        int ret = 0;
 
        if (curStatus == MSG_NETWORK_SENDING)
-               ret = cv.timedwait(mx.pMutex(), 65);
+               ret = cv.timedwait(mx.pMutex(), 125);
 
        mx.unlock();
 
index 0e97339..a61d630 100755 (executable)
@@ -85,9 +85,12 @@ void SmsPluginUAManager::run()
 }
 
 
-void SmsPluginUAManager::addReqEntity(SMS_REQUEST_INFO_S request)
+void SmsPluginUAManager::addReqEntity(SMS_REQUEST_INFO_S *request)
 {
-       smsTranQ.push_back(request);
+       SMS_REQUEST_INFO_S reqTmp = {0,};
+
+       memcpy(&reqTmp, request, sizeof(SMS_REQUEST_INFO_S));
+       smsTranQ.push_back(reqTmp);
        cv.signal();
 }
 
index e953d95..32d67ff 100755 (executable)
@@ -284,9 +284,8 @@ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
                {
                        headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
 
-                       if (headerLen <= 0)
-                       {
-                               MSG_DEBUG("Error to decode User Data Header");
+                       if (headerLen <= 0) {
+                               MSG_DEBUG("Error to decode User Data Header. headerLen [%d]", headerLen);
 
                                pUserData->length = 0;
                                memset(pUserData->data, 0x00, sizeof(pUserData->data));
@@ -296,6 +295,15 @@ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
 
                        offset += headerLen;
 
+                       if (offset > (udhl+2)) {
+                               MSG_DEBUG("Error to decode User Data Header. offset [%d] > (udhl [%d] + 2)", offset, udhl);
+
+                               pUserData->length = 0;
+                               memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+                               return 0;
+                       }
+
                        pUserData->headerCnt++;
                }
        }
@@ -318,6 +326,10 @@ 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;
 }
 
@@ -361,9 +373,8 @@ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
                {
                        headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
 
-                       if (headerLen <= 0)
-                       {
-                               MSG_DEBUG("Error to decode User Data Header");
+                       if (headerLen <= 0) {
+                               MSG_DEBUG("Error to decode User Data Header. headerLen [%d]", headerLen);
 
                                pUserData->length = 0;
                                memset(pUserData->data, 0x00, sizeof(pUserData->data));
@@ -373,6 +384,15 @@ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
 
                        offset += headerLen;
 
+                       if (offset > (udhl+2)) {
+                               MSG_DEBUG("Error to decode User Data Header. offset [%d] > (udhl [%d] + 2)", offset, udhl);
+
+                               pUserData->length = 0;
+                               memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+                               return 0;
+                       }
+
                        pUserData->headerCnt++;
                }
        }
@@ -435,9 +455,8 @@ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
                {
                        headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
 
-                       if (headerLen <= 0)
-                       {
-                               MSG_DEBUG("Error to decode User Data Header");
+                       if (headerLen <= 0) {
+                               MSG_DEBUG("Error to decode User Data Header. headerLen [%d]", headerLen);
 
                                pUserData->length = 0;
                                memset(pUserData->data, 0x00, sizeof(pUserData->data));
@@ -447,6 +466,15 @@ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
 
                        offset += headerLen;
 
+                       if (offset > (udhl+2)) {
+                               MSG_DEBUG("Error to decode User Data Header. offset [%d] > (udhl [%d] + 2)", offset, udhl);
+
+                               pUserData->length = 0;
+                               memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+                               return 0;
+                       }
+
                        pUserData->headerCnt++;
                }
        }
@@ -712,7 +740,11 @@ MSG_DEBUG("lockingShift.langId [%02x]", pHeader->udh.lockingShift.langId);
                default :
                {
                        MSG_DEBUG("Not Supported Header Type [%02x]", pHeader->udhType);
-                       return 0;
+
+                       IEDL = pTpdu[offset++];
+
+                       MSG_DEBUG("IEDL [%d]", IEDL);
+                       return (offset + IEDL);
                }
                break;
        }
@@ -725,6 +757,8 @@ 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;
 
@@ -732,9 +766,14 @@ int SmsPluginUDCodec::pack7bitChar(const unsigned char *pUserData, int dataLen,
        {
                if (shift == 0)
                {
+//                     if (srcIdx > 0) srcIdx++;
+
+//MSG_DEBUG("pUserData [%02x]", pUserData[srcIdx]);
+//MSG_DEBUG("shift = %d", shift);
 
                        pPackData[dstIdx] = pUserData[srcIdx];
 
+//MSG_DEBUG("pPackData [%02x]", pPackData[dstIdx]);
                        if (srcIdx >= dataLen) break;
 
                        shift = 7;
@@ -744,24 +783,34 @@ int SmsPluginUDCodec::pack7bitChar(const unsigned char *pUserData, int dataLen,
 
                if (shift > 1)
                {
+//MSG_DEBUG("pUserData [%02x]", pUserData[srcIdx]);
+
+//MSG_DEBUG("shift = %d", shift);
 
                        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);
                        pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
 
+//MSG_DEBUG("pPackData [%02x]", pPackData[dstIdx-1]);
+
                        srcIdx++;
 
                        shift--;
                }
        }
 
+//MSG_DEBUG("dstIdx = %d", dstIdx);
+
        return dstIdx;
 }
 
@@ -779,8 +828,11 @@ MSG_DEBUG("dataLen = %d", dataLen);
        {
                if (shift == 0)
                {
+//MSG_DEBUG("shift = %d", shift);
+
                        pUnpackData[dstIdx] = pTpdu[srcIdx] & 0x7F;
 
+//MSG_DEBUG("UserData[%d] = %02x", dstIdx, pUnpackData[dstIdx]);
                        shift = 7;
                        srcIdx++;
                        dstIdx++;
@@ -790,10 +842,14 @@ MSG_DEBUG("dataLen = %d", dataLen);
 
                if (shift > 0)
                {
+//MSG_DEBUG("shift = %d", shift);
+
                        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++;
@@ -802,3 +858,4 @@ MSG_DEBUG("dataLen = %d", dataLen);
 
        return dstIdx;
 }
+
index ac0b498..63a95a5 100755 (executable)
@@ -25,6 +25,7 @@
 #include "SmsPluginWapPushHandler.h"
 
 #include <drm_client.h>
+#include <dbus/dbus-glib.h>
 
 static unsigned short wapPushPortList [] = {0x0b84, 0x0b85, 0x23F0, 0x23F1, 0x23F2, 0x23F3, 0xC34F};
 
@@ -810,6 +811,17 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi
 {
        MSG_BEGIN();
 
+#ifdef MSG_FW_FOR_DEBUG
+       MSG_DEBUG("DataSize [%d]", DataSize);
+
+       MSG_DEBUG("[pUserData]");
+       for (int i = 0; i < DataSize; i++)
+       {
+               printf("[%02x]", pUserData[i]);
+       }
+       printf("\n\n");
+#endif
+
        unsigned char* pPDUTypeData = (unsigned char*)pUserData;
        unsigned long PDUTypeDataLen = DataSize;
 
@@ -856,6 +868,17 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi
                }
        }
 
+#ifdef MSG_FW_FOR_DEBUG
+       MSG_DEBUG("wspHeaderLen [%d]", wspHeaderLen);
+
+       MSG_DEBUG("[pWspHeader]");
+       for (int i = 0; i < wspHeaderLen; i++)
+       {
+               printf("[%02x]", pWspHeader[i]);
+       }
+       printf("\n\n");
+#endif
+
        /** return if it is below case error */
        if (PDUTypeDataLen < wspHeaderLen) {
                MSG_DEBUG("PDUTypeDataLen < wspHeaderLen !!!");
@@ -1051,6 +1074,61 @@ void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPu
        MSG_END();
 }
 #else
+static void launchProcessByAppcode(int appcode)
+{
+       MSG_BEGIN();
+       GError *error = NULL;
+       DBusGConnection *connection = NULL;
+       DBusGProxy *dbus_proxy;
+
+       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 = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+                               if (error != NULL) {
+                                       MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+                                       g_error_free(error);
+                                       MSG_END();
+                               }
+                               dbus_proxy = dbus_g_proxy_new_for_name(connection, "com.samsung.omadmagent",
+                                                                      "/com/samsung/omadmagent", "com.samsung.omadmagent");
+                               MSG_DEBUG("dbus_proxy %x", dbus_proxy);
+                               dbus_g_proxy_call(dbus_proxy, "Hello_Agent", &error, G_TYPE_INVALID, G_TYPE_INVALID);
+                               g_object_unref(dbus_proxy);
+                               dbus_g_connection_unref(connection);
+                               MSG_END();
+                       }
+                       break;
+               case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+               case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
+                       {
+                               connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+                               if (error != NULL) {
+                                       MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+                                       g_error_free(error);
+                                       MSG_END();
+                               }
+                               dbus_proxy = dbus_g_proxy_new_for_name(connection, "com.samsung.omadsagent",
+                                                                                "/com/samsung/omadsagent", "com.samsung.omadsagent");
+                               MSG_DEBUG("dbus_proxy %x", dbus_proxy);
+                               dbus_g_proxy_call(dbus_proxy, "Hello_Agent", &error, G_TYPE_INVALID, G_TYPE_INVALID);
+                               g_object_unref(dbus_proxy);
+                               dbus_g_connection_unref(connection);
+                               MSG_END();
+                       }
+                       break;
+               default:
+                       break;
+       }
+       MSG_END();
+}
+
 void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen)
 {
        MSG_BEGIN();
@@ -1086,6 +1164,8 @@ void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPu
                        return;
                }
 
+               launchProcessByAppcode(appcode);
+
                switch (appcode) {
                case SMS_WAP_APPLICATION_MMS_UA:
                        MSG_DEBUG("Received MMS Notification");
@@ -1218,6 +1298,16 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P
 {
        MSG_BEGIN();
 
+#ifdef MSG_FW_FOR_DEBUG
+       printf("\n\n[handleMMSNotification] Push Body.\n");
+
+       for (int i = 0; i < PushBodyLen; i++)
+       {
+               printf(" [%02x]", pPushBody[i]);
+       }
+       printf("\n\n");
+#endif
+
        /** Make MSG_MESSAGE_INFO_S */
        MSG_MESSAGE_INFO_S msgInfo;
        memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
@@ -1234,7 +1324,7 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P
                msgInfo.bTextSms = false;
 
                /** Save Message Data into File */
-               char fileName[MAX_COMMON_INFO_SIZE+1];
+               char fileName[MSG_FILENAME_LEN_MAX+1];
                memset(fileName, 0x00, sizeof(fileName));
 
                if (MsgCreateFileName(fileName) == false)
@@ -1296,8 +1386,8 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen,
 
        topNode = xmlDocGetRootElement(xmlDoc);
 
-       if (xmlDoc == NULL) {
-               MSG_DEBUG("Empty Document");
+       if (topNode == NULL) {
+               MSG_DEBUG("topNode is NULL");
                xmlFreeDoc(xmlDoc);
                return;
        }
@@ -1369,7 +1459,7 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen,
        strncpy(pushMsg.contents, (char*)tmpXmlChar, MAX_WAPPUSH_CONTENTS_LEN-1);
 
        /** Write push Msg to file */
-       char fileName[MAX_COMMON_INFO_SIZE+1];
+       char fileName[MSG_FILENAME_LEN_MAX+1];
        memset(fileName, 0x00, sizeof(fileName));
 
        if (MsgCreateFileName(fileName) == false) {
@@ -1434,6 +1524,8 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen,
 
        xmlChar*                tmpXmlChar = NULL;
 
+       msg_error_t err = MSG_SUCCESS;
+
        if (pPushBody == NULL) {
                MSG_DEBUG("pPushBody is NULL \n" );
                return;
@@ -1500,7 +1592,7 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen,
        MSG_DEBUG("pushMsg.contents : [%s]", pushMsg.contents);
 
        /** Write push Msg to file */
-       char fileName[MAX_COMMON_INFO_SIZE+1];
+       char fileName[MSG_FILENAME_LEN_MAX+1];
        memset(fileName, 0x00, sizeof(fileName));
 
        if (MsgCreateFileName(fileName) == false)
@@ -1528,7 +1620,10 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen,
        MSG_DEBUG("dataSize : %d", msgInfo.dataSize);
 
        /** Callback to MSG FW */
-       SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+       err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+       if (err != MSG_SUCCESS)
+               MSG_DEBUG("callbackMsgIncoming is failed, err=[%d]", err);
 
        xmlFree(xmlDoc);
        xmlFree(tmpXmlChar);
@@ -1606,7 +1701,7 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen,
        }
 
        /**  Write push Msg to file */
-       char fileName[MAX_COMMON_INFO_SIZE+1];
+       char fileName[MSG_FILENAME_LEN_MAX+1];
        memset(fileName, 0x00, sizeof(fileName));
 
        if (MsgCreateFileName(fileName) == false) {
@@ -1703,6 +1798,60 @@ void SmsPluginWapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
 
        time_t rawtime = time(NULL);
 
+/*** 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);
+               MSG_DEBUG("month : %d", tmpTimeStamp.time.absolute.month);
+               MSG_DEBUG("day : %d", tmpTimeStamp.time.absolute.day);
+               MSG_DEBUG("hour : %d", tmpTimeStamp.time.absolute.hour);
+               MSG_DEBUG("minute : %d", tmpTimeStamp.time.absolute.minute);
+               MSG_DEBUG("second : %d", tmpTimeStamp.time.absolute.second);
+               MSG_DEBUG("timezone : %d", tmpTimeStamp.time.absolute.timeZone);
+
+               char displayTime[32];
+               struct tm * timeTM;
+
+               struct tm timeinfo;
+               memset(&timeinfo, 0x00, sizeof(tm));
+
+               timeinfo.tm_year = (tmpTimeStamp.time.absolute.year + 100);
+               timeinfo.tm_mon = (tmpTimeStamp.time.absolute.month - 1);
+               timeinfo.tm_mday = tmpTimeStamp.time.absolute.day;
+               timeinfo.tm_hour = tmpTimeStamp.time.absolute.hour;
+               timeinfo.tm_min = tmpTimeStamp.time.absolute.minute;
+               timeinfo.tm_sec = tmpTimeStamp.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 -= (tmpTimeStamp.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);
+       }
+
+***/
+
        pMsgInfo->displayTime = rawtime;
 
        /**  Convert Address values */
@@ -1759,7 +1908,7 @@ unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
        int                     i = 0, index = 0;
 
        memset(tmpBuf, 0x00, sizeof(tmpBuf));
-       memset(&timeStruct, 0x00, sizeof(&timeStruct));
+       memset(&timeStruct, 0x00, sizeof(struct tm));
 
        /** check pDate */
        if (strlen(pDate)<20)
@@ -3033,6 +3182,28 @@ 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 :
+                       sprintf( (char*)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 :
+                       sprintf( (char*)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.                     */
+                       sprintf( (char*)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 : */
        sprintf( (char*)*pDecodedString, "%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 );
index 90b6740..3587833 100755 (executable)
@@ -46,6 +46,7 @@ void TapiEventDeliveryReportCNF(TapiHandle *handle, int result, void *data, void
 void TapiEventGetSimMsgCnt(TapiHandle *handle, int result, void *data, void *user_data);
 void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_data);
 void TapiEventSaveSimMsg(TapiHandle *handle, int result, void *data, void *user_data);
+void TapiEventSaveClass2Msg(TapiHandle *handle, int result, void *data, void *user_data);
 void TapiEventDeleteSimMsg(TapiHandle *handle, int result, void *data, void *user_data);
 
 void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *user_data);
index 7f61dfc..aa01bf1 100755 (executable)
@@ -82,7 +82,7 @@ private:
        bool checkCbOpt(SMS_CBMSG_PAGE_S CbPage, bool *pJavaMsg);
        unsigned char checkCbPage(SMS_CBMSG_PAGE_S CbPage);
        void MakeCbMsg(SMS_CBMSG_PAGE_S CbPage, SMS_CBMSG_S *pCbMsg);
-       void convertCbMsgToMsginfo(SMS_CBMSG_S cbMsg, MSG_MESSAGE_INFO_S *pMsgInfo);
+       void convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo);
        void convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo);
        int convertTextToUtf8 (unsigned char* outBuf, int outBufSize, SMS_CBMSG_S* pCbMsg);
        void addToPageLiat(SMS_CBMSG_PAGE_S CbPage);
index 18e3731..417d3b2 100755 (executable)
@@ -88,7 +88,9 @@ public:
 
        bool IsConcatMsg(SMS_USERDATA_S *pUserData);
        void handleConcatMsg(SMS_TPDU_S *pTpdu);
+//     void handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t SimMsgId, bool bRead);
 
+//     void handleBrokenMsg();
 
 private:
        SmsPluginConcatHandler();
@@ -100,10 +102,15 @@ private:
        int makeConcatUserData(unsigned short MsgRef, char **ppTotalData);
 
        void convertConcatToMsginfo(const SMS_DELIVER_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);
 
+//     void addToSimIdList(unsigned short MsgRef, msg_sim_id_t SimMsgId);
+//     void removeFromSimIdList(unsigned short MsgRef);
+
        vector<SMS_CONCAT_INFO_S> concatList;
+//     vector<SMS_SIM_ID_S> simIdList;
 
        MsgTextConvert textCvt;
 };
index c83bd6e..8a3640b 100755 (executable)
@@ -53,8 +53,12 @@ public:
 
        void setSimMsgCntEvent(const MSG_SIM_COUNT_S *pSimMsgCnt);
        void setSimMsgEvent(const MSG_MESSAGE_INFO_S *pMsgInfo, bool bSuccess);
+       void setSaveSimMsgEvent(int simMsgId, int result);
+       void setSaveClass2MsgEvent(int simMsgId, int result);
        void setSimEvent(msg_sim_id_t SimId, bool bResult);
 
+       void setSmsData(const char *sca, const char *szData, int msgLength);
+
 private:
        SmsPluginSimMsg();
        ~SmsPluginSimMsg();
@@ -71,7 +75,7 @@ private:
 
        static SmsPluginSimMsg* pInstance;
 
-       msg_sim_id_t                    simMsgId;
+       msg_sim_id_t                            simMsgId;
 
        MSG_SIM_COUNT_S                 simMsgCnt;
 
@@ -81,7 +85,8 @@ private:
        unsigned int                            totalCnt;
 
        bool                                            bTapiResult;
-       bool                                            bClass2Msg;
+
+       SMS_DATA_INFO_S                 simMsgDataInfo;
 
        Mutex mx;
        CndVar cv;
index 5013aee..c7c4aba 100755 (executable)
@@ -38,6 +38,7 @@ public:
 
        void submitRequest(SMS_REQUEST_INFO_S *pReqInfo);
        void sendDeliverReport(msg_error_t err);
+       void sendClass0DeliverReport(msg_error_t err);
 
        void setSmsSendOptions(SMS_SUBMIT_S *pSubmit);
        void setSmscOptions(SMS_ADDRESS_S *pSmsc);
index 4d72f92..de47114 100755 (executable)
@@ -991,5 +991,14 @@ typedef struct {
        SMS_SIM_MWI_CPHS_INFO_S cphs_mwi;
 } SMS_SIM_MWI_INFO_S;
 
+/**
+ *     @brief  Represents Message Data Information from Telephony.
+ */
+typedef struct {
+       unsigned char sca[MAX_ADDRESS_LEN]; /**< Service Center address */
+       int msgLength; /**< Size of array szData (which is actual TPDU message) */
+       unsigned char szData[MAX_TPDU_DATA_LEN + 1]; /**< SMS TPDU message */
+} SMS_DATA_INFO_S;
+
 #endif //SMS_PLUGIN_TYPES_H
 
index 02d0ccb..756521b 100755 (executable)
@@ -37,7 +37,7 @@ public:
 
        //virtual void start();
 
-       void addReqEntity(SMS_REQUEST_INFO_S request);
+       void addReqEntity(SMS_REQUEST_INFO_S *request);
 
 private:
        SmsPluginUAManager();
index 096bdac..dc6fabc 100755 (executable)
@@ -33,6 +33,7 @@
 MsgHandle::MsgHandle() : mCounter(0), mClientSock()
 {
        memset(mConnectionId, 0x00, sizeof(mConnectionId));
+       memset(mCookie, 0x00, sizeof(mCookie));
 }
 
 
@@ -59,18 +60,17 @@ void MsgHandle::openHandle()
        }
 
        // Get Cookie Size
-       cookieSize = security_server_get_cookie_size();
+//     cookieSize = security_server_get_cookie_size();
 
-       MSG_DEBUG("cookie size : [%d]", cookieSize);
+//     MSG_DEBUG("cookie size : [%d]", cookieSize);
 
        // Request Cookie
-       ret = security_server_request_cookie(mCookie, cookieSize);
+//     ret = security_server_request_cookie(mCookie, cookieSize);
 
-       if (ret < 0) {
-
-               MSG_DEBUG("security_server_request_cookie() error!! [%d]", ret);
-               return;
-       }
+//     if (ret < 0) {
+//             MSG_DEBUG("security_server_request_cookie() error!! [%d]", ret);
+//             return;
+//     }
 
        // Open Socket IPC
        connectSocket();
@@ -112,14 +112,23 @@ void MsgHandle::write(const char *pCmdData, int cmdSize, char **ppEvent)
                THROW(MsgException::INVALID_PARAM, "Param is NULL");
        }
 
+       int ret = 0;
+
        // Send Command to MSG FW
-       mClientSock.write(pCmdData, cmdSize);
+       ret = mClientSock.write(pCmdData, cmdSize);
+       if (ret < 0)
+               THROW(MsgException::IPC_ERROR, "IPC write error");
 
-       // Receive Result from MSG FW
-       read(ppEvent);
+       while(1)
+       {
+               // Receive Result from MSG FW
+               read(ppEvent);
 
-       if (ppEvent == NULL) {
-               THROW(MsgException::INVALID_RESULT, "event is NULL");
+               if(!CheckEventData(*ppEvent)) {
+                       delete [] (*ppEvent);
+               } else {
+                       break;
+               }
        }
 }
 
@@ -132,8 +141,6 @@ void MsgHandle::read(char **ppEvent)
 
        if (dataSize == 0) {
                THROW(MsgException::IPC_ERROR, "Server closed connection");
-       } else if(dataSize < 0) {
-               THROW(MsgException::IPC_ERROR, "negative length??? %d", dataSize);
        }
 }
 
@@ -237,7 +244,7 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_I
                        memcpy(pDest->msgData, pSrc->pMmsData, pSrc->dataSize);
                } else {
                        // Save Message Data into File
-                       char fileName[MAX_COMMON_INFO_SIZE+1];
+                       char fileName[MSG_FILENAME_LEN_MAX+1];
                        memset(fileName, 0x00, sizeof(fileName));
 
                        if(MsgCreateFileName(fileName) == false)
@@ -247,7 +254,7 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_I
                        if (pSrc->subType == MSG_SENDREQ_JAVA_MMS) {
                                char* pFileNameExt;
                                pFileNameExt = strstr(fileName,"DATA");
-                               strncpy(pFileNameExt,"JAVA", MAX_COMMON_INFO_SIZE);
+                               strncpy(pFileNameExt,"JAVA", MSG_FILENAME_LEN_MAX);
                        }
 
                        MSG_DEBUG("Save Message Data into file : size[%d] name[%s]", pDest->dataSize, fileName);
@@ -258,7 +265,12 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_I
                        memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
                        strncpy(pDest->msgData, fileName, MAX_MSG_DATA_LEN);
                        if (pSrc->pData) {
-                               strncpy(pDest->msgText, (char*)pSrc->pData, sizeof(pDest->msgText));
+                               strncpy(pDest->msgText, (char*)pSrc->pData, MAX_MSG_TEXT_LEN);
+                       }
+
+                       if (strlen(pSrc->thumbPath) > 0) {
+                               memset(pDest->thumbPath, 0x00, sizeof(pDest->thumbPath));
+                               memcpy(pDest->thumbPath, pSrc->thumbPath, sizeof(pDest->thumbPath));
                        }
                }
        }
@@ -510,3 +522,29 @@ int MsgHandle::getSettingCmdSize(MSG_OPTION_TYPE_T optionType)
 
        return cmdSize;
 }
+
+
+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_SYNCML_OPERATION :
+       case MSG_EVENT_PLG_STORAGE_CHANGE_IND :
+       case MSG_EVENT_PLG_INCOMING_CB_MSG_IND :
+       case MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND :
+               return false;
+               break;
+       default :
+               return true;
+               break;
+       }
+
+       return true;
+}
index 716cdf8..445d7c8 100755 (executable)
@@ -83,6 +83,7 @@ msg_error_t MsgHandle::getSMSCOption(msg_struct_t msg_struct)
 
                MSG_SMSC_LIST_HIDDEN_S *pTmp = (MSG_SMSC_LIST_HIDDEN_S *)smsc_opt->data;
 
+               pTmp->selected = smsc_list_tmp.selected;
                pTmp->smsc_list->nCount = smsc_list_tmp.totalCnt;
 
                msg_struct_s *pStructTmp = NULL;
@@ -137,7 +138,7 @@ msg_error_t MsgHandle::setSMSCOption(msg_struct_t msg_struct)
        MSG_SETTING_S pSetting = {0,};
 
        pSetting.type = optionType;
-       memcpy(&(pSetting.option), &smsc_list_tmp, sizeof(MSG_SMSC_LIST_S));
+       memcpy(&(pSetting.option.smscList), &smsc_list_tmp, sizeof(MSG_SMSC_LIST_S));
 
     // Copy Command Data
     memcpy(pCmd->cmdData, &pSetting, cmdSize-sizeof(MSG_CMD_S));
index f837168..0febc58 100755 (executable)
 
 #include "MsgStorageHandler.h"
 
-
+#include "MsgVMessage.h"
 /*==================================================================================================
                                      IMPLEMENTATION OF MsgHandle - Storage Member Functions
 ==================================================================================================*/
 int MsgHandle::addMessage(MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt)
 {
-       MSG_MESSAGE_INFO_S msgInfo = {0};
-       MSG_SENDINGOPT_INFO_S sendOptInfo;
+       MSG_MESSAGE_INFO_S msgInfo = {0,};
+       MSG_SENDINGOPT_INFO_S sendOptInfo = {0,};
 
        // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
        convertMsgStruct(pMsg, &msgInfo);
@@ -89,7 +89,7 @@ int MsgHandle::addMessage(MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pS
 
 msg_error_t MsgHandle::addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg)
 {
-       MSG_MESSAGE_INFO_S msgInfo;
+       MSG_MESSAGE_INFO_S msgInfo = {0, };
 
        // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
        msg_struct_s *msg = (msg_struct_s *)pSyncMLMsg->msg;
@@ -134,8 +134,8 @@ msg_error_t MsgHandle::addSyncMLMessage(const MSG_SYNCML_MESSAGE_S *pSyncMLMsg)
 
 msg_error_t MsgHandle::updateMessage(const MSG_MESSAGE_HIDDEN_S *pMsg, const MSG_SENDINGOPT_S *pSendOpt)
 {
-       MSG_MESSAGE_INFO_S msgInfo;
-       MSG_SENDINGOPT_INFO_S sendOptInfo;
+       MSG_MESSAGE_INFO_S msgInfo = {0, };
+       MSG_SENDINGOPT_INFO_S sendOptInfo = {0, };
 
        // Covert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
        convertMsgStruct(pMsg, &msgInfo);
@@ -1073,11 +1073,26 @@ msg_error_t MsgHandle::getMemSize(unsigned int* memsize)
        return MSG_SUCCESS;
 }
 
-
-msg_error_t MsgHandle::backupMessage()
+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.
+       FILE *pFile = MsgOpenFile(backup_filepath, "w");
+       if (pFile == NULL) {
+               MSG_DEBUG("File Open error");
+               return MSG_ERR_STORAGE_ERROR;
+       }
+       MsgCloseFile(pFile);
+
+       char path[MSG_FILEPATH_LEN_MAX+1] = {0,};
+       strncpy(path, backup_filepath, MSG_FILEPATH_LEN_MAX);
+
        // Allocate Memory to Command Data
-       int cmdSize = sizeof(MSG_CMD_S);
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(msg_message_backup_type_t) + sizeof(path);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
@@ -1088,12 +1103,13 @@ msg_error_t MsgHandle::backupMessage()
 
        // 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
        char* pEventData = NULL;
        AutoPtr<char> eventBuf(&pEventData);
 
-
        write((char*)pCmd, cmdSize, &pEventData);
 
        // Get Return Data
@@ -1109,11 +1125,21 @@ msg_error_t MsgHandle::backupMessage()
        return MSG_SUCCESS;
 }
 
-
-msg_error_t MsgHandle::restoreMessage()
+msg_error_t MsgHandle::restoreMessage(const char *backup_filepath)
 {
+       if (backup_filepath == NULL)
+               return MSG_ERR_NULL_POINTER;
+
+       if (MsgAccessFile(backup_filepath, R_OK) == false) {
+               MSG_DEBUG("File access error");
+               return MSG_ERR_UNKNOWN;
+       }
+
+       char path[MSG_FILEPATH_LEN_MAX+1] = {0,};
+       strncpy(path, backup_filepath, MSG_FILEPATH_LEN_MAX);
+
        // Allocate Memory to Command Data
-       int cmdSize = sizeof(MSG_CMD_S);
+       int cmdSize = sizeof(MSG_CMD_S) + sizeof(path);
 
        char cmdBuf[cmdSize];
        bzero(cmdBuf, cmdSize);
@@ -1124,6 +1150,7 @@ msg_error_t MsgHandle::restoreMessage()
 
        // 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
        char* pEventData = NULL;
@@ -1554,3 +1581,64 @@ int MsgHandle::updatePushEvent(MSG_PUSH_EVENT_INFO_S *pSrc, MSG_PUSH_EVENT_INFO_
 
        return pEvent->result;
 }
+
+msg_error_t MsgHandle::getVobject(msg_message_id_t MsgId, void** encodedData)
+{
+       // 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
+       pCmd->cmdType = MSG_CMD_GET_MSG;
+
+       // Copy Cookie
+       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+
+       // 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
+       char* pEventData = NULL;
+       AutoPtr<char> eventBuf(&pEventData);
+
+
+       write((char*)pCmd, cmdSize, &pEventData);
+
+       // Get Return Data
+       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+
+       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
+       MSG_MESSAGE_INFO_S msgInfo = {0,};
+       MSG_SENDINGOPT_INFO_S sendOptInfo = {0,};
+
+       MsgDecodeMsgInfo(pEvent->data, &msgInfo, &sendOptInfo);
+
+       //Convert MSG_MESSAGE_INFO_S to
+       encode_data = MsgVMessageEncode(&msgInfo);
+       if (encode_data) {
+               *encodedData = (void*)encode_data;
+       } else {
+               MSG_DEBUG("Error Encode data");
+               *encodedData = NULL;
+       }
+
+       // Delete Temp File
+       if (msgInfo.bTextSms == false)
+       {
+               // Delete Temp File
+               MsgDeleteFile(msgInfo.msgData); //ipc
+       }
+
+       return MSG_SUCCESS;
+}
index 2888381..c291a02 100755 (executable)
@@ -34,6 +34,11 @@ msg_error_t MsgHandle::submitReq(MSG_REQUEST_S* pReq)
        if (pReq == NULL)
                THROW(MsgException::INVALID_PARAM, "pReq is NULL");
 
+#ifdef CHECK_SENT_STATUS_CALLBACK
+       if (MsgProxyListener::instance()->getSentStatusCbCnt() <= 0)
+               THROW(MsgException::SENT_STATUS_ERROR,"Register sent status callback");
+#endif
+
        MSG_REQUEST_INFO_S reqInfo = {0};
        char trId[MMS_TR_ID_LEN+1] = {0};
 
index 9ec05d1..f1999de 100755 (executable)
@@ -66,6 +66,11 @@ gboolean readSocket(GIOChannel *source, GIOCondition condition, gpointer data)
        {
                MSG_DEBUG("Server closed connection");
                MsgProxyListener::instance()->stop();
+               if (buf)
+               {
+                       delete [] buf;
+                       buf = NULL;
+               }
                return FALSE;
        }
        else // dataSize < 0
@@ -988,3 +993,16 @@ int MsgProxyListener::readFromSocket(char** buf, unsigned int* len)
 {
        return cliSock.read(buf, len);
 }
+
+#ifdef CHECK_SENT_STATUS_CALLBACK
+int MsgProxyListener::getSentStatusCbCnt()
+{
+       int cbCnt = 0;
+
+       cbCnt = sentStatusCBList.size();
+
+       MSG_DEBUG("registered sent status callback count : [%d]", cbCnt);
+
+       return cbCnt;
+}
+#endif
index 552f721..28c9085 100755 (executable)
@@ -27,6 +27,7 @@ SET(UTILS-SRCS
        ${CMAKE_SOURCE_DIR}/utils/MsgGconfWrapper.cpp
        ${CMAKE_SOURCE_DIR}/utils/MsgContact.cpp
        ${CMAKE_SOURCE_DIR}/utils/MsgNotificationWrapper.cpp
+       ${CMAKE_SOURCE_DIR}/utils/MsgVMessage.cpp
        ${CMAKE_SOURCE_DIR}/utils/MsgMemory.cpp
        ${CMAKE_SOURCE_DIR}/utils/MsgMmsMessage.cpp
        ${CMAKE_SOURCE_DIR}/utils/MsgSpamFilter.cpp
@@ -39,10 +40,11 @@ INCLUDE_DIRECTORIES(
        ${CMAKE_SOURCE_DIR}/include/framework
        ${CMAKE_SOURCE_DIR}/include/msg_helper
        ${CMAKE_SOURCE_DIR}/include/utils
+       ${CMAKE_SOURCE_DIR}/vobject-engine/include
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(utils_pkgs REQUIRED glib-2.0 vconf db-util contacts-service dlog pmapi mm-session alarm-service notification drm-client)
+pkg_check_modules(utils_pkgs REQUIRED glib-2.0 vconf db-util contacts-service2 dlog pmapi mm-session alarm-service notification drm-client)
 
 FOREACH(flag ${utils_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 8be3436..455e6bb 100755 (executable)
@@ -16,7 +16,7 @@
 
 extern "C"
 {
-       #include <contacts-svc.h>
+       #include <contacts.h>
 }
 
 #include "MsgDebug.h"
@@ -28,7 +28,7 @@ extern "C"
 /*==================================================================================================
                                      VARIABLES
 ==================================================================================================*/
-static bool isContactSvcOpened = false;
+//static bool isContactSvcOpened = false;
 
 MsgDbHandler ContactDbHandle;
 
@@ -36,7 +36,7 @@ MsgContactChangeCB cbFunction = NULL;
 /*==================================================================================================
                                      FUNCTION IMPLEMENTATION
 ==================================================================================================*/
-static void MsgContactSvcCallback(void *pData)
+static void MsgContactSvcCallback(const char *view_uri, void *user_data)
 {
        MSG_DEBUG("Contact Data is Changed!!!");
 
@@ -49,22 +49,22 @@ static void MsgContactSvcCallback(void *pData)
 
 msg_error_t MsgOpenContactSvc()
 {
-       int errCode = CTS_SUCCESS;
+       int errCode = CONTACTS_ERROR_NONE;
 
-       if (!isContactSvcOpened) {
-               errCode = contacts_svc_connect();
+//     if (!isContactSvcOpened) {
+               errCode = contacts_connect2();
 
-               if (errCode == CTS_SUCCESS) {
+               if (errCode == CONTACTS_ERROR_NONE) {
                        MSG_DEBUG("Connect to Contact Service Success");
-                       isContactSvcOpened = true;
+//                     isContactSvcOpened = true;
                } else {
                        MSG_DEBUG("Connect to Contact Service Fail [%d]", errCode);
-                       isContactSvcOpened = false;
+//                     isContactSvcOpened = false;
                        return MSG_ERR_DB_CONNECT;
                }
-       } else {
-               MSG_DEBUG("Already connected to Contact Service.");
-       }
+//     } else {
+//             MSG_DEBUG("Already connected to Contact Service.");
+//     }
 
        return MSG_SUCCESS;
 }
@@ -72,18 +72,18 @@ msg_error_t MsgOpenContactSvc()
 
 msg_error_t MsgCloseContactSvc()
 {
-       int errCode = CTS_SUCCESS;
+       int errCode = CONTACTS_ERROR_NONE;
 
-       if (isContactSvcOpened) {
-               errCode = contacts_svc_disconnect();
+//     if (isContactSvcOpened) {
+               errCode = contacts_disconnect2();
 
-               if (errCode == CTS_SUCCESS) {
+               if (errCode == CONTACTS_ERROR_NONE) {
                        MSG_DEBUG("Disconnect to Contact Service Success");
                } else {
                        MSG_DEBUG("Disconnect to Contact Service Fail [%d]", errCode);
                        return MSG_ERR_DB_DISCONNECT;
                }
-       }
+//     }
 
        return MSG_SUCCESS;
 }
@@ -91,15 +91,15 @@ msg_error_t MsgCloseContactSvc()
 
 msg_error_t MsgInitContactSvc(MsgContactChangeCB cb)
 {
-       int errCode = CTS_SUCCESS;
+       int errCode = CONTACTS_ERROR_NONE;
 
        if (cb != NULL)
                cbFunction = cb;
 
        // Register callback function
-       errCode = contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE, MsgContactSvcCallback, NULL);
+       errCode = contacts_db_add_changed_cb(_contacts_contact._uri, MsgContactSvcCallback, NULL);
 
-       if (errCode == CTS_SUCCESS)
+       if (errCode == CONTACTS_ERROR_NONE)
                MSG_DEBUG("Register Contact Service Callback");
        else
                MSG_DEBUG("Fail to Register Contact Service Callback [%d]", errCode);
@@ -118,43 +118,136 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I
 
        if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_PLMN && strlen(pAddrInfo->addressVal) > (MAX_PHONE_NUMBER_LEN+1)) {
                MSG_DEBUG("Phone Number is too long [%s]", pAddrInfo->addressVal);
-               return MSG_ERR_INVALID_PARAMETER;
+               return MSG_SUCCESS;
        }
 
-       int index, ret = -1;
+       int ret = 0;
+       int index = 0;
+       unsigned int count = 0;
+       contacts_query_h query = NULL;
+       contacts_filter_h filter = NULL;
+       contacts_list_h contacts = NULL;
 
-       CTSstruct* contact = NULL;
+       if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_PLMN) {
+               ret = contacts_query_create(_contacts_contact_number._uri, &query);
+               ret = contacts_filter_create(_contacts_contact_number._uri, &filter);
 
-       cts_find_op recordType;
+               ret = contacts_filter_add_str(filter, _contacts_contact_number.number_filter, CONTACTS_MATCH_EXACTLY, pAddrInfo->addressVal);
 
-       if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_EMAIL)
-               recordType = CTS_FIND_BY_EMAIL;
-       else
-               recordType = CTS_FIND_BY_NUMBER;
+       } else if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_EMAIL) {
+               ret = contacts_query_create(_contacts_contact_email._uri, &query);
+               ret = contacts_filter_create(_contacts_contact_email._uri, &filter);
 
-       index = contacts_svc_find_contact_by(recordType, (char*)pAddrInfo->addressVal);
+               ret = contacts_filter_add_str(filter, _contacts_contact_email.email, CONTACTS_MATCH_EXACTLY, pAddrInfo->addressVal);
 
-       if (index > CTS_SUCCESS) {
-               MSG_DEBUG("Index : [%d]", index);
-               ret = contacts_svc_get_contact(index, &contact);
+       } else {
+               MSG_DEBUG("Invalid pAddrInfo->addressType.");
+               return MSG_SUCCESS;
+       }
+
+       ret = contacts_query_set_filter(query, filter);
+       ret = contacts_db_get_records_with_query(query, 0, 1, &contacts);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_db_get_records_with_query() Error [%d]", ret);
+               contacts_query_destroy(query);
+               contacts_filter_destroy(filter);
+               contacts_list_destroy(contacts, true);
+               return MSG_SUCCESS;
        }
 
-       if (ret < 0) {
-               MSG_DEBUG("No Contact Info");
+       ret = contacts_list_get_count(contacts, &count);
+
+       if (count == 0 || ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("No Serach Data from Contact Service.");
+               contacts_query_destroy(query);
+               contacts_filter_destroy(filter);
+               contacts_list_destroy(contacts, true);
                return MSG_SUCCESS;
        }
 
-       CTSvalue* name = NULL;
+       contacts_record_h contact = NULL;
+
+       if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_PLMN) {
+               contacts_record_h number = NULL;
+
+               ret = contacts_list_get_current_record_p(contacts, &number);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret);
+                       contacts_list_destroy(contacts, true);
+                       return MSG_SUCCESS;
+               }
+
+               ret = contacts_record_get_int(number, _contacts_contact_number.contact_id, &index);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_record_get_int() Error [%d]", ret);
+                       contacts_list_destroy(contacts, true);
+                       contacts_record_destroy(number, true);
+                       return MSG_SUCCESS;
+               }
+
+               ret = contacts_db_get_record(_contacts_contact._uri, index, &contact);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_db_get_record() Error [%d]", ret);
+                       contacts_list_destroy(contacts, true);
+                       contacts_record_destroy(contact, true);
+                       contacts_record_destroy(number, true);
+                       return MSG_SUCCESS;
+               }
+       } else if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_EMAIL) {
+               contacts_record_h email = NULL;
+
+               ret = contacts_list_get_current_record_p(contacts, &email);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret);
+                       contacts_list_destroy(contacts, true);
+                       return MSG_SUCCESS;
+               }
+
+               ret = contacts_record_get_int(email, _contacts_contact_email.contact_id, &index);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_record_get_int() Error [%d]", ret);
+                       contacts_list_destroy(contacts, true);
+                       contacts_record_destroy(email, true);
+                       return MSG_SUCCESS;
+               }
+
+               ret = contacts_db_get_record(_contacts_contact._uri, index, &contact);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_db_get_record() Error [%d]", ret);
+                       contacts_list_destroy(contacts, true);
+                       contacts_record_destroy(contact, true);
+                       contacts_record_destroy(email, true);
+                       return MSG_SUCCESS;
+               }
+       }
 
-       ret = contacts_svc_struct_get_value(contact, CTS_CF_NAME_VALUE, &name);
+       contacts_list_destroy(contacts, true);
 
-       if (ret != CTS_SUCCESS) {
-               MSG_DEBUG("contacts_svc_struct_get_value() Error [%d]", ret);
+       // Name Info
+       contacts_record_h name = NULL;
+
+       ret = contacts_record_get_child_record_at_p(contact, _contacts_contact.name, 0, &name);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_record_get_child_record_at_p() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
+               return MSG_SUCCESS;
+       }
+
+       char* strFirstName = NULL;
+       ret = contacts_record_get_str_p(name, _contacts_name.first, &strFirstName);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
                return MSG_SUCCESS;
        }
 
-       const char* strFirstName = contacts_svc_value_get_str(name, CTS_NAME_VAL_FIRST_STR);
-       const char* strLastName = contacts_svc_value_get_str(name, CTS_NAME_VAL_LAST_STR);
+       char* strLastName = NULL;
+       ret = contacts_record_get_str_p(name, _contacts_name.last, &strLastName);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
+               return MSG_SUCCESS;
+       }
 
        MSG_DEBUG("First Name : [%s], Last Name : [%s]", strFirstName, strLastName);
 
@@ -164,30 +257,29 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I
        if (strLastName != NULL)
                strncpy(pContactInfo->lastName, strLastName, MAX_DISPLAY_NAME_LEN);
 
-       CTSvalue* base = NULL;
-
-       ret = contacts_svc_struct_get_value(contact, CTS_CF_BASE_INFO_VALUE, &base);
-
-       if (ret != CTS_SUCCESS) {
-               MSG_DEBUG("contacts_svc_struct_get_value() Error [%d]", ret);
+       ret = contacts_record_get_int(contact, _contacts_contact.id, (int*)&pContactInfo->contactId);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_db_get_record() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
                return MSG_SUCCESS;
        }
 
-       pContactInfo->contactId = contacts_svc_value_get_int(base, CTS_BASE_VAL_ID_INT);
-
        MSG_DEBUG("Contact ID [%d]", pContactInfo->contactId);
 
-       const char* strImagePath = contacts_svc_value_get_str(base, CTS_BASE_VAL_IMG_PATH_STR);
+       char* strImagePath = NULL;
+       ret = contacts_record_get_str_p(contact, _contacts_contact.image_thumbnail_path, &strImagePath);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
+               return MSG_SUCCESS;
+       }
 
        if (strImagePath != NULL)
                strncpy(pContactInfo->imagePath , strImagePath, MAX_IMAGE_PATH_LEN);
 
        MSG_DEBUG("Image Path [%s]", pContactInfo->imagePath);
 
-       contacts_svc_value_free(base);
-       contacts_svc_value_free(name);
-
-       contacts_svc_struct_free(contact);
+       contacts_record_destroy(contact, true);
 
        MSG_END();
 
@@ -198,9 +290,9 @@ msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_I
 void MsgSyncContact()
 {
        int ret = -1;
-       int index_num = 0;
-       int changed_count = 0;
+       unsigned int changed_count = 0;
        int lastSyncTime = 0;
+       int finalSyncTime = 0;
 
        /* get contact sync time */
        lastSyncTime = MsgSettingGetInt(CONTACT_SYNC_TIME);
@@ -210,46 +302,69 @@ void MsgSyncContact()
                lastSyncTime = 0;
        }
 
-       CTSiter* pIter;
+       contacts_list_h contactsList = NULL;
 
-       ret = contacts_svc_get_updated_contacts(-1, lastSyncTime, &pIter);
+       ret = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, -1, lastSyncTime, &contactsList, &finalSyncTime);
 
-       if (ret != CTS_SUCCESS) {
-               MSG_DEBUG("contacts_svc_get_updated_contacts() Error [%d]", ret);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_db_get_changes_by_version() Error [%d]", ret);
                return;
        }
 
-       while (contacts_svc_iter_next(pIter) == CTS_SUCCESS)
-       {
-               CTSvalue *row_info = NULL;
+       ret = contacts_list_get_count(contactsList, &changed_count);
+
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_list_get_count() Error [%d]", ret);
+               contacts_list_destroy(contactsList, true);
+               return;
+       }
 
-               row_info = contacts_svc_iter_get_info(pIter);
+       for (unsigned int i = 0; i < changed_count; i++);
+       {
+               int index_num = 0;
+               int type = 0;
+               contacts_record_h event = NULL;
+
+               ret = contacts_list_get_current_record_p(contactsList, &event);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret);
+                       contacts_list_destroy(contactsList, true);
+                       return;
+               }
 
-               index_num = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_ID_INT);
+               ret = contacts_record_get_int(event, _contacts_contact_updated_info.contact_id, &index_num);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_record_get_int() Error [%d]", ret);
+                       contacts_list_destroy(contactsList, true);
+                       return;
+               }
 
                MSG_DEBUG("index (%d)", index_num);
 
-               int type = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_TYPE_INT);
+               ret = contacts_record_get_int(event, _contacts_contact_updated_info.type, &type);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_record_get_int() Error [%d]", ret);
+                       contacts_list_destroy(contactsList, true);
+                       return;
+               }
 
-               if (type == CTS_OPERATION_UPDATED || type == CTS_OPERATION_INSERTED) {
+               if (type == CONTACTS_CHANGE_UPDATED || type == CONTACTS_CHANGE_INSERTED) {
                        MsgUpdateContact(index_num, type);
                } else {// Delete
                        MSG_DEBUG("Delete Contact");
                        MsgDeleteContact(index_num);
                }
 
-               if(lastSyncTime < contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_VER_INT))
-                       lastSyncTime = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_VER_INT);
-
-               contacts_svc_value_free(row_info);
-
-               changed_count++;
+               ret = contacts_list_next(contactsList);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_list_next() Error [%d]", ret);
+               }
        }
 
-       MsgSettingSetInt(CONTACT_SYNC_TIME, lastSyncTime);
-       MSG_DEBUG("lastSyncTime : %d", lastSyncTime);
+       MsgSettingSetInt(CONTACT_SYNC_TIME, finalSyncTime);
+       MSG_DEBUG("lastSyncTime : %d", finalSyncTime);
 
-       contacts_svc_iter_remove(pIter);
+       contacts_list_destroy(contactsList, true);
 
        if(changed_count > 0)
                cbFunction();
@@ -272,34 +387,36 @@ bool MsgInsertContact(MSG_CONTACT_INFO_S *pContactInfo, const char *pNumber)
 
 bool MsgUpdateContact(int index, int type)
 {
-       int ret = -1;
-
-       CTSstruct *contact = NULL;
+       int ret = CONTACTS_ERROR_NONE;
 
-       ret = contacts_svc_get_contact(index, &contact);
+       contacts_record_h contact = NULL;
 
-       if (ret != CTS_SUCCESS) {
-               MSG_DEBUG("contacts_svc_get_contact() Error [%d]", ret);
+       ret = contacts_db_get_record(_contacts_contact._uri, index, &contact);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_db_get_record() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
                return false;
        }
 
-       // Base Info
-       CTSvalue *base = NULL;
+       MSG_CONTACT_INFO_S contactInfo;
+       memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
 
-       ret = contacts_svc_struct_get_value(contact, CTS_CF_BASE_INFO_VALUE, &base);
-
-       if (ret != CTS_SUCCESS) {
-               MSG_DEBUG("contacts_svc_struct_get_value() Error [%d]", ret);
+       ret = contacts_record_get_int(contact, _contacts_contact.id, (int*)&contactInfo.contactId);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_db_get_record() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
                return false;
        }
 
-       MSG_CONTACT_INFO_S contactInfo = {0};
-
-       contactInfo.contactId = contacts_svc_value_get_int(base, CTS_BASE_VAL_ID_INT);
-
        MSG_DEBUG("Contact ID [%d]", contactInfo.contactId);
 
-       const char* strImagePath = contacts_svc_value_get_str(base, CTS_BASE_VAL_IMG_PATH_STR);
+       char* strImagePath = NULL;
+       ret = contacts_record_get_str_p(contact, _contacts_contact.image_thumbnail_path, &strImagePath);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
+               return false;
+       }
 
        if (strImagePath != NULL)
                strncpy(contactInfo.imagePath , strImagePath, MAX_IMAGE_PATH_LEN);
@@ -307,17 +424,30 @@ bool MsgUpdateContact(int index, int type)
        MSG_DEBUG("Image Path [%s]", contactInfo.imagePath);
 
        // Name Info
-       CTSvalue* name = NULL;
+       contacts_record_h name = NULL;
 
-       ret = contacts_svc_struct_get_value(contact, CTS_CF_NAME_VALUE, &name);
+       ret = contacts_record_get_child_record_at_p(contact, _contacts_contact.name, 0, &name);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_record_get_child_record_at_p() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
+               return false;
+       }
 
-       if (ret != CTS_SUCCESS) {
-               MSG_DEBUG("contacts_svc_struct_get_value() Error [%d]", ret);
-               return MSG_SUCCESS;
+       char* strFirstName = NULL;
+       ret = contacts_record_get_str_p(name, _contacts_name.first, &strFirstName);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
+               return false;
        }
 
-       const char* strFirstName = contacts_svc_value_get_str(name, CTS_NAME_VAL_FIRST_STR);
-       const char* strLastName = contacts_svc_value_get_str(name, CTS_NAME_VAL_LAST_STR);
+       char* strLastName = NULL;
+       ret = contacts_record_get_str_p(name, _contacts_name.last, &strLastName);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
+               return false;
+       }
 
        MSG_DEBUG("First Name : [%s], Last Name : [%s]", strFirstName, strLastName);
 
@@ -329,35 +459,51 @@ bool MsgUpdateContact(int index, int type)
 
        MsgStoClearContactInfo(&ContactDbHandle, index);
 
-       GSList *get_list, *cursor;
-
-       get_list = NULL;
-
-       contacts_svc_struct_get_list(contact, CTS_CF_NUMBER_LIST, &get_list);
-
-       cursor = get_list;
+       unsigned int count = 0;
+       ret = contacts_record_get_child_record_count(contact, _contacts_contact.number, &count);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_record_get_child_record_count() Error [%d]", ret);
+               contacts_record_destroy(contact, true);
+               return false;
+       }
 
-       // No phone number in contact
-       if (cursor == NULL) {
-                contacts_svc_struct_free(contact);
+       if (count > 0) {
+               for(unsigned int i=0; i < count; i++)
+               {
+                       MSG_DEBUG("Add Contact Data");
+
+                       contacts_record_h number = NULL;
+
+                       ret = contacts_record_get_child_record_at_p(contact, _contacts_contact.number, i, &number);
+                       if (ret != CONTACTS_ERROR_NONE) {
+                               MSG_DEBUG("contacts_record_get_child_record_at_p() Error [%d]", ret);
+                               contacts_record_destroy(contact, true);
+                               return false;
+                       }
+
+                       char* strNumber = NULL;
+                       ret = contacts_record_get_str_p(number, _contacts_number.number, &strNumber);
+                       if (ret != CONTACTS_ERROR_NONE) {
+                               MSG_DEBUG("contacts_record_get_str_p() Error [%d]", ret);
+                               contacts_record_destroy(contact, true);
+                               return false;
+                       }
+
+                       if (strNumber != NULL) {
+                               MSG_DEBUG("Number = %s", strNumber);
+                               if (!MsgInsertContact(&contactInfo, strNumber)) {
+                                       MSG_DEBUG("MsgInsertContact fail.");
+                               }
+                       }
+               }
+       } else {// No phone number in contact
+               contacts_record_destroy(contact, true);
                return true;
        }
 
-       for(; cursor; cursor = g_slist_next(cursor))
-       {
-               MSG_DEBUG("Add Contact Data");
-
-               const char* strNumber = contacts_svc_value_get_str((CTSvalue*)cursor->data, CTS_NUM_VAL_NUMBER_STR);
-
-               MSG_DEBUG("Number = %s", strNumber);
-
-               if (MsgInsertContact(&contactInfo, strNumber) == false)
-                       continue;
-       }
-
        MsgStoSetConversationDisplayName(&ContactDbHandle, index);
 
-       contacts_svc_struct_free(contact);
+       contacts_record_destroy(contact, true);
 
        return true;
 }
@@ -374,33 +520,39 @@ bool MsgDeleteContact(int index)
 
 int MsgGetContactNameOrder()
 {
-       int ret = 0;
+       int ret = CONTACTS_ERROR_NONE;
 
-       cts_order_type order = CTS_ORDER_NAME_FIRSTLAST;
+       contacts_name_display_order_e order = CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST;
 
-       order = contacts_svc_get_order(CTS_ORDER_OF_DISPLAY);
-
-       if (order == CTS_ORDER_NAME_FIRSTLAST)
-               ret = 0;
-       else if (order == CTS_ORDER_NAME_LASTFIRST)
-               ret = 1;
+       ret = contacts_setting_get_name_display_order(&order);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_setting_get_name_display_order() Error [%d]", ret);
+               return 0;
+       }
 
-       return ret;
+       if (order == CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST)
+               return 0;
+       else
+               return 1;
 }
 
 
-msg_error_t MsgAddPhoneLog(const MSG_MESSAGE_INFO_S *pMsgInfo)
+void MsgAddPhoneLog(const MSG_MESSAGE_INFO_S *pMsgInfo)
 {
-       msg_error_t err = MSG_SUCCESS;
+       int ret = 0;
 
        MSG_DEBUG("folderId [%d], number [%s]", pMsgInfo->folderId, pMsgInfo->addressList[0].addressVal);
 
-       CTSvalue* plog;
+       contacts_record_h plog = NULL;
 
-       plog = contacts_svc_value_new(CTS_VALUE_PHONELOG);
+       ret = contacts_record_create(_contacts_phone_log._uri, &plog);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_record_create() Error [%d]", ret);
+               contacts_record_destroy(plog, true);
+       }
 
-       contacts_svc_value_set_str(plog, CTS_PLOG_VAL_NUMBER_STR, (char*)pMsgInfo->addressList[0].addressVal);
-       contacts_svc_value_set_int(plog, CTS_PLOG_VAL_LOG_TIME_INT, (int)time(NULL));
+       contacts_record_set_str(plog, _contacts_phone_log.address, (char*)pMsgInfo->addressList[0].addressVal);
+       contacts_record_set_int(plog, _contacts_phone_log.log_time, (int)time(NULL));
 
        char strText[101];
        memset(strText, 0x00, sizeof(strText));
@@ -418,59 +570,96 @@ msg_error_t MsgAddPhoneLog(const MSG_MESSAGE_INFO_S *pMsgInfo)
                }
        }
 
-       contacts_svc_value_set_str(plog, CTS_PLOG_VAL_SHORTMSG_STR, strText);
-       contacts_svc_value_set_int(plog, CTS_PLOG_VAL_MSGID_INT, (int)pMsgInfo->msgId);
+       contacts_record_set_str(plog, _contacts_phone_log.extra_data2, strText);
+       contacts_record_set_int(plog, _contacts_phone_log.extra_data1, (int)pMsgInfo->msgId);
 
        if (pMsgInfo->folderId == MSG_INBOX_ID) {
                if (pMsgInfo->msgType.mainType == MSG_SMS_TYPE)
-                       contacts_svc_value_set_int(plog, CTS_PLOG_VAL_LOG_TYPE_INT, CTS_PLOG_TYPE_SMS_INCOMMING);
+                       contacts_record_set_int(plog, _contacts_phone_log.log_type, CONTACTS_PLOG_TYPE_SMS_INCOMMING);
                else if (pMsgInfo->msgType.mainType == MSG_MMS_TYPE)
-                       contacts_svc_value_set_int(plog, CTS_PLOG_VAL_LOG_TYPE_INT, CTS_PLOG_TYPE_MMS_INCOMMING);
+                       contacts_record_set_int(plog, _contacts_phone_log.log_type, CONTACTS_PLOG_TYPE_MMS_INCOMMING);
        } else if (pMsgInfo->folderId == MSG_OUTBOX_ID) {
                if (pMsgInfo->msgType.mainType == MSG_SMS_TYPE)
-                       contacts_svc_value_set_int(plog, CTS_PLOG_VAL_LOG_TYPE_INT, CTS_PLOG_TYPE_SMS_OUTGOING);
+                       contacts_record_set_int(plog, _contacts_phone_log.log_type, CONTACTS_PLOG_TYPE_SMS_OUTGOING);
                else if (pMsgInfo->msgType.mainType == MSG_MMS_TYPE)
-                       contacts_svc_value_set_int(plog, CTS_PLOG_VAL_LOG_TYPE_INT, CTS_PLOG_TYPE_MMS_OUTGOING);
+                       contacts_record_set_int(plog, _contacts_phone_log.log_type, CONTACTS_PLOG_TYPE_MMS_OUTGOING);
        } else if (pMsgInfo->folderId == MSG_SPAMBOX_ID) {
                if (pMsgInfo->msgType.mainType == MSG_SMS_TYPE)
-                       contacts_svc_value_set_int(plog, CTS_PLOG_VAL_LOG_TYPE_INT, CTS_PLOG_TYPE_SMS_BLOCKED);
+                       contacts_record_set_int(plog, _contacts_phone_log.log_type, CONTACTS_PLOG_TYPE_SMS_BLOCKED);
                else if (pMsgInfo->msgType.mainType == MSG_MMS_TYPE)
-                       contacts_svc_value_set_int(plog, CTS_PLOG_VAL_LOG_TYPE_INT, CTS_PLOG_TYPE_MMS_BLOCKED);
+                       contacts_record_set_int(plog, _contacts_phone_log.log_type, CONTACTS_PLOG_TYPE_MMS_BLOCKED);
        }
 
-       int ret = contacts_svc_insert_phonelog(plog);
-
-       if (ret != CTS_SUCCESS)
-               MSG_DEBUG("contacts_svc_insert_phonelog() Failed!!! [%d]", ret);
-
-       contacts_svc_value_free(plog);
+       ret = contacts_db_insert_record(plog, NULL);
+       if (ret != CONTACTS_ERROR_NONE) {
+               MSG_DEBUG("contacts_db_insert_record() Error [%d]", ret);
+       }
 
-       return err;
+       contacts_record_destroy(plog, true);
 }
 
 
-msg_error_t MsgDeletePhoneLog(msg_message_id_t msgId)
+void MsgDeletePhoneLog(msg_message_id_t msgId)
 {
-       msg_error_t err = MSG_SUCCESS;
-
        MSG_DEBUG("MsgDeletePhoneLog [%d]", msgId);
 
-       int ret = contacts_svc_delete_phonelog(CTS_PLOG_DEL_BY_MSGID, msgId);
+       int ret = CONTACTS_ERROR_NONE;
+       int index = 0;
+       unsigned int count = 0;
+       contacts_query_h query;
+       contacts_filter_h filter;
+       contacts_list_h plogs = NULL;
+
+       ret = contacts_query_create(_contacts_phone_log._uri, &query);
+       ret = contacts_filter_create(_contacts_phone_log._uri, &filter);
+
+       ret = contacts_filter_add_int(filter, _contacts_phone_log.extra_data1, CONTACTS_MATCH_EQUAL, (int)msgId);
+
+
+       ret = contacts_query_set_filter(query, filter);
+       ret = contacts_db_get_records_with_query(query, 0, 1, &plogs);
+
+       ret = contacts_list_get_count(plogs, &count);
+
+       if (count == 0) {
+               MSG_DEBUG("No Serach Data from Contact Service.");
+       } else {
+               contacts_record_h plog = NULL;
+
+               ret = contacts_list_get_current_record_p(plogs, &plog);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret);
+               }
+
+               ret = contacts_record_get_int(plog, _contacts_phone_log.id, &index);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_record_get_int() Error [%d]", ret);
+               }
+
+               ret = contacts_db_delete_record(_contacts_phone_log._uri, index);
+               if (ret != CONTACTS_ERROR_NONE) {
+                       MSG_DEBUG("contacts_record_get_int() Error [%d]", ret);
+               } else {
+                       MSG_DEBUG("contacts_db_delete_record() Success.");
+               }
+       }
 
-       if (ret != CTS_SUCCESS)
-               MSG_DEBUG("contacts_svc_delete_phonelog() Failed!!! [%d]", ret);
+       contacts_query_destroy(query);
+       contacts_filter_destroy(filter);
+       contacts_list_destroy(plogs, true);
 
-       return err;
 }
 
 
 int MsgContactSVCBeginTrans()
 {
-       return contacts_svc_begin_trans();
+       //return contacts_svc_begin_trans();
+       return 0;
 }
 
 
 int MsgContactSVCEndTrans(bool bSuccess)
 {
-       return contacts_svc_end_trans(bSuccess);
+       //return contacts_svc_end_trans(bSuccess);
+       return 0;
 }
index 70e11b7..e1dc88a 100755 (executable)
@@ -166,10 +166,10 @@ const char * MsgDbgCmdStr(MSG_CMD_TYPE_T cmdType)
                        return "MSG_CMD_GET_SMSC_OPT";
                case MSG_CMD_GET_CB_OPT:
                        return "MSG_CMD_GET_CB_OPT";
-               case MSG_CMD_GET_SMS_SEND_OPT:
-                       return "MSG_CMD_GET_SMS_SEND_OPT";
 
 // 60
+               case MSG_CMD_GET_SMS_SEND_OPT:
+                       return "MSG_CMD_GET_SMS_SEND_OPT";
                case MSG_CMD_GET_MMS_SEND_OPT:
                        return "MSG_CMD_GET_MMS_SEND_OPT";
                case MSG_CMD_GET_MMS_RECV_OPT:
@@ -178,12 +178,19 @@ const char * MsgDbgCmdStr(MSG_CMD_TYPE_T cmdType)
                        return "MSG_CMD_GET_PUSH_MSG_OPT";
                case MSG_CMD_GET_VOICE_MSG_OPT:
                        return "MSG_CMD_GET_VOICE_MSG_OPT";
+
+// 65
                case MSG_CMD_GET_GENERAL_MSG_OPT:
                        return "MSG_CMD_GET_GENERAL_MSG_OPT";
 
-// 65
+               case MSG_CMD_GET_MSG_SIZE_OPT:
+                       return "MSG_CMD_GET_MSG_SIZE_OPT";
+
                case MSG_CMD_SET_SMSC_OPT:
                        return "MSG_CMD_SET_SMSC_OPT";
+
+
+// 70
                case MSG_CMD_SET_CB_OPT:
                        return "MSG_CMD_SET_CB_OPT";
                case MSG_CMD_SET_SMS_SEND_OPT:
@@ -192,14 +199,17 @@ const char * MsgDbgCmdStr(MSG_CMD_TYPE_T cmdType)
                        return "MSG_CMD_SET_MMS_SEND_OPT";
                case MSG_CMD_SET_MMS_RECV_OPT:
                        return "MSG_CMD_SET_MMS_RECV_OPT";
-
-// 70
                case MSG_CMD_SET_PUSH_MSG_OPT:
                        return "MSG_CMD_SET_PUSH_MSG_OPT";
+
+// 75
                case MSG_CMD_SET_VOICE_MSG_OPT:
                        return "MSG_CMD_SET_VOICE_MSG_OPT";
                case MSG_CMD_SET_GENERAL_MSG_OPT:
                        return "MSG_CMD_SET_GENERAL_MSG_OPT";
+               case MSG_CMD_SET_MSG_SIZE_OPT:
+                       return "MSG_CMD_SET_MSG_SIZE_OPT";
+// 80
                case MSG_CMD_REG_INCOMING_PUSH_MSG_CB:
                        return "MSG_CMD_REG_INCOMING_PUSH_MSG_CB";
                case MSG_CMD_PLG_INCOMING_PUSH_IND:
@@ -362,10 +372,10 @@ const char * MsgDbgEvtStr(MSG_EVENT_TYPE_T evtType)
                        return "MSG_EVENT_GET_SMSC_OPT";
                case MSG_EVENT_GET_CB_OPT:
                        return "MSG_EVENT_GET_CB_OPT";
-               case MSG_EVENT_GET_SMS_SEND_OPT:
-                       return "MSG_EVENT_GET_SMS_SEND_OPT";
 
 // 60
+               case MSG_EVENT_GET_SMS_SEND_OPT:
+                       return "MSG_EVENT_GET_SMS_SEND_OPT";
                case MSG_EVENT_GET_MMS_SEND_OPT:
                        return "MSG_EVENT_GET_MMS_SEND_OPT";
                case MSG_EVENT_GET_MMS_RECV_OPT:
@@ -374,10 +384,14 @@ const char * MsgDbgEvtStr(MSG_EVENT_TYPE_T evtType)
                        return "MSG_EVENT_GET_PUSH_MSG_OPT";
                case MSG_EVENT_GET_VOICE_MSG_OPT:
                        return "MSG_EVENT_GET_VOICE_MSG_OPT";
+
+// 65
                case MSG_EVENT_GET_GENERAL_MSG_OPT:
                        return "MSG_EVENT_GET_GENERAL_MSG_OPT";
 
 // 65
+               case MSG_EVENT_GET_MSG_SIZE_OPT:
+                       return "MSG_EVENT_GET_MSG_SIZE_OPT";
                case MSG_EVENT_SET_SMSC_OPT:
                        return "MSG_EVENT_SET_SMSC_OPT";
                case MSG_EVENT_SET_CB_OPT:
@@ -396,6 +410,8 @@ const char * MsgDbgEvtStr(MSG_EVENT_TYPE_T evtType)
                        return "MSG_EVENT_SET_VOICE_MSG_OPT";
                case MSG_EVENT_SET_GENERAL_MSG_OPT:
                        return "MSG_EVENT_SET_GENERAL_MSG_OPT";
+               case MSG_EVENT_SET_MSG_SIZE_OPT:
+                       return "MSG_EVENT_SET_MSG_SIZE_OPT";
                case MSG_EVENT_REG_INCOMING_PUSH_MSG_CB:
                        return "MSG_EVENT_REG_INCOMING_PUSH_MSG_CB";
                case MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND:
index c2f63ec..cee4ee2 100755 (executable)
@@ -20,6 +20,7 @@
 
 #include "MsgDebug.h"
 #include "MsgUtilStorage.h"
+#include "MsgNotificationWrapper.h"
 #include "MsgGconfWrapper.h"
 
 #ifdef USE_GCONF
@@ -37,6 +38,7 @@ bool bUnknownAutoReject = false;
 /*==================================================================================================
                                      DEFINES
 ==================================================================================================*/
+#define MSG_UNREAD_CNT         "db/badge/org.tizen.message"
 
 
 /*==================================================================================================
@@ -180,6 +182,23 @@ int MsgSettingGetBool(const char *pKey, bool *pVal)
        return retVal;
 }
 
+void MsgChangePmState()
+{
+       MSG_BEGIN();
+       int callStatus = 0;
+
+       callStatus = MsgSettingGetInt(VCONFKEY_CALL_STATE);
+       MSG_DEBUG("Call Status = %d", callStatus);
+
+       if (callStatus > VCONFKEY_CALL_OFF && callStatus < VCONFKEY_CALL_STATE_MAX) {
+               MSG_DEBUG("Call is activated. Do not turn on the lcd.");
+       } else {
+               MSG_DEBUG("Call is activated. Turn on the lcd.");
+               pm_change_state(LCD_NORMAL);
+       }
+
+       MSG_END();
+}
 
 msg_error_t MsgSettingHandleNewMsg(int SmsCnt, int MmsCnt)
 {
@@ -201,7 +220,7 @@ msg_error_t MsgSettingHandleNewMsg(int SmsCnt, int MmsCnt)
        else
        {
                MSG_DEBUG("New Message.");
-               pm_change_state(LCD_NORMAL);
+               MsgChangePmState();
        }
 
        MSG_END();
@@ -218,12 +237,11 @@ msg_error_t MsgSettingSetIndicator(int SmsCnt, int MmsCnt)
        if (MsgSettingSetInt(VCONFKEY_MESSAGE_RECV_MMS_STATE, MmsCnt) != 0)
                return MSG_ERR_SET_SETTING;
 
-       /* Not used currently.
        int sumCnt = SmsCnt + MmsCnt;
 
-       if (MsgSettingSetInt(MSG_UNREAD_CNT, sumCnt) != 0)
+//     if (MsgSettingSetInt(MSG_UNREAD_CNT, sumCnt) != 0)
+       if (MsgInsertBadge(sumCnt) != MSG_SUCCESS)
                return MSG_ERR_SET_SETTING;
-       */
 
        return MSG_SUCCESS;
 }
index e5b9eaf..144b1bc 100755 (executable)
@@ -215,8 +215,8 @@ int MsgIpcClientSocket::read(char** buf, unsigned int* len)
 
        /*  read the data in subsequence */
        unsigned int ulen = (unsigned int)*len;
-       *buf = new char[ulen+1];
-       bzero(*buf, ulen+1);
+       *buf = new char[ulen];
+       bzero(*buf, ulen);
        n = readn(*buf, ulen);
 
        if ((unsigned int)n !=  ulen) {
@@ -380,9 +380,10 @@ void MsgIpcServerSocket::close(int fd)
 
 int MsgIpcServerSocket::readn( int fd, char *buf, unsigned int len )
 {
-       unsigned int nleft, nread;
+       size_t nleft;
+       int nread;
 
-       nleft = len;
+       nleft = (size_t)len;
        while (nleft > 0) {
                nread = ::read(fd, (void*)buf, nleft);
                if (nread < 0) {
index e9fd34e..6a2d569 100755 (executable)
@@ -319,6 +319,10 @@ char* _MsgMmsSerializeMessageData(const MMS_MESSAGE_DATA_S* pMsgData, unsigned i
                                                        + sizeof(MsgDrmType) + MSG_FILEPATH_LEN_MAX
 #endif
                                                        + MAX_SMIL_TRANSIN_ID + MAX_SMIL_TRANSOUT_ID + 5 * sizeof(int)
+#ifdef MMS_SMIL_ANIMATE
+                                                       + MAX_SMIL_ANIMATE_ATTRIBUTE_NAME + MAX_SMIL_ANIMATE_ATTRIBUTE_TYPE + MAX_SMIL_ANIMATE_TARGET_ELEMENT
+                                                       + MAX_SMIL_ANIMATE_CALC_MODE + 5 * sizeof(int)
+#endif
                                                        );
                                        }
                                }
@@ -508,6 +512,35 @@ char* _MsgMmsSerializeMessageData(const MMS_MESSAGE_DATA_S* pMsgData, unsigned i
 
                                                memcpy(buf + offset, &(media->sMedia.sAVI.nBgColor), sizeof(int));
                                                offset += sizeof(int);
+
+#ifdef MMS_SMIL_ANIMATE
+                                               memcpy(buf + offset, media->sMedia.sAVI.nAttributeName, MAX_SMIL_ANIMATE_ATTRIBUTE_NAME);
+                                               offset +=  MAX_SMIL_ANIMATE_ATTRIBUTE_NAME;
+
+                                               memcpy(buf + offset, media->sMedia.sAVI.nAttributeType, MAX_SMIL_ANIMATE_ATTRIBUTE_TYPE);
+                                               offset +=  MAX_SMIL_ANIMATE_ATTRIBUTE_TYPE;
+
+                                               memcpy(buf + offset, media->sMedia.sAVI.nTargetElement, MAX_SMIL_ANIMATE_TARGET_ELEMENT);
+                                               offset +=  MAX_SMIL_ANIMATE_TARGET_ELEMENT;
+
+                                               memcpy(buf + offset, &(media->sMedia.sAVI.nFrom), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sAVI.nTo), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sAVI.nBy), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sAVI.nValues), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, &(media->sMedia.sAVI.nDur), sizeof(int));
+                                               offset += sizeof(int);
+
+                                               memcpy(buf + offset, media->sMedia.sAVI.nCalcMode, MAX_SMIL_ANIMATE_CALC_MODE);
+                                               offset +=  MAX_SMIL_ANIMATE_CALC_MODE;
+#endif
                                        }
                                }
                        }
@@ -954,6 +987,34 @@ bool               _MsgMmsDeserializeMessageData(MMS_MESSAGE_DATA_S* pBody, char* pData)
 
                                memcpy(&pMedia->sMedia.sAVI.nBgColor, pData + offset, sizeof(int));
                                offset += sizeof(int);
+#ifdef MMS_SMIL_ANIMATE
+                               memcpy(pMedia->sMedia.sAVI.nAttributeName, pData + offset, MAX_SMIL_ANIMATE_ATTRIBUTE_NAME);
+                               offset += MAX_SMIL_ANIMATE_ATTRIBUTE_NAME;
+
+                               memcpy(pMedia->sMedia.sAVI.nAttributeType, pData + offset, MAX_SMIL_ANIMATE_ATTRIBUTE_TYPE);
+                               offset += MAX_SMIL_ANIMATE_ATTRIBUTE_TYPE;
+
+                               memcpy(pMedia->sMedia.sAVI.nTargetElement, pData + offset, MAX_SMIL_ANIMATE_TARGET_ELEMENT);
+                               offset += MAX_SMIL_ANIMATE_TARGET_ELEMENT;
+
+                               memcpy(&pMedia->sMedia.sAVI.nFrom, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sAVI.nTo, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sAVI.nBy, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sAVI.nValues, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(&pMedia->sMedia.sAVI.nDur, pData + offset, sizeof(int));
+                               offset += sizeof(int);
+
+                               memcpy(pMedia->sMedia.sAVI.nCalcMode, pData + offset, MAX_SMIL_ANIMATE_CALC_MODE);
+                               offset += MAX_SMIL_ANIMATE_CALC_MODE;
+#endif
                        }
                        pPage->medialist = g_list_append(pPage->medialist, pMedia);
                }
index c5a1c6a..b2189ff 100755 (executable)
@@ -18,6 +18,7 @@
 #include "MsgContact.h"
 #include "MsgStorageTypes.h"
 #include "MsgUtilStorage.h"
+#include "MsgGconfWrapper.h"
 #include "MsgNotificationWrapper.h"
 
 extern "C"
@@ -30,6 +31,9 @@ extern "C"
 ==================================================================================================*/
 msg_error_t MsgInsertNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
 {
+
+       int notiPrivId = MsgSettingGetInt(NOTIFICATION_PRIV_ID);
+
        notification_h noti = NULL;
        notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
        bundle* args;
@@ -116,7 +120,7 @@ msg_error_t MsgInsertNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
 
        if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.subType == MSG_CB_SMS) {
 
-               noti = notification_new(NOTIFICATION_TYPE_NOTI, 1, pMsg->msgId);
+               noti = notification_create(NOTIFICATION_TYPE_NOTI);
                if (noti == NULL) {
                        MSG_DEBUG("notification_new is failed.");
                        bundle_free(args);
@@ -127,21 +131,61 @@ msg_error_t MsgInsertNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
                if (noti_err != NOTIFICATION_ERROR_NONE) {
                        MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
                }
+               noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
+               }
 
                noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, CB_MSG_ICON_PATH);
                if (noti_err != NOTIFICATION_ERROR_NONE) {
                        MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
                }
 
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "CB Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New CB Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               if (displayName[0] == '\0')
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               else
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               if (pMsg->msgType.mainType == MSG_SMS_TYPE)
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               else
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               // set time.
+               notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
                memset(&tempId, 0x00, sizeof(tempId));
 
                bundle_add(args, "type", "msg_id");
 
-               snprintf(tempId, 5, "%d", pMsg->msgId);
+               snprintf(tempId, 5, "%d", pMsg->msgId);
                bundle_add(args, "msgId", tempId);
+
+
+               if (args != NULL) {
+                       noti_err = notification_set_args(noti, args, NULL);
+                       if (noti_err != NOTIFICATION_ERROR_NONE) {
+                               MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
+                       }
+               }
+
+               noti_err = notification_insert(noti, NULL);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_insert");
+               }
+
+               noti_err = notification_free(noti);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_free");
+               }
+
+
        } else if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.classType == MSG_CLASS_0) {
 
-               noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+               noti = notification_create(NOTIFICATION_TYPE_NOTI);
                if (noti == NULL) {
                        MSG_DEBUG("notification_new is failed.");
                        bundle_free(args);
@@ -158,10 +202,44 @@ msg_error_t MsgInsertNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
                        MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
                }
 
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New CLASS 0 Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               if (displayName[0] == '\0')
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               else
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               if (pMsg->msgType.mainType == MSG_SMS_TYPE)
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               else
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               // set time.
+               notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
                bundle_add(args, "type", "msg_id");
 
                snprintf(tempId, 5, "%d", pMsg->msgId);
                bundle_add(args, "msgId", tempId);
+
+               if (args != NULL) {
+                       noti_err = notification_set_args(noti, args, NULL);
+                       if (noti_err != NOTIFICATION_ERROR_NONE) {
+                               MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
+                       }
+               }
+
+               noti_err = notification_insert(noti, NULL);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_insert");
+               }
+
+               noti_err = notification_free(noti);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_free");
+               }
+
        } else if (pMsg->msgType.mainType == MSG_SMS_TYPE &&
                        (pMsg->msgType.subType >= MSG_MWI_VOICE_SMS && pMsg->msgType.subType <= MSG_MWI_OTHER_SMS)) {
 
@@ -171,29 +249,83 @@ msg_error_t MsgInsertNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
                        bundle_free(args);
                        return MSG_ERR_UNKNOWN;
                }
-
-               noti_err = notification_set_application(noti, "org.tizen.message");
+               noti_err = notification_set_application(noti, "org.tizen.call");
                if (noti_err != NOTIFICATION_ERROR_NONE) {
                        MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
                }
 
+               noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
+               }
+
                noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, VOICE_MSG_ICON_PATH);
                if (noti_err != NOTIFICATION_ERROR_NONE) {
                        MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
                }
 
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Voice Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Voice Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               if (displayName[0] == '\0')
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               else
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               if (pMsg->msgType.mainType == MSG_SMS_TYPE)
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               else
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               // set time.
+               notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
                memset(&tempId, 0x00, sizeof(tempId));
 
+               //FIXME :: Temp code for voice number, 2012.08.16 sangkoo.kim
                bundle_add(args, "launch-type", "MO");
                bundle_add(args, "number", addressVal);
 
+
+               if (args != NULL) {
+                       noti_err = notification_set_args(noti, args, NULL);
+                       if (noti_err != NOTIFICATION_ERROR_NONE) {
+                               MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
+                       }
+               }
+
+               noti_err = notification_insert(noti, NULL);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_insert");
+               }
+
+               noti_err = notification_free(noti);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_free");
+               }
+
        } else {
-               MSG_DEBUG("notification_new pMsg->msgId [%d]", pMsg->msgId);
-               noti = notification_new(NOTIFICATION_TYPE_NOTI, 1, pMsg->msgId);
+
+               int unreadMsgCnt = MsgStoGetUnreadCnt(pDbHandle, MSG_SMS_TYPE);
+               unreadMsgCnt += MsgStoGetUnreadCnt(pDbHandle, MSG_MMS_TYPE);
+
+               MSG_DEBUG("notiPrivId [%d], unreadMsgCnt [%d]", notiPrivId, unreadMsgCnt);
+
+               if (notiPrivId > 0) {
+                       noti = notification_load(NULL, notiPrivId);
+                       if (noti == NULL)
+                               MSG_DEBUG("notification_load is failed.");
+               }
+
                if (noti == NULL) {
-                       MSG_DEBUG("notification_new is failed.");
-                       bundle_free(args);
-                       return MSG_ERR_UNKNOWN;
+                       noti = notification_create(NOTIFICATION_TYPE_NOTI);
+                       if (noti == NULL) {
+                               MSG_DEBUG("notification_new is failed.");
+                               bundle_free(args);
+                               return MSG_ERR_UNKNOWN;
+                       }
+
+                       notiPrivId = 0;
                }
 
                noti_err = notification_set_application(noti, "org.tizen.message");
@@ -206,59 +338,95 @@ msg_error_t MsgInsertNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
                        MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
                }
 
+
+               if (unreadMsgCnt > 1) {
+
+                       noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
+                       if (noti_err != NOTIFICATION_ERROR_NONE) {
+                               MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
+                       }
+
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+                       char unreadMsgCntStr[5] = {0,};
+                       snprintf(unreadMsgCntStr, 5, "%d", unreadMsgCnt);
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+                       if (displayName[0] == '\0')
+                               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+                       else
+                               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+                       if (pMsg->msgType.mainType == MSG_SMS_TYPE)
+                               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+                       else
+                               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+                       // set time.
+                       notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
+
+               } else {
+
+                       noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
+                       if (noti_err != NOTIFICATION_ERROR_NONE) {
+                               MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
+                       }
+
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+                       if (displayName[0] == '\0')
+                               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+                       else
+                               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+                       if (pMsg->msgType.mainType == MSG_SMS_TYPE)
+                               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+                       else
+                               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+                       // set time.
+                       notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
+
+               }
                memset(&tempId, 0x00, sizeof(tempId));
 
                bundle_add(args, "type", "msg_id");
 
                snprintf(tempId, 5, "%d", pMsg->msgId);
                bundle_add(args, "msgId", tempId);
-       }
 
-       if (displayName[0] == '\0')
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-       else
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-
-       if (pMsg->msgType.mainType == MSG_SMS_TYPE)
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-       else
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-
-
-       if (args != NULL) {
-               noti_err = notification_set_args(noti, args, NULL);
-               if (noti_err != NOTIFICATION_ERROR_NONE) {
-                       MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
+               if (args != NULL) {
+                       noti_err = notification_set_args(noti, args, NULL);
+                       if (noti_err != NOTIFICATION_ERROR_NONE) {
+                               MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
+                       }
                }
-       }
 
-       noti_err = notification_set_time(noti, msgTime);
-       if (noti_err != NOTIFICATION_ERROR_NONE) {
-               MSG_DEBUG("Fail to notification_set_time : %d", noti_err);
-       }
+               if (notiPrivId > 0) {
+                       noti_err = notification_update(noti);
+                       if (noti_err != NOTIFICATION_ERROR_NONE) {
+                               MSG_DEBUG("Fail to notification_update");
+                       }
+               } else {
+                       noti_err = notification_insert(noti, &notiPrivId);
+                       if (noti_err != NOTIFICATION_ERROR_NONE) {
+                               MSG_DEBUG("Fail to notification_insert");
+                       }
 
-       if (thumbPath[0] != '\0') {
-               noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, thumbPath);
-               if (noti_err != NOTIFICATION_ERROR_NONE) {
-                       MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
+                       MsgSettingSetInt(NOTIFICATION_PRIV_ID, notiPrivId);
+                       MSG_DEBUG("Insert notiPrivId [%d]", notiPrivId);
                }
 
-               noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL_FOR_LOCK, thumbPath);
+               noti_err = notification_free(noti);
                if (noti_err != NOTIFICATION_ERROR_NONE) {
-                       MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
+                       MSG_DEBUG("Fail to notification_free");
                }
        }
 
-       noti_err = notification_insert(noti, NULL);
-       if (noti_err != NOTIFICATION_ERROR_NONE) {
-               MSG_DEBUG("Fail to notification_insert");
-       }
-
-       noti_err = notification_free(noti);
-       if (noti_err != NOTIFICATION_ERROR_NONE) {
-               MSG_DEBUG("Fail to notification_free");
-       }
-
        bundle_free(args);
 
        return MSG_SUCCESS;
@@ -266,6 +434,7 @@ msg_error_t MsgInsertNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
 
 msg_error_t MsgInsertNoti(MSG_MESSAGE_INFO_S* pMsg)
 {
+
        notification_h noti = NULL;
        notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
        bundle* args;
@@ -279,23 +448,31 @@ msg_error_t MsgInsertNoti(MSG_MESSAGE_INFO_S* pMsg)
        snprintf(addressVal, sizeof(addressVal), "%s", pMsg->addressList[0].addressVal);
        snprintf(displayName, sizeof(displayName), "%s", pMsg->addressList[0].displayName);
 
+       noti = notification_create(NOTIFICATION_TYPE_NOTI);
+       if (noti == NULL) {
+               MSG_DEBUG("notification_create is failed.");
+               return MSG_ERR_UNKNOWN;
+       }
+
        if (pMsg->msgType.mainType == MSG_SMS_TYPE &&
                        (pMsg->msgType.subType >= MSG_MWI_VOICE_SMS && pMsg->msgType.subType <= MSG_MWI_OTHER_SMS)) {
 
                args = bundle_create();
 
-               noti = notification_new(NOTIFICATION_TYPE_NOTI, 1, NOTIFICATION_PRIV_ID_NONE);
-               if (noti == NULL) {
-                       MSG_DEBUG("notification_new is failed.");
-                       bundle_free(args);
-                       return MSG_ERR_UNKNOWN;
-               }
-
                noti_err = notification_set_application(noti, "com.samsung.call");
                if (noti_err != NOTIFICATION_ERROR_NONE) {
                        MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
                }
 
+               noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
+               }
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Voice Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Voice Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
                noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, VOICE_MSG_ICON_PATH);
                if (noti_err != NOTIFICATION_ERROR_NONE) {
                        MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
@@ -305,16 +482,48 @@ msg_error_t MsgInsertNoti(MSG_MESSAGE_INFO_S* pMsg)
                bundle_add(args, "launch-type", "MO");
                bundle_add(args, "number", pMsg->addressList[0].addressVal);
 
+       } else if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.subType == MSG_STATUS_REPORT_SMS) {
+
+               noti_err = notification_set_application(noti, "com.samsung.message");
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
+               }
+
+               noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
+               }
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Delivery Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NOTI_MSG_ICON_PATH);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
+               }
+
        } else {
+
+               MSG_DEBUG("Message type does not match.");
+
+               noti_err = notification_free(noti);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_free");
+               }
+
                return MSG_ERR_INVALID_PARAMETER;
        }
 
        if (displayName[0] == '\0')
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
        else
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
 
-       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+       // set time.
+       notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
 
        if (args != NULL) {
                noti_err = notification_set_args(noti, args, NULL);
@@ -323,11 +532,6 @@ msg_error_t MsgInsertNoti(MSG_MESSAGE_INFO_S* pMsg)
                }
        }
 
-       noti_err = notification_set_time(noti, pMsg->displayTime);
-       if (noti_err != NOTIFICATION_ERROR_NONE) {
-               MSG_DEBUG("Fail to notification_set_time : %d", noti_err);
-       }
-
        noti_err = notification_insert(noti, NULL);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
                MSG_DEBUG("Fail to notification_insert");
@@ -338,13 +542,18 @@ msg_error_t MsgInsertNoti(MSG_MESSAGE_INFO_S* pMsg)
                MSG_DEBUG("Fail to notification_free");
        }
 
-       bundle_free(args);
+       if (args != NULL) {
+               bundle_free(args);
+       }
+
+       MsgChangePmState();
 
        return MSG_SUCCESS;
 }
 
 msg_error_t MsgInsertSmsReportToNoti(MsgDbHandler *pDbHandle, msg_message_id_t msgId, msg_delivery_report_status_t status)
 {
+
        notification_h noti = NULL;
        notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
 
@@ -414,29 +623,40 @@ msg_error_t MsgInsertSmsReportToNoti(MsgDbHandler *pDbHandle, msg_message_id_t m
        pDbHandle->finalizeQuery();
 
 
-       noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+       noti = notification_create(NOTIFICATION_TYPE_NOTI);
        if (noti == NULL) {
-               MSG_DEBUG("notification_new is failed.");
+               MSG_DEBUG("notification_create is failed.");
                return MSG_ERR_UNKNOWN;
        }
+       noti_err = notification_set_application(noti, "org.tizen.call");
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
+       }
+       noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
+       }
 
        noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NOTI_MSG_ICON_PATH);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
                MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
        }
 
+       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Delivery Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
        if (displayName[0] == '\0')
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
        else
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
 
        if (status == MSG_DELIVERY_REPORT_SUCCESS)
                snprintf(contents, MAX_DISPLAY_NAME_LEN, "Delivered.");
        else
                snprintf(contents, MAX_DISPLAY_NAME_LEN, "Deliver Failed.");
 
-       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
 
        noti_err = notification_insert(noti, NULL);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
@@ -454,6 +674,7 @@ msg_error_t MsgInsertSmsReportToNoti(MsgDbHandler *pDbHandle, msg_message_id_t m
 
 msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
 {
+
        notification_h noti = NULL;
        notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
 
@@ -580,21 +801,34 @@ msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S
 
        pDbHandle->finalizeQuery();
 
-       noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+       noti = notification_create(NOTIFICATION_TYPE_NOTI);
        if (noti == NULL) {
-               MSG_DEBUG("notification_new is failed.");
+               MSG_DEBUG("notification_create is failed.");
                return MSG_ERR_UNKNOWN;
        }
 
+       noti_err = notification_set_application(noti, "org.tizen.message");
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
+       }
+       noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
+       }
+
        noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NOTI_MSG_ICON_PATH);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
                MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
        }
 
        if (displayName[0] == '\0')
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
        else
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+       // set time.
+//     notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
+
 
        if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) {
 
@@ -641,9 +875,12 @@ msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S
 
                default :
                        snprintf(contents, MAX_DISPLAY_NAME_LEN, "Delivered.");
+                       break;
                }
 
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               MSG_DEBUG("content text : %s", contents);
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
                notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
 
                noti_err = notification_insert(noti, NULL);
@@ -666,9 +903,12 @@ msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S
 
                default :
                        snprintf(contents, MAX_DISPLAY_NAME_LEN, "Read.");
+                       break;
                }
 
-               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               MSG_DEBUG("content text : %s", contents);
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
 
                noti_err = notification_insert(noti, NULL);
                if (noti_err != NOTIFICATION_ERROR_NONE) {
@@ -693,30 +933,267 @@ msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S
 }
 
 
-msg_error_t MsgDeleteNotiByMsgId(msg_message_id_t msgId)
+msg_error_t MsgRefreshNoti()
 {
 
+       MsgDbHandler dbhandler;
+       MSG_MESSAGE_INFO_S msg = {0,};
+
+       int notiPrivId = MsgSettingGetInt(NOTIFICATION_PRIV_ID);
+
+       notification_h noti = NULL;
        notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+       bundle* args;
+
+       int contactId = 0;
+       msg_thread_id_t threadId = 0;
+       time_t msgTime = 0;
+       char tempId[6];
+       char addressVal[MAX_ADDRESS_VAL_LEN+1];
+       char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
+       char displayName[MAX_DISPLAY_NAME_LEN+1];
+       char thumbPath[MAX_IMAGE_PATH_LEN+1];
+       char sqlQuery[MAX_QUERY_LEN+1];
+
+       memset(tempId, 0x00, sizeof(tempId));
+       memset(addressVal, 0x00, sizeof(addressVal));
+       memset(firstName, 0x00, sizeof(firstName));
+       memset(lastName, 0x00, sizeof(lastName));
+       memset(displayName, 0x00, sizeof(displayName));
+       memset(thumbPath, 0x00, sizeof(thumbPath));
+       memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+       snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.CONV_ID, A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, \
+                       B.DISPLAY_TIME, A.CONTACT_ID, A.IMAGE_PATH, B.MSG_ID, B.MSG_TEXT, B.SUBJECT, B.MAIN_TYPE \
+                       FROM %s A, %s B WHERE A.CONV_ID=B.CONV_ID AND B.READ_STATUS=0 AND B.FOLDER_ID=%d ORDER BY B.DISPLAY_TIME, B.MSG_ID ASC;",
+                       MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID);
+
+       if (dbhandler.prepareQuery(sqlQuery) != MSG_SUCCESS)
+               return MSG_ERR_DB_PREPARE;
+
+       if (dbhandler.stepQuery() == MSG_ERR_DB_ROW) {
+               threadId = dbhandler.columnInt(0);
+
+               if (dbhandler.columnText(1) != NULL)
+                       strncpy(addressVal, (char*)dbhandler.columnText(1), MAX_ADDRESS_VAL_LEN);
+
+
+               char *pTempDisplayName = (char *)dbhandler.columnText(2);
+               if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
+                       strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
+               } else {
+                       if (dbhandler.columnText(3) != NULL)
+                               strncpy(firstName, (char*)dbhandler.columnText(3), MAX_DISPLAY_NAME_LEN);
+
+                       if (dbhandler.columnText(4) != NULL)
+                               strncpy(lastName, (char*)dbhandler.columnText(4), MAX_DISPLAY_NAME_LEN);
+
+                       int order = MsgGetContactNameOrder();
+
+                       if (order == 0) {
+                               if (firstName[0] != '\0') {
+                                       strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
+                               }
+
+                               if (lastName[0] != '\0') {
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                                       strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       } else if (order == 1) {
+                               if (lastName[0] != '\0') {
+                                       strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
+                                       strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+
+                               if (firstName[0] != '\0') {
+                                       strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
+                               }
+                       }
+               }
+
+               msgTime = (time_t)dbhandler.columnInt(5);
+
+               contactId = dbhandler.columnInt(6);
+
+               strncpy(thumbPath, (char*)dbhandler.columnText(7), MAX_IMAGE_PATH_LEN);
+
+               msg.msgId = dbhandler.columnInt(8);
+
+               strncpy(msg.msgText, (char*)dbhandler.columnText(9), MAX_MSG_TEXT_LEN);
+
+               strncpy(msg.subject, (char*)dbhandler.columnText(10), MAX_SUBJECT_LEN);
+
+               msg.msgType.mainType = dbhandler.columnInt(11);
+
+               MSG_DEBUG("unread message [%d].", msg.msgId);
+       } else {
 
-       MSG_DEBUG("notification_delete_by_priv_id msgId [%d]", msgId);
+               MSG_DEBUG("No unread message.");
+               MSG_DEBUG("notiPrivId [%d]", notiPrivId);
 
-       noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, msgId);
+               dbhandler.finalizeQuery();
 
+               // No unread message.
+               if (notiPrivId > 0) {
+                       notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, notiPrivId);
+                       if (noti_err != NOTIFICATION_ERROR_NONE) {
+                               MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
+                       }
+               }
+
+               notiPrivId = 0;
+
+               MsgSettingSetInt(NOTIFICATION_PRIV_ID, notiPrivId);
+
+               return MSG_ERR_DB_STEP;
+       }
+
+       dbhandler.finalizeQuery();
+
+
+       args = bundle_create();
+
+       int unreadMsgCnt = MsgStoGetUnreadCnt(&dbhandler, MSG_SMS_TYPE);
+       unreadMsgCnt += MsgStoGetUnreadCnt(&dbhandler, MSG_MMS_TYPE);
+
+       MSG_DEBUG("notiPrivId [%d], unreadMsgCnt [%d]", notiPrivId, unreadMsgCnt);
+
+       if (notiPrivId > 0) {
+               noti = notification_load(NULL, notiPrivId);
+               if (noti == NULL)
+                       MSG_DEBUG("notification_load is failed.");
+       }
+
+       if (noti == NULL) {
+               noti = notification_create(NOTIFICATION_TYPE_NOTI);
+               if (noti == NULL) {
+                       MSG_DEBUG("notification_new is failed.");
+                       bundle_free(args);
+                       return MSG_ERR_UNKNOWN;
+               }
+
+               notiPrivId = 0;
+       }
+       noti_err = notification_set_application(noti, "org.tizen.message");
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
+       }
+       noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
-               MSG_DEBUG("Fail to notification_delete_by_priv_id noti_err [%d]", noti_err);
+               MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
        }
 
-       return MSG_SUCCESS;
-}
 
+       if (unreadMsgCnt > 1) {
 
-msg_error_t MsgDeleteNotiByThreadId(msg_thread_id_t ThreadId)
-{
-       notification_delete_group_by_group_id(NULL, NOTIFICATION_TYPE_NOTI, ThreadId);
+               noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
+               }
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               char unreadMsgCntStr[5] = {0,};
+               snprintf(unreadMsgCntStr, 5, "%d", unreadMsgCnt);
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               if (displayName[0] == '\0')
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               else
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               if (msg.msgType.mainType == MSG_SMS_TYPE)
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2,msg.msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               else
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, msg.subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               // set time.
+               notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
+
+       } else {
+
+               noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
+               }
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               if (displayName[0] == '\0')
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               else
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               if (msg.msgType.mainType == MSG_SMS_TYPE)
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2,msg.msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               else
+                       notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, msg.subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+
+               // set time.
+               notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
+
+       }
+       memset(&tempId, 0x00, sizeof(tempId));
+
+       bundle_add(args, "type", "msg_id");
+
+       snprintf(tempId, 5, "%d", msg.msgId);
+       bundle_add(args, "msgId", tempId);
+
+       if (args != NULL) {
+               noti_err = notification_set_args(noti, args, NULL);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
+               }
+       }
+
+       if (notiPrivId > 0) {
+               noti_err = notification_update(noti);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_update");
+               }
+       } else {
+               noti_err = notification_insert(noti, &notiPrivId);
+               if (noti_err != NOTIFICATION_ERROR_NONE) {
+                       MSG_DEBUG("Fail to notification_insert");
+               }
+
+               MsgSettingSetInt(NOTIFICATION_PRIV_ID, notiPrivId);
+               MSG_DEBUG("Insert notiPrivId [%d]", notiPrivId);
+       }
+
+       noti_err = notification_free(noti);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_free");
+       }
+
+       bundle_free(args);
 
        return MSG_SUCCESS;
 }
 
+msg_error_t MsgCleanAndResetNoti()
+{
+       msg_error_t err = MSG_SUCCESS;
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+       noti_err = notification_delete_all_by_type("msg-server", NOTIFICATION_TYPE_NOTI);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               MSG_DEBUG("Fail to notification_delete_all_by_type noti_err [%d]", noti_err);
+               return MSG_ERR_UNKNOWN;
+       }
+
+       err = MsgRefreshNoti();
+       if (err != MSG_SUCCESS) {
+                       MSG_DEBUG("Fail to MsgRefreshNoti");
+       }
+
+       return err;
+}
 
 msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg)
 {
@@ -775,3 +1252,7 @@ msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg
 
        return MSG_SUCCESS;
 }
+msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt)
+{
+       return MSG_SUCCESS;
+}
index 15fd2f0..0e80551 100755 (executable)
@@ -36,7 +36,7 @@ static alarm_id_t g_alarmId = 0;
 ==================================================================================================*/
 
 
-void MsgSoundPlayStart()
+void MsgSoundPlayStart(bool isEmergency)
 {
        MSG_BEGIN();
 
@@ -53,7 +53,10 @@ void MsgSoundPlayStart()
        {
                MSG_DEBUG("Child Process - Run helper app for Sound");
 
-               execl("/usr/bin/msg-helper", MSG_SOUND_START, NULL);
+               if (isEmergency)
+                       execl("/usr/bin/msg-helper", MSG_EMERGENCY_SOUND_START, NULL);
+               else
+                       execl("/usr/bin/msg-helper", MSG_NORMAL_SOUND_START, NULL);
 
                MSG_DEBUG("Faild to run helper app for Sound");
 
@@ -201,7 +204,7 @@ bool MsgSoundCreateRepeatAlarm(int RepeatTime)
        alarmmgr_set_type(alarm_info, ALARM_TYPE_VOLATILE);
        alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &g_alarmId);
 
-       retval = alarmmgr_set_cb(MsgSoundRepeatAlarmCB, NULL);
+       retval = alarmmgr_set_cb(MsgSoundRepeatAlarmCB, (void *)alarm_info);
 
        if (retval != 0)
        {
@@ -223,16 +226,18 @@ int MsgSoundRepeatAlarmCB(int TimerId, void *pUserParam)
 {
        MSG_BEGIN();
 
+       alarm_info_t *alarm_info = (alarm_info_t *)pUserParam;
+
        g_bRepeat = false;
 
-       if (MsgSoundGetUnreadMsgCnt() <= 0)
-       {
+       if (MsgSoundGetUnreadMsgCnt() <= 0) {
                MSG_DEBUG("no unread msg");
-
-               return 0;
+       } else {
+               MsgSoundPlayStart(false);
        }
 
-       MsgSoundPlayStart();
+       if (alarmmgr_free_alarm(alarm_info) != ALARMMGR_RESULT_SUCCESS)
+               MSG_DEBUG("alarmmgr_free_alarm is failed");
 
        MSG_END();
 
@@ -297,7 +302,7 @@ void MsgSoundInitRepeatAlarm()
        MSG_DEBUG("nRepeatTime = %d", nRepeatTime);
 
        if (nRepeatTime > 0)
-               MsgSoundPlayStart();
+               MsgSoundPlayStart(false);
 
        MSG_END();
 }
index dc5461d..7b7d652 100755 (executable)
@@ -50,8 +50,10 @@ MsgDbHandler::MsgDbHandler()
 
 MsgDbHandler::~MsgDbHandler()
 {
-       if(handle != NULL)
-               disconnect();
+       if(handle != NULL) {
+               if (disconnect() != MSG_SUCCESS)
+                       MSG_DEBUG("disconnect is failed!!");
+       }
 
        if(stmt != NULL)
                finalizeQuery();
index a72768a..456f9b0 100755 (executable)
@@ -187,7 +187,7 @@ MsgTextConvert::~MsgTextConvert()
 
 
 
-int MsgTextConvert::convertUTF8ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength,  IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_LANGUAGE_ID_T *pLangId)
+int MsgTextConvert::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 utf8Length = 0;
        int gsm7bitLength = 0;
@@ -212,7 +212,7 @@ int MsgTextConvert::convertUTF8ToGSM7bit(OUT unsigned char *pDestText, IN int ma
        MSG_DEBUG("max dest Length = %d", maxLength);
 
        ucs2Length = convertUTF8ToUCS2((unsigned char*)pUCS2Text, maxUCS2Length * sizeof(WCHAR), pSrcText, srcTextLen);
-       gsm7bitLength = convertUCS2ToGSM7bit(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, pLangId);
+       gsm7bitLength = convertUCS2ToGSM7bit(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, pLangId, bIncludeAbnormalChar);
 
        return gsm7bitLength;
 }
@@ -467,7 +467,7 @@ return:
                bytelength of gsm7bit text
                -1 : converting error
 */
-int MsgTextConvert::convertUCS2ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_LANGUAGE_ID_T *pLangId)
+int MsgTextConvert::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)
 {
        // for UNICODE
        int outTextLen = 0;
@@ -553,6 +553,7 @@ MSG_DEBUG("default char");
                                else
                                {
                                        pDestText[outTextLen++] = 0x20;
+                                       *bIncludeAbnormalChar = true;
                                }
                        }
                        else if (currType == MSG_CHAR_TURKISH)
@@ -576,6 +577,7 @@ MSG_DEBUG("default char");
                                else
                                {
                                        pDestText[outTextLen++] = 0x20;
+                                       *bIncludeAbnormalChar = true;
                                }
                        }
                        else if (currType == MSG_CHAR_SPANISH)
@@ -599,6 +601,7 @@ MSG_DEBUG("default char");
                                else
                                {
                                        pDestText[outTextLen++] = 0x20;
+                                       *bIncludeAbnormalChar = true;
                                }
                        }
                        else if (currType == MSG_CHAR_PORTUGUESE)
@@ -625,11 +628,13 @@ MSG_DEBUG("ucs2toPortuList : [%02x]", (unsigned char)itExt->second);
                                {
 MSG_DEBUG("no char");
                                        pDestText[outTextLen++] = 0x20;
+                                       *bIncludeAbnormalChar = true;
                                }
                        }
                        else
                        {
                                pDestText[outTextLen++] = 0x20;
+                               *bIncludeAbnormalChar = true;
                        }
                }
 
index 499ac32..bf2fdc2 100755 (executable)
@@ -717,6 +717,7 @@ int MsgRmRf(char *pDirPath)
 
        if (path == NULL) {
                MSG_DEBUG("path is NULL");
+               closedir(dir);
                return -1;
        }
 
@@ -824,6 +825,8 @@ unsigned int MsgDu(const char *pDirPath)
 
                        if (fileSize < 0) {
                                MSG_FATAL("error MsgGetFileSize");
+                               closedir(dir);
+                               free(path);
                                return fileSize;
                        }
 
index b2a1bf3..3aa2626 100755 (executable)
@@ -26,7 +26,7 @@
 #include <sys/vfs.h>
 
 
-static int msgCntLimit[MSG_COUNT_LIMIT_MAILBOX_TYPE_MAX][MSG_COUNT_LIMIT_MSG_TYPE_MAX] = {{1500, 500, 0, 50, 50}, {50, 50, 0, 0, 0}, {1000, 250, 0, 0, 0}, {50, 50, 0, 0, 0}, {0, 0, 200, 0, 0}};
+static int msgCntLimit[MSG_COUNT_LIMIT_MAILBOX_TYPE_MAX][MSG_COUNT_LIMIT_MSG_TYPE_MAX] = {{10, 10, 0, 10, 10}, {5, 10, 0, 0, 0}, {10, 10, 0, 0, 0}, {10, 10, 0, 0, 0}, {0, 0, 10, 0, 0}};
 
 
 /*==================================================================================================
@@ -143,7 +143,8 @@ msg_error_t MsgStoSetReadStatus(MsgDbHandler *pDbHandle, msg_message_id_t msgId,
 
        MsgSettingSetIndicator(smsCnt, mmsCnt);
 
-       MsgDeleteNotiByMsgId(msgId);
+//     MsgDeleteNotiByMsgId(msgId);
+       MsgRefreshNoti();
 
        return MSG_SUCCESS;
 }
@@ -181,23 +182,22 @@ msg_error_t MsgStoCheckMsgCntFull(MsgDbHandler *pDbHandle, const MSG_MESSAGE_TYP
        MSG_BEGIN();
 
        msg_error_t err = MSG_SUCCESS;
+               struct statfs buf = {0};
 
-       struct statfs buf = {0};
-
-       if (statfs(MSG_DATA_ROOT_PATH, &buf) == -1) {
-               MSG_DEBUG("statfs(\"%s\") failed - %d", MSG_DATA_ROOT_PATH);
-               return MSG_ERR_STORAGE_ERROR;
-       }
+               if (statfs(MSG_DATA_ROOT_PATH, &buf) == -1) {
+                       MSG_DEBUG("statfs(\"%s\") failed - %d", MSG_DATA_ROOT_PATH);
+                       return MSG_ERR_STORAGE_ERROR;
+               }
 
-       unsigned long freeSpace = (buf.f_bfree * buf.f_bsize);
+               unsigned long freeSpace = (buf.f_bfree * buf.f_bsize);
 
-       MSG_DEBUG("f_bfree [%d] f_bsize [%d]", buf.f_bfree, buf.f_bsize);
-       MSG_DEBUG("Free space of storage is [%ul] MB.", freeSpace);
+               MSG_DEBUG("f_bfree [%d] f_bsize [%d]", buf.f_bfree, buf.f_bsize);
+               MSG_DEBUG("Free space of storage is [%ul] MB.", freeSpace);
 
-       if (freeSpace < SMS_MINIMUM_SPACE && pMsgType->mainType == MSG_SMS_TYPE)
-               err = MSG_ERR_MESSAGE_COUNT_FULL;
-       else if(freeSpace < MMS_MINIMUM_SPACE && pMsgType->mainType == MSG_MMS_TYPE)
-               err = MSG_ERR_MESSAGE_COUNT_FULL;
+               if (freeSpace < SMS_MINIMUM_SPACE && pMsgType->mainType == MSG_SMS_TYPE)
+                       err = MSG_ERR_MESSAGE_COUNT_FULL;
+               else if(freeSpace < MMS_MINIMUM_SPACE && pMsgType->mainType == MSG_MMS_TYPE)
+                       err = MSG_ERR_MESSAGE_COUNT_FULL;
 
        MSG_END();
 
@@ -889,8 +889,6 @@ bool MsgExistAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsg, ms
                                pDbHandle->freeTable();
                                return false;
                        }
-
-                       pDbHandle->freeTable();
                }
 
        } else { /* multiple address */
@@ -1045,8 +1043,10 @@ msg_error_t MsgStoAddContactInfo(MsgDbHandler *pDbHandle, MSG_CONTACT_INFO_S *pC
                                MSGFW_ADDRESS_TABLE_NAME, pContactInfo->contactId, pContactInfo->imagePath, pNumber);
        }
 
-       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+       if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
+               MSG_DEBUG("sqlQuery [%s]", sqlQuery);
                return MSG_ERR_DB_PREPARE;
+       }
 
        pDbHandle->bindText(pContactInfo->firstName, 1);
 
diff --git a/utils/MsgVMessage.cpp b/utils/MsgVMessage.cpp
new file mode 100755 (executable)
index 0000000..43277f5
--- /dev/null
@@ -0,0 +1,618 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 <VMessage.h>
+#include <VCard.h>
+#include <time.h>
+
+#include "MsgMmsTypes.h"
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgCppTypes.h"
+#include "MsgVMessage.h"
+
+
+/*==================================================================================================
+                                     DEFINES
+==================================================================================================*/
+#define INSERT_VMSG_OBJ pObject = (VObject*)calloc(1, sizeof(VObject));        \
+                                      if ( !pObject )\
+{\
+   vmsg_free_vtree_memory( pMessage );\
+   return false;\
+}\
+if (pMessage->pTop == NULL)\
+{\
+   pMessage->pTop = pObject;\
+}\
+else\
+{\
+   pMessage->pCur->pSibling = pObject;\
+}\
+pMessage->pCur = pObject;
+
+
+#define INSERT_VBODY_OBJ pObject = (VObject*)calloc(1, sizeof(VObject));       \
+                                      if ( !pObject )\
+{\
+   vmsg_free_vtree_memory( pMessage );\
+   return false;\
+}\
+if (pBody->pTop == NULL)\
+{\
+   pBody->pTop = pObject;\
+}\
+else\
+{\
+   pBody->pCur->pSibling = pObject;\
+}\
+pBody->pCur = pObject;
+
+
+#define INSERT_VCARD_OBJ pObject = (VObject*)calloc(1, sizeof(VObject));       \
+                                      if ( !pObject )\
+{\
+   vmsg_free_vtree_memory( pMessage );\
+   return false;\
+}\
+if (pCard->pTop == NULL)\
+{\
+   pCard->pTop = pObject;\
+}\
+else\
+{\
+   pCard->pCur->pSibling = pObject;\
+}\
+pCard->pCur = pObject;
+
+
+#define INSERT_PARAM  param = (VParam*)calloc(1, sizeof(VParam));\
+                             if (!param)\
+{\
+   vmsg_free_vtree_memory( pMessage );\
+   if (pObject != NULL)\
+   {\
+      free(pObject);\
+      pObject = NULL;\
+   }\
+   return false;\
+}
+
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+char* MsgVMessageAddRecord(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
+{
+       MSG_BEGIN();
+
+       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;
+
+       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;
+
+       }
+               pCurrent = pMessage;
+
+       //Insert VObject (X-MESSAGE-TYPE) to VMessage tree
+       INSERT_VMSG_OBJ;
+
+       pObject->property = VMSG_TYPE_MSGTYPE;
+
+       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
+
+       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))
+               pObject->pszValue[0] = strdup("MMS RETRIEVED");
+
+       else
+               goto __CATCH_FAIL__;
+
+       pObject->valueCount = 1;
+
+
+       //Insert VObject (X-IRMC-BOX) to VMessate tree
+       INSERT_VMSG_OBJ;
+
+       pObject->property = VMSG_TYPE_MSGBOX;
+
+       switch(pMsg->folderId)
+       {
+               case MSG_INBOX_ID:
+                       pObject->pszValue[0] = strdup("INBOX");
+                       break;
+               case MSG_OUTBOX_ID:
+                       pObject->pszValue[0] = strdup("OUTBOX");
+                       break;
+               case MSG_SENTBOX_ID:
+                       pObject->pszValue[0] = strdup("SENTBOX");
+                       break;
+               case MSG_DRAFT_ID:
+                       pObject->pszValue[0] = strdup("DRAFTBOX");
+                       break;
+               default:
+                       // Discard User Defined or Spam folder's messages.
+                       goto __CATCH_FAIL__;
+       }
+       pObject->valueCount = 1;
+
+
+       //Insert VObject (X-SS-DT) to VMessage tree
+       INSERT_VMSG_OBJ;
+
+       pObject->property = VMSG_TYPE_DATE;
+       localtime_r(&(pMsg->displayTime), &display_time);
+       pObject->pszValue[0] = _convert_tm_to_vdata_str(&display_time);
+       pObject->valueCount = 1;
+
+
+       //Insert Vobject read status to VMessage tree
+       INSERT_VMSG_OBJ;
+
+       pObject->property = VMSG_TYPE_STATUS;
+
+       if(pMsg->bRead)
+               pObject->pszValue[0] = strdup("READ");
+       else
+               pObject->pszValue[0] = strdup("UNREAD");
+
+       pObject->valueCount = 1;
+
+
+       //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;
+
+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;
+                               AutoPtr<char> buf(&pFileData);
+
+                               int             fileSize = 0;
+                               char*   msgText = NULL;
+
+                               if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false)
+                                       goto __CATCH_FAIL__;
+
+                               msgText = (char *)calloc(1, fileSize);
+                               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)
+       {
+               //Insert VBody for mms raw data;
+               char* pFileData = NULL;
+
+               int             fileSize = 0;
+               char*   msgText = NULL;
+               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);
+               }
+               MSG_DEBUG("FILE SIZE IS %d", fileSize);
+               msgText = (char *)calloc(1, fileSize);
+               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;
+
+__CATCH_FAIL__ :
+       vmsg_free_vtree_memory( pMessage );
+
+       return NULL;
+}
+
+
+char* _convert_tm_to_vdata_str(const struct tm * tm)
+{
+       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)
+{
+
+   if (szText == NULL) return false;
+   if (strlen(szText) < 15) return false;
+   if (szText[8] != 'T') return false;
+
+   char szBuff[8]={0};
+   memset(tm, 0, sizeof(struct tm));
+
+   // 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;
+
+   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;
+
+   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;
+}
+
+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;
+
+       struct tm       display_time;
+       char *encoded_data = NULL;
+       int err = MSG_SUCCESS;
+
+       if (pMessage == NULL) {
+               pMessage = (VTree *)malloc(sizeof(VTree));
+               if (!pMessage) {
+                       return NULL;
+               }
+               pMessage->treeType = VMESSAGE;
+               pMessage->pTop = NULL;
+               pMessage->pCur = NULL;
+               pMessage->pNext = NULL;
+
+       }
+               pCurrent = pMessage;
+
+       //Insert VObject (X-MESSAGE-TYPE) to VMessage tree
+       INSERT_VMSG_OBJ;
+
+       pObject->property = VMSG_TYPE_MSGTYPE;
+
+       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
+
+       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))
+               pObject->pszValue[0] = strdup("MMS RETRIEVED");
+
+       else
+               goto __CATCH_FAIL__;
+
+       pObject->valueCount = 1;
+
+
+       //Insert VObject (X-IRMC-BOX) to VMessate tree
+       INSERT_VMSG_OBJ;
+
+       pObject->property = VMSG_TYPE_MSGBOX;
+
+       switch(pMsg->folderId)
+       {
+               case MSG_INBOX_ID:
+                       pObject->pszValue[0] = strdup("INBOX");
+                       break;
+               case MSG_OUTBOX_ID:
+                       pObject->pszValue[0] = strdup("OUTBOX");
+                       break;
+               case MSG_SENTBOX_ID:
+                       pObject->pszValue[0] = strdup("SENTBOX");
+                       break;
+               case MSG_DRAFT_ID:
+                       pObject->pszValue[0] = strdup("DRAFTBOX");
+                       break;
+               default:
+                       // Discard User Defined or Spam folder's messages.
+                       goto __CATCH_FAIL__;
+       }
+       pObject->valueCount = 1;
+
+
+       //Insert VObject (X-SS-DT) to VMessage tree
+       INSERT_VMSG_OBJ;
+
+       pObject->property = VMSG_TYPE_DATE;
+       localtime_r(&(pMsg->displayTime), &display_time);
+       pObject->pszValue[0] = _convert_tm_to_vdata_str(&display_time);
+       pObject->valueCount = 1;
+
+
+       //Insert Vobject read status to VMessage tree
+       INSERT_VMSG_OBJ;
+
+       pObject->property = VMSG_TYPE_STATUS;
+
+       if(pMsg->bRead)
+               pObject->pszValue[0] = strdup("READ");
+       else
+               pObject->pszValue[0] = strdup("UNREAD");
+
+       pObject->valueCount = 1;
+
+
+       //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;
+
+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;
+                               AutoPtr<char> buf(&pFileData);
+
+                               int             fileSize = 0;
+                               char*   msgText = NULL;
+
+                               if (MsgOpenAndReadFile(pMsg->msgData, &pFileData, &fileSize) == false)
+                                       goto __CATCH_FAIL__;
+
+                               msgText = (char *)calloc(1, fileSize);
+                               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)
+       {
+               //Insert VBody for mms raw data;
+               char* pFileData = NULL;
+
+               int             fileSize = 0;
+               char*   msgText = NULL;
+               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);
+
+                       if (err != MSG_SUCCESS)
+                               goto __CATCH_FAIL__;
+
+                       pFileData = MsgOpenAndReadMmsFile(filePath, 0, -1, &fileSize);
+               }
+               MSG_DEBUG("FILE SIZE IS %d", fileSize);
+               msgText = (char *)calloc(1, fileSize);
+               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;
+
+__CATCH_FAIL__ :
+       vmsg_free_vtree_memory( pMessage );
+
+       return NULL;
+}
diff --git a/vobject-engine/CMakeLists.txt b/vobject-engine/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..114a14b
--- /dev/null
@@ -0,0 +1,40 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(msg-server CXX)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Debug")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+#SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall")
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall")
+
+SET(VOBJECT-SRCS
+               ${CMAKE_SOURCE_DIR}/vobject-engine/VCard.c
+               ${CMAKE_SOURCE_DIR}/vobject-engine/VCardCalUtil.c
+             ${CMAKE_SOURCE_DIR}/vobject-engine/VMessage.c
+       )
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(vobject_pkgs REQUIRED dlog)
+
+SET(EXTRA_CFLAGS "")
+FOREACH(flag ${vobject_pkgs_CFLAGS})
+        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+#SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${VOBJECT-LIB} SHARED ${VOBJECT-SRCS})
+TARGET_LINK_LIBRARIES(${VOBJECT-LIB} ${vobject_pkgs_LDFLAGS})
+
+INSTALL(TARGETS ${VOBJECT-LIB} DESTINATION lib)
diff --git a/vobject-engine/VCard.c b/vobject-engine/VCard.c
new file mode 100755 (executable)
index 0000000..71810d4
--- /dev/null
@@ -0,0 +1,1534 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 "VTypes.h"
+#include "VCard.h"
+#include "vobject.h"
+
+#define MAX_TYPE_NAME_LEN 50
+#define MAX_PARAM_NAME_LEN 50
+#define CHECK_START 1
+#define CHECK_END 2
+
+#define VFREE(obj) if(obj != NULL) { /*VDATA_TRACE("%p",obj);*/ free(obj); \
+       obj = NULL; \
+}
+
+#define TRIM(obj) if(obj != NULL) {\
+       _VRLSpace(obj);\
+       _VRTSpace(obj);\
+}
+
+#define UPPER(obj,start,end) if(obj != NULL) {\
+       for(start = 0; start < end; start++)\
+               obj[start] = toupper(obj[start]);\
+}
+
+#define GO_NEXT_CHAR(current, rowData, addedCnt) {\
+       current = *rowData;\
+       rowData++;\
+       (*addedCnt)++;\
+}
+
+#define SET_PARAM_VALUE(PARAM, SZVALUE, LIST, LISTCNT, PARAMOBJ, PTYPE, ENC) {\
+       PARAM = 0;\
+       PARAM |= __VCardGetValue(SZVALUE, LIST, LISTCNT);\
+       if ( PARAM != UNKNOWN_NAME ) {\
+               PARAMOBJ->parameter = PTYPE;\
+               if(PTYPE == VCARD_PARAM_ENCODING)\
+                       ENC = PARAM;\
+               break;\
+       }\
+}
+
+#define LENGTH_TYPE_LIST(obj, len) for(len =0; obj[len] != NULL; len++);
+
+extern char* _VUnfoldingNoSpecNew( char *string );
+
+/** GLOBAL VARIABLE DECLARATION AND INITIALIZATION */
+/** vCard Types. */
+char* pszCardTypeList[] =
+{
+       "ADR",                  /* Delivery Address -> address*/
+       "AGENT",                        /* Agent -> assistant name, assistant number*/
+       "BDAY",                 /* Birthday -> birthday */
+       "BEGIN",                        /* BEGIN VCARD DELIMITER*/
+       "CATEGORIES",   /* Categories is a multivalued attribute */
+       "CLASS",                        /* */
+       "EMAIL",                        /* Email -> email */
+       "END",                  /* END VCARD DELIMITER*/
+       "FN",                   /* Formatted Name -> display_name */
+       "GEO",                  /* Geographic Positioning*/
+       "KEY",                  /* Public Key*/
+       "LABEL",                        /* Label Address -> address*/
+       "LOGO",                 /* Logo*/
+       "MAILER",               /* Email Program (Optional)*/
+       "N",                            /* Name -> name */
+       "NAME",                 /* Name -> name */
+       "NICKNAME",             /* Nickname -> nickname */
+       "NOTE",                 /* Note -> note */
+       "ORG",                  /* Organization Name or Organizational unit -> department*/
+       "PHOTO",                        /* Photograph -> caller id*/
+       "PRODID",               /* */
+       "PROFILE",              /* */
+       "REV",                  /* Last Revision(combination of calendar date & time)*/
+       "ROLE",                 /* Role or occupation */
+       "SORT-STRING",  /* */
+       "SOUND",                        /* Sound*/
+       "SOURCE",               /* */
+       "TEL",                  /* Telephone -> phone number */
+       "TITLE",                        /* Job Title -> job title */
+       "TZ",                   /* Time Zone*/
+       "UID",                  /* Unique Identifier*/
+       "URL",                  /* URL -> web address */
+       "VERSION",              /* Version*/
+       "X-IRMC-LUID",  /* */
+       NULL
+};
+
+/** Parameter */
+char* pszCardParamList[] =
+{
+       "CHARSET",
+       "CONTEXT",
+       "ENCODING",
+       "LANGUAGE",
+       "TYPE",
+       "VALUE"
+};
+
+/** Encoding value */
+ValueObj pEncList[] =
+{
+       {"B",                   0x00000001},
+       {"BASE64",      0x00000002},
+       {"QUOTED-PRINTABLE", 0x00000004},
+       {"7BIT",                0x00000008},
+       {"8BIT",                0x00000010}
+};
+
+/** Character set value */
+ValueObj pCharsetList[] =
+{
+       {"UTF-8",                       0x00000001},
+       {"UTF-16",              0x00000002},
+       {"ISO-8859-1",  0x00000004}
+};
+
+/** Value value */
+ValueObj pValueList[] =
+{
+       {"BINARY",                      0x00000001},
+       {"BOOLEAN",                     0x00000002},
+       {"DATE",                                0x00000004},
+       {"DATE-TIME",           0x00000008},
+       {"FLOAT",                               0x00000010},
+       {"INTEGER",                     0x00000020},
+       {"PHONE-NUMBER",        0x00000040},
+       {"TEXT",                                0x00000080},
+       {"TIME",                                0x00000100},
+       {"URI",                                 0x00000200},
+       {"URL",                                 0x00000400},
+       {"UTC-OFFSET",          0x00000800},
+       {"VCARD",                               0x00001000}
+};
+
+/** Type value */
+ValueObj pTypeList[] =
+{
+       {"AIFF",                0x00000001},
+       {"BBS",                 0x00000002},
+       {"CAR",                 0x00000004},
+       {"CELL",                0x00000008},
+       {"DOM",                 0x00000010},
+       {"WORK",                0x00000020},
+       {"FAX",                 0x00000040},
+       {"GIF",                 0x00000080},
+       {"HOME",                0x00000100},
+       {"INTL",                0x00000200},
+       {"INTERNET",    0x00000400},
+       {"ISDN",                0x00000800},
+       {"JPEG",                0x00001000},
+       {"MOBILE",      0x00002000},
+       {"MODEM",               0x00004000},
+       {"MSG",                 0x00008000},
+       {"PAGER",               0x00010000},
+       {"PARCEL",      0x00020000},
+       {"PCM",                 0x00040000},
+       {"PCS",                 0x00080000},
+       {"PNG",                 0x00100000},
+       {"POSTAL",      0x00200000},
+       {"PREF",                0x00400000},
+       {"VIDEO",               0x00800000},
+       {"VOICE",               0x01000000},
+       {"WAVE",                0x02000000},
+       {"WBMP",                0x04000000},
+       {"ETC",                 0x08000000},
+       {"X400",                0x10000000}
+};
+
+/** FUNCTION DECLARATION       */
+int __VCardGetName(char*, char**, int);
+int __VCardGetValue(char*, const ValueObj*, int);
+int __VCardGetTypeName(char*, int*, int*);
+int __VCardGetParamName(char*, int*, int*);
+int __VIsVcardFile(char*, int);
+char* __VCardGetParamVal(char*,int*, int*);
+char* __VCardGetTypeVal(char*, int*, int*, int, VObject*);
+char* __VCardTypeEncode(VObject*, char*);
+char* __VCardParamEncode(VObject*, int*);
+
+#ifdef VDATA_GROUPNAME_SUPPORTED
+char*  gszGroupName;
+#endif // VDATA_GROUPNAME_SUPPORTED
+
+
+/**
+ * __VCardGetName() compares the string and vCard type, parameter name.
+ *
+ * @param      szString        Name which will compare
+ * @param              pszList[]               Name list of vCard type and param
+ * @param              size                            Number of total element of list
+ *
+ * @return     index           The index in the list
+ */
+int
+__VCardGetName(char* szString, char* pszList[], int size)
+{
+       VDATA_TRACE_BEGINE
+       int high, low, i, diff;
+
+       low = 0;
+       high = size - 1;
+
+       for(; high >= low; diff<0 ? (low = i+1):(high = i-1)) {
+               i = ( low + high ) / 2;
+               if((diff = strcmp( pszList[i], szString )) == 0) /* success: found it */
+                       return i;
+       }
+       VDATA_TRACE_END
+       return UNKNOWN_NAME;
+}
+
+/**
+ * __VCardGetValue() compares the string and vCard type, parameter value.
+ *
+ * @param      szString        Value which will compare
+ * @param              list[]          Value list of vCard param
+ * @param              size                    Number of total element of list
+ *
+ * @return     flag      The value's flag.
+ */
+int
+__VCardGetValue( char* szString, const ValueObj list[], int size)
+{
+       VDATA_TRACE_BEGINE
+       int i = 0, diff = -1;
+       char* szTemp = szString;
+
+       SysRequireEx(szString, UNKNOWN_NAME);
+       SysRequireEx(size > 0, UNKNOWN_NAME);
+
+       UPPER(szTemp,i,strlen(szTemp));
+
+       for(i = 0; i < size-1; i++)
+       {
+               VDATA_TRACE(" i : %d",i);
+               VDATA_TRACE(" for loop %d < %d, list[%d] : %p, list[%d].szName : %p",i,size,i,list[i],i,list[i].szName);
+               VDATA_TRACE(" i : %d",i);
+               if(list[i].szName != NULL)
+               {
+                       VDATA_TRACE(" list[%d].szName != NULL",i);
+                       VDATA_TRACE(" before strcmp %s %s",list[i].szName,szTemp);
+                       VDATA_TRACE(" before strcmp %d",strcmp(list[i].szName, szTemp));
+                       if((diff = strcmp(list[i].szName, szTemp)) == 0) /* success: found it */
+                       {
+                               VDATA_TRACE(" return %d",list[i].flag);
+                               VDATA_TRACE_END
+                               return list[i].flag;
+                       }
+                       VDATA_TRACE(" after strcmp %s %s",list[i].szName,szTemp);
+               }
+       }
+       VDATA_TRACE(" return UNKNOWN_NAME");
+       VDATA_TRACE_END
+       return UNKNOWN_NAME;
+}
+
+/**
+ * __VCardGetTypeName() fine the type name and returns the index number
+ *
+ * @param              pVCardRaw       The raw data
+ * @param              pStatus         Decoder status
+ * @param              pDLen           retrived length
+ *
+ * @return     res                     The index in type list
+ */
+int
+__VCardGetTypeName(char* pVCardRaw, int* pStatus, int* pDLen)
+{
+       VDATA_TRACE_BEGINE
+       int     i, index, res;
+       char    c;
+       char    name[MAX_TYPE_NAME_LEN+1]={0,};
+
+#ifdef VDATA_GROUPNAME_SUPPORTED
+       char*   szGroupName = NULL;
+#endif // VDATA_GROUPNAME_SUPPORTED
+
+       SysRequireEx(pVCardRaw, UNKNOWN_NAME);
+
+       i = index = 0;
+       res = UNKNOWN_NAME;
+
+       while(true) {
+
+               GO_NEXT_CHAR(c, pVCardRaw, pDLen);
+
+               /**
+                * TYPE NAME's length is must be less than MAX_TYPE_NAME_LEN.
+                * If TYPE NAME's value is over MAX_TYPE_NAME_LEN, return UNKNOWN_NAME.
+                * And then Decoding Step shoud not be changed.
+                */
+               if(index >= MAX_TYPE_NAME_LEN) {
+                       *pStatus = VCARD_TYPE_NAME_STATUS;
+                       res = UNKNOWN_NAME;
+                       break;
+               }
+
+               /**
+                * There is a delimeter between TYPE NAME and next element(=Param, or Type Value).
+                * If VTYPE_TOKEN_SEMICOLON or VTYPE_TOKEN_COLON is faced with,
+                * find TYPE NAME's value in pszCardTypeList, and then return searched result.
+                */
+               if ((c == VTYPE_TOKEN_SEMICOLON ) || ( c == VTYPE_TOKEN_COLON)) {
+                       name[index] = 0x00;
+                       TRIM(name);
+                       UPPER(name,i,index);
+                       res = __VCardGetName( name, (char**)pszCardTypeList, VCARD_TYPE_NUM );
+                       break;
+               }
+               /** current version not support grouping vcard type */
+               else if ( c == VTYPE_TOKEN_DOT ) {
+#ifdef VDATA_GROUPNAME_SUPPORTED
+                       name[index] = '\0';
+                       szGroupName = ( char* ) malloc ( index+1 );
+                       if(szGroupName != NULL){
+                               strncpy( szGroupName, name, index );
+                               gszGroupName = szGroupName;
+                       }
+                       index = 0;
+#endif
+               }
+               /**
+                * There is no new line in TYPE NAME.
+                * If new line character is faced with, return UNKNOWN_NAME;
+                */
+               else if ( ( c == '\r' ) || ( c == '\n' ) )
+               {
+                       (*pDLen)++;
+                       *pStatus = VCARD_TYPE_NAME_STATUS;
+                       res = UNKNOWN_NAME;
+                       return res;
+               }
+               else if(_VIsSpace(c));
+               else    name[index++] = c;
+       }
+
+       /**
+        *      Set Next Step.
+        *
+        */
+       if ( c == VTYPE_TOKEN_SEMICOLON )
+               /**
+                * This case next token is parameter. So set VCARD_PARAM_NAME_STATUS step.
+                */
+               *pStatus = VCARD_PARAM_NAME_STATUS;
+       else {
+               if(res != UNKNOWN_NAME)
+                       /**
+                        * This case next string is value. So set VCARD_TYPE_VALUE_STATUS step.
+                        */
+                       *pStatus = VCARD_TYPE_VALUE_STATUS;
+               else
+                       /**
+                        * In current step, TYPE NAME is invalid. So Try to get TYPE NAME again from next position.
+                        */
+                       *pStatus = VCARD_TYPE_NAME_STATUS;
+       }
+       VDATA_TRACE_END
+       return res;
+}
+
+/**
+ * __VCardGetParamName() fine the param name and returns the index number
+ *
+ * @param              pVCardRaw       The raw data
+ * @param              pStatus         Decoder status
+ * @param              pDLen           retrived length
+ *
+ * @return     res                     The index in type list
+ */
+int
+__VCardGetParamName( char* pVCardRaw, int* pStatus, int* pDLen )
+{
+       VDATA_TRACE_BEGINE
+       int     i, index, res;
+
+       char    c;
+       char    name[MAX_PARAM_NAME_LEN+1]={0,};
+       char* pTemp = pVCardRaw;
+
+       SysRequireEx( pVCardRaw, UNKNOWN_NAME );
+
+       i = index = 0;
+       res = UNKNOWN_NAME;
+
+       while ( true )
+       {
+               GO_NEXT_CHAR(c, pVCardRaw, pDLen);
+
+               /**
+                * PARAM NAME's length is must be less than MAX_PARAM_NAME_LEN.
+                * If PARAM NAME's value is over MAX_PARAM_NAME_LEN, return UNKNOWN_NAME.
+                * And then Decoding Step shoud not be changed.
+                */
+               if(index >= MAX_PARAM_NAME_LEN) {
+                       *pStatus = VCARD_TYPE_NAME_STATUS;
+                       res = UNKNOWN_NAME;
+                       break;
+               }
+
+               /**
+                * There is a delimeter between PARAM NAME and next element(=Param, or Param Value).
+                * If VTYPE_TOKEN_EQUAL is faced with,
+                * find PARAM NAME's value in pszCardParamList, and then return searched result.
+                */
+               if(c == VTYPE_TOKEN_EQUAL) {
+                       name[index] = '\0';
+                       TRIM(name);
+                       UPPER(name, i, index);
+                       res = __VCardGetName( name, ( char** )pszCardParamList, VCARD_PARAM_NUM );
+                       if(res==UNKNOWN_NAME){
+                               (*pDLen) = 0;
+                       }
+                       *pStatus = VCARD_PARAM_VALUE_STATUS;
+                       break;
+               }
+               /**
+                * This case, There is no parameter type. Only Parameter Value.
+                * In VCARD_PARAM_NAME_STATUS status, VTYPE_TOKEN_COLON means that anything parameter is no more.
+                * so set next step to VCARD_PARAM_VALUE_STATUS.
+                *
+                * Ex) TEL;WORK:+12341234
+                *        ------ ":" next is TEL TYPE's value.
+                *
+                * VCARD_PARAM_NAME_STATUS(current) -> VCARD_PARAM_VALUE_STATUS
+                * -> VCARD_TYPE_VALUE_STATUS -> MOVE TO NEXT TYPE
+                */
+               else if(c == VTYPE_TOKEN_COLON) {
+                       *pStatus = VCARD_PARAM_VALUE_STATUS;
+                       pVCardRaw = pTemp;
+                       (*pDLen) = 0;
+                       res = UNKNOWN_NAME;
+                       break;
+               }
+               /**
+                * This case, There is no parameter type. Only Parameter Value.
+                * In VCARD_PARAM_NAME_STATUS status, VTYPE_TOKEN_SEMICOLON means that there is a next parameter.
+                * so set next step to VCARD_PARAM_NAME_STATUS.
+                *
+                * Ex) TEL;WORK;PREF:+12341234
+                *        ------ ":" next is TEL TYPE's value.
+                *
+                * VCARD_PARAM_NAME_STATUS(current) -> VCARD_PARAM_NAME_STATUS
+                * -> VCARD_PARAM_VALUE_STATUS -> VCARD_TYPE_VALUE_STATUS -> MOVE TO NEXT TYPE
+                */
+               else if(c == VTYPE_TOKEN_SEMICOLON) {
+                       *pStatus = VCARD_PARAM_NAME_STATUS;
+                       pVCardRaw = pTemp;
+                       (*pDLen) = 0;
+                       res = UNKNOWN_NAME;
+                       break;
+               }
+               else if((c == '\r') || (c == '\n') || (_VIsSpace(c)));
+               else
+                       name[index++] = c;
+       }
+       VDATA_TRACE_END
+       return res;
+}
+
+bool
+__VCardFreeVTreeMemory(VTree * pTree)
+{
+       VDATA_TRACE_BEGINE
+       VObject*                pCurObj = NULL;
+       VObject*                pNextObj = NULL;
+
+       VTree*                  pCurTree = NULL;
+       VTree*                  pNextTree = NULL;
+
+       VParam* pCurParam = NULL;
+       VParam* pNextParam = NULL;
+
+       int count = 0;
+       int i = 0;
+
+       SysRequireEx( pTree->treeType == VCARD, false );
+       SysRequireEx( pTree != NULL, false );
+       VDATA_TRACE("vcard_free_vtree_memory() entered.");
+
+       if (pTree->treeType != VCARD)
+       {
+               VDATA_TRACE_END
+               return true;
+       }
+
+       pCurTree = pTree;
+
+       while(pCurTree)
+       {
+               pNextTree = pCurTree->pNext;
+               pCurObj = pCurTree->pTop;
+
+               while ( pCurObj )
+               {
+
+                       pNextObj = pCurObj->pSibling;
+                       count = pCurObj->valueCount;
+
+                       for ( i = 0; i < count; i++ ) {
+                               VFREE( pCurObj->pszValue[i]);
+                       }
+
+#ifdef VDATA_GROUPNAME_SUPPORTED
+                       if ( pCurObj->pszGroupName )
+                               VFREE( pCurObj->pszGroupName );
+#endif
+
+                       if ( pCurObj->pParam )
+                       {
+
+                               pCurParam = pCurObj->pParam;
+
+                               while(pCurParam != NULL)
+                               {
+                                       pNextParam = pCurParam->pNext;
+                                       VDATA_TRACE("pNEXT ==> %p", pCurParam->pNext);
+                                       VDATA_TRACE("pPARAM ==> %p", pCurParam->parameter);
+                                       VDATA_TRACE("pVALUE ==> %p", pCurParam->paramValue);
+                                       VDATA_TRACE("pCurParam : %p", pCurParam);
+                                       VDATA_TRACE("pCurParam->parameter : %d", pCurParam->parameter);
+                                       VDATA_TRACE("pCurParam->paramValue : %d", pCurParam->paramValue);
+                                       if(pNextParam != NULL) {
+                                               VDATA_TRACE("pNextParam : %p", pNextParam);
+                                               VDATA_TRACE("pNextParam->parameter : %d", pNextParam->parameter);
+                                               VDATA_TRACE("pNextParam->paramValue : %d", pNextParam->paramValue);
+                                       }
+                                       VFREE(pCurParam);
+                                       pCurParam = pNextParam;
+                               }
+                       }
+
+                       VFREE( pCurObj );
+                       pCurObj = pNextObj;
+               }
+
+               VFREE( pCurTree );
+               pCurTree = pNextTree;
+       }
+
+       VDATA_TRACE("exit vcard_free_vtree_memory");
+       VDATA_TRACE_END
+       return true;
+}
+
+/**
+ * __VCardGetParamVal() fine the param value and returns value.
+ *
+ * @param              pVCardRaw       The raw data
+ * @param              pStatus         Decoder status
+ * @param              pDLen           retrived length
+ *
+ * @return     buffer          The result value
+ */
+char*
+__VCardGetParamVal( char* pVCardRaw, int* pStatus, int* pDLen )
+{
+       VDATA_TRACE_BEGINE
+       int len = 0;
+       char    c;
+       char* pBuf = NULL;
+       char* pTemp = pVCardRaw;
+
+       SysRequireEx( pVCardRaw, NULL );
+
+       while(true) {
+               GO_NEXT_CHAR(c, pVCardRaw, pDLen);
+               len++;
+               switch(c) {
+                       case VTYPE_TOKEN_SEMICOLON :
+                               *pStatus = VCARD_PARAM_NAME_STATUS;
+                               break;
+                       case VTYPE_TOKEN_COLON :
+                               *pStatus = VCARD_TYPE_VALUE_STATUS;
+                               break;
+                       case VTYPE_TOKEN_COMMA :
+                               *pStatus = VCARD_PARAM_VALUE_STATUS;
+                               break;
+               }
+               if( c == VTYPE_TOKEN_SEMICOLON
+                               || c == VTYPE_TOKEN_COLON
+                               || c == VTYPE_TOKEN_COMMA
+                               || c == 0x00)
+                       break;
+       }
+
+       pBuf = (char *)malloc(len);
+       if(len < 1 || (pBuf  == NULL)) {
+               if (pBuf) {
+                       free(pBuf);
+                       pBuf = NULL;
+               }
+
+               return NULL;
+       }
+       memset(pBuf, 0x00, len);
+       memcpy( pBuf, pTemp, len-1 );
+       TRIM(pBuf);
+       VDATA_TRACE_END
+       return pBuf;
+}
+
+
+/**
+ * __VCardGetTypeVal() fine the type value and returns value.
+ *
+ * @param      pVCardRaw       The raw data
+ * @param              status                  Decoder status
+ * @return     buffer          The result value
+ */
+char*
+__VCardGetTypeVal( char* pVCardRaw, int* pStatus, int* pDLen, int enc, VObject* pType)
+{
+       VDATA_TRACE_BEGINE
+       int num = 0;
+       int len = 0;
+       int bufferCount = 0;
+
+       bool bEscape = false;
+
+       char    c, c1, c2;
+       char* pBuf = NULL;
+       char* pTemp = pVCardRaw;
+       char* pTmpBuf = NULL;
+       int Status = 0;
+       int Len = 0;
+
+       SysRequireEx( pVCardRaw, NULL );
+
+       while(true)
+       {
+               GO_NEXT_CHAR(c, pVCardRaw, pDLen);
+
+               if( c == 0x00) break;
+
+               len++;
+
+               /** This case means that there are more type's value. */
+               if ( c == VTYPE_TOKEN_SEMICOLON && bEscape == false ) {
+
+                       if((pBuf = (char *)malloc(len)) == NULL) return NULL;
+
+                       memset(pBuf, 0x00, len);
+                       memcpy(pBuf,pTemp,len-1);
+
+                       TRIM(pBuf);
+                       _VUnescape(pBuf);
+
+                       *pStatus = VCARD_TYPE_VALUE_STATUS;
+
+                       /** Base 64 Decoding */
+                       if((enc & pEncList[1].flag) || (enc & pEncList[0].flag)) {
+
+                               bufferCount = (len * 6 / 8) + 2;
+
+                               if((pTmpBuf = (char *)malloc(bufferCount)) == NULL) {
+                                       VFREE(pBuf);
+                                       return NULL;
+                               }
+
+                               memset(pTmpBuf, 0x00, bufferCount);
+                               num = _VB64Decode(pTmpBuf, pBuf);
+
+                               if(pType != NULL) pType->numOfBiData = num;
+
+                               VFREE(pBuf);
+                               pBuf = pTmpBuf;
+                               pTmpBuf = NULL;
+                               break;
+                       }
+
+                       /** Quoted Printable Decoding */
+                       if(enc & pEncList[2].flag) {
+
+                               int i = 0, j = 0;
+
+                               while(pBuf[i]) {
+                                       if(pBuf[i] == '\n' || pBuf[i] == '\r'){
+                                               i++;
+                                               if(pBuf[i] == '\n'|| pBuf[i] == '\r')
+                                                       i++;
+
+                                               if(pBuf[j-1] == '=') j--;
+                                       }
+                                       else
+                                               pBuf[j++] = pBuf[i++];
+                               }
+                               pBuf[j] = '\0';
+
+                               _VQPDecode(pBuf);
+                               TRIM(pBuf);
+                               break;
+                       }
+                       break;
+               }
+
+               if(c == '\\')
+                       bEscape = true;
+               else if(bEscape == true && c != VTYPE_TOKEN_SEMICOLON )
+                       bEscape = false;
+               else if((c == '\r') || (c == '\n'))
+               {
+                       c2 = *(pVCardRaw-2);
+
+                       if(c2 == '=' && (enc & pEncList[2].flag))
+                       {
+                               c1 = *pVCardRaw;
+                               if((c1 == '\r') || (c1 == '\n'))
+                               {
+                                       pVCardRaw += 1;
+                                       (*pDLen) += 1;
+                                       len++;
+                               }
+                       }
+                       else if(__VCardGetTypeName(pVCardRaw, &Status, &Len) != UNKNOWN_NAME)
+                       {
+                               --len;
+                               if((pBuf = (char *)malloc(len)) == NULL) return NULL;
+
+                               memset(pBuf, 0x00, len);
+                               memcpy(pBuf,pTemp,len-1);
+
+                               TRIM(pBuf);
+                               _VUnescape(pBuf);
+
+                               *pStatus = VCARD_TYPE_NAME_STATUS;
+
+                               c1 = *pVCardRaw;
+
+                               if((c1 == '\r') || (c1 == '\n')) {
+                                       pVCardRaw += 1;
+                                       (*pDLen) += 1;
+                               }
+
+                               if((enc & pEncList[1].flag) || (enc & pEncList[0].flag)) {
+
+                                       bufferCount = (len * 6 / 8) + 5;
+
+                                       if((pTmpBuf = (char *)malloc(bufferCount)) == NULL) {
+                                               VFREE(pBuf);
+                                               return NULL;
+                                       }
+
+                                       memset(pTmpBuf, 0x00, bufferCount);
+                                       num = _VB64Decode(pTmpBuf, pBuf);
+
+                                       if(pType != NULL)
+                                               pType->numOfBiData = num;
+
+                                       VFREE(pBuf);
+                                       pBuf = pTmpBuf;
+                                       pTmpBuf = NULL;
+                                       break;
+                               }
+
+                               if(enc & pEncList[2].flag) {
+
+                                       int i = 0, j = 0;
+
+                                       while(pBuf[i])
+                                       {
+                                               if(pBuf[i] == '\n' || pBuf[i] == '\r')
+                                               {
+                                                       i++;
+                                                       if(pBuf[i] == '\n' || pBuf[i] == '\r')
+                                                               i++;
+
+                                                       if(pBuf[j-1] == '=') j--;
+                                               }
+                                               else
+                                                       pBuf[j++] = pBuf[i++];
+                                       }
+                                       pBuf[j] = '\0';
+
+                                       _VQPDecode(pBuf);
+                                       TRIM(pBuf);
+                                       break;
+                               }
+                               break;
+                       }
+               }
+       }
+       VDATA_TRACE_END
+       return pBuf;
+}
+
+
+int
+VCardGetTypeValue( int index )
+{
+       VDATA_TRACE_BEGINE
+       VDATA_TRACE("VCardGetTypeValue() enter..\n");
+       VDATA_TRACE_END
+       return pTypeList[index].flag;
+}
+
+int
+VCardGetValValue( int index )
+{
+       VDATA_TRACE_BEGINE
+       VDATA_TRACE("VCardGetValValue() enter..\n");
+       VDATA_TRACE_END
+       return pValueList[index].flag;
+}
+
+int
+VCardGetEncValue( int index )
+{
+       VDATA_TRACE_BEGINE
+       VDATA_TRACE("VCardGetEncValue() enter..\n");
+       VDATA_TRACE_END
+       return pEncList[index].flag;
+}
+
+int
+VCardGetCharsetValue( int index )
+{
+       VDATA_TRACE_BEGINE
+       VDATA_TRACE("VCardGetCharsetValue() enter..\n");
+       VDATA_TRACE_END
+       return pCharsetList[index].flag;
+}
+
+/*
+ * vcard_decode() decode the vCard data and returns vObject struct
+ *
+ * @param       pVCardRaw            The raw data
+ * @return      vObject             The result value
+ */
+SLPAPI VTree*
+vcard_decode( char *pCardRaw )
+{
+       VDATA_TRACE_BEGINE;
+       char* szValue = NULL;
+       char* szCardBegin = NULL;
+       char* pCardRawTmp = NULL;
+       VTree* pVCard = NULL;
+       VParam* pTmpParam = NULL;
+       VObject* pTemp = NULL;
+
+       char    c;
+
+       int type, param;
+       int status = VCARD_TYPE_NAME_STATUS;
+       int done = false;
+       int valueCount = 0;
+       int len;
+       int dLen = 0;
+       int param_status = false;
+       int numberedParam = 0;
+       int enc = 0;
+       int start_status = 0;
+       char* temp = NULL;
+
+       bool vcard_ended = false;
+
+       SysRequireEx(pCardRaw != NULL, NULL);
+       len = strlen(pCardRaw);
+
+       pCardRaw = _VUnfoldingNoSpecNew(pCardRaw);
+       pCardRawTmp = pCardRaw;
+       len = _VManySpace2Space( pCardRaw );
+
+       if(!__VIsVcardFile(pCardRaw, CHECK_START)) {
+               VFREE(pCardRawTmp);
+               VDATA_TRACE_END
+               return NULL;
+       }
+
+
+       while(true && !done)
+       {
+               c = *pCardRaw;
+
+               if((c == '\0') || done)
+                       break;
+
+               switch(status) {
+                       case VCARD_TYPE_NAME_STATUS:
+                               dLen = 0;
+                               type = __VCardGetTypeName(pCardRaw, &status, &dLen);
+                               pCardRaw += dLen;
+
+                               if(type == -1)
+                                       break;
+
+                               switch ( type )
+                               {
+                                       case VCARD_TYPE_BEGIN:
+                                               if(start_status == 1) {
+                                                       goto CATCH;
+                                               }
+                                               if ( ( pVCard = ( VTree* )malloc( sizeof( VTree ) ) ) == NULL ) {
+                                                       start_status = 1;
+                                                       goto CATCH;
+                                               }
+
+                                               memset(pVCard,0x00, sizeof(VTree));
+
+                                               dLen = 0;
+                                               szCardBegin = __VCardGetTypeVal(pCardRaw, &status, &dLen, enc, NULL);
+                                               pCardRaw += dLen;
+                                               VFREE(szCardBegin);
+
+                                               pVCard->treeType = VCARD;
+                                               pVCard->pTop = NULL;
+                                               pVCard->pCur = NULL;
+                                               pVCard->pNext = NULL;
+                                               break;
+
+                                       case VCARD_TYPE_END:
+                                               enc = 0;
+                                               if(strstr(pCardRaw,"VCARD") != NULL) {
+                                                       pCardRaw += dLen;
+                                                       done = true;
+                                               vcard_ended = true;
+                                               }
+                                               else    {
+                                                       status = VCARD_TYPE_NAME_STATUS;
+                                                       pCardRaw += dLen;
+                                                       //VFREE(etemp);
+                                               }
+                                               break;
+
+                                       case UNKNOWN_NAME :
+                                               break;
+
+                                       default:
+                                               if(UNKNOWN_NAME == type || type < 0) {
+                                                       status = VCARD_TYPE_NAME_STATUS;
+                                                       break;
+                                               }
+
+                                               if ( ( pTemp = ( VObject* )malloc( sizeof( VObject ) ) ) == NULL ) {
+                                                       goto CATCH;
+                                               }
+
+                                               memset( pTemp, 0, sizeof( VObject ) );
+                                               pTemp->property = type;
+
+                                               if ( pVCard->pTop == NULL ) {
+                                                       pVCard->pTop = pTemp;
+                                                       pVCard->pCur = pTemp;
+                                               }
+                                               else {
+                                                       pVCard->pCur->pSibling = pTemp;
+                                                       pVCard->pCur = pTemp;
+                                               }
+
+                                               break;
+                               }
+
+                               numberedParam = 0;
+                               param_status = false;
+                               valueCount = 0;
+
+#ifdef VDATA_GROUPNAME_SUPPORTED
+                               if ( gszGroupName != NULL )
+                                       pVCard->pCur->pszGroupName = gszGroupName;
+#endif
+                               break;
+
+                       case VCARD_PARAM_NAME_STATUS:
+                       {
+                               dLen = 0;
+                               param = __VCardGetParamName( pCardRaw, &status, &dLen );
+                               pCardRaw += dLen;
+
+                               if ( param_status != true ) {
+
+                                       if ( ( pTmpParam = ( VParam* )malloc( sizeof( VParam ) ) ) == NULL )
+                                                       goto CATCH;
+
+                                       param_status = true;
+                                       pVCard->pCur->pParam = pTmpParam;
+                                       memset( pTmpParam, 0x00, sizeof( VParam ) );
+                                       VDATA_TRACE("pTmpParam : %p", pTmpParam);
+                               }
+                               else
+                               {
+                                       if ( ( pTmpParam->pNext = ( VParam* )malloc( sizeof( VParam ) ) ) == NULL )
+                                                       goto CATCH;
+
+                                       pTmpParam = pTmpParam->pNext;
+                                       memset( pTmpParam, 0x00, sizeof(VParam));
+                                       VDATA_TRACE("pTmpParam : %p", pTmpParam);
+                               }
+
+                               pTmpParam->parameter = param;
+                               break;
+                       }
+                       case VCARD_PARAM_VALUE_STATUS:
+                               dLen = 0;
+                               numberedParam = 0;
+                               switch ( pTmpParam->parameter )
+                               {
+                                       case VCARD_PARAM_TYPE:
+                                               szValue = __VCardGetParamVal( pCardRaw, &status, &dLen );
+                                               numberedParam |= __VCardGetValue( szValue, pTypeList, VCARD_TYPE_PARAM_NUM );
+                                               break;
+                                       case VCARD_PARAM_VALUE:
+                                               szValue = __VCardGetParamVal( pCardRaw, &status, &dLen );
+                                               numberedParam |= __VCardGetValue( szValue, pValueList, VCARD_VALUE_PARAM_NUM );
+                                               break;
+                                       case VCARD_PARAM_ENCODING:
+                                               szValue = __VCardGetParamVal( pCardRaw, &status, &dLen );
+                                               numberedParam |= __VCardGetValue( szValue, pEncList, VCARD_ENCODE_PARAM_NUM );
+                                               enc = numberedParam;
+                                               break;
+                                       case VCARD_PARAM_CHARSET:
+                                               szValue = __VCardGetParamVal( pCardRaw, &status, &dLen );
+                                               numberedParam |= __VCardGetValue( szValue, pCharsetList, VCARD_CHARSET_PARAM_NUM );
+                                               break;
+                                       case VCARD_PARAM_CONTEXT:
+                                       case VCARD_PARAM_LANGUAGE:
+                                               // prevent 7605 08.03.13
+                                               szValue = __VCardGetParamVal( pCardRaw, &status, &dLen );
+                                               numberedParam = 0;
+                                               break;
+                                       default:
+                                               szValue = __VCardGetParamVal( pCardRaw, &status, &dLen );
+
+                                               SET_PARAM_VALUE(numberedParam, szValue, pTypeList, VCARD_TYPE_PARAM_NUM, pTmpParam, VCARD_PARAM_TYPE, enc);
+                                               SET_PARAM_VALUE(numberedParam, szValue, pValueList, VCARD_VALUE_PARAM_NUM, pTmpParam, VCARD_PARAM_VALUE, enc);
+                                               SET_PARAM_VALUE(numberedParam, szValue, pEncList, VCARD_ENCODE_PARAM_NUM, pTmpParam, VCARD_PARAM_ENCODING, enc);
+                                               SET_PARAM_VALUE(numberedParam, szValue, pCharsetList, VCARD_CHARSET_PARAM_NUM, pTmpParam, VCARD_PARAM_CHARSET, enc);
+
+                                               numberedParam = 0;
+                                               pCardRaw += dLen;
+                                               dLen = 0;
+
+                                               break;
+                               }
+
+                               VDATA_TRACE("%d, %s, %p",numberedParam, szValue, pTmpParam);
+                               pTmpParam->paramValue = numberedParam;
+                               pTmpParam->pNext = NULL;
+                               VFREE(szValue);
+                               pCardRaw += dLen;
+                               break;
+                       case VCARD_TYPE_VALUE_STATUS:
+                               dLen = 0;
+                               temp = __VCardGetTypeVal( pCardRaw, &status, &dLen, enc, pVCard->pCur);
+
+                               if(valueCount <= VDATA_VALUE_COUNT_MAX) {
+                                       pVCard->pCur->pszValue[valueCount] = temp;
+                                       valueCount++;
+                                       pVCard->pCur->valueCount = valueCount;
+                               }
+                               else
+                                       VFREE(temp);
+
+                               pCardRaw += dLen;
+                               break;
+               }
+       }
+
+       VFREE(pCardRawTmp);
+
+       if(pVCard->pTop == NULL)
+               goto CATCH;
+
+       if(!vcard_ended) {
+               goto CATCH1;
+       }
+       VDATA_TRACE_END
+       return pVCard;
+
+CATCH :
+       VFREE(pTemp);
+CATCH1 :
+       VFREE(pCardRawTmp);
+       __VCardFreeVTreeMemory(pVCard);
+       VDATA_TRACE_END
+       return NULL;
+}
+
+/*
+ * vcard_encode() compares the string and vCard type, parameter value.
+ *
+ * @param       pVCardRaw            Data which will be encoded
+ * @return      char *              Encoded result
+ */
+SLPAPI char*
+vcard_encode( VTree *pVCardRaw )
+{
+       VDATA_TRACE_BEGINE
+       char*           pVCardRes = NULL;
+       VObject *       pTmpObj =  NULL;
+       char*           pTemp = NULL;
+       int                     len;
+       int                     total = 0;
+       int             cnt = 0;
+       int             lenTypeList = 0;
+
+       LENGTH_TYPE_LIST(pszCardTypeList, lenTypeList);
+
+       SysRequireEx(pVCardRaw != NULL, NULL);
+       SysRequireEx(pVCardRaw->pTop != NULL, NULL);
+       SysRequireEx(pVCardRaw->pTop->property >= 0, NULL);
+       SysRequireEx(pVCardRaw->pTop->property < lenTypeList, NULL);
+       SysRequireEx(pVCardRaw->treeType == VCARD, NULL);
+       SysRequireEx(pVCardRaw->pTop->valueCount > 0, NULL);
+
+       //VDATA_TRACE("START %d %d", pVCardRaw->pTop->property, lenTypeList);
+
+       for(;cnt < pVCardRaw->pTop->valueCount;cnt++) {
+
+               if(pVCardRaw->pTop->pszValue[cnt] == NULL)  {
+                       VDATA_TRACE("pVCardRaw->pTop->valueCount : %d",pVCardRaw->pTop->valueCount);
+                       VDATA_TRACE("pVCardRaw->pTop->pszValue[%d] : %s", cnt, pVCardRaw->pTop->pszValue[cnt]);
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+       }
+
+       if ( ( pVCardRes = ( char * )malloc( sizeof( char ) * ( total += 14 + 14 ) ) ) == NULL )
+       {
+               VDATA_TRACE(  "vcard_encode:malloc failed\n" );
+               VDATA_TRACE_END
+               return NULL;
+       }
+
+       memcpy( pVCardRes, "BEGIN:VCARD\r\n", 14 );
+       strcat( pVCardRes, "VERSION:2.1\r\n" );
+
+       pTmpObj = pVCardRaw->pTop;
+
+       while ( true )
+       {
+               if(pTmpObj == NULL)
+                       break;
+
+               if ( ( pTemp = __VCardTypeEncode( pTmpObj, pszCardTypeList[pTmpObj->property] ) ) != NULL )
+               {
+                       len = strlen( pTemp );
+
+                       if ( ( pVCardRes = ( char* )realloc( pVCardRes, ( total += len+10 ) ) ) == NULL )
+                       {
+                               VDATA_TRACE(  "vcard_encode():realloc failed\n");
+                               VFREE( pTemp );
+                               pTemp = NULL;
+                               VDATA_TRACE_END
+                               return NULL;
+                       }
+
+                       if( strncmp(pTemp,"VERSION", strlen("VERSION")) != 0)
+                               strncat(pVCardRes, pTemp, strlen(pTemp));
+
+                       VDATA_TRACE("pTemp : %s", pTemp);
+
+                       VFREE( pTemp );
+                       pTemp = NULL;
+               }
+
+               if ( pTmpObj->pSibling != NULL )
+                       pTmpObj = pTmpObj->pSibling;
+               else
+                       break;
+       }
+
+       if ( ( pVCardRes = ( char * )realloc( pVCardRes, ( total += 12 ) ) ) == NULL )
+       {
+               VDATA_TRACE(  "vcard_encode:realloc failed\n");
+               VDATA_TRACE_END
+               return NULL;
+       }
+       strcat( pVCardRes, "END:VCARD\r\n" );
+       VDATA_TRACE_END
+       return pVCardRes;
+}
+
+
+/*
+ * VIsVcardFile() verify VCard file.
+ *
+ * @param       pVCardRaw           Data which will be encoded
+ * @return      int                 result (true or false)
+ */
+int
+__VIsVcardFile(char *pCardRaw, int mode)
+{
+       int i=0;
+       bool rtnValue = true;
+       char *pszVcardBegin = "BEGIN:VCARD";
+
+       switch(mode)
+       {
+               case CHECK_START :
+                       for(i=0; i < 11; i++)
+               if(*pszVcardBegin++ != *pCardRaw++)
+                                       rtnValue = false;
+                       break;
+
+               default :
+                       rtnValue = false;
+       }
+       VDATA_TRACE_END
+       return rtnValue;
+}
+
+
+/*
+ * vCardTypeEncoder() compares the string and vCard type, parameter value.
+ *
+ * @param              typeObj                         Data which will be encoded
+ * @param              type                            Name of the type
+ * @return      char *              Encoded result
+ */
+char*
+__VCardTypeEncode( VObject *pTypeObj, char *pType )
+{
+       VDATA_TRACE_BEGINE
+       int                     len;
+       char*           pTemp = NULL;
+       char*           szTypeValue = NULL;
+       int                     i;
+       int                     enc = 0;
+       char*           pEncode = NULL;
+       char*           pRes = NULL;
+       int                     total = 0;
+       int                     biLen = 0;
+
+       len = strlen( pType );
+       biLen = pTypeObj->numOfBiData;
+
+#ifdef VDATA_GROUPNAME_SUPPORTED
+       if ( pTypeObj->pszGroupName != NULL )
+       {
+               len += strlen( pTypeObj->pszGroupName ) + 1;
+       }
+#endif // VDATA_GROUPNAME_SUPPORTED
+       if ( ( szTypeValue = ( char * )malloc( total += ( len+1 ) ) ) == NULL )
+       {
+               VDATA_TRACE(  "__VCardTypeEncode():malloc failed\n");
+               VDATA_TRACE_END
+               return NULL;
+       }
+       memset( szTypeValue, '\0', ( len+1 ) );
+#ifdef VDATA_GROUPNAME_SUPPORTED
+       if ( pTypeObj->pszGroupName != NULL )
+       {
+               strcat( szTypeValue, pTypeObj->pszGroupName );
+               strcat( szTypeValue, "." );
+       }
+#endif // VDATA_GROUPNAME_SUPPORTED
+       strcat( szTypeValue, pType );
+
+       pTemp = __VCardParamEncode( pTypeObj, &enc );
+       if ( pTemp != NULL )
+       {
+               len = strlen( pTemp );
+               if ( ( szTypeValue = ( char * )realloc( szTypeValue, ( total += len ) ) ) == NULL )
+               {
+                       VDATA_TRACE(  "__VCardTypeEncode():realloc failed\n");
+                       VFREE( pTemp );
+                       pTemp = NULL
+                       VDATA_TRACE_END;
+                       return NULL;
+               }
+               strcat( szTypeValue, pTemp );
+               VFREE( pTemp );
+               pTemp = NULL;
+       }
+
+       if ( ( szTypeValue = ( char * )realloc( szTypeValue, ( total += 2 ) ) ) == NULL )
+       {
+               VDATA_TRACE_END
+               return NULL;
+       }
+
+       strcat( szTypeValue, ":" );
+
+       len = 0;
+
+       if(strcmp(pType, pszCardTypeList[19]) != 0)     {
+               for ( i = 0; i < pTypeObj->valueCount; i++ ) {
+
+                       if(pTypeObj->pszValue[i] != NULL)
+                       len += strlen( pTypeObj->pszValue[i] );
+               }
+       }
+       else {
+               len += biLen;
+       }
+
+       for ( i = 0; i < pTypeObj->valueCount; i++ ) {
+
+               if ( i == 0 ) {
+                       if ( ( pEncode = ( char * )malloc( len+20 ) ) == NULL ) {
+                               VFREE(szTypeValue);
+                               VDATA_TRACE_END
+                               return NULL;
+                       }
+
+                       memset( pEncode, '\0', len+20 );
+
+                       if(strcmp(pType, pszCardTypeList[19]) != 0)     {
+                               strcat( pEncode, pTypeObj->pszValue[i] );
+                               _VEscape(pEncode);
+                       }
+                       else
+                               memcpy(pEncode, pTypeObj->pszValue[i], biLen);
+                       }
+               else {
+                       char    buf[1000];
+                       strncpy( buf, pTypeObj->pszValue[i], 999 );
+                       _VEscape( buf );
+                       strcat( pEncode, ";" );
+                       strcat( pEncode, buf );
+               }
+       }
+
+       if(strcmp(pType, pszCardTypeList[19]) != 0)     {
+               if (pEncode) {
+                       strcat( pEncode, "\0\0" );
+                       len = strlen( pEncode );
+               }
+       }
+       else {
+               len = biLen;
+       }
+
+       if ( enc & pEncList[2].flag ) {
+               if((pRes = (char *)malloc(len * 6 + 10)) == NULL) {
+                       VFREE(pEncode);
+                       VFREE(szTypeValue);
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+               _VQPEncode( pRes, pEncode );
+               VFREE(pEncode);
+                       }
+       else if(enc & pEncList[1].flag ) {
+               if((pRes = (char *)malloc((len * 8 / 6) + 4)) == NULL){
+                       VFREE(pEncode);
+                       VFREE(szTypeValue);
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+
+               memset( pRes, '\0', ( ( len * 8 / 6 ) + 4 ) );
+               _VB64Encode( pRes, pEncode, biLen );
+               VFREE(pEncode);
+                       }
+       else {
+               if((pRes = (char *)malloc(len+30)) == NULL) {
+                       VFREE(pEncode);
+                       VFREE(szTypeValue);
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+               memset( pRes, '\0', ( len + 30 ) );
+               memcpy( pRes, pEncode, len );
+               VFREE(pEncode);
+       }
+
+       if((pRes = (char *)realloc(pRes, strlen(pRes) + 3)) == NULL)
+       {
+               VFREE(pEncode);
+               VFREE(szTypeValue);
+               VDATA_TRACE_END
+               return NULL;
+       }
+       strncat( pRes, "\r\n", strlen(pRes) + 2);
+
+       len = strlen( pRes );
+
+       if ((szTypeValue = (char *)realloc(szTypeValue, (total += (len+3)))) == NULL) {
+               VFREE(pEncode);
+               VFREE(pRes);
+               VDATA_TRACE_END
+               return NULL;
+       }
+
+       strncat(szTypeValue, pRes, total - 1);
+
+       if(strcmp(pType, pszCardTypeList[19]) != 0) {
+               _VRLSpace( szTypeValue );
+               _VRTSpace( szTypeValue );
+       }
+
+       VFREE(pRes);
+       VDATA_TRACE_END
+       return szTypeValue;
+}
+
+/**
+ * __VCardParamEncode() Parameter Encoding.
+ *
+ * @param              pTypeObj                Data which will be encoded
+ * @param              pEnc                            Name of the type
+ */
+char *
+__VCardParamEncode(VObject* pTypeObj, int* pEnc)
+{
+       VDATA_TRACE_BEGINE
+       int i = 0;
+       int len = 0;
+       int sNum = 0;
+       int shift = 0;
+       bool bSupported;
+       char* szParam = NULL;
+       VParam* pTemp = NULL;
+       ValueObj*       pList = NULL;
+
+       /** Paramter initialize. */
+       pTemp = pTypeObj->pParam;
+
+       /** Momory Allocation for parameter string. */
+       if(pTemp != NULL) {
+               if ((szParam = (char*)malloc(len+=2)) == NULL)
+               {
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+               memset(szParam, 0x00, 2);
+       }
+
+       /** appending pamaters. */
+       while(true) {
+
+               if(pTemp == NULL) break;
+
+               bSupported = false;
+
+               /** Expand szParam string. For appending.*/
+               if((szParam = (char *)realloc(szParam, len += 15)) == NULL)
+               {
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+
+               /** appending paramter name. */
+               strcat( szParam, ";" );
+               if(pTemp->parameter != VCARD_PARAM_TYPE) {
+                       strcat( szParam, pszCardParamList[pTemp->parameter] );
+                       strcat( szParam, "=" );
+               }
+
+               /** Set Parameter Value name. */
+               switch ( pTemp->parameter )
+               {
+                       case VCARD_PARAM_ENCODING:
+                               *pEnc = pTemp->paramValue;
+                               shift = VCARD_ENCODE_PARAM_NUM;
+                               pList = pEncList; bSupported = true;
+                               break;
+                       case VCARD_PARAM_TYPE:
+                               shift = VCARD_TYPE_PARAM_NUM;
+                               pList = pTypeList; bSupported = true;
+                               break;
+                       case VCARD_PARAM_VALUE:
+                               shift = VCARD_VALUE_PARAM_NUM;
+                               pList = pValueList; bSupported = true;
+                               break;
+                       case VCARD_PARAM_CHARSET:
+                               shift = VCARD_CHARSET_PARAM_NUM;
+                               pList = pCharsetList; bSupported = true;
+                               break;
+                       default:
+                               if ( ( szParam = ( char* )realloc( szParam, 5 ) ) == NULL )
+                               {
+                                       VDATA_TRACE_END
+                                       return NULL;
+                               }
+                               strcat( szParam, "NONE" );
+               }
+
+               /** exchage parameter value's to string.*/
+               if(bSupported == true) {
+
+                       for(i = 0, sNum = 0x00000001; i < shift; i++) {
+
+                               if(pTemp->paramValue & sNum) {
+                                       if((szParam = (char *)realloc(szParam, ( len += (strlen(pList[i].szName) + 2)))) == NULL)
+                                       {
+                                               VDATA_TRACE_END
+                                               return NULL;
+                                       }
+
+                                       strcat( szParam, pList[i].szName );
+                                       strcat( szParam, "; " );
+                               }
+
+                               sNum <<= 1;
+                       }
+               }
+
+               /** remove semicolon from tail. */
+               for(i = strlen( szParam ); i > 0 ; i--) {
+
+                       if ( szParam[i] == ' ' && szParam[i-1] == ';' ) {
+                               szParam[i-1] = '\0';
+                               break;
+                       }
+               }
+
+               if ( pTemp->pNext != NULL )
+                       pTemp = pTemp->pNext;
+               else
+                       break;
+       }
+       VDATA_TRACE_END
+       return szParam;
+}
+
+SLPAPI bool
+vcard_free_vtree_memory(VTree * pTree)
+{
+       VDATA_TRACE_BEGINE
+       if(pTree == NULL)
+       {
+               VDATA_TRACE_END
+               return false;
+       }
+       VDATA_TRACE_END
+       return __VCardFreeVTreeMemory(pTree);
+}
+
diff --git a/vobject-engine/VCardCalUtil.c b/vobject-engine/VCardCalUtil.c
new file mode 100755 (executable)
index 0000000..e56c69c
--- /dev/null
@@ -0,0 +1,1233 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 "VTypes.h"
+#include "vobject.h"
+
+#define VCARD_TYPE_NUM 34
+#define VCAL_TYPE_NUM  66
+#define VMSG_TYPE_NUM 12
+extern char *pszCardTypeList[];
+
+/* BASE64 TABLE */
+char Base64Table[65] = {                                                                                                       'A',
+       'B',    'C',    'D',    'E',    'F',    'G',    'H',    'I',    'J',    'K',
+       'L',    'M',    'N',    'O',    'P',    'Q',    'R',    'S',    'T',    'U',
+       'V',    'W',    'X',    'Y',    'Z',    'a',    'b',    'c',    'd',    'e',
+       'f',    'g',    'h',    'i',    'j',    'k',    'l',    'm',    'n',    'o',
+       'p',    'q',    'r',    's',    't',    'u',    'v',    'w',    'x',    'y',
+       'z',    '0',    '1',    '2',    '3',    '4',    '5',    '6',    '7',    '8',
+       '9',    '+',    '/',    '='
+};
+
+/* Function Declaration */
+int            __VFindBase64( char );
+int            __VBase64Check( char * );
+int            __VRepChar2Space( char *, char );
+char   __VHexaDecoder( char * );
+void   __VHexaEncoder( char * );
+int            __VIsPrintable( char );
+
+
+/**
+ * vCardIsSpace() returns one if char is either a space, tab, or newline.
+ *
+ * @param      s1                [in] pointer to first string.
+ * @param      s2                [in] pointer to second string.
+ * @return     1                 'in' is a space character.
+ * @return     0                 'in' is not a space.
+ */
+int
+_VIsSpace( char in )
+{
+    if ( ( in == TAB ) || ( in == WSP ) )
+       {
+               return 1;
+    }
+       else
+       {
+               return 0;
+    }
+}
+
+
+/*
+ * vRemLeadSpace() removes leading space in string 'in'.
+ *
+ * @param      in                 [inout] pointer to string.
+ * @return     0                  if success.
+ */
+int
+_VRLSpace( char *in )
+{
+    int                        i, j;
+    short int  done;
+
+    i = 0;
+    done = 0;
+
+    while ( !done && in[i] )
+       {
+               if ( _VIsSpace( in[i] ) )
+               {
+                       i++;
+               }
+               else
+               {
+                       done = 1;
+               }
+    }
+
+    j = 0;
+    while ( in[i] )
+       {
+               in[j++] = in[i++];
+    }
+
+    in[j] = '\0';
+
+    return 0;
+}
+
+
+/*
+ * vRemTermSpace() removes terminating space.
+ *
+ * @param      in                 [inout] pointer to string.
+ * @return     0                  if success.
+ */
+int
+_VRTSpace( char *in )
+{
+    int                        i;
+    short int  done;
+
+    i = strlen(in) - 1;
+    done = 0;
+
+    while ( !done && !( i < 0 ) )
+       {
+               if ( _VIsSpace( in[i] ) )
+               {
+                       in[i--] = '\0';
+               }
+               else
+               {
+                       done = 1;
+               }
+    }
+
+    return(0);
+}
+
+
+/*
+ * VUnescape() unescapes escaped character.
+ *
+ * @param      in                 [inout] pointer to string.
+ * @return     0                  if success.
+ */
+int
+_VUnescape( char *in )
+{
+    int                        i;
+    int                        index;
+       int                     len;
+       char c1;
+       char c2;
+
+    len = strlen(in);
+
+    for ( i = 0, index = 0; i < len; i++ )
+       {
+               c1 = in[i];
+
+               if ( c1 == '\\' )
+               {
+                       c2 = in[i+1];
+                       if ( c2 == ';' ) continue;
+               }
+               in[index++] = c1;
+       }
+
+       in[index] = '\0';
+
+    return(0);
+}
+
+/*
+ * VEscape() escapes character.
+ *
+ * @param      in                 [inout] pointer to string.
+ * @return     0                  if success.
+ */
+int
+_VEscape( char *in )
+{
+    int                        i;
+    int                        index;
+       int                     len;
+       char *buf = NULL;
+       char            c;
+
+    len = strlen(in);
+       buf = (char*) calloc(1, len*2+1);
+
+    for ( i = 0, index = 0; i < len; i++ ){
+               c = in[i];
+               if ( c == ';' ) {
+                       buf[index++] = '\\';
+               }
+               buf[index++] = c;
+       }
+
+       strncpy( in, buf, len*2+1 );
+       free(buf);
+
+    return(0);
+}
+
+
+
+/*
+ * vManySpace2Space() converts multiple spaces to single space in 'in'.
+ *
+ * @param      in                 [inout] pointer to string.
+ * @return     int                length of converted string.
+ */
+int
+_VManySpace2Space( char *in )
+{
+    int                i, j;
+    int                spaced = 0;
+
+    j = 0;
+    for ( i = 0; in[i]; i++ )
+       {
+               if ( _VIsSpace( in[i] ) )
+               {
+                       if ( !spaced )
+                       {
+                               in[j] = WSP;
+                               spaced = 1;
+                               j++;
+                       }
+               }
+               else
+               {
+                       spaced = 0;
+                       in[j] = in[i];
+                       j++;
+               }
+    }
+
+
+    in[j] = '\0';
+
+    return j;
+}
+
+
+/**
+ * vFindBase64() returns the integer repesentation of the location in base64 table.
+ *
+ * @param      in                a character
+ * @return     int               The base64 table location of input character
+ */
+int
+__VFindBase64( char in )
+{
+    int                i;
+
+    for ( i = 0; i < 65; i++ )
+       {
+               if ( Base64Table[i] == in )
+                       return i;
+    }
+    return -1;
+}
+
+
+
+/**
+ * vBase64Check() returns the total length of input except non-base64 value.
+ *
+ * @param      in               char values which are base64 or non-base64
+ * @return     int              the total length of input except non-base64
+ */
+int
+__VBase64Check( char *in )
+{
+       int             i = 0, j = 0;
+       int             base;
+
+       while ( in[i] )
+       {
+               base = __VFindBase64( in[i] );
+               if ( base < 0 )
+               {
+                       i++;
+               }
+               else
+               {
+                       in[j] = in[i];
+                       j++; i++;
+               }
+       }
+
+       in[j] = '\0';
+
+       return j;
+}
+
+/**
+ * vBase64Decoder() decodes the base64 encoded input.
+ *
+ * @param      Src                Base64 encoded input
+ * @param      Dest               The destination buffer of decoded value
+ * @return     int                The total length decoded value
+ */
+int
+_VB64Decode( char *Dest, char *Src )
+{
+       char*           Encoded = Src;
+       int                     i, j = 0;
+       int                     res;
+       char            Base = 0;
+       char            DecodeTemp;
+       char            Debuffer[4] = {0x00, 0x00, 0x00, '\0'};
+       int                     index = 0;
+       int                     len;
+
+       len = __VBase64Check( Src );
+
+       while ( *Encoded )
+       {
+               for ( i = 0; i < 3; i++ )
+                       Debuffer[i] = 0x00;
+
+               for ( i = 0; i < 4; i++, Encoded++, j++ )
+               {
+                       if(*Encoded == 0x00) break;
+                       if((res = __VFindBase64(*Encoded)) < 0) continue;
+
+                       Base = ( char )res;
+                       DecodeTemp = 0x00;
+
+                       if(Base == 64)  {
+                               Encoded++;
+                               break;
+                       }
+
+                       switch ( i )
+                       {
+                       case 0:
+                               DecodeTemp = Base << 2;
+                               Debuffer[0] |= DecodeTemp;
+                               break;
+                       case 1:
+                               DecodeTemp = Base >> 4;
+                               Debuffer[0] |= DecodeTemp;
+                               DecodeTemp = Base << 4;
+                               Debuffer[1] |= DecodeTemp;
+                               break;
+                       case 2:
+                               DecodeTemp = Base >> 2;
+                               Debuffer[1] |= DecodeTemp;
+                               DecodeTemp = Base << 6;
+                               Debuffer[2] |= DecodeTemp;
+                               break;
+                       case 3:
+                               DecodeTemp = Base;
+                               Debuffer[2] |= DecodeTemp;
+                               break;
+                       }
+               }
+
+               if ( Base == 64 )
+               {
+                       switch ( i )
+                       {
+                       case 0: break;
+                       case 1:
+                       case 2:
+                               Dest[index] = Debuffer[0];
+                               index++;
+                               break;
+                       case 3:
+                               Dest[index++] = Debuffer[0];
+                               Dest[index++] = Debuffer[1];
+                               break;
+                       }
+               }
+               else
+               {
+                       Dest[index++] = Debuffer[0];
+                       Dest[index++] = Debuffer[1];
+                       Dest[index++] = Debuffer[2];
+               }
+       }
+
+       return index;
+}
+
+
+/**
+ * vBase64Encoder() encode the input to base64.
+ *
+ * @param      Src                non-base64 char input
+ * @param      Dest               The destination buffer of encoded value
+ * @return     0
+ */
+int
+_VB64Encode( char *Dest, char *Src, int len )
+{
+       char*   Encoded = Dest;
+       char*   Decoded = Src;
+       int             i, j;
+       int             index;
+       int             res = 0;
+       int             base1 = 0, base2 = 0;
+       char    Enbuffer[4];
+       char    Debuffer[3];
+       int             length = 0;
+
+       for ( i = 0; i < 4; i++ )
+               Enbuffer[i] = 0x00;
+
+       for ( i = 0; i < len; i++ )
+       {
+               res = i%3;
+
+               switch ( res )
+               {
+               case 0:
+                       Debuffer[0] = *Decoded;
+                       break;
+               case 1:
+                       Debuffer[1] = *Decoded;
+                       break;
+               case 2:
+                       Debuffer[2] = *Decoded;
+                       index = ( int )( ( Debuffer[0] & 0xFC ) >> 2 );
+                       Enbuffer[0] = Base64Table[index];
+                       base1 = ( int )( ( Debuffer[0] & 0x03 ) << 4 );
+                       base2 = ( int )( ( Debuffer[1] & 0xF0 ) >> 4 );
+                       index = ( int )( base1 | base2 );
+                       Enbuffer[1] = Base64Table[index];
+                       base1 = ( int )( ( Debuffer[1] & 0x0F ) << 2 );
+                       base2 = ( int )( ( Debuffer[2] & 0xC0 ) >> 6 );
+                       index = ( int )( base1 | base2 );
+                       Enbuffer[2] = Base64Table[index];
+                       index = ( int )( Debuffer[2] & 0x3F );
+                       Enbuffer[3] = Base64Table[index];
+
+                       Encoded[length++] = Enbuffer[0];
+                       Encoded[length++] = Enbuffer[1];
+                       Encoded[length++] = Enbuffer[2];
+                       Encoded[length++] = Enbuffer[3];
+
+                       for ( j = 0; j < 3; j++ )
+                               Debuffer[j] = 0x00;
+
+                       break;
+               }
+
+               Decoded++;
+       }
+
+       res = i % 3;
+
+       switch ( res )
+       {
+       case 0:
+               break;
+       case 1:
+               index = ( int )( ( Debuffer[0] & 0xFC ) >> 2 );
+               Enbuffer[0] = Base64Table[index];
+               base1 = ( int )( ( Debuffer[0] & 0x03 ) << 4 );
+               base2 = ( int )( ( Debuffer[1] & 0xF0 ) >> 4 );
+               index = ( int )( base1 | base2 );
+               Enbuffer[1] = Base64Table[index];
+               Enbuffer[2] = Base64Table[64];
+               Enbuffer[3] = Base64Table[64];
+
+               Encoded[length++] = Enbuffer[0];
+               Encoded[length++] = Enbuffer[1];
+               Encoded[length++] = Enbuffer[2];
+               Encoded[length++] = Enbuffer[3];
+
+               break;
+       case 2:
+               index = ( int )( ( Debuffer[0] & 0xFC ) >> 2 );
+               Enbuffer[0] = Base64Table[index];
+               base1 = ( int )( ( Debuffer[0] & 0x03 ) << 4 );
+               base2 = ( int )( ( Debuffer[1] & 0xF0 ) >> 4 );
+               index = ( int )( base1 | base2 );
+               Enbuffer[1] = Base64Table[index];
+               base1 = ( int )( ( Debuffer[1] & 0x0F ) << 2 );
+               base2 = ( int )( ( Debuffer[2] & 0xC0 ) >> 6 );
+               index = ( int )( base1 | base2 );
+               Enbuffer[2] = Base64Table[index];
+               Enbuffer[3] = Base64Table[64];
+
+               Encoded[length++] = Enbuffer[0];
+               Encoded[length++] = Enbuffer[1];
+               Encoded[length++] = Enbuffer[2];
+               Encoded[length++] = Enbuffer[3];
+
+               break;
+       }
+
+       Encoded[length] = '\0';
+
+       return 0;
+}
+
+
+
+int
+__VRepChar2Space( char *vRaw, char replaced )
+{
+       int length = 0;
+
+       while ( *vRaw )
+       {
+               if ( *vRaw == replaced )
+                       *vRaw = WSP;
+
+               vRaw++;
+               length++;
+       }
+
+       return length;
+}
+
+
+/**
+ * vUnfolding() unfold the folded line.
+ *
+ * @param      string             The folded line input
+ * @return     int                Total length of unfolded output
+ */
+int
+_VUnfolding( char *string )
+{
+       unsigned int i, j;
+       unsigned int len;
+
+       len = strlen( string );
+
+       for ( i = 0, j = 0; i < len; i++, j++ )
+       {
+               string[j] = string[i];
+
+               // 12.03.2004 Process garbage character at the end of vcard/vcal
+               if ( _VIsSpace( string[i] ) &&  ( i < len-5 ) )
+               {
+                       if ( string[i-1] == LF || string[i-1] == CR )
+                       {
+                               if (j < 2)
+                                       j = 0;
+                               else
+                                       j -= 2;
+
+                               string[i-1] = 0;
+                       }
+                       if ( string[i-2] == LF || string[i-2] == CR )
+                       {
+                               if (j < 1)
+                                       j = 0;
+                               else
+                                       j -= 1;
+
+                               string[i-2] = 0;
+                       }
+               }
+       }
+
+       string[j] = '\0';
+
+       return j;
+}
+
+
+int
+__VIsNewType( char *pCardRaw )
+{
+       int count=0, i = 0, low=0, high=0, diff=0;
+       char strTypeName[50]={0};
+
+       while(1)
+       {
+               if(*pCardRaw == CR || *pCardRaw == LF)
+                       pCardRaw++;
+               else
+               {
+                       if(*pCardRaw == ';' || *pCardRaw == ':' || count >= 50)
+                       {
+                               break;
+                       }
+                       else
+                               strTypeName[count++] = *pCardRaw++;
+               }
+
+       }
+
+
+    for ( low = 0, high = VCARD_TYPE_NUM - 1; high >= low; diff < 0 ? ( low = i+1 ) : ( high = i-1 ) )
+       {
+               i = ( low + high ) / 2;
+               diff = strcmp( pszCardTypeList[i], strTypeName );
+               if ( diff == 0 )        /* success: found it */
+                       return true;
+    }
+
+
+
+    return false;
+       //res = __VCardGetName( strTypeName, (char**)pszCardTypeList, VCARD_TYPE_NUM );
+}
+
+
+int
+__VIsNewTypeforOrg( char *pCardRaw, int vType )
+{
+       int count=0, i = 0, low=0, high=0, diff=0,vTypeNum;
+       char strTypeName[50]={0};
+       extern char* pszCardTypeList[];
+       extern char* pszMsgTypeList[];
+
+       while(1)
+       {
+               if(*pCardRaw == CR || *pCardRaw == LF)
+                       pCardRaw++;
+               else
+               {
+                       if(*pCardRaw == ';' || *pCardRaw == ':' || count >= 50)
+                       {
+                               break;
+                       }
+                       else
+                               strTypeName[count++] = *pCardRaw++;
+               }
+       }
+
+       if(vType == VCARD)
+               vTypeNum = VCARD_TYPE_NUM;
+       else if(vType == VMESSAGE)
+               vTypeNum = VMSG_TYPE_NUM;
+       else
+                return false;
+
+       for ( low = 0, high = vTypeNum - 1; high >= low; diff < 0 ? ( low = i+1 ) : ( high = i-1 ) )
+       {
+               i = ( low + high ) / 2;
+
+               if(vType == VCARD)
+                       diff = strcmp( pszCardTypeList[i], strTypeName );
+               else if(vType == VMESSAGE)
+                       diff = strcmp( pszMsgTypeList[i], strTypeName );
+
+               if ( diff == 0 )        /* success: found it */
+                       return true;
+               else if( !strncmp( strTypeName, "X-", 2 ))
+                       return true;
+       }
+
+       //if(count <= 50) return TRUE;
+
+    return false;
+
+       //res = __VCardGetName( strTypeName, (char**)pszCardTypeList, VCARD_TYPE_NUM );
+}
+
+char*
+_VUnfoldingNoSpecNew(char *string)
+{
+       unsigned int i, j;
+       unsigned int len;
+
+       char* newString;
+
+       len = strlen( string );
+
+       if( !(newString = (char*) malloc(len+1) )) {
+               return NULL;
+       }
+
+
+       for ( i = 0, j = 0; i < len; i++, j++ ) {
+
+               newString[j] = string[i];
+
+               if( i < len-5 ) {
+
+                       if ( string[i] == '=' ) {
+
+                               if(string[i+1] == CR && string[i+2] == LF) {
+
+                                       if(__VIsNewType(string) == false){
+                                               j -= 2;
+                                       i += 2;
+                               }
+                               }
+                               else if(string[i+1] == CR || string[i+1] == LF) {
+                                       if(__VIsNewType(string) == false){
+                                       j -= 1;
+                                       i += 1;
+                               }
+                       }
+                       }
+                       else if(string[i] == ' ') {
+
+                               if(string[i-2] == CR && string[i-1] == LF) {
+                                       if(__VIsNewType(string) == false)
+                                       j -= 3;
+                                       else
+                                               j -= 1;
+                               }
+                               else if(string[i-1] == CR || string[i-1] == LF) {
+                                       j -= 2;
+                               }
+                       }
+
+                       else if((string[i] == CR || string[i] == LF) && __VIsNewType(string) == false) {
+
+                               if(string[i+1] == LF) {
+                                       j -= 1;
+                                       i += 1;
+                               }
+                       }
+               }
+       }
+
+       newString[j] = '\0';
+
+       return newString;
+}
+
+/**
+ * vUnfolding() unfold the folded line.
+ *
+ * @param      string             The folded line input
+ * @return     int                Total length of unfolded output
+ */
+int
+_VUnfoldingNoSpec( char *string, int vType )
+{
+       unsigned int i, j;
+       unsigned int len;
+
+       len = strlen( string );
+
+       for ( i = 0, j = 0; i < len; i++, j++ )
+       {
+               string[j] = string[i];
+
+               if ( ( i < len-5 ) )
+               {
+                       if ( string[i] == '=' )
+                       {
+                               if(string[i+1] == CR && string[i+2] == LF && string[i+3] =='=' )
+                               {
+                                       string[i] = 0;
+                                       string[i+1] = 0;
+                                       string[i+2] = 0;
+                                       if (j > 0)
+                                                j -= 1;
+                                       i += 2;
+                               }
+                               else if(string[i+1] == CR && string[i+2] == LF &&  __VIsNewTypeforOrg(&string[i+3], vType) == false)
+                               {
+                                       string[i] = 0;
+                                       string[i+1] = 0;
+                                       string[i+2] = 0;
+                                       if (j > 0)
+                                               j -= 1;
+                                       i += 2;
+                               }
+                       }
+                       else if(string[i] ==WSP
+                               ||string[i]==TAB)
+                       {
+                               if(string[i-2] == CR && string[i-1] == LF)
+                               {
+                                       string[i] = 0;
+                                       string[i-1] = 0;
+                                       string[i-2] = 0;
+                                       if (j >= 3)
+                                               j -= 3;
+                                       else
+                                               j = 0;
+                               }
+                               else if(string[i-1] == CR || string[i-1] == LF)
+                               {
+                                       string[i] = 0;
+                                       string[i-1] = 0;
+
+                                       if (j >=2)
+                                               j -= 2;
+                                       else
+                                               j = 0;
+                               }
+                       }
+
+               }
+       }
+
+       string[j] = '\0';
+
+       return j;
+}
+
+/**
+ * vFolding() decodes the base64 encoded input.
+ *
+ * @param      contentline        Original line (unfolded)
+ * @param      Dest               The destination buffer of folded result
+ */
+void
+_VFolding( char *result, char *contentline )
+{
+       int             i = 0;
+
+       while ( *contentline )
+       {
+               if ( i == 75 )
+               {
+                       i = 0;
+                       *result++ = '\r';
+                       *result++ = '\n';
+                       *result++ = ' ';
+               }
+
+               *result++ = *contentline++;
+               i++;
+       }
+
+       *result++ = '\0';
+}
+
+
+/**
+ * vFolding() decodes the base64 encoded input.
+ *
+ * @param      contentline        Original line (unfolded)
+ * @param      Dest               The destination buffer of folded result
+ */
+void
+_VFoldingQP( char *result, char *contentline )
+{
+       int             i = 0;
+
+       while ( *contentline )
+       {
+               if ( i == 74 )
+               {
+                       i = 0;
+                       *result++= '=';
+                       *result++ = '\r';
+                       *result++ = '\n';
+               }
+
+               *result++ = *contentline++;
+               i++;
+       }
+
+       *result++ = '\0';
+}
+
+
+/**
+ * vFolding() decodes the base64 encoded input.
+ *
+ * @param      contentline        Original line (unfolded)
+ * @param      Dest               The destination buffer of folded result
+ */
+void
+_VFoldingNoSpace( char *result, char *contentline )
+{
+       int             i = 0;
+
+       while ( *contentline )
+       {
+               if ( i == 75 )
+               {
+                       i = 0;
+                       *result++ = '\r';
+                       *result++ = '\n';
+               }
+
+               *result++ = *contentline++;
+               i++;
+       }
+
+       *result++ = '\0';
+}
+
+
+/**
+ * vQuotedPrintalbeDecoder() decodes the quoted-printable encoded input.
+ *
+ * @param      Src                Quoted-printable encoded input
+ * @return     int                The total length decoded value
+ */
+int
+_VQPDecode( char *src )
+{
+       int             i = 0, j = 0;
+       char    qp[2];
+       char    decodedNum;
+
+       while ( src[i] )
+       {
+               if ( src[i] == '=' )
+               {
+                       if ( !( _VIsSpace( src[i + 1] ) || ( src[i + 1] == '\r' ) || ( src[i+1] == '\n' ) ) )
+                       {
+                               if ( src[i + 1] == '0' && ( src[i + 2] == 'D' || src[i +2] == 'd' ) && src[i + 3] == '='
+                                       && src[i + 4] == '0' && ( src[i + 5] == 'A' || src[i + 5] == 'a' ) )
+                               {
+                                       src[j] = '\n';
+                                       j++;
+                                       i += 6;
+                               }
+                               else
+                               {
+                                       qp[0] = src[i + 1];
+                                       qp[1] = src[i + 2];
+                                       decodedNum = __VHexaDecoder( qp );
+                                       src[j] = decodedNum;
+                                       i += 3; j++;
+                               }
+                       }
+                       else
+                       {
+                               i += 3;
+                       }
+               }
+               else
+               {
+                       src[j] = src[i];
+                       i++; j++;
+               }
+       }
+
+       src[j] = '\0';
+
+       j =     _VManySpace2Space( src );
+
+       return j;
+}
+
+
+
+/**
+ * vQuotedPrintableEncoder() decodes the quoted-printalbe encoded input.
+ *
+ * @param      Src                Quoted-printable encoded input
+ * @param      Dest               The destination buffer of decoded value
+ * @return     int                The total length decoded value
+ */
+int
+_VQPEncode( char *dest, char *src )
+{
+       int             i = 0, j = 0, k = 0;
+       char    encoded[2] = {0x0f, 0x0f};
+
+       while ( src[i] /*&& ( src[i] > 0 )*/ )
+       {
+               if ( k == 73 && _VIsSpace( src[i] ) )
+               {
+                       if( src[i] == WSP )
+                       {
+                               dest[j++] = '='; dest[j++] = '2'; dest[j++] = '0';
+                               k += 3;
+                       }
+                       else if ( src[i] == TAB )
+                       {
+                               dest[j++] = '='; dest[j++] = '0'; dest[j++] = '9';
+                               k += 3;
+                       }
+               }
+       /*      else if ( k == 76 )
+               {
+                       dest[j++] = '='; dest[j++] = WSP;
+                       k = 0;
+               } */
+               else if ( !__VIsPrintable( src[i] ) )
+               {
+                       dest[j++] = '=';
+                       encoded[0] &= (src[i] >> 4);
+                       encoded[1] &= (src[i]);
+                       __VHexaEncoder( encoded );
+                       dest[j++] = encoded[0]; encoded[0] = 0x0f;
+                       dest[j++] = encoded[1]; encoded[1] = 0x0f;
+                       k += 3;
+               }
+               else if ( src[i] == '\r' || src[i] == '\n' )
+               {
+                       dest[j++] = '='; dest[j++] = '0'; dest[j++] = 'D'; k += 3;
+                       dest[j++] = '='; dest[j++] = '0'; dest[j++] = 'A'; k += 3;
+               }
+               else
+               {
+                       dest[j++] = src[i]; k++;
+               }
+               i++;
+       }
+
+       dest[j] = '\0';
+
+       return j;
+}
+
+
+/**
+ * vIsPrintable() check whether the input is printable.
+ *
+ * @param      in
+ * @return     true/false            if input is printable :true else : false
+ */
+int
+__VIsPrintable( char in )
+{
+       if ( in >= 33 && in <= 60 ) return true;
+       else if ( in >= 62 && in <= 126 ) return true;
+       else if ( in == WSP || in == TAB ) return true;
+       else if ( in == '\r' || in == '\n' ) return true;
+       else return false;
+}
+
+
+
+/**
+ * vHexaDecoder() output the character value of inputed hexadecimal value.
+ *
+ * @param      qp               Hexadecimal input value
+ * @return     char             Character representation of input hexadecimal value
+ */
+char
+__VHexaDecoder( char *qp )
+{
+       int             i;
+       char    decoded[2] = {0x00, 0x00};
+       char    res;
+
+       for ( i = 0; i < 2; i++ )
+       {
+               switch ( qp[i] )
+               {
+               case '0':
+                       decoded[i] = 0x00;
+                       break;
+               case '1':
+                       decoded[i] = 0x01;
+                       break;
+               case '2':
+                       decoded[i] = 0x02;
+                       break;
+               case '3':
+                       decoded[i] = 0x03;
+                       break;
+               case '4':
+                       decoded[i] = 0x04;
+                       break;
+               case '5':
+                       decoded[i] = 0x05;
+                       break;
+               case '6':
+                       decoded[i] = 0x06;
+                       break;
+               case '7':
+                       decoded[i] = 0x07;
+                       break;
+               case '8':
+                       decoded[i] = 0x08;
+                       break;
+               case '9':
+                       decoded[i] = 0x09;
+                       break;
+               case 'a':
+               case 'A':
+                       decoded[i] = 0x0a;
+                       break;
+               case 'b':
+               case 'B':
+                       decoded[i] = 0x0b;
+                       break;
+               case 'c':
+               case 'C':
+                       decoded[i] = 0x0c;
+                       break;
+               case 'd':
+               case 'D':
+                       decoded[i] = 0x0d;
+                       break;
+               case 'e':
+               case 'E':
+                       decoded[i] = 0x0e;
+                       break;
+               case 'f':
+               case 'F':
+                       decoded[i] = 0x0f;
+                       break;
+               }
+       }
+
+       res = ( char )( ( decoded[0] << 4 ) + decoded[1] );
+
+       return res;
+}
+
+
+
+/**
+ * vHexaEncoder() output the hexadecimal value of input character value.
+ *
+ * @return     qp               Character representation of input hexadecimal value
+ */
+void
+__VHexaEncoder( char *qp )
+{
+       int             i;
+
+       for ( i = 0; i < 2; i++ )
+       {
+               switch ( qp[i] )
+               {
+               case 0:
+                       qp[i] = '0';
+                       break;
+               case 1:
+                       qp[i] = '1';
+                       break;
+               case 2:
+                       qp[i] = '2';
+                       break;
+               case 3:
+                       qp[i] = '3';
+                       break;
+               case 4:
+                       qp[i] = '4';
+                       break;
+               case 5:
+                       qp[i] = '5';
+                       break;
+               case 6:
+                       qp[i] = '6';
+                       break;
+               case 7:
+                       qp[i] = '7';
+                       break;
+               case 8:
+                       qp[i] = '8';
+                       break;
+               case 9:
+                       qp[i] = '9';
+                       break;
+               case 10:
+                       qp[i] = 'A';
+                       break;
+               case 11:
+                       qp[i] = 'B';
+                       break;
+               case 12:
+                       qp[i] = 'C';
+                       break;
+               case 13:
+                       qp[i] = 'D';
+                       break;
+               case 14:
+                       qp[i] = 'E';
+                       break;
+               case 15:
+                       qp[i] = 'F';
+                       break;
+               }
+       }
+
+}
+
+/**
+ * _VIsCrLf() returns one if char is either a space, tab, or newline.
+ *
+ * @param      s1                [in] pointer to first string.
+ * @param      s2                [in] pointer to second string.
+ * @return     1                 'in' is a space character.
+ * @return     0                 'in' is not a space.
+ */
+int
+_VIsCrLf(char in)
+{
+       if ( ( in == CR ) || ( in == LF ) )
+       {
+               return 1;
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+/*
+ * vManySpace2Space() converts multiple spaces to single space in 'in'.
+ *
+ * @param      in                 [inout] pointer to string.
+ * @return     int                length of converted string.
+ */
+int
+_VManyCRLF2CRLF(char *pIn)
+{
+       int             i, j;
+       bool    bCrLf = false, bFirstCrLf = true;
+
+       j = 0;
+       for ( i = 0; pIn[i]; i++ )
+       {
+               if ( _VIsCrLf( pIn[i] ) && _VIsCrLf( pIn[i+1] ))
+               {
+                       if( bFirstCrLf && !bCrLf)
+                       {
+                               bCrLf = 1;
+                       }
+                       else if( !bFirstCrLf )
+                       {
+                               if ( !bCrLf )
+                               {
+                                       pIn[j] = CR;
+                                       pIn[++j] = LF;
+                                       bCrLf = true;
+                                       j++;
+                               }
+                       }
+                       i++;
+               }
+               else
+               {
+                       bCrLf = false;
+                       bFirstCrLf = false;
+                       pIn[j] = pIn[i];
+                       j++;
+               }
+       }
+
+       pIn[j] = '\0';
+
+       return j;
+}
diff --git a/vobject-engine/VMessage.c b/vobject-engine/VMessage.c
new file mode 100755 (executable)
index 0000000..406820b
--- /dev/null
@@ -0,0 +1,1628 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 "VTypes.h"
+#include "VMessage.h"
+#include "VCard.h"
+#include "vobject.h"
+
+#define MAX_TYPE_NAME_LEN 50
+#define MAX_PARAM_NAME_LEN 50
+#define CHECK_START 1
+#define CHECK_END 2
+
+#define VFREE(obj) if(obj != NULL) { /*VDATA_TRACE("%p",obj);*/ free(obj); \
+       obj = NULL; \
+}
+
+#define TRIM(obj) if(obj != NULL) {\
+       _VRLSpace(obj);\
+       _VRTSpace(obj);\
+}
+
+#define UPPER(obj,start,end) if(obj != NULL) {\
+       for(start = 0; start < end; start++)\
+               obj[start] = toupper(obj[start]);\
+}
+
+#define GO_NEXT_CHAR(current, rowData, addedCnt) {\
+       current = *rowData;\
+       rowData++;\
+       (*addedCnt)++;\
+}
+
+#define SET_PARAM_VALUE(PARAM, SZVALUE, LIST, LISTCNT, PARAMOBJ, PTYPE, ENC) {\
+       PARAM = 0;\
+       PARAM |= __VMsgGetValue(SZVALUE, LIST, LISTCNT);\
+       if ( PARAM != UNKNOWN_NAME ) {\
+               PARAMOBJ->parameter = PTYPE;\
+               if(PTYPE == VMSG_PARAM_ENCODING)\
+                       ENC = PARAM;\
+               break;\
+       }\
+}
+
+#define LENGTH_TYPE_LIST(obj, len) for(len =0; obj[len] != NULL; len++);
+
+extern char* _VUnfoldingNoSpecNew( char *string );
+
+/** GLOBAL VARIABLE DECLARATION AND INITIALIZATION */
+/** vMsg Types. */
+char* pszMsgTypeList[] =
+{
+       "BEGIN",
+       "END",
+       "TEL",
+       "VBODY",
+       "VCARD",
+       "VMSG",
+       "X-BODY-CONTENTS",
+       "X-BODY-SUBJECT",
+       "X-IRMC-BOX",
+       "X-IRMC-STATUS",
+       "X-MESSAGE-TYPE",
+       "X-SS-DT",
+};
+
+/** Parameter */
+char* pszMsgParamList[] =
+{
+       "CHARSET",
+       "CONTEXT",
+       "ENCODING",
+       "LANGUAGE",
+       "TYPE",
+       "VALUE"
+};
+
+/** Encoding value */
+ValueObj pMsgEncList[] =
+{
+       {"B",                   0x00000001},
+       {"BASE64",      0x00000002},
+       {"QUOTED-PRINTABLE", 0x00000004},
+       {"7BIT",                0x00000008},
+       {"8BIT",                0x00000010}
+};
+
+/** Character set value */
+ValueObj pMsgCharsetList[] =
+{
+       {"UTF-8",                       0x00000001},
+       {"UTF-16",              0x00000002},
+       {"ISO-8859-1",  0x00000004}
+};
+
+/** Value value */
+ValueObj pMsgValueList[] =
+{
+       {"BINARY",                      0x00000001},
+       {"BOOLEAN",                     0x00000002},
+       {"DATE",                                0x00000004},
+       {"DATE-TIME",           0x00000008},
+       {"FLOAT",                               0x00000010},
+       {"INTEGER",                     0x00000020},
+       {"PHONE-NUMBER",        0x00000040},
+       {"TEXT",                                0x00000080},
+       {"TIME",                                0x00000100},
+       {"URI",                                 0x00000200},
+       {"URL",                                 0x00000400},
+       {"UTC-OFFSET",          0x00000800},
+       {"VMSG",                                0x00001000}
+};
+
+/** Type value */
+ValueObj pMsgTypeList[] =
+{
+       {"AIFF",                0x00000001},
+       {"BBS",                 0x00000002},
+       {"CAR",                 0x00000004},
+       {"CELL",                0x00000008},
+       {"DOM",                 0x00000010},
+       {"WORK",                0x00000020},
+       {"FAX",                 0x00000040},
+       {"GIF",                 0x00000080},
+       {"HOME",                0x00000100},
+       {"INTL",                0x00000200},
+       {"INTERNET",    0x00000400},
+       {"ISDN",                0x00000800},
+       {"JPEG",                0x00001000},
+       {"MOBILE",      0x00002000},
+       {"MODEM",               0x00004000},
+       {"MSG",                 0x00008000},
+       {"PAGER",               0x00010000},
+       {"PARCEL",      0x00020000},
+       {"PCM",                 0x00040000},
+       {"PCS",                 0x00080000},
+       {"PNG",                 0x00100000},
+       {"POSTAL",      0x00200000},
+       {"PREF",                0x00400000},
+       {"VIDEO",               0x00800000},
+       {"VOICE",               0x01000000},
+       {"WAVE",                0x02000000},
+       {"WBMP",                0x04000000},
+       {"ETC",                 0x08000000},
+       {"X400",                0x10000000}
+};
+
+/** FUNCTION DECLARATION       */
+int __VMsgGetName(char*, char**, int);
+int __VMsgGetValue(char*, const ValueObj*, int);
+int __VMsgGetTypeName(char*, int*, int*);
+int __VMsgGetParamName(char*, int*, int*);
+int __VIsVmsgFile(char*, int);
+char* __VMsgGetParamVal(char*,int*, int*);
+char* __VMsgGetTypeVal(char*, int*, int*, int, VObject*);
+char* __VMsgTypeEncode(VObject*, char*);
+char* __VMsgParamEncode(VObject*, int*);
+
+
+/**
+ * __VMsgGetName() compares the string and vMsg type, parameter name.
+ *
+ * @param      szString        Name which will compare
+ * @param              pszList[]               Name list of vMsg type and param
+ * @param              size                            Number of total element of list
+ *
+ * @return     index           The index in the list
+ */
+int
+__VMsgGetName(char* szString, char* pszList[], int size)
+{
+       VDATA_TRACE_BEGINE
+       int high, low, i, diff = 0;
+
+       low = 0;
+       high = size - 1;
+
+       for(; high >= low; diff<0 ? (low = i+1):(high = i-1)) {
+               i = ( low + high ) / 2;
+               if((diff = strcmp( pszList[i], szString )) == 0) /* success: found it */
+                       return i;
+       }
+       VDATA_TRACE_END
+       return UNKNOWN_NAME;
+}
+
+/**
+ * __VMsgGetValue() compares the string and vMsg type, parameter value.
+ *
+ * @param      szString        Value which will compare
+ * @param              list[]          Value list of vMsg param
+ * @param              size                    Number of total element of list
+ *
+ * @return     flag      The value's flag.
+ */
+int
+__VMsgGetValue( char* szString, const ValueObj list[], int size)
+{
+       VDATA_TRACE_BEGINE
+       int i = 0, diff = -1;
+       char* szTemp = szString;
+
+       SysRequireEx(szString, UNKNOWN_NAME);
+       SysRequireEx(size > 0, UNKNOWN_NAME);
+
+       UPPER(szTemp,i,strlen(szTemp));
+
+       for(i = 0; i < size-1; i++)
+       {
+               VDATA_TRACE(" i : %d",i);
+               VDATA_TRACE(" for loop %d < %d, list[%d] : %p, list[%d].szName : %p",i,size,i,list[i],i,list[i].szName);
+               VDATA_TRACE(" i : %d",i);
+               if(list[i].szName != NULL)
+               {
+                       VDATA_TRACE(" list[%d].szName != NULL",i);
+                       VDATA_TRACE(" before strcmp %s %s",list[i].szName,szTemp);
+                       VDATA_TRACE(" before strcmp %d",strcmp(list[i].szName, szTemp));
+                       if((diff = strcmp(list[i].szName, szTemp)) == 0) /* success: found it */
+                       {
+                               VDATA_TRACE(" return %d",list[i].flag);
+                               VDATA_TRACE_END
+                               return list[i].flag;
+                       }
+                       VDATA_TRACE(" after strcmp %s %s",list[i].szName,szTemp);
+               }
+       }
+       VDATA_TRACE(" return UNKNOWN_NAME");
+       VDATA_TRACE_END
+       return UNKNOWN_NAME;
+}
+
+/**
+ * __VMsgGetTypeName() fine the type name and returns the index number
+ *
+ * @param              pVMsgRaw        The raw data
+ * @param              pStatus         Decoder status
+ * @param              pDLen           retrived length
+ *
+ * @return     res                     The index in type list
+ */
+int
+__VMsgGetTypeName(char* pVMsgRaw, int* pStatus, int* pDLen)
+{
+       VDATA_TRACE_BEGINE
+       int     i, index, res;
+       char    c;
+       char    name[MAX_TYPE_NAME_LEN+1]={0,};
+
+       SysRequireEx(pVMsgRaw, UNKNOWN_NAME);
+
+       i = index = 0;
+       res = UNKNOWN_NAME;
+
+       while(true) {
+
+               GO_NEXT_CHAR(c, pVMsgRaw, pDLen);
+
+               /**
+                * TYPE NAME's length is must be less than MAX_TYPE_NAME_LEN.
+                * If TYPE NAME's value is over MAX_TYPE_NAME_LEN, return UNKNOWN_NAME.
+                * And then Decoding Step shoud not be changed.
+                */
+               if(index >= MAX_TYPE_NAME_LEN) {
+                       *pStatus = VMSG_TYPE_NAME_STATUS;
+                       res = UNKNOWN_NAME;
+                       break;
+               }
+
+               /**
+                * There is a delimeter between TYPE NAME and next element(=Param, or Type Value).
+                * If VTYPE_TOKEN_SEMICOLON or VTYPE_TOKEN_COLON is faced with,
+                * find TYPE NAME's value in pszMsgTypeList, and then return searched result.
+                */
+               if ((c == VTYPE_TOKEN_SEMICOLON ) || ( c == VTYPE_TOKEN_COLON)) {
+                       name[index] = 0x00;
+                       TRIM(name);
+                       UPPER(name,i,index);
+                       res = __VMsgGetName( name, (char**)pszMsgTypeList, VMSG_TYPE_NUM );
+                       break;
+               }
+               /**
+                * There is no new line in TYPE NAME.
+                * If new line character is faced with, return UNKNOWN_NAME;
+                */
+               else if ( ( c == '\r' ) || ( c == '\n' ) )
+               {
+                       (*pDLen)++;
+                       *pStatus = VMSG_TYPE_NAME_STATUS;
+                       res = UNKNOWN_NAME;
+                       return res;
+               }
+               else if(_VIsSpace(c));
+               else    name[index++] = c;
+       }
+
+       /**
+        *      Set Next Step.
+        *
+        */
+       if ( c == VTYPE_TOKEN_SEMICOLON )
+               /**
+                * This case next token is parameter. So set VMSG_PARAM_NAME_STATUS step.
+                */
+               *pStatus = VMSG_PARAM_NAME_STATUS;
+       else
+       {
+               if(res != UNKNOWN_NAME)
+                       /**
+                        * This case next string is value. So set VMSG_TYPE_VALUE_STATUS step.
+                        */
+                       *pStatus = VMSG_TYPE_VALUE_STATUS;
+               else
+                       /**
+                        * In current step, TYPE NAME is invalid. So Try to get TYPE NAME again from next position.
+                        */
+                       *pStatus = VMSG_TYPE_NAME_STATUS;
+       }
+       VDATA_TRACE_END
+       return res;
+}
+
+/**
+ * __VMsgGetParamName() fine the param name and returns the index number
+ *
+ * @param              pVMsgRaw        The raw data
+ * @param              pStatus         Decoder status
+ * @param              pDLen           retrived length
+ *
+ * @return     res                     The index in type list
+ */
+int
+__VMsgGetParamName( char* pVMsgRaw, int* pStatus, int* pDLen )
+{
+       VDATA_TRACE_BEGINE
+       int     i, index, res;
+
+       char    c;
+       char    name[MAX_PARAM_NAME_LEN+1]={0,};
+       char* pTemp = pVMsgRaw;
+
+       SysRequireEx( pVMsgRaw, UNKNOWN_NAME );
+
+       i = index = 0;
+       res = UNKNOWN_NAME;
+
+       while ( true )
+       {
+               GO_NEXT_CHAR(c, pVMsgRaw, pDLen);
+
+               /**
+                * PARAM NAME's length is must be less than MAX_PARAM_NAME_LEN.
+                * If PARAM NAME's value is over MAX_PARAM_NAME_LEN, return UNKNOWN_NAME.
+                * And then Decoding Step shoud not be changed.
+                */
+               if(index >= MAX_PARAM_NAME_LEN) {
+                       *pStatus = VMSG_TYPE_NAME_STATUS;
+                       res = UNKNOWN_NAME;
+                       break;
+               }
+
+               /**
+                * There is a delimeter between PARAM NAME and next element(=Param, or Param Value).
+                * If VTYPE_TOKEN_EQUAL is faced with,
+                * find PARAM NAME's value in pszMsgParamList, and then return searched result.
+                */
+               if(c == VTYPE_TOKEN_EQUAL) {
+                       name[index] = '\0';
+                       TRIM(name);
+                       UPPER(name, i, index);
+                       res = __VMsgGetName( name, ( char** )pszMsgParamList, VMSG_PARAM_NUM );
+                       if(res==UNKNOWN_NAME){
+                               (*pDLen) = 0;
+                       }
+                       *pStatus = VMSG_PARAM_VALUE_STATUS;
+                       break;
+               }
+               /**
+                * This case, There is no parameter type. Only Parameter Value.
+                * In VMSG_PARAM_NAME_STATUS status, VTYPE_TOKEN_COLON means that anything parameter is no more.
+                * so set next step to VMSG_PARAM_VALUE_STATUS.
+                *
+                * Ex) TEL;WORK:+12341234
+                *        ------ ":" next is TEL TYPE's value.
+                *
+                * VMSG_PARAM_NAME_STATUS(current) -> VMSG_PARAM_VALUE_STATUS
+                * -> VMSG_TYPE_VALUE_STATUS -> MOVE TO NEXT TYPE
+                */
+               else if(c == VTYPE_TOKEN_COLON) {
+                       *pStatus = VMSG_PARAM_VALUE_STATUS;
+                       pVMsgRaw = pTemp;
+                       (*pDLen) = 0;
+                       res = UNKNOWN_NAME;
+                       break;
+               }
+               /**
+                * This case, There is no parameter type. Only Parameter Value.
+                * In VMSG_PARAM_NAME_STATUS status, VTYPE_TOKEN_SEMICOLON means that there is a next parameter.
+                * so set next step to VMSG_PARAM_NAME_STATUS.
+                *
+                * Ex) TEL;WORK;PREF:+12341234
+                *        ------ ":" next is TEL TYPE's value.
+                *
+                * VMSG_PARAM_NAME_STATUS(current) -> VMSG_PARAM_NAME_STATUS
+                * -> VMSG_PARAM_VALUE_STATUS -> VMSG_TYPE_VALUE_STATUS -> MOVE TO NEXT TYPE
+                */
+               else if(c == VTYPE_TOKEN_SEMICOLON) {
+                       *pStatus = VMSG_PARAM_NAME_STATUS;
+                       pVMsgRaw = pTemp;
+                       (*pDLen) = 0;
+                       res = UNKNOWN_NAME;
+                       break;
+               }
+               else if((c == '\r') || (c == '\n') || (_VIsSpace(c)));
+               else
+                       name[index++] = c;
+       }
+       VDATA_TRACE_END
+       return res;
+}
+
+bool
+__VMsgFreeVTreeMemory(VTree * pTree)
+{
+       VDATA_TRACE_BEGINE
+       VObject*                pCurObj = NULL;
+       VObject*                pNextObj = NULL;
+
+       VTree*                  pCurTree = NULL;
+       VTree*                  pNextTree = NULL;
+
+       VParam* pCurParam = NULL;
+       VParam* pNextParam = NULL;
+
+       int count = 0;
+       int i = 0;
+
+       SysRequireEx( pTree->treeType == VMESSAGE, false );
+       SysRequireEx( pTree != NULL, false );
+       VDATA_TRACE("vmsg_free_vtree_memory() entered.");
+
+       if (pTree->treeType != VMESSAGE)
+       {
+               VDATA_TRACE_END
+               return true;
+       }
+
+       pCurTree = pTree;
+
+       while(pCurTree)
+       {
+               pNextTree = pCurTree->pNext;
+               pCurObj = pCurTree->pTop;
+
+               while ( pCurObj )
+               {
+
+                       pNextObj = pCurObj->pSibling;
+                       count = pCurObj->valueCount;
+
+                       for ( i = 0; i < count; i++ ) {
+                               VFREE( pCurObj->pszValue[i]);
+                       }
+
+                       if ( pCurObj->pParam )
+                       {
+
+                               pCurParam = pCurObj->pParam;
+
+                               while(pCurParam != NULL)
+                               {
+                                       pNextParam = pCurParam->pNext;
+                                       VDATA_TRACE("pNEXT ==> %p", pCurParam->pNext);
+                                       VDATA_TRACE("pPARAM ==> %p", pCurParam->parameter);
+                                       VDATA_TRACE("pVALUE ==> %p", pCurParam->paramValue);
+                                       VDATA_TRACE("pCurParam : %p", pCurParam);
+                                       VDATA_TRACE("pCurParam->parameter : %d", pCurParam->parameter);
+                                       VDATA_TRACE("pCurParam->paramValue : %d", pCurParam->paramValue);
+                                       if(pNextParam != NULL) {
+                                               VDATA_TRACE("pNextParam : %p", pNextParam);
+                                               VDATA_TRACE("pNextParam->parameter : %d", pNextParam->parameter);
+                                               VDATA_TRACE("pNextParam->paramValue : %d", pNextParam->paramValue);
+                                       }
+                                       VFREE(pCurParam);
+                                       pCurParam = pNextParam;
+                               }
+                       }
+
+                       VFREE( pCurObj );
+                       pCurObj = pNextObj;
+               }
+
+               VFREE( pCurTree );
+               pCurTree = pNextTree;
+       }
+
+       VDATA_TRACE("exit vmsg_free_vtree_memory");
+       VDATA_TRACE_END
+       return true;
+}
+
+/**
+ * __VMsgGetParamVal() fine the param value and returns value.
+ *
+ * @param              pVMsgRaw        The raw data
+ * @param              pStatus         Decoder status
+ * @param              pDLen           retrived length
+ *
+ * @return     buffer          The result value
+ */
+char*
+__VMsgGetParamVal( char* pVMsgRaw, int* pStatus, int* pDLen )
+{
+       VDATA_TRACE_BEGINE
+       int len = 0;
+       char    c;
+       char* pBuf = NULL;
+       char* pTemp = pVMsgRaw;
+
+       SysRequireEx( pVMsgRaw, NULL );
+
+       while(true) {
+               GO_NEXT_CHAR(c, pVMsgRaw, pDLen);
+               len++;
+               switch(c) {
+                       case VTYPE_TOKEN_SEMICOLON :
+                               *pStatus = VMSG_PARAM_NAME_STATUS;
+                               break;
+                       case VTYPE_TOKEN_COLON :
+                               *pStatus = VMSG_TYPE_VALUE_STATUS;
+                               break;
+                       case VTYPE_TOKEN_COMMA :
+                               *pStatus = VMSG_PARAM_VALUE_STATUS;
+                               break;
+               }
+               if( c == VTYPE_TOKEN_SEMICOLON
+                               || c == VTYPE_TOKEN_COLON
+                               || c == VTYPE_TOKEN_COMMA
+                               || c == 0x00)
+                       break;
+       }
+
+       if(len < 1 || (pBuf = (char *)malloc(len)) == NULL)
+               return NULL;
+       memset(pBuf, 0x00, len);
+       memcpy( pBuf, pTemp, len-1 );
+       TRIM(pBuf);
+       VDATA_TRACE_END
+       return pBuf;
+}
+
+
+/**
+ * __VMsgGetTypeVal() fine the type value and returns value.
+ *
+ * @param      pVMsgRaw        The raw data
+ * @param              status                  Decoder status
+ * @return     buffer          The result value
+ */
+char*
+__VMsgGetTypeVal( char* pVMsgRaw, int* pStatus, int* pDLen, int enc, VObject* pType)
+{
+       VDATA_TRACE_BEGINE
+       int num = 0;
+       int len = 0;
+       int bufferCount = 0;
+
+       bool bEscape = false;
+
+       char    c, c1, c2;
+       char* pBuf = NULL;
+       char* pTemp = pVMsgRaw;
+       char* pTmpBuf = NULL;
+       int Status = 0;
+       int Len = 0;
+
+       SysRequireEx( pVMsgRaw, NULL );
+       VDATA_TRACE("pVMsgRaw: %s", pVMsgRaw);
+       while(true)
+       {
+               GO_NEXT_CHAR(c, pVMsgRaw, pDLen);
+
+               if( c == 0x00)
+                       break;
+
+               len++;
+
+               /** This case means that there are more type's value. */
+               if ( c == VTYPE_TOKEN_SEMICOLON && bEscape == false )
+               {
+                       if((pBuf = (char *)malloc(len)) == NULL)
+                               return NULL;
+
+                       memset(pBuf, 0x00, len);
+                       memcpy(pBuf,pTemp,len-1);
+
+                       TRIM(pBuf);
+                       _VUnescape(pBuf);
+
+                       *pStatus = VMSG_TYPE_VALUE_STATUS;
+
+                       /** Base 64 Decoding */
+                       if((enc & pMsgEncList[1].flag) || (enc & pMsgEncList[0].flag))
+                       {
+
+                               bufferCount = (len * 6 / 8) + 2;
+
+                               if((pTmpBuf = (char *)malloc(bufferCount)) == NULL)
+                               {
+                                       VFREE(pBuf);
+                                       return NULL;
+                               }
+
+                               memset(pTmpBuf, 0x00, bufferCount);
+                               num = _VB64Decode(pTmpBuf, pBuf);
+
+                               if(pType != NULL)
+                                       pType->numOfBiData = num;
+
+                               VFREE(pBuf);
+                               pBuf = pTmpBuf;
+                               pTmpBuf = NULL;
+                               break;
+                       }
+
+                       /** Quoted Printable Decoding */
+                       if(enc & pMsgEncList[2].flag)
+                       {
+
+                               int i = 0, j = 0;
+
+                               while(pBuf[i])
+                               {
+                                       if(pBuf[i] == '\n' || pBuf[i] == '\r')
+                                       {
+                                               i++;
+                                               if(pBuf[i] == '\n'|| pBuf[i] == '\r')
+                                                       i++;
+
+                                               if(pBuf[j-1] == '=')
+                                                       j--;
+                                       }
+                                       else
+                                               pBuf[j++] = pBuf[i++];
+                               }
+                               pBuf[j] = '\0';
+
+                               _VQPDecode(pBuf);
+                               TRIM(pBuf);
+                               break;
+                       }
+                       break;
+               }
+
+               if(c == '\\')
+                       bEscape = true;
+               else if(bEscape == true && c != VTYPE_TOKEN_SEMICOLON )
+                       bEscape = false;
+               else if((c == '\r') || (c == '\n'))
+               {
+                       c2 = *(pVMsgRaw-2);
+
+                       if(c2 == '=' && (enc & pMsgEncList[2].flag))
+                       {
+                               c1 = *pVMsgRaw;
+                               if((c1 == '\r') || (c1 == '\n'))
+                               {
+                                       pVMsgRaw += 1;
+                                       (*pDLen) += 1;
+                                       len++;
+                               }
+                       }
+                       else if(__VMsgGetTypeName(pVMsgRaw, &Status, &Len) != UNKNOWN_NAME)
+                       {
+                               if((pBuf = (char *)malloc(len)) == NULL)
+                                       return NULL;
+
+                               memset(pBuf, 0x00, len);
+                               memcpy(pBuf, pTemp, len-1);
+
+                               TRIM(pBuf);
+                               _VUnescape(pBuf);
+                               VDATA_TRACE("pVMsgRaw: %s", pVMsgRaw);
+                               *pStatus = VMSG_TYPE_NAME_STATUS;
+
+                               c1 = *pVMsgRaw;
+
+                               if((c1 == '\r') || (c1 == '\n'))
+                               {
+                                       pVMsgRaw += 1;
+                                       (*pDLen) += 1;
+                               }
+
+                               if((enc & pMsgEncList[1].flag) || (enc & pMsgEncList[0].flag))
+                               {
+
+                                       bufferCount = (len * 6 / 8) + 5;
+
+                                       if((pTmpBuf = (char *)malloc(bufferCount)) == NULL)
+                                       {
+                                               VFREE(pBuf);
+                                               return NULL;
+                                       }
+
+                                       memset(pTmpBuf, 0x00, bufferCount);
+                                       num = _VB64Decode(pTmpBuf, pBuf);
+
+                                       if(pType != NULL)
+                                               pType->numOfBiData = num;
+
+                                       VFREE(pBuf);
+                                       pBuf = pTmpBuf;
+                                       pTmpBuf = NULL;
+                                       break;
+                               }
+
+                               if(enc & pMsgEncList[2].flag)
+                               {
+
+                                       int i = 0, j = 0;
+
+                                       while(pBuf[i])
+                                       {
+                                               if(pBuf[i] == '\n' || pBuf[i] == '\r')
+                                               {
+                                                       i++;
+                                                       if(pBuf[i] == '\n' || pBuf[i] == '\r')
+                                                               i++;
+
+                                                       if(pBuf[j-1] == '=') j--;
+                                               }
+                                               else
+                                                       pBuf[j++] = pBuf[i++];
+                                       }
+                                       pBuf[j] = '\0';
+
+                                       _VQPDecode(pBuf);
+                                       TRIM(pBuf);
+                                       break;
+                               }
+                               break;
+                       }
+               }
+       }
+
+       VDATA_TRACE_END
+       return pBuf;
+}
+
+
+int
+VMsgGetTypeValue( int index )
+{
+       VDATA_TRACE_BEGINE
+       VDATA_TRACE("VMsgGetTypeValue() enter..\n");
+       VDATA_TRACE_END
+       return pMsgTypeList[index].flag;
+}
+
+int
+VMsgGetValValue( int index )
+{
+       VDATA_TRACE_BEGINE
+       VDATA_TRACE("VMsgGetValValue() enter..\n");
+       VDATA_TRACE_END
+       return pMsgValueList[index].flag;
+}
+
+int
+VMsgGetEncValue( int index )
+{
+       VDATA_TRACE_BEGINE
+       VDATA_TRACE("VMsgGetEncValue() enter..\n");
+       VDATA_TRACE_END
+       return pMsgEncList[index].flag;
+}
+
+int
+VMsgGetCharsetValue( int index )
+{
+       VDATA_TRACE_BEGINE
+       VDATA_TRACE("VMsgGetCharsetValue() enter..\n");
+       VDATA_TRACE_END
+       return pMsgCharsetList[index].flag;
+}
+
+/*
+ * vmsg_decode() decode the vMsg data and returns vObject struct
+ *
+ * @param       pVMsgRaw            The raw data
+ * @return      vObject             The result value
+ */
+SLPAPI VTree*
+vmsg_decode( char *pMsgRaw )
+{
+       VDATA_TRACE_BEGINE;
+
+       char* szValue = NULL;
+       char* szMsgBegin = NULL;
+       char* pMsgRawTmp = NULL;
+       VTree* pVMsg = NULL;
+       VTree* pVBody = NULL;
+       VTree* pCurrent = NULL;
+       VTree* pVCard = NULL;
+       VParam* pTmpParam = NULL;
+       VObject* pTemp = NULL;
+
+       char    c;
+
+       int type, param;
+       int status = VMSG_TYPE_NAME_STATUS;
+       int done = false;
+       int valueCount = 0;
+       int len;
+       int dLen = 0;
+       int param_status = false;
+       int numberedParam = 0;
+       int enc = 0;
+       int start_status = 0;
+       char* temp = NULL;
+       char* pVTree = NULL;
+       bool vmsg_ended = false;
+
+       SysRequireEx(pMsgRaw != NULL, NULL);
+       len = strlen(pMsgRaw);
+       len = _VUnfoldingNoSpec(pMsgRaw, VMESSAGE);
+       pMsgRawTmp = pMsgRaw;
+       len = _VManySpace2Space( pMsgRaw );
+
+       if(!__VIsVmsgFile(pMsgRaw, CHECK_START)) {
+               VFREE(pMsgRawTmp);
+               VDATA_TRACE_END
+               return NULL;
+       }
+
+       while(true && !done)
+       {
+               c = *pMsgRaw;
+
+               if((c == '\0') || done)
+                       break;
+
+               switch(status) {
+                       case VMSG_TYPE_NAME_STATUS:
+                               dLen = 0;
+                               type = __VMsgGetTypeName(pMsgRaw, &status, &dLen);
+
+                               if(type == VMSG_TYPE_BEGIN)
+                                       pVTree = pMsgRaw;
+
+                               pMsgRaw += dLen;
+
+                               if(type == -1)
+                                       break;
+
+                               switch ( type )
+                               {
+                                       case VMSG_TYPE_BEGIN:
+                                               dLen = 0;
+                                               enc = 0;
+                                               szMsgBegin = __VMsgGetTypeVal(pMsgRaw, &status, &dLen, enc, NULL);
+                                               pMsgRaw += dLen;
+
+                                               if(szMsgBegin == NULL)
+                                                       goto CATCH;
+
+                                               if(!strncmp(szMsgBegin, "VCARD", strlen("VCARD")))
+                                               {
+                                                       VDATA_TRACE("pVTree: %s", pVTree);
+                                                       pVCard = vcard_decode(pVTree);
+                                                       pCurrent->pNext = pVCard;
+                                                       pCurrent = pVCard;
+
+                                                       dLen = ((strstr(pMsgRaw,"END:VCARD") + 9) - pMsgRaw);
+                                                       pMsgRaw += dLen;
+                                               }
+
+                                               else
+                                               {
+
+                                                       if(start_status == 1)
+                                                               goto CATCH;
+
+
+
+
+                                                       if(!strncmp(szMsgBegin, "VMSG", strlen("VMSG")))
+                                                       {
+                                                               if ( ( pVMsg = ( VTree* )malloc( sizeof( VTree ) ) ) == NULL )
+                                                               {
+                                                                       start_status = 1;
+                                                                       goto CATCH;
+                                                               }
+                                                               memset(pVMsg,0x00, sizeof(VTree));
+
+                                                               pVMsg->treeType = VMESSAGE;
+                                                               pVMsg->pTop = NULL;
+                                                               pVMsg->pCur = NULL;
+                                                               pVMsg->pNext = NULL;
+                                                               pCurrent = pVMsg;
+                                                       }
+
+                                                       else if(!strncmp(szMsgBegin, "VBODY", strlen("VBODY")))
+                                                       {
+                                                               if ( ( pVBody = ( VTree* )malloc( sizeof( VTree ) ) ) == NULL )
+                                                               {
+                                                                       start_status = 1;
+                                                                       goto CATCH;
+                                                               }
+
+                                                               memset(pVBody,0x00, sizeof(VTree));
+                                                               pVBody->treeType = VBODY;
+                                                               pVBody->pTop = NULL;
+                                                               pVBody->pCur = NULL;
+                                                               pVBody->pNext = NULL;
+                                                               pCurrent->pNext = pVBody;
+                                                               pCurrent = pVBody;
+                                                       }
+                                               }
+
+                                               VFREE(szMsgBegin);
+                                               break;
+
+                                       case VMSG_TYPE_END:
+                                               dLen = 0;
+                                               enc = 0;
+                                               //szMsgBegin = __VMsgGetTypeVal(pMsgRaw, &status, &dLen, enc, NULL);
+
+                                               if(!strncmp(pMsgRaw,"VMSG", strlen("VMSG")))
+                                               {
+                                                       done = true;
+                                                       vmsg_ended = true;
+                                               }
+                                               else
+                                               {
+                                                       status = VMSG_TYPE_NAME_STATUS;
+                                                       //pMsgRaw += dLen;
+                                               }
+                                               VDATA_TRACE("pMsgRaw:%s", pMsgRaw);
+                                               pMsgRaw += dLen;
+                                               break;
+
+                                       case UNKNOWN_NAME :
+                                               break;
+
+                                       default:
+                                               if(UNKNOWN_NAME == type || type < 0) {
+                                                       status = VMSG_TYPE_NAME_STATUS;
+                                                       break;
+                                               }
+
+                                               if ( ( pTemp = ( VObject* )malloc( sizeof( VObject ) ) ) == NULL )
+                                               {
+                                                       goto CATCH;
+                                               }
+
+                                               memset( pTemp, 0, sizeof( VObject ) );
+                                               pTemp->property = type;
+
+                                               if ( pCurrent->pTop == NULL ) {
+                                                       pCurrent->pTop = pTemp;
+                                                       pCurrent->pCur = pTemp;
+                                               }
+                                               else {
+                                                       pCurrent->pCur->pSibling = pTemp;
+                                                       pCurrent->pCur = pTemp;
+                                               }
+
+                                               break;
+                               }
+
+                               numberedParam = 0;
+                               param_status = false;
+                               valueCount = 0;
+                               break;
+
+                       case VMSG_PARAM_NAME_STATUS:
+                       {
+                               dLen = 0;
+                               param = __VMsgGetParamName( pMsgRaw, &status, &dLen );
+                               pMsgRaw += dLen;
+
+                               if ( param_status != true ) {
+
+                                       if ( ( pTmpParam = ( VParam* )malloc( sizeof( VParam ) ) ) == NULL )
+                                                       goto CATCH;
+
+                                       param_status = true;
+                                       pCurrent->pCur->pParam = pTmpParam;
+                                       memset( pTmpParam, 0x00, sizeof( VParam ) );
+                                       VDATA_TRACE("pTmpParam : %p", pTmpParam);
+                               }
+                               else
+                               {
+                                       if ( ( pTmpParam->pNext = ( VParam* )malloc( sizeof( VParam ) ) ) == NULL )
+                                                       goto CATCH;
+
+                                       pTmpParam = pTmpParam->pNext;
+                                       memset( pTmpParam, 0x00, sizeof(VParam));
+                                       VDATA_TRACE("pTmpParam : %p", pTmpParam);
+                               }
+
+                               pTmpParam->parameter = param;
+                               break;
+                       }
+                       case VMSG_PARAM_VALUE_STATUS:
+                               dLen = 0;
+                               numberedParam = 0;
+                               switch ( pTmpParam->parameter )
+                               {
+                                       case VMSG_PARAM_TYPE:
+                                               szValue = __VMsgGetParamVal( pMsgRaw, &status, &dLen );
+                                               numberedParam |= __VMsgGetValue( szValue, pMsgTypeList, VMSG_TYPE_PARAM_NUM );
+                                               break;
+                                       case VMSG_PARAM_VALUE:
+                                               szValue = __VMsgGetParamVal( pMsgRaw, &status, &dLen );
+                                               numberedParam |= __VMsgGetValue( szValue, pMsgValueList, VMSG_VALUE_PARAM_NUM );
+                                               break;
+                                       case VMSG_PARAM_ENCODING:
+                                               szValue = __VMsgGetParamVal( pMsgRaw, &status, &dLen );
+                                               numberedParam |= __VMsgGetValue( szValue, pMsgEncList, VMSG_ENCODE_PARAM_NUM );
+                                               enc = numberedParam;
+                                               break;
+                                       case VMSG_PARAM_CHARSET:
+                                               szValue = __VMsgGetParamVal( pMsgRaw, &status, &dLen );
+                                               numberedParam |= __VMsgGetValue( szValue, pMsgCharsetList, VMSG_CHARSET_PARAM_NUM );
+                                               break;
+                                       case VMSG_PARAM_CONTEXT:
+                                       case VMSG_PARAM_LANGUAGE:
+                                               // prevent 7605 08.03.13
+                                               szValue = __VMsgGetParamVal( pMsgRaw, &status, &dLen );
+                                               numberedParam = 0;
+                                               break;
+                                       default:
+                                               szValue = __VMsgGetParamVal( pMsgRaw, &status, &dLen );
+
+                                               SET_PARAM_VALUE(numberedParam, szValue, pMsgTypeList, VMSG_TYPE_PARAM_NUM, pTmpParam, VMSG_PARAM_TYPE, enc);
+                                               SET_PARAM_VALUE(numberedParam, szValue, pMsgValueList, VMSG_VALUE_PARAM_NUM, pTmpParam, VMSG_PARAM_VALUE, enc);
+                                               SET_PARAM_VALUE(numberedParam, szValue, pMsgEncList, VMSG_ENCODE_PARAM_NUM, pTmpParam, VMSG_PARAM_ENCODING, enc);
+                                               SET_PARAM_VALUE(numberedParam, szValue, pMsgCharsetList, VMSG_CHARSET_PARAM_NUM, pTmpParam, VMSG_PARAM_CHARSET, enc);
+
+                                               numberedParam = 0;
+                                               pMsgRaw += dLen;
+                                               dLen = 0;
+
+                                               break;
+                               }
+
+                               VDATA_TRACE("%d, %s, %p",numberedParam, szValue, pTmpParam);
+                               pTmpParam->paramValue = numberedParam;
+                               pTmpParam->pNext = NULL;
+                               VFREE(szValue);
+                               pMsgRaw += dLen;
+                               break;
+                       case VMSG_TYPE_VALUE_STATUS:
+                               dLen = 0;
+                               temp = __VMsgGetTypeVal( pMsgRaw, &status, &dLen, enc, pCurrent->pCur);
+
+                               if(valueCount <= VDATA_VALUE_COUNT_MAX) {
+                                       pCurrent->pCur->pszValue[valueCount] = temp;
+                                       valueCount++;
+                                       pCurrent->pCur->valueCount = valueCount;
+                                       VDATA_TRACE("object property: %d, value: %s", pCurrent->pCur->property, pCurrent->pCur->pszValue[valueCount - 1]);
+                               }
+                               else
+                                       VFREE(temp);
+
+                               pMsgRaw += dLen;
+                               break;
+               }
+       }
+       VDATA_TRACE("pMsgRawTmp: %s", pMsgRawTmp);
+       //VFREE(pMsgRawTmp);
+
+       if(pVMsg->pTop == NULL)
+       {
+               VDATA_TRACE("pVMsg->Top: NULL");
+               goto CATCH;
+       }
+
+       if(!vmsg_ended) {
+               VDATA_TRACE("vmsg_ended: false");
+               goto CATCH1;
+       }
+       VDATA_TRACE_END
+       return pVMsg;
+
+CATCH :
+       VFREE(pTemp);
+CATCH1 :
+       VFREE(pMsgRawTmp);
+       __VMsgFreeVTreeMemory(pVMsg);
+       VDATA_TRACE_END
+       return NULL;
+}
+
+/*
+ * vmsg_encode() compares the string and vMsg type, parameter value.
+ *
+ * @param       pVMsgRaw            Data which will be encoded
+ * @return      char *              Encoded result
+ */
+SLPAPI char*
+vmsg_encode( VTree *pVMsgRaw )
+{
+       VDATA_TRACE_BEGINE
+       char*           pVMsgRes = NULL;
+       char*           pTmpVMsgRes = NULL;
+       VTree*          pTmpTree = NULL;
+       VObject *       pTmpObj =  NULL;
+       char*           pTemp = NULL;
+       int                     len;
+       int                     total = 0;
+       int             cnt = 0;
+
+       for(;cnt < pVMsgRaw->pTop->valueCount;cnt++) {
+
+               if(pVMsgRaw->pTop->pszValue[cnt] == NULL)  {
+                       VDATA_TRACE("pVMsgRaw->pTop->valueCount : %d",pVMsgRaw->pTop->valueCount);
+                       VDATA_TRACE("pVMsgRaw->pTop->pszValue[%d] : %s", cnt, pVMsgRaw->pTop->pszValue[cnt]);
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+       }
+
+       pTmpTree = pVMsgRaw;
+       pTmpObj = pVMsgRaw->pTop;
+
+       while(true)
+       {
+               switch(pTmpTree->treeType)
+               {
+                       case VMESSAGE:
+                               if (pVMsgRes) {
+                                       free(pVMsgRes);
+                                       pVMsgRes = NULL;
+                               }
+
+                               if ( ( pVMsgRes = ( char * )malloc( sizeof( char ) * ( total += 13 ) ) ) == NULL )
+                               {
+                                       VDATA_TRACE(  "vmsg_encode:malloc failed\n" );
+                                       VDATA_TRACE_END
+                                       return NULL;
+                               }
+                               memcpy( pVMsgRes, "BEGIN:VMSG\r\n", 13 );
+                               break;
+
+                       case VBODY:
+                               if ( ( pTmpVMsgRes = ( char * )realloc( pVMsgRes,  sizeof( char ) * ( total += 14 ) ) ) == NULL )
+                               {
+                                       VDATA_TRACE(  "vmsg_encode:realloc failed\n" );
+                                       VFREE(pVMsgRes);
+                                       VDATA_TRACE_END
+                                       return NULL;
+                               }
+
+                               pVMsgRes = pTmpVMsgRes;
+                               strncat( pVMsgRes, "BEGIN:VBODY\r\n", 13);
+                               break;
+
+                       case VCARD:
+                               break;
+               }
+
+               while ( true )
+               {
+                       if(pTmpObj == NULL)
+                               break;
+
+                       if ( ( pTemp = __VMsgTypeEncode( pTmpObj, pTmpObj->property == VCARD_TYPE_TEL ? "TEL" : pszMsgTypeList[pTmpObj->property] ) ) != NULL )
+                       {
+                               if(pTmpTree->treeType == VCARD)
+                               {
+                                       char* encoded  = NULL;
+
+                                       encoded = vcard_encode(pTmpTree);
+                                       if (encoded == NULL) {
+                                               VDATA_TRACE(  "vcard_encode() failed\n");
+                                               VFREE(pTemp);
+                                               VDATA_TRACE_END
+                                               return NULL;
+                                       }
+
+                                       len= strlen(encoded);
+
+                                       if ( ( pTmpVMsgRes = ( char* )realloc( pVMsgRes, ( total += len+10 ) ) ) == NULL )
+                                       {
+                                               VDATA_TRACE(  "vmsg_encode():realloc failed\n");
+                                               VFREE( pTemp );
+                                               VFREE( encoded );
+                                               VFREE(pVMsgRes);
+                                               VDATA_TRACE_END
+                                               return NULL;
+                                       }
+
+                                       pVMsgRes = pTmpVMsgRes;
+                                       strncat(pVMsgRes, encoded, len+10);
+                                       VDATA_TRACE("pTemp : %s", encoded);
+                                       VFREE( pTemp );
+                                       VFREE( encoded );
+                                       break;
+                               }
+                               else
+                               {
+                                       len = strlen( pTemp );
+
+                                       if ( ( pTmpVMsgRes = ( char* )realloc( pVMsgRes, ( total += len+10 ) ) ) == NULL )
+                                       {
+                                               VDATA_TRACE(  "vmsg_encode():realloc failed\n");
+                                               VFREE( pTemp );
+                                               VFREE(pVMsgRes);
+                                               VDATA_TRACE_END
+                                               return NULL;
+                                       }
+                                       pVMsgRes = pTmpVMsgRes;
+                                       strncat(pVMsgRes, pTemp, len+10);
+                                       VDATA_TRACE("pTemp : %s", pTemp);
+                                       VFREE( pTemp );
+
+                                       if ( pTmpObj->pSibling != NULL )
+                                               pTmpObj = pTmpObj->pSibling;
+                                       else
+                                               break;
+                               }
+                       }
+
+
+               }
+
+               switch(pTmpTree->treeType)
+               {
+                       case VBODY:
+                               if ( ( pTmpVMsgRes = ( char * )realloc( pVMsgRes, ( total += 12 ) ) ) == NULL )
+                               {
+                                       VFREE(pVMsgRes);
+                                       VDATA_TRACE(  "vcal_encode():realloc failed\n");
+                                       return NULL;
+                               }
+
+                               pVMsgRes = pTmpVMsgRes;
+                               strncat( pVMsgRes, "END:VBODY\r\n", 12);
+                               break;
+
+                       case VCARD:
+                               break;
+
+                       case VMESSAGE:
+                               break;
+
+               }
+
+               if ( pTmpTree->pNext != NULL )
+                       pTmpTree = pTmpTree->pNext;
+               else
+                       break;
+               pTmpObj = pTmpTree->pTop;
+       }
+
+       if ( ( pTmpVMsgRes = ( char * )realloc( pVMsgRes, ( total += 11 ) ) ) == NULL )
+       {
+               VDATA_TRACE(  "vmsg_encode:realloc failed\n");
+               VFREE(pVMsgRes);
+               VDATA_TRACE_END
+               return NULL;
+       }
+
+       pVMsgRes = pTmpVMsgRes;
+       strncat( pVMsgRes, "END:VMSG\r\n", 11);
+       VDATA_TRACE_END
+       return pVMsgRes;
+}
+
+
+/*
+ * VIsVmsgFile() verify VMsg file.
+ *
+ * @param       pVMsgRaw           Data which will be encoded
+ * @return      int                 result (true or false)
+ */
+int
+__VIsVmsgFile(char *pMsgRaw, int mode)
+{
+       int i=0;
+       bool rtnValue = true;
+       char *pszVmsgBegin = "BEGIN:VMSG";
+
+       switch(mode)
+       {
+               case CHECK_START :
+                       for(i=0; i < 10; i++)
+               if(*pszVmsgBegin++ != *pMsgRaw++)
+                                       rtnValue = false;
+                       break;
+
+               default :
+                       rtnValue = false;
+       }
+       VDATA_TRACE_END
+       return rtnValue;
+}
+
+
+/*
+ * vMsgTypeEncoder() compares the string and vMsg type, parameter value.
+ *
+ * @param              typeObj                         Data which will be encoded
+ * @param              type                            Name of the type
+ * @return      char *              Encoded result
+ */
+char*
+__VMsgTypeEncode( VObject *pTypeObj, char *pType )
+{
+       VDATA_TRACE_BEGINE
+       int                     len;
+       char*           pTemp = NULL;
+       char*           szTypeValue = NULL;
+       int                     i;
+       int                     enc = 0;
+       char*           pEncode = NULL;
+       char*           pRes = NULL;
+       int                     total = 0;
+       int                     biLen = 0;
+
+       len = strlen( pType );
+       biLen = pTypeObj->numOfBiData;
+
+       if ( ( szTypeValue = ( char * )malloc( total += ( len+1 ) ) ) == NULL )
+       {
+               VDATA_TRACE(  "__VMsgTypeEncode():malloc failed\n");
+               VDATA_TRACE_END
+               return NULL;
+       }
+       memset( szTypeValue, '\0', ( len+1 ) );
+       strncat( szTypeValue, pType, len+1);
+
+       pTemp = __VMsgParamEncode( pTypeObj, &enc );
+       if ( pTemp != NULL )
+       {
+               len = strlen( pTemp );
+               if ( ( szTypeValue = ( char * )realloc( szTypeValue, ( total += len ) ) ) == NULL )
+               {
+                       VDATA_TRACE(  "__VMsgTypeEncode():realloc failed\n");
+                       VFREE( pTemp );
+                       pTemp = NULL
+                       VDATA_TRACE_END;
+                       return NULL;
+               }
+               strncat( szTypeValue, pTemp, len);
+               VFREE( pTemp );
+               pTemp = NULL;
+       }
+
+       if ( ( szTypeValue = ( char * )realloc( szTypeValue, ( total += 2 ) ) ) == NULL )
+       {
+               VDATA_TRACE_END
+               return NULL;
+       }
+
+       strncat( szTypeValue, ":", 2 );
+
+       len = 0;
+
+       if(strcmp(pType, pszMsgTypeList[6]) != 0)       {
+               for ( i = 0; i < pTypeObj->valueCount; i++ ) {
+
+                       if(pTypeObj->pszValue[i] != NULL)
+                       len += strlen( pTypeObj->pszValue[i] );
+               }
+       }
+       else
+               len += biLen;
+
+
+       for ( i = 0; i < pTypeObj->valueCount; i++ ) {
+
+               if ( i == 0 )
+               {
+                       if ( ( pEncode = ( char * )malloc( len+20 ) ) == NULL )
+                       {
+                               VFREE(szTypeValue);
+                               VDATA_TRACE_END
+                               return NULL;
+                       }
+
+                       memset( pEncode, '\0', len+20 );
+
+                       if(strcmp(pType, pszMsgTypeList[6]) != 0)
+                       {
+                               strncat( pEncode, pTypeObj->pszValue[i], 20 );
+                               _VEscape(pEncode);
+                       }
+                       else
+                               memcpy(pEncode, pTypeObj->pszValue[i], biLen);
+               }
+               else
+               {
+                       char    buf[1000];
+                       strncpy( buf, pTypeObj->pszValue[i], 999 );
+                       _VEscape( buf );
+                       strcat( pEncode, ";" );
+                       strcat( pEncode, buf );
+               }
+       }
+
+       if(strcmp(pType, pszMsgTypeList[6]) != 0)       {
+               if (pEncode) {
+                       strcat( pEncode, "\0\0" );
+                       len = strlen( pEncode );
+               }
+       }
+       else {
+               len = biLen;
+       }
+
+       if ( enc & pMsgEncList[2].flag ) {
+               if((pRes = (char *)malloc(len * 6 + 10)) == NULL) {
+                       VFREE(pEncode);
+                       VFREE(szTypeValue);
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+               _VQPEncode( pRes, pEncode );
+               VFREE(pEncode);
+                       }
+       else if(enc & pMsgEncList[1].flag )
+       {
+               if((pRes = (char *)malloc((len * 8 / 6) + 48)) == NULL)
+               {
+                       VFREE(pEncode);
+                       VFREE(szTypeValue);
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+
+               memset( pRes, '\0', ( ( len * 8 / 6 ) + 48 ) );
+               _VB64Encode( pRes, pEncode, biLen );
+               VDATA_TRACE(  "Origin Size: %d, Allocated Size %d, Coverted Size: %d\n", biLen, ( len * 8 / 6 ) + 48, strlen(pRes));
+               VFREE(pEncode);
+       }
+       else
+       {
+               if((pRes = (char *)malloc(len+30)) == NULL)
+               {
+                       VFREE(pEncode);
+                       VFREE(szTypeValue);
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+               memset( pRes, '\0', ( len + 30 ) );
+               memcpy( pRes, pEncode, len );
+               VFREE(pEncode);
+       }
+
+       if((pRes = (char *)realloc(pRes, strlen(pRes) + 3)) == NULL)
+       {
+               VFREE(pEncode);
+               VFREE(szTypeValue);
+               VDATA_TRACE_END
+               return NULL;
+       }
+       strncat( pRes, "\r\n", strlen(pRes) + 2);
+
+       len = strlen( pRes );
+
+       if ((szTypeValue = (char *)realloc(szTypeValue, (total += (len+3)))) == NULL) {
+               VFREE(pEncode);
+               VFREE(pRes);
+               VDATA_TRACE_END
+               return NULL;
+       }
+
+       strncat(szTypeValue, pRes, total - 1);
+
+       if(strcmp(pType, pszMsgTypeList[6]) != 0) {
+               _VRLSpace( szTypeValue );
+               _VRTSpace( szTypeValue );
+       }
+
+       VFREE(pRes);
+
+       VDATA_TRACE_END
+       return szTypeValue;
+}
+
+/**
+ * __VMsgParamEncode() Parameter Encoding.
+ *
+ * @param              pTypeObj                Data which will be encoded
+ * @param              pEnc                            Name of the type
+ */
+char *
+__VMsgParamEncode(VObject* pTypeObj, int* pEnc)
+{
+       VDATA_TRACE_BEGINE
+       int i = 0;
+       int len = 0;
+       int sNum = 0;
+       int shift = 0;
+       bool bSupported;
+       char* szParam = NULL;
+       VParam* pTemp = NULL;
+       ValueObj*       pList = NULL;
+
+       /** Paramter initialize. */
+       pTemp = pTypeObj->pParam;
+
+       /** Momory Allocation for parameter string. */
+       if(pTemp != NULL) {
+               if ((szParam = (char*)malloc(len+=2)) == NULL)
+               {
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+               memset(szParam, 0x00, 2);
+       }
+
+       /** appending pamaters. */
+       while(true) {
+
+               if(pTemp == NULL) break;
+
+               bSupported = false;
+
+               /** Expand szParam string. For appending.*/
+               if((szParam = (char *)realloc(szParam, len += 15)) == NULL)
+               {
+                       VDATA_TRACE_END
+                       return NULL;
+               }
+
+               /** appending paramter name. */
+               strcat( szParam, ";" );
+               if(pTemp->parameter != VMSG_PARAM_TYPE) {
+                       strcat( szParam, pszMsgParamList[pTemp->parameter] );
+                       strcat( szParam, "=" );
+               }
+
+               /** Set Parameter Value name. */
+               switch ( pTemp->parameter )
+               {
+                       case VMSG_PARAM_ENCODING:
+                               *pEnc = pMsgEncList[pTemp->paramValue].flag;
+                               shift = VMSG_ENCODE_PARAM_NUM;
+                               pList = pMsgEncList; bSupported = true;
+                               break;
+                       case VMSG_PARAM_TYPE:
+                               shift = VMSG_TYPE_PARAM_NUM;
+                               pList = pMsgTypeList; bSupported = true;
+                               break;
+                       case VMSG_PARAM_VALUE:
+                               shift = VMSG_VALUE_PARAM_NUM;
+                               pList = pMsgValueList; bSupported = true;
+                               break;
+                       case VMSG_PARAM_CHARSET:
+                               shift = VMSG_CHARSET_PARAM_NUM;
+                               pList = pMsgCharsetList; bSupported = true;
+                               break;
+                       default:
+                               if ( ( szParam = ( char* )realloc( szParam, 5 ) ) == NULL )
+                               {
+                                       VDATA_TRACE_END
+                                       return NULL;
+                               }
+                               strcat( szParam, "NONE" );
+               }
+
+               /** exchage parameter value's to string.*/
+               if(bSupported == true) {
+
+                       for(i = 0, sNum = 0x00000001; i < shift; i++) {
+
+                               if(pList[pTemp->paramValue].flag & sNum) {
+                                       if((szParam = (char *)realloc(szParam, ( len += (strlen(pList[i].szName) + 2)))) == NULL)
+                                       {
+                                               VDATA_TRACE_END
+                                               return NULL;
+                                       }
+
+                                       strcat( szParam, pList[i].szName );
+                                       strcat( szParam, "; " );
+                               }
+
+                               sNum <<= 1;
+                       }
+               }
+
+               /** remove semicolon from tail. */
+               for(i = strlen( szParam ); i > 0 ; i--) {
+
+                       if ( szParam[i] == ' ' && szParam[i-1] == ';' ) {
+                               szParam[i-1] = '\0';
+                               break;
+                       }
+               }
+
+               if ( pTemp->pNext != NULL )
+                       pTemp = pTemp->pNext;
+               else
+                       break;
+       }
+       VDATA_TRACE_END
+       return szParam;
+}
+
+SLPAPI bool
+vmsg_free_vtree_memory(VTree * pTree)
+{
+       VDATA_TRACE_BEGINE
+       if(pTree == NULL)
+       {
+               VDATA_TRACE_END
+               return false;
+       }
+       VDATA_TRACE_END
+       return __VMsgFreeVTreeMemory(pTree);
+}
diff --git a/vobject-engine/include/VCard.h b/vobject-engine/include/VCard.h
new file mode 100755 (executable)
index 0000000..7a0bc5f
--- /dev/null
@@ -0,0 +1,231 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 _VCARD_H
+#define _VCARD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "VTypes.h"
+
+/****************************************************************************************************/
+/*                                                                                     ENUMERATION DECLARATION                                                                 */
+/****************************************************************************************************/
+
+/**
+* @enum vCardType
+* This enumeration defines the property of vcard.
+*/
+typedef enum
+{
+       VCARD_TYPE_ADR,                 /**<This is address of vcard. */
+       VCARD_TYPE_AGENT,                       /**<This is agent of vcard. */
+       VCARD_TYPE_BDAY,                        /**<This is bday of vcard. */
+       VCARD_TYPE_BEGIN,                       /**<This is begin of vcard. */
+       VCARD_TYPE_CATEGORIES,  /**<This is categories of vcard. */
+       VCARD_TYPE_CLASS,                       /**<This is class of vcard. */
+       VCARD_TYPE_EMAIL,                       /**<This is email of vcard. */
+       VCARD_TYPE_END,                 /**<This is end of vcard. */
+       VCARD_TYPE_FN,                          /**<This is FN  of vcard. */
+       VCARD_TYPE_GEO,                 /**<This is GEO of vcard. */
+       VCARD_TYPE_KEY,                 /**<This is key of vcard. */
+       VCARD_TYPE_LABEL,                       /**<This is label of vcard. */
+       VCARD_TYPE_LOGO,                        /**<This is logo of vcard. */
+       VCARD_TYPE_MAILER,              /**<This is mailer of vcar. */
+       VCARD_TYPE_N,                           /**<This is N of vcard. */
+       VCARD_TYPE_NAME,                        /**<This is name of vcard. */
+       VCARD_TYPE_NICKNAME,            /**<This is nick name of vcard. */
+       VCARD_TYPE_NOTE,                        /**<This is note of vcard. */
+       VCARD_TYPE_ORG,                 /**<This is ORG of vcard. */
+       VCARD_TYPE_PHOTO,                       /**<This is photo of vcard. */
+       VCARD_TYPE_PRODID,              /**<This is PRODID of vcard. */
+       VCARD_TYPE_PROFILE,             /**<This is profile of vcard. */
+       VCARD_TYPE_REV,                 /**<This is REV of vcard. */
+       VCARD_TYPE_ROLE,                        /**<This is ROLE of vcard. */
+       VCARD_TYPE_SORT_STRING, /**<This is sort string of vcard. */
+       VCARD_TYPE_SOUND,                       /**<This is sound of vcard. */
+       VCARD_TYPE_SOURCE,              /**<This is source of vcard. */
+       VCARD_TYPE_TEL,                 /**<This is tel of vcard. */
+       VCARD_TYPE_TITLE,                       /**<This is title of vcard. */
+       VCARD_TYPE_TZ,                          /**<This is TZ of vcard. */
+       VCARD_TYPE_UID,                 /**<This is uid of vcard. */
+       VCARD_TYPE_URL,                 /**<This is url of vcard. */
+       VCARD_TYPE_VERSION,             /**<This is version of vcard. */
+       VCARD_TYPE_XIRMCLUID            /**<This is xirmcl uid of vcard. */
+}vCardType;
+
+#define VCARD_TYPE_NUM 34              /**< number of vcard type */
+
+/**
+* @enum vCardParamName
+* This enumeration defines the name of vcard parameter.
+*/
+typedef enum
+{
+       VCARD_PARAM_CHARSET,            /**<This is charset parameter. */
+       VCARD_PARAM_CONTEXT,            /**<This is context parameter. */
+       VCARD_PARAM_ENCODING,   /**<This is encoding parameter. */
+       VCARD_PARAM_LANGUAGE,   /**<This is language parameter. */
+       VCARD_PARAM_TYPE,                       /**<This is type parameter. */
+       VCARD_PARAM_VALUE               /**<This is value parameter. */
+}vCardParamName;
+
+#define VCARD_PARAM_NUM                6       /**< number of vcard parameter */
+
+/**
+* @enum vCardParamName
+* This enumeration defines the value of encoding parameter.
+*/
+typedef enum
+{
+       VCARD_ENC_PARAM_B,                                      /**<This is b encoding parameter. */
+       VCARD_ENC_PARAM_BASE64,                         /**<This isbase64 encoding parameter. */
+       VCARD_ENC_PARAM_QUOTED_PRINTABLE,       /**<This is quoted printable encoding parameter. */
+       VCARD_ENC_PARAM_7BIT,                           /**<This is 7 bit encoding parameter. */
+       VCARD_ENC_PARAM_8BIT                                    /**<This is 8 bit encoding parameter. */
+}vCardEncVal;
+
+#define VCARD_ENCODE_PARAM_NUM 5       /**< number of vcard encoding parameter */
+
+/**
+* @enum vCardCharsetVal
+* This enumeration defines the value of charset parameter.
+*/
+typedef enum
+{
+       VCARD_CHARSET_PARAM_UTF_8,              /**<This is utf-8 charset parameter. */
+       VCARD_CHARSET_PARAM_UTF_16,             /**<This is utf-16 charset parameter. */
+       VCARD_CHARSET_PARAM_SHIFT_JIS,  /**<This is shift-jis charset parameter. */
+       VCARD_CHARSET_PARAM_ISO_8859_1  /**<This is iso-8859-1 charset parameter. */
+}vCardCharsetVal;
+
+#define VCARD_CHARSET_PARAM_NUM  4     /**< number of vcard charset parameter */
+
+/**
+* @enum vCardValVal
+* This enumeration defines the value of value parameter.
+*/
+typedef enum
+{
+       VCARD_VALUE_PARAM_BINARY,               /**<This is binary value parameter. */
+       VCARD_VALUE_PARAM_BOOLEAN,              /**<This is boolean value parameter. */
+       VCARD_VALUE_PARAM_DATE,                 /**<This is date value parameter. */
+       VCARD_VALUE_PARAM_DATE_TIME,    /**<This is date time value parameter. */
+       VCARD_VALUE_PARAM_FLOAT,                /**<This is float value parameter. */
+       VCARD_VALUE_PARAM_INTEGER,              /**<This is integer value parameter. */
+       VCARD_VALUE_PARAM_PHONE_NUMBER, /**<This is phone number value parameter. */
+       VCARD_VALUE_PARAM_TEXT,                         /**<This is text value parameter. */
+       VCARD_VALUE_PARAM_TIME,                         /**<This is time value parameter. */
+       VCARD_VALUE_PARAM_URI,                          /**<This is uri value parameter. */
+       VCARD_VALUE_PARAM_URL,                          /**<This is url value parameter. */
+       VCARD_VALUE_PARAM_UTC_OFFSET,           /**<This is utc offset value parameter. */
+       VCARD_VALUE_PARAM_VCARD                         /**<This is vcard value parameter. */
+}vCardValVal;
+
+#define VCARD_VALUE_PARAM_NUM          13              /**< number of vcard value parameter */
+
+/**
+* @enum vCardValVal
+* This enumeration defines the value of type parameter.
+*/
+typedef enum
+{
+       VCARD_TYPE_PARAM_AIFF,          /**<This is aiff type parameter. */
+       VCARD_TYPE_PARAM_BBS,           /**<This is bbs type parameter. */
+       VCARD_TYPE_PARAM_CAR,           /**<This is car type parameter. */
+       VCARD_TYPE_PARAM_CELL,          /**<This is cell type parameter. */
+       VCARD_TYPE_PARAM_DOM,           /**<This is dom type parameter. */
+       VCARD_TYPE_PARAM_WORK,          /**<This is work type parameter. */
+       VCARD_TYPE_PARAM_FAX,           /**<This is fax type parameter. */
+       VCARD_TYPE_PARAM_GIF,           /**<This is gif type parameter. */
+       VCARD_TYPE_PARAM_HOME,          /**<This is home type parameter. */
+       VCARD_TYPE_PARAM_INTL,          /**<This is intl type parameter. */
+       VCARD_TYPE_PARAM_INTERNET,      /**<This is internet type parameter. */
+       VCARD_TYPE_PARAM_ISDN,          /**<This is ISDN type parameter. */
+       VCARD_TYPE_PARAM_JPEG,          /**<This is jpeg type parameter. */
+       VCARD_TYPE_PARAM_MOBILE,                /**<This is mobile type parameter. */
+       VCARD_TYPE_PARAM_MODEM,         /**<This is mpdem type parameter. */
+       VCARD_TYPE_PARAM_MSG,           /**<This is msg type parameter. */
+       VCARD_TYPE_PARAM_PAGER,         /**<This is pager type parameter. */
+       VCARD_TYPE_PARAM_PARCEL,                /**<This is parcel type parameter. */
+       VCARD_TYPE_PARAM_PCM,           /**<This is PCM type parameter. */
+       VCARD_TYPE_PARAM_PCS,           /**<This is PCS type parameter. */
+       VCARD_TYPE_PARAM_PNG,           /**<This is png type parameter. */
+       VCARD_TYPE_PARAM_POSTAL,                /**<This is potsal type parameter. */
+       VCARD_TYPE_PARAM_PREF,          /**<This is pref type parameter. */
+       VCARD_TYPE_PARAM_VIDEO,         /**<This is video type parameter. */
+       VCARD_TYPE_PARAM_VOICE,         /**<This is voice type parameter. */
+       VCARD_TYPE_PARAM_WAVE,          /**<This is wave type parameter. */
+       VCARD_TYPE_PARAM_WBMP,          /**<This is wbmp type parameter. */
+       VCARD_TYPE_PARAM_ETC,           /**<This is etc type parameter. */
+       VCARD_TYPE_PARAM_X400,          /**<This is X400 type parameter. */
+       VCARD_TYPE_PARAM_X_IRMC_N       /**<This is X-IRMC-N type parameter. */
+}vCardTypeVal;
+
+#define VCARD_TYPE_PARAM_NUM           30              /**< number of vcard type parameter */
+
+/* VCard Encoder/Decoder status. */
+#define VCARD_TYPE_NAME_STATUS 1       /**< vcard type name status */
+#define VCARD_PARAM_NAME_STATUS        2       /**< vcard parameter name status */
+#define VCARD_TYPE_VALUE_STATUS        3       /**< vcard type value status */
+#define VCARD_PARAM_VALUE_STATUS 4     /**< vcard parameter value status */
+
+
+/*
+ * Public Function Prototypes
+ */
+
+
+/**
+* @fn VTree* vcard_decode(char* pVCardRaw);
+* This function decodes a vcard string to a vTree.
+*
+* @return      This function returns a pointer to VTree.
+* @param[in] pVCardRaw  Points to the vcard string.
+* @see vcard_encode
+*/
+SLPAPI VTree*  vcard_decode(char* pVCardRaw);
+
+/**
+* @fn char* vcard_encode(VTree* pVTree);
+* This function encodes a vTree to a string.
+*
+* @return      This function returns a pointer to a vcard string.
+* @param[in] pVTree  Points to a VTree.
+* @see vcard_decode
+*/
+SLPAPI char*   vcard_encode(VTree* pVTree);
+
+/**
+* @fn char* vcard_free_vtree_memory(VTree* pTree);
+* This function free a pTree allocated memory
+*
+* @return      This function returns value of success or fail
+* @param[in] pVTree  Points to a VTree.
+*/
+SLPAPI bool vcard_free_vtree_memory(VTree * pTree);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _VCARD_H_ */
+
+/**
+* @}
+*/
diff --git a/vobject-engine/include/VMessage.h b/vobject-engine/include/VMessage.h
new file mode 100755 (executable)
index 0000000..9631d4b
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 _VMSG_H
+#define _VMSG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "VTypes.h"
+
+/****************************************************************************************************/
+/*                                                                                     ENUMERATION DECLARATION                                                                 */
+/****************************************************************************************************/
+
+/**
+* @enum vMsgType
+* This enumeration defines the property of vcard.
+*/
+typedef enum
+{
+       VMSG_TYPE_BEGIN,
+       VMSG_TYPE_END,
+       VMSG_TYPE_TEL,
+       VMSG_TYPE_VBODY,
+       VMSG_TYPE_VCARD,
+       VMSG_TYPE_VMSG,
+       VMSG_TYPE_BODY,
+       VMSG_TYPE_SUBJECT,
+       VMSG_TYPE_MSGBOX,
+       VMSG_TYPE_STATUS,
+       VMSG_TYPE_MSGTYPE,
+       VMSG_TYPE_DATE,
+}vMsgType;
+
+#define VMSG_TYPE_NUM  12              /**< number of vcard type */
+
+/**
+* @enum vMsgParamName
+* This enumeration defines the name of vcard parameter.
+*/
+typedef enum
+{
+       VMSG_PARAM_CHARSET,             /**<This is charset parameter. */
+       VMSG_PARAM_CONTEXT,             /**<This is context parameter. */
+       VMSG_PARAM_ENCODING,    /**<This is encoding parameter. */
+       VMSG_PARAM_LANGUAGE,    /**<This is language parameter. */
+       VMSG_PARAM_TYPE,                        /**<This is type parameter. */
+       VMSG_PARAM_VALUE                /**<This is value parameter. */
+}vMsgParamName;
+
+#define VMSG_PARAM_NUM         6       /**< number of vcard parameter */
+
+/**
+* @enum vMsgParamName
+* This enumeration defines the value of encoding parameter.
+*/
+typedef enum
+{
+       VMSG_ENC_PARAM_B,                                       /**<This is b encoding parameter. */
+       VMSG_ENC_PARAM_BASE64,                          /**<This isbase64 encoding parameter. */
+       VMSG_ENC_PARAM_QUOTED_PRINTABLE,        /**<This is quoted printable encoding parameter. */
+       VMSG_ENC_PARAM_7BIT,                            /**<This is 7 bit encoding parameter. */
+       VMSG_ENC_PARAM_8BIT                                     /**<This is 8 bit encoding parameter. */
+}vMsgEncVal;
+
+#define VMSG_ENCODE_PARAM_NUM  5       /**< number of vcard encoding parameter */
+
+/**
+* @enum vMsgCharsetVal
+* This enumeration defines the value of charset parameter.
+*/
+typedef enum
+{
+       VMSG_CHARSET_PARAM_UTF_8,               /**<This is utf-8 charset parameter. */
+       VMSG_CHARSET_PARAM_UTF_16,              /**<This is utf-16 charset parameter. */
+       VMSG_CHARSET_PARAM_SHIFT_JIS,   /**<This is shift-jis charset parameter. */
+       VMSG_CHARSET_PARAM_ISO_8859_1   /**<This is iso-8859-1 charset parameter. */
+}vMsgCharsetVal;
+
+#define VMSG_CHARSET_PARAM_NUM  4      /**< number of vcard charset parameter */
+
+/**
+* @enum vMsgValVal
+* This enumeration defines the value of value parameter.
+*/
+typedef enum
+{
+       VMSG_VALUE_PARAM_BINARY,                /**<This is binary value parameter. */
+       VMSG_VALUE_PARAM_BOOLEAN,               /**<This is boolean value parameter. */
+       VMSG_VALUE_PARAM_DATE,                  /**<This is date value parameter. */
+       VMSG_VALUE_PARAM_DATE_TIME,     /**<This is date time value parameter. */
+       VMSG_VALUE_PARAM_FLOAT,         /**<This is float value parameter. */
+       VMSG_VALUE_PARAM_INTEGER,               /**<This is integer value parameter. */
+       VMSG_VALUE_PARAM_PHONE_NUMBER,  /**<This is phone number value parameter. */
+       VMSG_VALUE_PARAM_TEXT,                          /**<This is text value parameter. */
+       VMSG_VALUE_PARAM_TIME,                          /**<This is time value parameter. */
+       VMSG_VALUE_PARAM_URI,                           /**<This is uri value parameter. */
+       VMSG_VALUE_PARAM_URL,                           /**<This is url value parameter. */
+       VMSG_VALUE_PARAM_UTC_OFFSET,            /**<This is utc offset value parameter. */
+       VMSG_VALUE_PARAM_VMSG                           /**<This is vcard value parameter. */
+}vMsgValVal;
+
+#define VMSG_VALUE_PARAM_NUM           13              /**< number of vcard value parameter */
+
+/**
+* @enum vMsgValVal
+* This enumeration defines the value of type parameter.
+*/
+typedef enum
+{
+       VMSG_TYPE_PARAM_AIFF,           /**<This is aiff type parameter. */
+       VMSG_TYPE_PARAM_BBS,            /**<This is bbs type parameter. */
+       VMSG_TYPE_PARAM_CAR,            /**<This is car type parameter. */
+       VMSG_TYPE_PARAM_CELL,           /**<This is cell type parameter. */
+       VMSG_TYPE_PARAM_DOM,            /**<This is dom type parameter. */
+       VMSG_TYPE_PARAM_WORK,           /**<This is work type parameter. */
+       VMSG_TYPE_PARAM_FAX,            /**<This is fax type parameter. */
+       VMSG_TYPE_PARAM_GIF,            /**<This is gif type parameter. */
+       VMSG_TYPE_PARAM_HOME,           /**<This is home type parameter. */
+       VMSG_TYPE_PARAM_INTL,           /**<This is intl type parameter. */
+       VMSG_TYPE_PARAM_INTERNET,       /**<This is internet type parameter. */
+       VMSG_TYPE_PARAM_ISDN,           /**<This is ISDN type parameter. */
+       VMSG_TYPE_PARAM_JPEG,           /**<This is jpeg type parameter. */
+       VMSG_TYPE_PARAM_MOBILE,         /**<This is mobile type parameter. */
+       VMSG_TYPE_PARAM_MODEM,          /**<This is mpdem type parameter. */
+       VMSG_TYPE_PARAM_MSG,            /**<This is msg type parameter. */
+       VMSG_TYPE_PARAM_PAGER,          /**<This is pager type parameter. */
+       VMSG_TYPE_PARAM_PARCEL,         /**<This is parcel type parameter. */
+       VMSG_TYPE_PARAM_PCM,            /**<This is PCM type parameter. */
+       VMSG_TYPE_PARAM_PCS,            /**<This is PCS type parameter. */
+       VMSG_TYPE_PARAM_PNG,            /**<This is png type parameter. */
+       VMSG_TYPE_PARAM_POSTAL,         /**<This is potsal type parameter. */
+       VMSG_TYPE_PARAM_PREF,           /**<This is pref type parameter. */
+       VMSG_TYPE_PARAM_VIDEO,          /**<This is video type parameter. */
+       VMSG_TYPE_PARAM_VOICE,          /**<This is voice type parameter. */
+       VMSG_TYPE_PARAM_WAVE,           /**<This is wave type parameter. */
+       VMSG_TYPE_PARAM_WBMP,           /**<This is wbmp type parameter. */
+       VMSG_TYPE_PARAM_ETC,            /**<This is etc type parameter. */
+       VMSG_TYPE_PARAM_X400,           /**<This is X400 type parameter. */
+       VMSG_TYPE_PARAM_X_IRMC_N        /**<This is X-IRMC-N type parameter. */
+}vMsgTypeVal;
+
+#define VMSG_TYPE_PARAM_NUM            30              /**< number of vcard type parameter */
+
+/* VCard Encoder/Decoder status. */
+#define VMSG_TYPE_NAME_STATUS  1       /**< vcard type name status */
+#define VMSG_PARAM_NAME_STATUS 2       /**< vcard parameter name status */
+#define VMSG_TYPE_VALUE_STATUS 3       /**< vcard type value status */
+#define VMSG_PARAM_VALUE_STATUS 4      /**< vcard parameter value status */
+
+
+/*
+ * Public Function Prototypes
+ */
+
+
+/**
+* @fn VTree* vcard_decode(char* pVCardRaw);
+* This function decodes a vcard string to a vTree.
+*
+* @return      This function returns a pointer to VTree.
+* @param[in] pVCardRaw  Points to the vcard string.
+* @see vcard_encode
+*/
+SLPAPI VTree*  vmsg_decode(char* pVMsgRaw);
+
+/**
+* @fn char* vcard_encode(VTree* pVTree);
+* This function encodes a vTree to a string.
+*
+* @return      This function returns a pointer to a vcard string.
+* @param[in] pVTree  Points to a VTree.
+* @see vcard_decode
+*/
+SLPAPI char*   vmsg_encode(VTree* pVTree);
+
+/**
+* @fn char* vcard_free_vtree_memory(VTree* pTree);
+* This function free a pTree allocated memory
+*
+* @return      This function returns value of success or fail
+* @param[in] pVTree  Points to a VTree.
+*/
+SLPAPI bool vmsg_free_vtree_memory(VTree * pTree);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _VMSG_H_ */
+
+/**
+* @}
+*/
diff --git a/vobject-engine/include/VTypes.h b/vobject-engine/include/VTypes.h
new file mode 100755 (executable)
index 0000000..05f3b7f
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 _VTYPES_H
+#define _VTYPES_H
+
+#include "stdio.h"
+#include "stdbool.h"
+#include "stdlib.h"
+#include "string.h"
+#include "ctype.h"
+
+#ifndef SLPAPI
+#define SLPAPI __attribute__ ((visibility("default")))
+#endif
+
+#define CR                             0x0d
+#define LF                             0x0a
+#define TAB                            0x09
+#define WSP                            0x20
+#define UNKNOWN_NAME   0x80000000
+
+#define VCARD                  0x01
+#define VCALENDAR              0x02
+#define VNOTE 0x0b
+
+#define VEVENT                 0x03
+#define VTODO                  0x04
+#define VJOURNAL               0x05
+#define VFREEBUSY              0x06
+#define VTIMEZONE              0x07
+#define VALARM                 0x08
+#define VMESSAGE               0x0c
+#define VBODY                  0X0d
+#define STANDARD               0x09
+#define DAYLIGHT               0x0a
+
+#define VTYPE_TOKEN_SEMICOLON          ';'
+#define VTYPE_TOKEN_COLON                      ':'
+#define VTYPE_TOKEN_EQUAL                      '='
+#define VTYPE_TOKEN_COMMA                      ','
+#define VTYPE_TOKEN_DOT                                '.'
+#define VTYPE_TOKEN_QUOTE                      '\''
+#define VTYPE_TOKEN_DBLQUOTE           '"'
+
+#define VDATA_VALUE_COUNT_MAX  2000
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/****************************************************************************************************/
+/*                                                                      GLOBAL STRUCTURE DECLARATION                                                                   */
+/****************************************************************************************************/
+
+typedef struct _VParam VParam;
+typedef struct _VObject VObject;
+typedef struct _ValueObj ValueObj;
+typedef struct _VTree VTree;
+
+struct _VTree
+{
+       int                     treeType;
+       VObject*        pTop;
+       VObject*        pCur;
+       VTree*          pNext;
+};
+
+struct _VParam
+{
+       int                     parameter;
+       int                     paramValue;
+       VParam*         pNext;
+};
+
+struct _VObject
+{
+       int                     property;
+       VParam*         pParam;
+       int                     valueCount;
+       int                     numOfBiData;
+       char*           pszValue[VDATA_VALUE_COUNT_MAX];
+       VObject*        pSibling;
+       VObject*        pParent;
+       VObject*        pChild;
+
+       char*           pszGroupName; //VDATA_GROUPNAME_SUPPORTED
+};
+
+struct _ValueObj
+{
+       char*           szName;
+       int                     flag;
+};
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif // _VTYPES_H
diff --git a/vobject-engine/include/vobject.h b/vobject-engine/include/vobject.h
new file mode 100755 (executable)
index 0000000..466c4e3
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 _VOBJECT_H
+#define _VOBJECT_H
+
+#include "stdio.h"
+#include "stdbool.h"
+#include "stdlib.h"
+#include "string.h"
+#include "ctype.h"
+
+#include <dlog.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+//#define ORG_ENABLE_TRACE
+#define FEATURE_SHIFT_JIS
+
+#ifdef ORG_ENABLE_TRACE
+#define USER_TAG "MSG_FW"
+#define VDATA_TRACE(fmt, arg...) \
+       do\
+       {\
+               SLOG(LOG_DEBUG, USER_TAG, "\n[calendarui] %s:%d: " fmt "\n", __FUNCTION__, __LINE__, ##arg); \
+       } while (0)
+
+
+#define VDATA_TRACE_LINE() fprintf(stderr, "\n[calendarui] %s:%d\n", __FUNCTION__, __LINE__ )
+
+#define SysRequireEx(expr, retValue) \
+       if (!(expr)) { \
+               fprintf(stderr,"INVALID_PARAM (%d lines in %s)\n", __LINE__,__FILE__); \
+               return retValue; }\
+       else {;}
+#else
+#define VDATA_TRACE(fmt, arg...)
+#define VDATA_TRACE_LINE()
+#define SysRequireEx(expr, retValue)
+#endif
+
+#define VDATA_TRACE_BEGINE //VDATA_TRACE(">>>>>> start. >>>>>>"); //usleep(1000);
+#define VDATA_TRACE_END //VDATA_TRACE(">>>>>> end. >>>>>>");
+
+/****************************************************************************************************/
+/*                                                                              FUNCTION DECLARATION                                                                           */
+/****************************************************************************************************/
+int            _VIsSpace( char );
+int            _VRLSpace( char * );
+int            _VRTSpace( char * );
+int            _VUnescape( char* );
+int            _VEscape(char*);
+int            _VManySpace2Space( char * );
+int            _VB64Decode( char *, char * );
+int            _VB64Encode( char *, char *, int );
+int            _VUnfolding( char * );
+void   _VFolding( char *, char * );
+int            _VQPDecode( char * );
+int            _VQPEncode( char *, char * );
+
+void _VFoldingQP( char *result, char *contentline );
+void _VFoldingNoSpace( char *result, char *contentline );
+int _VManyCRLF2CRLF(char *pIn);
+int _VUnfoldingNoSpec( char *string, int vType );
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/vobject-engine/test_code/CQ_VCARD.c b/vobject-engine/test_code/CQ_VCARD.c
new file mode 100755 (executable)
index 0000000..e0453d5
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 <stdio.h>
+
+extern void utc_vdata_vcard_decode_1();
+extern void utc_vdata_vcard_decode_2();
+extern void utc_vdata_vcard_decode_3();
+extern void utc_vdata_vcard_decode_4();
+extern void utc_vdata_vcard_decode_5();
+extern void utc_vdata_vcard_decode_6();
+extern void utc_vdata_vcard_decode_7();
+extern void utc_vdata_vcard_encode_1();
+extern void utc_vdata_vcard_encode_0();
+extern void utc_vdata_vcard_encode_2();
+extern void utc_vdata_vcard_encode_3();
+extern void utc_vdata_vcard_encode_4();
+extern void utc_vdata_vcard_encode_5();
+extern void utc_vdata_vcard_encode_6();
+extern void utc_vdata_vcard_encode_7();
+extern void utc_vdata_vcard_encode_8();
+
+int CQ_TEST() {
+#if 0
+       printf("\n################################### VCard CQ Test  ##################################\n");
+       printf("[TEST CASE] utc_vdata_vcard_decode_1 : decode a raw buffer to a tree.\n");
+       utc_vdata_vcard_decode_1();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_decode_2 :  decode a raw buffer without begin token to a tree.\n");
+       utc_vdata_vcard_decode_2();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_decode_3 : decode a raw buffer without end token to a tree.\n");
+       utc_vdata_vcard_decode_3();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_decode_4 : decode a raw buffer having invalid version tag to a tree.\n");
+       utc_vdata_vcard_decode_4();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_decode_5 : decode a raw buffer without having crlf in between two tokens to a tree.\n");
+       utc_vdata_vcard_decode_5();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_decode_6 : decode a raw buffer having some invalid token to a tree.\n");
+       utc_vdata_vcard_decode_6();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_decode_7 : decode a NULL raw buffer to a tree.\n");
+       utc_vdata_vcard_decode_7();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_encode_0 : \n");
+       utc_vdata_vcard_encode_0();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_encode_1 : encode a tree to a buffer.\n");
+       utc_vdata_vcard_encode_1();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_encode_2 : encode a tree with tree type as vcalendar to a buffer.\n");
+       utc_vdata_vcard_encode_2();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_encode_3 : encode a tree with all the vobjects as NULL to a buffer.\n");
+       utc_vdata_vcard_encode_3();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_encode_4 : encode a tree with an object having property as very high value to a buffer.\n");
+       utc_vdata_vcard_encode_4();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_encode_5 : encode a NULL tree to a buffer.\n");
+       utc_vdata_vcard_encode_5();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_encode_6 : encode a tree with an object having property but no other value to a buffer.\n");
+       utc_vdata_vcard_encode_6();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_encode_7 : encode a tree with an object having value count greater than actual vales to a buffer.\n");
+       utc_vdata_vcard_encode_7();
+       printf("\n\n[TEST CASE] utc_vdata_vcard_encode_8 : encode a tree with tree type as a high value to a buffer.\n");
+       utc_vdata_vcard_encode_8();
+       printf("\n################################### VCard CQ Test  ##################################\n\n");
+#endif
+
+       return 0;
+}
+
+int main(int argc, char** argv) {
+
+       CQ_TEST();
+}
diff --git a/vobject-engine/test_code/uts_vdata_vcard_decode.c b/vobject-engine/test_code/uts_vdata_vcard_decode.c
new file mode 100755 (executable)
index 0000000..7a12474
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 <VCard.h>
+#include <VTypes.h>
+#include <glib.h>
+
+#define MT_CHECK_EQUAL(arg1, arg2) arg1 != arg2 ? \
+       fprintf(stderr,"[VOBJECT-TEST-CASE] %s %s:%d NOT EQUAL\n",__FILE__,__FUNCTION__,__LINE__) :\
+       fprintf(stderr,"[VOBJECT-TEST-CASE] %s %s:%d EQUAL\n",__FILE__,__FUNCTION__,__LINE__);
+
+#define VDATA_TEST_TRACE(fmt, arg...) \
+       do { {fprintf(stderr, "[VOBJECT-TEST-CASE] %s %s:%d: " fmt,__FILE__,__FUNCTION__, __LINE__, ##arg);}}while (false);
+
+
+/** decode a raw buffer to a tree */
+void utc_vdata_vcard_decode_1()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = g_strdup("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531\r\nEND:VCARD");
+
+       tree = VCardDecode(buffer);
+       VDATA_TEST_TRACE("call executed \n");
+
+       if(!(tree != NULL)) return;
+
+       VDATA_TEST_TRACE("treetype is %d \n", tree->treeType);
+
+       if (!(tree->pTop)){
+               VDATA_TEST_TRACE("decodeing faili - utc_vdata_vcard_decode_%d",1);
+               return;
+       }
+       VDATA_TEST_TRACE ("top property is %d \n", tree->pTop->property);
+       VDATA_TEST_TRACE ("top property value is %s \n", *(tree->pTop->pszValue));
+
+       if (tree->pTop->pParam){
+               VDATA_TEST_TRACE ("top param is %d \n", tree->pTop->pParam->parameter);
+               VDATA_TEST_TRACE ("top param val is %d \n", tree->pTop->pParam->paramValue);
+       }
+
+       if (tree->pCur){
+               VDATA_TEST_TRACE ("cur property is %d \n", tree->pCur->property);
+               VDATA_TEST_TRACE ("top property value is %s \n", *(tree->pCur->pszValue));
+       }
+
+       if (!(tree->pTop->pSibling)){
+               VDATA_TEST_TRACE("decodeing faili - utc_vdata_vcard_decode_%d",1);
+               return;
+       }
+
+       VDATA_TEST_TRACE ("sibling not NULL \n");
+       VDATA_TEST_TRACE ("sibling property is %d \n", tree->pTop->pSibling->property);
+       VDATA_TEST_TRACE ("sibling property value is %s \n", *(tree->pTop->pSibling->pszValue));
+
+       if (tree->pTop->pSibling->pParam){
+               VDATA_TEST_TRACE ("sibling param is %d \n", tree->pTop->pSibling->pParam->parameter);
+               VDATA_TEST_TRACE ("sibling param val is %d \n", tree->pTop->pSibling->pParam->paramValue);
+       }
+
+       VDATA_TEST_TRACE("decodeing success - utc_vdata_vcard_decode_%d\n",1);
+
+       VObject* pSibling2 = tree->pTop->pSibling->pSibling;
+       if (!pSibling2)
+               return;
+
+       VDATA_TEST_TRACE ("sibling2 not NULL \n");
+       VDATA_TEST_TRACE ("sibling2 property is %d \n", pSibling2->property);
+       VDATA_TEST_TRACE ("sibling2 property value is %s \n", *(pSibling2->pszValue));
+
+       if (pSibling2->pParam){
+               VDATA_TEST_TRACE ("sibling param is %d \n", pSibling2->pParam->parameter);
+               VDATA_TEST_TRACE ("sibling param val is %d \n", pSibling2->pParam->paramValue);
+       }
+
+       if (tree->pTop->pParent)
+               VDATA_TEST_TRACE ("parent not NULL \n");
+       if (tree->pTop->pChild)
+               VDATA_TEST_TRACE ("child not NULL \n");
+
+
+       if(buffer != NULL)
+               g_free(buffer);
+}
+
+/** decode a raw buffer without begin token to a tree */
+void utc_vdata_vcard_decode_2()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = g_strdup("VERSION:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531\r\nEND:VCARD");
+
+       tree = VCardDecode(buffer);
+       VDATA_TEST_TRACE("call executed \n");
+
+       if(!(tree != NULL)) VDATA_TEST_TRACE("tree is null");
+
+       if(buffer != NULL)
+               g_free(buffer);
+}
+
+/*decode a raw buffer without end token to a tree*/
+void utc_vdata_vcard_decode_3()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = g_strdup("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531");
+
+       VDATA_TEST_TRACE("%s\n", buffer);
+       tree = VCardDecode(buffer);
+       VDATA_TEST_TRACE("call executed \n");
+
+       if(!tree) return;
+
+       VDATA_TEST_TRACE ("treetype is %d \n", tree->treeType);
+
+
+       if(buffer != NULL)
+               g_free(buffer);
+}
+/*decode a raw buffer having invalid version tag to a tree*/
+void utc_vdata_vcard_decode_4()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = g_strdup("BEGIN:VCARD\r\nVE:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531\r\nEND:VCARD");
+
+       tree = VCardDecode(buffer);
+
+       VDATA_TEST_TRACE ("call executed \n");
+       VDATA_TEST_TRACE ("treetype is %d \n", tree->treeType);
+
+       if (!(tree->pTop)){
+               VDATA_TEST_TRACE ("tree->pTop null. \n");
+               return;
+       }
+
+       VDATA_TEST_TRACE ("top property is %d \n", tree->pTop->property);
+       VDATA_TEST_TRACE ("top property value is %s \n", *(tree->pTop->pszValue));
+
+       MT_CHECK_EQUAL(tree->pTop->property, (int)VCARD_TYPE_N);
+
+
+       if(buffer != NULL)
+               g_free(buffer);
+}
+
+/** decode a raw buffer without having crlf in between two tokens to a tree */
+void utc_vdata_vcard_decode_5()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = g_strdup("BEGIN:VCARDVERSION:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531\r\nEND:VCARD");
+
+       tree = VCardDecode(buffer);
+       VDATA_TEST_TRACE ("call executed \n");
+       VDATA_TEST_TRACE ("treetype is %d \n", tree->treeType);
+
+       if (!(tree->pTop)){
+               VDATA_TEST_TRACE ("tree->pTop null. \n");
+               return;
+       }
+
+       VDATA_TEST_TRACE ("top property is %d \n", tree->pTop->property);
+       VDATA_TEST_TRACE ("top property value is %s \n", *(tree->pTop->pszValue));
+
+       MT_CHECK_EQUAL(tree->pTop->property, (int)VCARD_TYPE_N);
+
+       if(buffer != NULL)
+               g_free(buffer);
+}
+
+/*decode a raw buffer having some invalid token to a tree*/
+void utc_vdata_vcard_decode_6()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = g_strdup("BEGIN:VCARD\r\nVERSIOOOONNNN:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531\r\nEND:VCARD");
+
+       tree = VCardDecode(buffer);
+       VDATA_TEST_TRACE ("call executed \n");
+       VDATA_TEST_TRACE ("treetype is %d \n", tree->treeType);
+
+       if (!(tree->pTop)){
+               VDATA_TEST_TRACE ("tree->pTop null. \n");
+               return;
+       }
+
+       VDATA_TEST_TRACE ("top property is %d \n", tree->pTop->property);
+       VDATA_TEST_TRACE ("top property value is %s \n", *(tree->pTop->pszValue));
+
+       MT_CHECK_EQUAL(tree->pTop->property, (int)VCARD_TYPE_N);
+
+       if(buffer != NULL)
+               g_free(buffer);
+}
+
+/*decode a NULL raw buffer to a tree*/
+void utc_vdata_vcard_decode_7()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       tree = VCardDecode(buffer);
+       VDATA_TEST_TRACE ("call executed \n");
+
+       MT_CHECK_EQUAL((VTree*)NULL, tree);
+
+       if(buffer != NULL)
+               g_free(buffer);
+}
diff --git a/vobject-engine/test_code/uts_vdata_vcard_encode.c b/vobject-engine/test_code/uts_vdata_vcard_encode.c
new file mode 100755 (executable)
index 0000000..eddb80e
--- /dev/null
@@ -0,0 +1,320 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+*
+* 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 <VCalendar.h>
+#include <VCard.h>
+#include <VTypes.h>
+#include <glib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#define MT_CHECK_EQUAL(arg1, arg2) arg1 != arg2 ? \
+  fprintf(stderr,"[VOBJECT-TEST-CASE] %s %s:%d NOT EQUAL",__FILE__,__FUNCTION__,__LINE__) :\
+  fprintf(stderr,"[VOBJECT-TEST-CASE] %s %s:%d EQUAL",__FILE__,__FUNCTION__,__LINE__);
+
+#define MT_CHECK_NOT_EQUAL(arg1, arg2) arg1 != arg2 ? \
+  fprintf(stderr,"[VOBJECT-TEST-CASE] %s %s:%d NOT EQUAL",__FILE__,__FUNCTION__,__LINE__) :\
+  fprintf(stderr,"[VOBJECT-TEST-CASE] %s %s:%d EQUAL",__FILE__,__FUNCTION__,__LINE__);
+
+#define VDATA_TEST_TRACE(fmt, arg...) \
+  do { {fprintf(stderr, "[VOBJECT-TEST-CASE] %s %s:%d: " fmt "\n" ,__FILE__,__FUNCTION__, __LINE__, ##arg);}}while (false);
+
+#define null NULL
+
+/* */
+void
+utc_vdata_vcard_encode_0() {
+
+       FILE* fp;
+       char* buffer;
+       char* temp;
+       VTree *tree = NULL;
+       VObject*        pTemp = NULL;
+       VParam*         pTmpParam = NULL;
+
+       struct stat stat_object;
+       VDATA_TEST_TRACE("START");
+
+       if(lstat("sample.vcf", &stat_object) != 0) {
+               VDATA_TEST_TRACE("error get file status..");
+               return ;
+       }
+
+       if( (buffer = (char*) malloc(stat_object.st_size)) == NULL )
+               return ;
+
+       VDATA_TEST_TRACE("sample.vcf file size : %d", stat_object.st_size);
+
+       if( (fp = fopen("sample.vcf",  "r")) == NULL )
+               return ;
+       fread(buffer, stat_object.st_size, sizeof(char), fp);
+       fclose(fp);
+
+       VDATA_TEST_TRACE("~~~~~");
+
+       tree = VCardDecode(buffer);
+
+       pTemp = tree->pTop;
+       pTmpParam = pTemp->pParam;
+
+       while(1) {
+               //VDATA_TEST_TRACE("%d %d",pTemp->property, VCARD_TYPE_PHOTO);
+               temp = pTemp->pszValue[0];
+               VDATA_TEST_TRACE("%s",temp);
+
+               if (pTemp->pSibling != NULL) {
+                       pTemp = pTemp->pSibling;
+                       pTmpParam = pTemp->pParam;
+               }
+               else {
+                       break;
+               }
+       }
+
+       VDATA_TEST_TRACE("END");
+
+
+       return ;
+
+}
+
+
+/*encode a tree to a buffer*/
+void utc_vdata_vcard_encode_1()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = g_strdup("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531\r\nEND:VCARD");
+
+       tree = VCardDecode(buffer);
+       tree->pTop->property = 32;
+
+       char *temp = g_strdup("2.2");;
+       tree->pTop->pszValue[0] = temp;
+
+       if(buffer != NULL) {
+       g_free(buffer);
+       buffer = NULL;
+       }
+
+       VDATA_TEST_TRACE ("top property value is %s \n", *(tree->pTop->pszValue));
+       buffer = VCardEncode(tree);
+
+       VCalFreeVTreeMemory(tree);
+       tree = VCardDecode(buffer);
+
+       VDATA_TEST_TRACE ("call executed buffer is %s\n", buffer);
+       MT_CHECK_NOT_EQUAL((gchar *)NULL, buffer);
+
+       if(buffer != NULL)
+               g_free(buffer);
+
+       if(temp != NULL)
+               g_free(temp);
+
+       buffer = NULL;
+       temp = NULL;
+}
+/*encode a tree with tree type as vcalendar to a buffer*/
+void utc_vdata_vcard_encode_2()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = g_strdup("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531\r\nEND:VCARD");
+       tree = VCardDecode(buffer);
+
+       tree->treeType = VCALENDAR;
+
+       if(buffer != NULL)
+       g_free(buffer);
+       buffer = NULL;
+
+       buffer = VCardEncode(tree);
+       VDATA_TEST_TRACE ("call executed buffer is %s\n", buffer);
+       MT_CHECK_EQUAL((gchar *)NULL, buffer);
+       VCalFreeVTreeMemory(tree);
+
+       if(buffer != NULL)
+               g_free(buffer);
+
+       buffer = NULL;
+}
+
+/*encode a tree with all the vobjects as NULL to a buffer*/
+void utc_vdata_vcard_encode_3()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       tree = g_new0(VTree, 1);
+       tree->treeType = VCARD;
+       tree->pTop = NULL;
+       tree->pCur = NULL;
+
+       buffer = VCardEncode(tree);
+       VDATA_TEST_TRACE ("call executed buffer is %s\n", buffer);
+       MT_CHECK_NOT_EQUAL((gchar *)NULL, buffer);
+       VCalFreeVTreeMemory(tree);
+
+       if(buffer != NULL)
+               g_free(buffer);
+
+       buffer = NULL;
+}
+
+/*encode a tree with an object having property as very high value to a buffer*/
+void utc_vdata_vcard_encode_4()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = g_strdup("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531\r\nEND:VCARD");
+       tree = VCardDecode(buffer);
+
+       tree->pTop->property = 65;
+
+       if(buffer != NULL)
+       g_free(buffer);
+
+       buffer = NULL;
+
+       buffer = VCardEncode(tree);
+
+       VDATA_TEST_TRACE ("call executed buffer is %s\n", buffer);
+       MT_CHECK_NOT_EQUAL((gchar*)NULL, buffer);
+
+       VCalFreeVTreeMemory(tree);
+
+       if(buffer != NULL)
+               g_free(buffer);
+
+       buffer = NULL;
+}
+
+/*encode a NULL tree to a buffer*/
+void utc_vdata_vcard_encode_5()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = VCardEncode(tree);
+       VDATA_TEST_TRACE ("call executed buffer is %s\n", buffer);
+       MT_CHECK_EQUAL((gchar *)NULL, buffer);
+
+       if(buffer != NULL)
+               g_free(buffer);
+
+       buffer = NULL;
+}
+
+/*encode a tree with an object having property but no other value to a buffer*/
+void utc_vdata_vcard_encode_6()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = g_strdup("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531\r\nEND:VCARD");
+       tree = VCardDecode(buffer);
+
+       tree->pTop->property = 14;
+       tree->pTop->pszValue[0] = NULL;
+
+       if(buffer != NULL)
+       g_free(buffer);
+
+       buffer = NULL;
+
+       buffer = VCardEncode(tree);
+       VDATA_TEST_TRACE ("call executed buffer is %s\n", buffer);
+       MT_CHECK_NOT_EQUAL((gchar *)NULL, buffer);
+       VCalFreeVTreeMemory(tree);
+
+       if(buffer != NULL)
+               g_free(buffer);
+
+       buffer = NULL;
+}
+
+/*encode a tree with an object having value count greater than actual vales to a buffer*/
+void utc_vdata_vcard_encode_7()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+       gchar *temp;
+
+       buffer = g_strdup("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531\r\nEND:VCARD");
+       tree = VCardDecode(buffer);
+
+       tree->pTop->property = VCARD_TYPE_N;
+       tree->pTop->valueCount = 5;
+       temp = g_strdup( "amit");
+       tree->pTop->pszValue[0] = temp;
+
+
+       if(buffer != NULL)
+       g_free(buffer);
+
+       buffer = NULL;
+
+       VDATA_TEST_TRACE ("top property value is %s \n", *(tree->pTop->pszValue));
+       buffer = VCardEncode(tree);
+
+       VDATA_TEST_TRACE ("call executed buffer is %s\n", buffer);
+       MT_CHECK_NOT_EQUAL((gchar *)NULL, buffer);
+       VCalFreeVTreeMemory(tree);
+
+
+       if(buffer != NULL)
+               g_free(buffer);
+
+       if(temp != NULL)
+               g_free(temp);
+
+       buffer = NULL;
+       temp = NULL;
+}
+
+/*encode a tree with tree type as a high value to a buffer*/
+void utc_vdata_vcard_encode_8()
+{
+       gchar *buffer = NULL;
+       VTree *tree = NULL;
+
+       buffer = g_strdup("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Martin;Stephen\r\nTEL;HOME;VOICE:+1 (210) 555-1357\r\nTEL;HOME;FAX:+1 (210) 555-0864\r\nADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531\r\nEND:VCARD");
+
+       tree = VCardDecode(buffer);
+
+       tree->treeType = 15;
+
+       if(buffer != NULL)
+       g_free(buffer);
+
+       buffer = NULL;
+
+       buffer = VCardEncode(tree);
+       VDATA_TEST_TRACE ("call executed buffer is %s\n", buffer);
+       MT_CHECK_EQUAL((gchar*)NULL, buffer);
+       VCalFreeVTreeMemory(tree);
+
+       if(buffer != NULL)
+               g_free(buffer);
+
+       buffer = NULL;
+}
+